/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d10;
  --bg2:       #141418;
  --bg3:       #1c1c22;
  --bg4:       #252530;
  --border:    #2a2a38;
  --accent:    #ff3a00;
  --accent2:   #ff7a00;
  --accent-glow: rgba(255, 58, 0, 0.35);
  --text:      #f0f0f5;
  --text2:     #9898b0;
  --text3:     #5a5a72;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
}

html, body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* ── Views ────────────────────────────────────────────────────────────────── */
.view { display: none; height: 100dvh; overflow-x: hidden; overflow-y: auto; }
.view.active { display: flex; flex-direction: column; }

/* ── Landing ──────────────────────────────────────────────────────────────── */
.landing-topbar {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  flex-shrink: 0;
}

.landing-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 1rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% 120%, rgba(255,58,0,0.18) 0%, transparent 70%),
    var(--bg);
}

.logo-mark {
  font-size: 4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 24px var(--accent-glow));
  line-height: 1;
}

.logo-title {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-title span {
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
}

.logo-sub {
  color: var(--text2);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
}

/* Public events on landing */
.public-events-section {
  width: 100%;
  max-width: 560px;
  margin: 0 auto 2rem;
  padding: 0 1rem;
}
.public-events-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 0.75rem;
}
.public-events-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.public-event-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.public-event-card:hover { border-color: var(--accent); background: var(--bg3); }
.public-event-info { flex: 1; min-width: 0; }
.public-event-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.public-event-meta { font-size: 0.82rem; color: var(--text3); margin-top: 0.15rem; }
.public-event-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255,58,0,0.12);
  border: 1px solid rgba(255,58,0,0.3);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 2px 16px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 24px var(--accent-glow); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); border-color: var(--text3); }

.btn-icon {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem;
  width: 40px;
  height: 40px;
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--bg4); border-color: var(--accent); color: var(--accent); }

.btn-lg { padding: 0.85rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-full { width: 100%; }

.btn-back {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}
.btn-back:hover { color: var(--text); }

.btn-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.btn-close:hover { color: var(--text); }

/* ── Card center (join / login) ───────────────────────────────────────────── */
#view-join, #view-admin-login {
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(255,58,0,0.12) 0%, transparent 70%),
    var(--bg);
}

/* Join page two-column layout */
.join-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  max-width: 820px;
}

.join-form-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.join-form-wrap h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Public events panel inside join view */
.join-layout .public-events-section {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 0;
}

.join-layout .public-events-list {
  max-height: calc(100dvh - 8rem);
  overflow-y: auto;
}

.card-center {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.card-center h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .join-layout {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .join-form-wrap { max-width: none; }
  .join-layout .public-events-list { max-height: none; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"], input[type="password"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,58,0,0.15);
}
input::placeholder { color: var(--text3); }

.error-msg {
  color: #ff6b6b;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ── Admin Dashboard ──────────────────────────────────────────────────────── */
#view-admin-dashboard {
  background: var(--bg);
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.room-event-id {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.08em;
  vertical-align: middle;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .room-event-id { display: none; }
}

.logo-small {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-admin {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dashboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.dashboard-body h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.dashboard-create {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.inline-form {
  display: flex;
  gap: 0.75rem;
}

.inline-form input { flex: 1; }

/* Toggle switch */
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.toggle-input { display: none; }
.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--bg4);
  border-radius: 11px;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text3);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle-input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); background: #fff; }
.toggle-text { font-size: 0.88rem; color: var(--text2); }

.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.event-card-info { flex: 1; min-width: 0; }
.event-card-name { font-weight: 700; font-size: 1.05rem; }
.event-card-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-shadow: 0 0 20px var(--accent-glow);
}
.event-card-meta { font-size: 0.82rem; color: var(--text3); margin-top: 0.2rem; }

.badge-live {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255,58,0,0.12);
  border: 1px solid rgba(255,58,0,0.3);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.event-card-track {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg3);
  border-radius: 6px;
}
.event-card-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.event-card-track-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.event-card-track-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-card-track-channel {
  font-size: 0.75rem;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.badge-public {
  font-size: 0.7rem;
  font-weight: 700;
  color: #4caf8a;
  background: rgba(76,175,138,0.12);
  border: 1px solid rgba(76,175,138,0.3);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
  vertical-align: middle;
  margin-left: 0.3rem;
}

.events-empty {
  color: var(--text3);
  text-align: center;
  padding: 2rem;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Room ─────────────────────────────────────────────────────────────────── */
#view-room {
  background: var(--bg);
  overflow: hidden;
}

.room-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-top: max(0.75rem, env(safe-area-inset-top));
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0.75rem;
}

.room-header-left { flex: 1; min-width: 0; }
.room-header-center { display: flex; justify-content: center; }
.room-header-right { flex: 1; display: flex; justify-content: flex-end; gap: 0.5rem; }

.user-count {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text2);
  font-size: 0.85rem;
}
.user-count svg { width: 14px; height: 14px; }

