/* ── CSS Variables ── */
:root {
  --bg: #100d0a;
  --surface: rgba(255,160,80,0.05);
  --surface2: rgba(255,160,80,0.09);
  --border: rgba(255,160,80,0.10);
  --border2: rgba(255,160,80,0.20);
  --accent: #ff7a2f;
  --accent-light: #ff9a5c;
  --accent2: #ff5252;
  --text: #f5ede6;
  --text2: rgba(245,237,230,0.5);
  --text3: rgba(245,237,230,0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  height: -webkit-fill-available;
  overflow-x: hidden;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  overflow: hidden;
  overflow-x: hidden;
  position: relative;
  width: 100%;
  max-width: 100vw;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(255,122,47,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 20%, rgba(255,80,40,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.container {
  flex: 1;
  position: relative;
  text-align: center;
  z-index: 1;
  overflow-x: hidden;
  max-width: 100vw;
}

#player {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Overlay ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
  padding-bottom: 36px;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
  width: 100%;
  max-width: 560px;
  padding: 0 20px;
}

.container:hover .overlay-content { opacity: 1; }

/* ── Controls Panel ── */
.controls-panel {
  background: rgba(16,13,10,0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 18px 22px 20px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.title {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Viewers badge */
.viewers-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  user-select: none;
  cursor: pointer;
}
.viewers-badge svg { opacity: 0.7; }
.viewers-badge:hover { border-color: var(--accent); color: var(--text); }

/* Icon buttons */
.icon-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border2); color: var(--text); }
.icon-btn.active { background: rgba(255,122,47,0.12); border-color: rgba(255,122,47,0.35); color: var(--accent); }
.icon-btn.mention-alert {
  border-color: #7dd3fc;
  color: #7dd3fc;
  box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.2);
  animation: mentionPulse 1.1s ease-in-out infinite;
}

@keyframes mentionPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Video title */
.videoTitle {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 100%;
  margin: 10px 0 14px;
  text-align: left;
  letter-spacing: -0.01em;
}

/* Search */
.search-box { display: flex; width: 100%; margin-bottom: 14px; }

.search-box input {
  flex: 1;
  padding: 9px 13px;
  border-radius: 9px 0 0 9px;
  border: 1px solid var(--border2);
  border-right: none;
  outline: none;
  background: var(--surface2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-size: max(13px, 16px); /* iOS zoom 방지 */
  transition: border-color 0.2s, background 0.2s;
}
.search-box input::placeholder { color: var(--text3); }
.search-box input:focus { background: rgba(255,160,80,0.12); border-color: var(--accent); }

.search-box button {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-left: none;
  background: var(--accent);
  color: #100d0a;
  border-radius: 0 9px 9px 0;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}
.search-box button:hover { background: var(--accent-light); }

/* Action buttons */
.actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin-bottom: 12px;
}

.actions button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}
.actions button:hover { background: var(--surface); border-color: var(--border2); }
.actions button:active { transform: scale(0.96); }

#togglePlayBtn {
  background: var(--accent);
  color: #100d0a;
  border-color: transparent;
  min-width: 96px;
  font-weight: 600;
}
#togglePlayBtn:hover { background: var(--accent-light); }

/* Progress */
.progress-container {
  width: 100%;
  height: 5px;
  background: var(--surface2);
  border-radius: 3px;
  margin-bottom: 6px;
  position: relative;
  cursor: grab;
}
.progress-container:active { cursor: grabbing; }

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  border-radius: 3px;
  position: relative;
  transition: width 0.08s linear;
}
.progress-bar::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
}
.progress-container:hover .progress-bar::after { opacity: 1; }

.time-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 12px;
  text-align: left;
}

/* Volume */
.volume-container { display: flex; align-items: center; gap: 8px; width: 100%; }
.volume-icon { font-size: 14px; color: var(--text2); }

