:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181c20;
  --panel-2: #20262b;
  --line: #333d44;
  --text: #f6f2ea;
  --muted: #aab3b6;
  --green: #65d28a;
  --cyan: #58c7d8;
  --red: #ff6b73;
  --violet: #b39cff;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(160deg, rgba(88, 199, 216, 0.14), transparent 36rem),
    linear-gradient(20deg, rgba(179, 156, 255, 0.13), transparent 34rem),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 90px),
    var(--bg);
}
button, input, select { font: inherit; min-width: 0; }
button { cursor: pointer; border: 0; }
button:disabled, input:disabled { opacity: 0.45; cursor: not-allowed; }
.is-hidden { display: none !important; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 42px);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent 48%), rgba(24,28,32,0.94);
  box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--text);
  color: #101214;
  font-weight: 900;
}
.auth-card h1 { margin: 22px 0 10px; font-size: clamp(2rem, 6vw, 3.7rem); line-height: 1; }
.auth-card p { color: var(--muted); line-height: 1.55; }
.auth-actions, .demo-auth { display: grid; gap: 10px; margin-top: 18px; }
.auth-button, .demo-auth button, .search-box button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  border-radius: 8px;
  color: #101214;
  background: var(--text);
  font-weight: 850;
  text-decoration: none;
}
.auth-button.discord { background: var(--violet); }
.auth-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}
.demo-auth { grid-template-columns: 1fr auto; }
input, select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #101416;
  outline: none;
}
input:focus, select:focus { border-color: var(--cyan); }
.fine-print { font-size: 0.86rem; }

.room-shell { width: min(1480px, 100%); margin: 0 auto; padding: 20px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.room-switch, .ghost-button, .avatar-button, .icon-button, .tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24,28,32,0.82);
  color: var(--text);
  padding: 0 12px;
}
.room-switch, .ghost-button, .tab { max-width: 100%; overflow-wrap: anywhere; }
.avatar-button { width: 42px; border-radius: 999px; padding: 0; }
.pill, .service-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}
.service-badge { width: fit-content; color: #111; background: var(--green); border: 0; }

.layout { display: flex; gap: 18px; align-items: stretch; min-width: 0; }
.stage, .side {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.035), transparent), rgba(24,28,32,0.94);
  box-shadow: var(--shadow);
}
.stage { flex: 1; min-width: 0; padding: 18px; }
.side { width: 440px; min-width: 0; padding: 14px; }
.now-playing { display: grid; grid-template-columns: minmax(140px, 230px) 1fr; gap: 24px; align-items: center; }
.cover {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(101,210,138,.28), rgba(88,199,216,.14)), #0b0e10;
  overflow: hidden;
  font-size: 2rem;
  font-weight: 900;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.track-copy h1 { margin: 10px 0; font-size: clamp(2rem, 5vw, 4.7rem); line-height: 1.02; overflow-wrap: anywhere; }
.track-copy p { color: var(--muted); font-size: 1.05rem; }
.player-frame {
  margin-top: 18px;
  display: grid;
  place-items: center;
  min-height: 315px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0b0e10;
}
.player-frame iframe, .player-frame > div:not(.empty-player) { width: 100%; height: 100%; border: 0; }
.player-frame audio {
  width: min(720px, calc(100% - 32px));
  accent-color: var(--green);
}
.empty-player { color: var(--muted); padding: 24px; text-align: center; }
.transport { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(10,13,15,0.58); min-width: 0; }
.icon-button { width: 44px; padding: 0; font-size: 1.3rem; }
.play-button { width: 56px; height: 56px; border-radius: 999px; background: linear-gradient(135deg, var(--green), var(--cyan)); color: #0b0e10; font-weight: 900; }
#seekBar { flex: 1; accent-color: var(--green); }
#timecode, .status, .permission-note { color: var(--muted); }
.permission-note { min-height: 22px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tab.active { background: var(--text); color: #101214; font-weight: 900; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.search-box { display: grid; grid-template-columns: 1fr 120px minmax(72px, auto); gap: 8px; }
.result-list, .queue-list, .people-list, .chart-list { display: grid; gap: 8px; padding: 0; margin: 12px 0 0; list-style: none; max-height: 52vh; overflow: auto; }
.result-item, .queue-item, .person-item {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12171a;
}
.charts-block { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.chart-actions { display: grid; grid-template-columns: repeat(2, minmax(64px, 1fr)); gap: 6px; }
.chart-tab {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  font-weight: 800;
}
.chart-tab.active { background: var(--text); color: #101214; }
.chart-rank {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: rgba(250,88,106,0.18);
  color: #ffc0c8;
  font-weight: 900;
}
.result-item img, .queue-item img, .person-avatar { width: 58px; height: 58px; border-radius: 8px; object-fit: cover; background: var(--panel-2); }
.result-item strong, .queue-item strong, .person-item strong { display: block; overflow-wrap: anywhere; }
.result-item span, .queue-item span, .person-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.82rem; }
.result-item button, .queue-item button, .role-actions button { min-height: 34px; border-radius: 8px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.queue-actions { display: grid; grid-template-columns: repeat(3, minmax(34px, auto)); gap: 6px; justify-content: end; }
.queue-actions button {
  min-height: 32px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 8px;
  font-size: 0.78rem;
}
.person-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; min-width: 0; }
.person-actions button {
  min-height: 32px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 8px;
  font-size: 0.78rem;
}
.queue-item.active { border-color: var(--green); background: rgba(101,210,138,0.09); }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.panel-head h2 { margin: 0 0 4px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.danger { color: #ffb0b4; border-color: rgba(255,107,115,.35); }
.role-tools { display: grid; gap: 10px; }
.role-tools summary { color: var(--muted); cursor: pointer; margin: 10px 0; }
.role-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.history-block { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.history-block h3 { margin: 0; font-size: 0.95rem; }
.history-list { display: grid; gap: 6px; padding: 0; margin: 10px 0 0; list-style: none; color: var(--muted); font-size: 0.84rem; }

@media (max-width: 950px) {
  .topbar, .layout { flex-direction: column; align-items: stretch; }
  .side { width: 100%; }
  .now-playing { grid-template-columns: 1fr; text-align: center; }
  .cover { width: min(240px, 72%); justify-self: center; }
}

@media (max-width: 560px) {
  .room-shell { padding: 12px; }
  .top-actions { justify-content: flex-start; }
  .top-actions > * { flex: 1 1 120px; }
  .search-box { grid-template-columns: 1fr; }
  .transport { flex-wrap: wrap; justify-content: center; }
  #seekBar { flex-basis: 100%; }
  .result-item, .queue-item, .person-item { grid-template-columns: 50px 1fr 40px; }
  .queue-item { grid-template-columns: 50px 1fr; }
  .queue-actions { grid-column: 1 / -1; grid-template-columns: repeat(5, 1fr); justify-content: stretch; }
  .person-item { grid-template-columns: 50px 1fr; }
  .person-actions { grid-column: 1 / -1; justify-content: stretch; }
  .person-actions button { flex: 1 1 auto; }
  .track-copy h1 { font-size: 2rem; }
}