/* #view-room is already flex-column from .view; music-player sits between
   header and room-body on mobile via flex order.                            */
#view-room { display: flex; flex-direction: column; }
#audio-player { display: none; }

/* Music player: mobile — inline between header and queue */
.music-player {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  order: 0; /* before room-body */
}

.room-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  order: 1;
}

/* No-track placeholder lives inside room-body on mobile */
.no-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2.5rem 2rem;
  color: var(--text3);
}
.no-track-icon { font-size: 3rem; opacity: 0.3; }
.no-track p { font-size: 1rem; }
.no-track .hint { font-size: 0.85rem; }

/* Artwork */
.mp-artwork-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 320px;
  position: relative;
  background: var(--bg3);
  overflow: hidden;
  flex-shrink: 0;
}
.mp-artwork {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.audio-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.audio-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Body below artwork */
.mp-body {
  padding: 1.1rem 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* Track info */
.mp-info { min-width: 0; }
.mp-title {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.mp-channel {
  font-size: 0.85rem;
  color: var(--text2);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Progress bar */
.mp-progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.mp-time {
  font-size: 0.75rem;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
  width: 36px;
  flex-shrink: 0;
}
.mp-time:last-child { text-align: right; }
.mp-bar-track {
  flex: 1;
  position: relative;
  height: 36px; /* tall tap target */
  display: flex;
  align-items: center;
}
.mp-bar-fill {
  position: absolute;
  inset: 0;
  margin: auto 0;
  height: 4px;
  border-radius: 2px;
  background: var(--bg4);
  pointer-events: none;
  overflow: hidden;
}
.mp-bar-fill::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s linear;
}
.mp-seek-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
.mp-seek-input:disabled { cursor: default; }

/* Controls */
.mp-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.mp-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.mp-btn:active { transform: scale(0.9); }
.mp-btn svg { display: block; }
.mp-btn-sec {
  width: 44px;
  height: 44px;
  color: var(--text2);
}
.mp-btn-sec svg { width: 22px; height: 22px; }
.mp-btn-sec:hover { background: var(--bg3); }
.mp-btn-play {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(255,100,0,0.35);
}
.mp-btn-play svg { width: 28px; height: 28px; }
.mp-btn-play:hover { background: var(--accent2); }
.mp-spin { animation: spin 1s linear infinite; }

/* Admin row */
.mp-admin-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}
.mp-admin-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

/* ── Queue column ─────────────────────────────────────────────────────────── */
.queue-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.queue-header h3 { font-size: 0.95rem; font-weight: 700; }
.queue-count { font-size: 0.8rem; color: var(--text3); }

.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.queue-empty {
  text-align: center;
  color: var(--text3);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.queue-item:hover { background: var(--bg3); }

.queue-item-num {
  font-size: 0.78rem;
  color: var(--text3);
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.queue-item-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg3);
  flex-shrink: 0;
}

.queue-item-info { flex: 1; min-width: 0; }
.queue-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.queue-item-meta { font-size: 0.77rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-channel { font-size: 0.77rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.queue-item-del {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.queue-item-del:hover { background: rgba(255,58,0,0.15); color: var(--accent); }

/* Queue action buttons (ban, replay, remove) */
.queue-item-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}
.queue-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--text3);
  transition: all 0.15s;
  line-height: 1;
}
.queue-action-btn.remove:hover   { background: rgba(255,58,0,0.15); color: var(--accent); }
.queue-action-btn.ban:hover      { background: rgba(255,58,0,0.15); color: var(--accent); }
.queue-action-btn.unban:hover    { background: rgba(76,175,138,0.15); color: #4caf8a; }
.queue-action-btn.replay:hover   { background: rgba(255,122,0,0.15); color: var(--accent2); }
.queue-action-btn.play-now:hover { background: rgba(255,122,0,0.2); color: var(--accent2); }

/* Drag handle */
.queue-drag-handle {
  cursor: grab;
  color: var(--text3);
  font-size: 1rem;
  padding: 0 0.2rem;
  opacity: 0.4;
  flex-shrink: 0;
}
.queue-drag-handle:active { cursor: grabbing; }
.draggable-item:hover .queue-drag-handle { opacity: 0.8; }

/* Drag-and-drop states */
.queue-item.dragging { opacity: 0.4; }
.queue-item.drag-over {
  border-top: 2px solid var(--accent2);
  margin-top: -2px;
}

/* History section */
.history-item { opacity: 0.65; }
.history-item:hover { opacity: 1; }
.queue-item.clickable { cursor: pointer; }
.queue-item.clickable:hover { background: var(--bg3); opacity: 1; }
.queue-item.banned { opacity: 0.45; }
/* ── Collapsible queue sections ───────────────────────────────────────────── */
.qs-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.75rem 0.85rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
}
.qs-header:hover { background: var(--bg3); }
.qs-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  flex: 1;
}
.qs-meta {
  font-size: 0.75rem;
  color: var(--text3);
}
.qs-chevron {
  width: 18px;
  height: 18px;
  color: var(--text3);
  flex-shrink: 0;
  transition: transform 0.2s;
  transform: rotate(-90deg); /* collapsed = pointing right */
}
.qs-chevron svg { width: 18px; height: 18px; display: block; }
.qs-chevron.open { transform: rotate(0deg); } /* open = pointing down */

.qs-body { padding: 0.35rem 0.5rem; }

/* Badge banned in search */
.badge-banned {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(255,58,0,0.12);
  border: 1px solid rgba(255,58,0,0.3);
  border-radius: 5px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.search-result-item.banned { opacity: 0.5; }

/* (seek bar now lives inside .mp-progress) */

/* Listeners panel (dropdown from header) */
.room-header-center { position: relative; }
.listeners-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  max-width: 260px;
  z-index: 50;
}
.listeners-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
}
.listeners-list { padding: 0.4rem; max-height: 240px; overflow-y: auto; }
.listeners-empty { padding: 0.8rem; text-align: center; font-size: 0.85rem; color: var(--text3); }
.listener-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
}
.listener-item:hover { background: var(--bg3); }
.listener-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.listener-name { font-size: 0.88rem; }