.volume-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
.volume-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Sync help */
.sync-help {
  margin-top: 10px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.sync-help-text { font-size: 12px; color: var(--accent); text-align: center; }
.sync-help button {
  background: var(--accent);
  border: none;
  color: #100d0a;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}
.sync-help button:hover { background: var(--accent-light); }

/* ── Playlist Menu ── */
.playlist-menu {
  position: absolute;
  top: 0; right: 0;
  width: 280px;
  height: 100%;
  background: rgba(16,13,10,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  padding: 16px 12px;
  z-index: 30;
  pointer-events: none;
}
.playlist-menu.open { transform: translateX(0); pointer-events: auto; }
.playlist-menu::-webkit-scrollbar { width: 4px; }
.playlist-menu::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.playlist-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 4px;
}

.playlist-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 2px;
}

.playlist-close-btn {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 13px;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.playlist-close-btn:hover { color: var(--text); border-color: var(--accent); }

@media (max-width: 600px) {
  .playlist-close-btn { display: flex; }
}

#clearPlaylistBtn {
  width: 100%;
  padding: 9px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,82,82,0.3);
  border-radius: 8px;
  background: rgba(255,82,82,0.07);
  color: var(--accent2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}
#clearPlaylistBtn:hover { background: rgba(255,82,82,0.14); border-color: rgba(255,82,82,0.5); }

.playlist-item {
  padding: 10px 11px;
  margin-bottom: 7px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  color: var(--text2);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.playlist-item:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
  transform: translateY(-1px);
}
.playlist-item.active {
  background: rgba(255,122,47,0.12);
  border-color: rgba(255,122,47,0.35);
  box-shadow: inset 0 0 0 1px rgba(255,122,47,0.15);
}
.playlist-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.playlist-index {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text3);
}
.playlist-state {
  font-size: 10px;
  color: var(--text3);
  flex: 1;
  margin: 0 6px;
  text-align: center;
}
.playlist-item.active .playlist-state {
  color: var(--accent);
  font-weight: 700;
}

.playlist-del-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.playlist-del-btn:hover {
  background: rgba(255,82,82,0.15);
  border-color: rgba(255,82,82,0.4);
  color: var(--accent2);
}
.playlist-title {
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.playlist-adder {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
  text-align: left;
}
.playlist-adder:hover .playlist-adder-name {
  color: var(--accent-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.playlist-adder-icon {
  flex-shrink: 0;
  opacity: 0.5;
}
.playlist-adder-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}
.playlist-item.active .playlist-adder {
  color: rgba(255,122,47,0.6);
}

.playlist-empty {
  border: 1px dashed var(--border2);
  border-radius: 11px;
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text3);
  text-align: center;
  margin-top: 6px;
}

/* ── Login Overlay ── */
.login-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16,13,10,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 100;
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.login-header p { font-size: 13px; color: var(--text2); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  width: 340px;
  max-width: 90vw;
}
.auth-box { display: flex; flex-direction: column; gap: 10px; }

.auth-input {
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-size: max(14px, 16px); /* iOS zoom 방지 */
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
}
.auth-input::placeholder { color: var(--text3); }
.auth-input:focus { border-color: var(--accent); background: rgba(255,160,80,0.08); }

.auth-actions { display: flex; gap: 8px; }
.auth-actions button {
  flex: 1;
  padding: 11px 12px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}
.auth-actions button:hover { background: var(--surface); }

#emailLoginBtn {
  background: var(--accent) !important;
  color: #100d0a !important;
  border-color: transparent !important;
  font-weight: 600 !important;
}
#emailLoginBtn:hover { background: var(--accent-light) !important; }

.auth-secondary { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-secondary button {
  flex: 1;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  transition: color 0.2s, border-color 0.2s;
}
.auth-secondary button:hover { color: var(--text); border-color: var(--border2); }

.auth-divider { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.auth-divider span { flex: 1; height: 1px; background: var(--border); }
.auth-divider em { font-size: 11px; color: var(--text3); font-style: normal; }

#googleLoginBtn {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}
#googleLoginBtn:hover { background: var(--surface); }
#googleLoginBtn::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.18 1.48-4.97 2.29-8.16 2.29-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

#authStatus { min-height: 18px; font-size: 12px; color: var(--accent); text-align: center; }

/* ── Chat ── */
#chatWrapper {
  position: absolute;
  bottom: 16px; right: 16px;
  width: 300px;
  height: 420px;
  background: rgba(14,11,9,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border2);
  border-radius: 16px;
  display: none;
  flex-direction: column;
  z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  overflow: hidden;
}

#chatHeader {
  padding: 13px 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

#chatClose {
  cursor: pointer;
  color: var(--text3);
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s;
  padding: 2px 4px;
}
#chatClose:hover { color: var(--text); }

#chatMessages {
  flex: 1;
  padding: 12px 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#chatMessages::-webkit-scrollbar { width: 3px; }
#chatMessages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* 채팅 메시지 버블 */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  gap: 2px;
}
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.other { align-self: flex-start; align-items: flex-start; }

.chat-msg .msg-sender {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-light);
  padding: 0 4px;
  letter-spacing: 0.02em;
}
.chat-msg.mine .msg-sender { display: none; }

.msg-sender-clickable {
  cursor: pointer;
  display: inline-block;
}
.msg-sender-clickable:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-msg .msg-bubble {
  padding: 7px 11px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  max-width: 100%;
}
.chat-msg.mine .msg-bubble {
  background: var(--accent);
  color: #100d0a;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-msg.other .msg-bubble {
  background: var(--surface2);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.chat-msg .msg-time {
  font-size: 10px;
  color: var(--text3);
  padding: 0 4px;
  letter-spacing: 0.02em;
}

.chat-msg .msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.chat-msg .msg-like-btn {
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  border-radius: 10px;
  font-size: 10px;
  line-height: 1;
  padding: 3px 7px;
  cursor: pointer;
}
.chat-msg .msg-like-btn:hover { border-color: var(--accent); color: var(--text); }
.chat-msg .msg-like-btn.liked { border-color: #ff6b93; color: #ff8cab; }

.chat-msg .msg-mention {
  color: #60a5fa;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-msg.mine .msg-mention { color: #93c5fd; }

#profileModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
}
#profileModal.show { display: flex; }
.profile-modal-card {
  width: min(320px, calc(100vw - 28px));
  background: rgba(14, 11, 9, 0.98);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 18px 16px 14px;
  position: relative;
}
.profile-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
}
#profileAvatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  object-fit: cover;
  display: block;
  margin: 0 auto 12px;
}
.profile-nickname {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
.profile-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 7px 2px;
  border-top: 1px solid var(--border);
}
.profile-row span { color: var(--text3); }
.profile-row strong { color: var(--text); font-weight: 600; }
#profileBio {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

#viewersModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 390;
}
#viewersModal.show { display: flex; }
.viewers-modal-card {
  width: min(360px, calc(100vw - 28px));
  max-height: min(70vh, 520px);
  background: rgba(14, 11, 9, 0.98);
  border: 1px solid var(--border2);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.viewers-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.viewers-close-btn {
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
}
.viewers-list {
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.viewer-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.viewer-item:hover { border-color: var(--accent); }
.viewer-item img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border2);
}
.viewer-item-text { display: flex; flex-direction: column; gap: 2px; }
.viewer-item-text strong { font-size: 13px; font-weight: 600; }
.viewer-item-text span { font-size: 11px; color: var(--text3); }
.viewer-me-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  color: #100d0a;
  background: var(--accent);
  vertical-align: middle;
}
.viewer-edit-btn {
  margin-left: auto;
  border: 1px solid var(--border2);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text2);
  border-radius: 8px;
  font-size: 11px;
  padding: 5px 8px;
  cursor: pointer;
}
.viewer-edit-btn:hover { border-color: var(--accent); color: var(--text); }
.viewers-empty {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 18px 8px;
}

#editProfileModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 410;
}
#editProfileModal.show { display: flex; }
.edit-profile-card {
  width: min(360px, calc(100vw - 28px));
  background: rgba(14, 11, 9, 0.98);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 14px;
}
.edit-profile-onboarding {
  display: none;
  font-size: 12px;
  line-height: 1.4;
  color: var(--accent-light);
  background: rgba(255, 154, 92, 0.1);
  border: 1px solid rgba(255, 154, 92, 0.3);
  border-radius: 9px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.edit-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.edit-profile-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
.edit-profile-label {
  display: block;
  font-size: 12px;
  color: var(--text3);
  margin: 8px 2px 6px;
}
#editNicknameInput,
#editBioInput {
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  padding: 9px 10px;
}
#editBioInput {
  min-height: 88px;
  resize: vertical;
}
.edit-profile-save {
  margin-top: 12px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #100d0a;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
}

/* 날짜 구분선 */
.chat-date-divider {
  text-align: center;
  font-size: 10px;
  color: var(--text3);
  margin: 6px 0;
  letter-spacing: 0.05em;
}

#chatInputWrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

#chatMentionSuggest {
  position: absolute;
  left: 12px;
  right: 54px;
  bottom: 48px;
  display: none;
  flex-direction: column;
  gap: 4px;
  background: rgba(16, 13, 10, 0.96);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 6px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 6;
}
#chatMentionSuggest.show { display: flex; }
#chatMentionSuggest .mention-item {
  border: none;
  background: transparent;
  color: var(--text2);
  padding: 6px 8px;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