/* ── Panels (search / fallback) ───────────────────────────────────────────── */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
}

.panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h3 { font-size: 1rem; font-weight: 700; }

.panel-hint {
  font-size: 0.85rem;
  color: var(--text2);
  padding: 0.75rem 1.25rem 0;
}

.search-bar {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.source-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.6rem;
}

.tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tab:not(.active):hover { border-color: var(--text3); color: var(--text); }

.search-input-row {
  display: flex;
  gap: 0.5rem;
}
.search-input-row input { flex: 1; }

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-hint {
  text-align: center;
  color: var(--text3);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover { background: var(--bg3); }

.search-result-thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg3);
  flex-shrink: 0;
}

.search-result-info { flex: 1; min-width: 0; }
.search-result-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-channel { font-size: 0.78rem; color: var(--text2); }
.search-result-dur { font-size: 0.75rem; color: var(--text3); margin-top: 0.1rem; }

.search-result-add {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.search-result-add:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.search-loading, .search-error {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.9rem;
}
.search-loading { color: var(--text3); }
.search-error { color: #ff6b6b; }

.fallback-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.fallback-list-header h4 { font-size: 0.88rem; font-weight: 600; color: var(--text2); }

/* ── Overlay bg ───────────────────────────────────────────────────────────── */
.overlay-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  align-items: center;
}

.toast {
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  max-width: min(360px, calc(100vw - 2rem));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease;
}
.toast.success { border-color: #22c55e; color: #86efac; }
.toast.error { border-color: #ef4444; color: #fca5a5; }
.toast.warning { border-color: #f59e0b; color: #fcd34d; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Desktop: fixed bottom player bar ────────────────────────────────────── */
@media (min-width: 641px) {
  /* room-body takes full width; no side-by-side split */
  .room-body {
    flex-direction: column;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .no-track { display: none; } /* placeholder not needed on desktop */

  /* Fixed bottom bar */
  .music-player {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(82px + env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: center;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 200;
    padding: 0 max(1rem, env(safe-area-inset-right));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-bottom: env(safe-area-inset-bottom);
    gap: 0;
  }

  /* Small square thumbnail */
  .mp-artwork-wrap {
    width: 52px;
    height: 52px;
    aspect-ratio: unset;
    max-height: none;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 0.85rem;
  }

  /* Body becomes a flex row filling the bar */
  .mp-body {
    flex: 1;
    flex-direction: row;
    align-items: center;
    padding: 0;
    gap: 0;
    min-width: 0;
  }

  /* Left: title + channel */
  .mp-info {
    flex: 0 0 200px;
    max-width: 200px;
    padding-right: 1rem;
  }
  .mp-title { font-size: 0.9rem; }
  .mp-channel { font-size: 0.78rem; }

  /* Center: controls, then progress to the right */
  .mp-controls {
    flex-shrink: 0;
    gap: 0.5rem;
    order: 2;
    padding: 0 1.25rem;
  }
  .mp-btn-play { width: 44px; height: 44px; box-shadow: none; }
  .mp-btn-play svg { width: 20px; height: 20px; }
  .mp-btn-sec { width: 36px; height: 36px; }
  .mp-btn-sec svg { width: 18px; height: 18px; }

  /* Right: timeline */
  .mp-progress {
    flex: 1;
    order: 3;
    padding-left: 1rem;
  }

  /* Admin row: right-most, compact */
  .mp-admin-row {
    order: 4;
    flex-shrink: 0;
    padding-top: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
    margin-left: 0.5rem;
    gap: 0.5rem;
  }
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .music-player {
    border-bottom: 1px solid var(--border);
  }

  .room-header-right .btn span { display: none; }
}