#chatMentionSuggest .mention-item strong { color: var(--accent-light); font-weight: 700; }
#chatMentionSuggest .mention-item span { color: var(--text3); }
#chatMentionSuggest .mention-item:hover,
#chatMentionSuggest .mention-item.active {
  background: rgba(255, 154, 92, 0.15);
  color: var(--text);
}

#chatInput {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-size: max(13px, 16px); /* iOS zoom 방지 */
  outline: none;
  transition: border-color 0.2s;
}
#chatInput::placeholder { color: var(--text3); }
#chatInput:focus { border-color: var(--accent); }

#chatSend {
  width: 34px; height: 34px;
  border: none;
  background: var(--accent);
  color: #100d0a;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}
#chatSend:hover { background: var(--accent-light); }
#chatSend:active { transform: scale(0.93); }

/* ── Chat Toast ── */
#chatToast {
  position: fixed;
  bottom: 80px; right: 20px;
  background: rgba(16,13,10,0.96);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 260px;
  z-index: 300;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#chatToast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#toastSender { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 3px; display: none; }
#toastText { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Mobile ── */
@media (max-width: 600px) {
  .overlay { padding-bottom: 12px; }
  .overlay-content { max-width: 100%; width: 100%; padding: 0 10px; box-sizing: border-box; }
  .controls-panel { padding: 14px 14px 16px; border-radius: 16px; }

  #chatWrapper {
    /* fixed로 변경 — 키보드 올라와도 뷰포트 기준으로 고정 */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    /* 키보드 올라올 때 대응: dvh 사용 */
    max-height: 70dvh;
    max-height: 70vh; /* fallback */
    height: auto;
    min-height: 260px;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
    /* 키보드 올라올 때 채팅창이 같이 올라오도록 */
    bottom: env(keyboard-inset-height, 0px);
  }

  #chatMessages {
    /* 채팅 메시지 영역 높이 유동적으로 */
    flex: 1;
    min-height: 120px;
    max-height: 45vh;
  }

  #chatInputWrapper {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    /* 키보드 위로 올라오게 */
    position: relative;
    z-index: 1;
  }

  #chatToast { bottom: 12px; right: 10px; left: 10px; max-width: 100%; }

  .playlist-menu { width: 100%; border-left: none; border-top: 1px solid var(--border); }
}

/* ── Update Banner ── */
#updateOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
}
#updateBanner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(16,13,10,0.97);
  border: 1px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 9999;
  white-space: nowrap;
  animation: slideUp 0.3s ease;
}
#updateBanner span {
  font-size: 13px;
  color: var(--text);
}
#updateNowBtn {
  padding: 6px 14px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #100d0a;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
#updateNowBtn:hover { background: var(--accent-light); }
#updateLaterBtn { display: none; }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 600px) {
  #updateBanner {
    bottom: 12px;
    left: 12px;
    right: 12px;
    transform: none;
    white-space: normal;
    flex-wrap: wrap;
  }
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ── Lock Mode Banner ── */
#lockBanner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9990;
  background: rgba(255, 82, 82, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  letter-spacing: 0.02em;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}
#lockBanner.show {
  transform: translateY(0);
  pointer-events: auto;
}

/* ── YouTube 동시 재생 안내 배너 ── */
#yt-notice-banner {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.22,1,0.36,1);
  width: min(480px, calc(100vw - 28px));
}
#yt-notice-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
#yt-notice-banner.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  pointer-events: none;
}
#yt-notice-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(16,13,10,0.97);
  border: 1px solid rgba(255,122,47,0.35);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
}
#yt-notice-icon {
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
}
#yt-notice-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#yt-notice-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
}
#yt-notice-text span {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
  font-family: 'DM Sans', sans-serif;
}
#yt-notice-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  margin-top: 1px;
}
#yt-notice-close:hover {
  color: var(--text);
  border-color: var(--accent);
}
@media (max-width: 600px) {
  #yt-notice-banner {
    bottom: 80px;
    left: 14px;
    right: 14px;
    width: auto;
    transform: translateY(20px);
  }
  #yt-notice-banner.show { transform: translateY(0); }
  #yt-notice-banner.hide { transform: translateY(12px); }
}
