:root {
  --bg: #0d0b12;
  --surface: #171420;
  --surface-2: #1f1b2c;
  --border: rgba(244, 241, 250, 0.09);
  --text: #f4f1fa;
  --text-dim: rgba(244, 241, 250, 0.58);
  --accent: #ffb648;
  --accent-bright: #ffc86b;
  --accent-ink: #2a1c04;
  --accent-focus: rgba(255, 182, 72, 0.55);
  --accent-ring: rgba(255, 182, 72, 0.5);
  --accent-glow: rgba(255, 182, 72, 0.13);
  --accent-tint: rgba(255, 182, 72, 0.14);
  --accent-tint-soft: rgba(255, 182, 72, 0.12);
  --accent-tint-strong: rgba(255, 182, 72, 0.28);
  --accent-title-1: #ffd58a;
  --accent-title-2: #ffb648;
  --accent-now-1: rgba(255, 182, 72, 0.16);
  --accent-now-2: rgba(255, 182, 72, 0.04);
  --accent-now-3: rgba(255, 182, 72, 0.4);
  --danger: #ff9c9c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  overscroll-behavior-y: contain;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen-center {
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 24px;
  position: relative;
}

.screen-center::before {
  content: "";
  position: absolute;
  top: -30%;
  left: 0;
  right: 0;
  height: 90%;
  background: radial-gradient(
    ellipse at center,
    var(--accent-glow),
    transparent 65%
  );
  pointer-events: none;
}

.app-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  background: linear-gradient(120deg, var(--accent-title-1), var(--accent-title-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--text-dim);
  font-size: 15px;
  text-align: center;
}

.screen-center form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.field-label {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.code-input,
.name-input {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.code-input {
  min-height: 62px;
  text-align: center;
  text-indent: 0.3em;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 0 12px;
}

.name-input {
  min-height: 52px;
  font-size: 17px;
  padding: 0 16px;
}

.code-input::placeholder,
.name-input::placeholder,
#search-input::placeholder {
  color: rgba(244, 241, 250, 0.32);
}

.code-input:focus,
.name-input:focus,
#search-input:focus {
  outline: none;
  border-color: var(--accent-focus);
}

.btn-primary {
  min-height: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 800;
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled {
  opacity: 0.55;
}

.inline-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 8px;
}

.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.room-chip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

.provider-badge {
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(94, 224, 138, 0.12);
  color: #8fe8ad;
}

.provider-badge.youtube {
  background: rgba(255, 99, 99, 0.12);
  color: var(--danger);
}

.source-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.source-tab {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 700;
}

.source-tab.active {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
}

.who {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
}

.guest-name {
  max-width: 44vw;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-btn {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 2px 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: underline;
}

.search-wrap {
  padding: 2px 16px 10px;
}

#search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.host-banner {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  background: rgba(255, 99, 99, 0.1);
  border: 1px solid rgba(255, 99, 99, 0.4);
  color: #ffb4b4;
}

.content-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}

.section-title {
  margin: 14px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.result-list,
.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 8px 10px 8px 8px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 14px;
}

.art {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  background-color: var(--surface-2);
  /* data-URI fill can't use var() — intentionally classic amber in all themes */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffb648' fill-opacity='0.28'%3E%3Cpath d='M12 3v10.55A4 4 0 1 0 14 17V7h4V3h-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 46%;
}

.art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.track-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.track-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.duration {
  flex: none;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.add-btn {
  flex: none;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
  font-size: 20px;
  font-weight: 800;
}

.add-btn.done {
  background: transparent;
  border: 1px solid var(--accent-ring);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.add-btn:disabled {
  opacity: 0.75;
}

.vote-box {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vote-badge {
  min-width: 36px;
  padding: 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.vote-badge.some {
  background: var(--accent-tint);
  color: var(--accent);
}

.vote-skip-btn {
  min-width: 96px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--accent-ring);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.vote-skip-btn:active {
  background: var(--accent-tint-soft);
}

.vote-skip-btn.voted {
  border-color: var(--accent-tint-strong);
  color: var(--text-dim);
}

.vote-skip-btn:disabled {
  opacity: 0.75;
}

.row.now-playing {
  background: linear-gradient(
      135deg,
      var(--accent-now-1),
      var(--accent-now-2)
    ),
    var(--surface);
  border-color: var(--accent-now-3);
}

.now-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.row.now-playing .track-name {
  font-size: 16px;
  font-weight: 700;
}

.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.eq span {
  width: 3px;
  height: 4px;
  border-radius: 1px;
  background: var(--accent);
  animation: eq-bounce 1s ease-in-out infinite;
}

.eq span:nth-child(2) {
  animation-delay: 0.2s;
}

.eq span:nth-child(3) {
  animation-delay: 0.45s;
}

@keyframes eq-bounce {
  0%,
  100% {
    height: 4px;
  }
  50% {
    height: 12px;
  }
}

.queue-num {
  flex: none;
  width: 22px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.rank-num {
  flex: none;
  width: 30px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.decade-group {
  margin: 0 0 8px;
}

.decade-head {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.decade-head::after {
  content: "▸";
  font-size: 12px;
  color: var(--text-dim);
}

.decade-head.open {
  border-color: var(--accent-ring);
  color: var(--accent);
}

.decade-head.open::after {
  content: "▾";
  color: var(--accent);
}

.year-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 2px 4px;
}

.year-chip {
  min-width: 58px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.year-chip.active {
  border-color: var(--accent-ring);
  background: var(--accent-tint);
  color: var(--accent);
}

.load-more-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.load-more-btn:disabled {
  opacity: 0.6;
}

.empty-state,
.muted-note {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: min(85vw, 420px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #2a2436;
  color: var(--text);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 40;
}

/* ------------------------------------------------------------ theme variants
   :root above IS the classic palette — [data-theme] override blocks mirror
   receiver/css/receiver.css. Registered in js/themes.js + the backend
   allow-list; those three move together. --text/--text-dim/--danger stay
   classic — every theme is dark. */

[data-theme="midnight"] {
  --bg: #060a14;
  --surface: #0d1526;
  --surface-2: #14203a;
  --border: rgba(125, 211, 252, 0.14);
  --accent: #7dd3fc;
  --accent-bright: #bae6fd;
  --accent-ink: #052738;
  --accent-focus: rgba(125, 211, 252, 0.55);
  --accent-ring: rgba(125, 211, 252, 0.5);
  --accent-glow: rgba(125, 211, 252, 0.13);
  --accent-tint: rgba(125, 211, 252, 0.14);
  --accent-tint-soft: rgba(125, 211, 252, 0.12);
  --accent-tint-strong: rgba(125, 211, 252, 0.28);
  --accent-title-1: #bae6fd;
  --accent-title-2: #7dd3fc;
  --accent-now-1: rgba(125, 211, 252, 0.16);
  --accent-now-2: rgba(125, 211, 252, 0.04);
  --accent-now-3: rgba(125, 211, 252, 0.4);
}

[data-theme="sunset"] {
  --bg: #16090f;
  --surface: #241019;
  --surface-2: #331825;
  --border: rgba(251, 113, 133, 0.14);
  --accent: #fb7185;
  --accent-bright: #fda4af;
  --accent-ink: #4c0519;
  --accent-focus: rgba(251, 113, 133, 0.55);
  --accent-ring: rgba(251, 113, 133, 0.5);
  --accent-glow: rgba(251, 113, 133, 0.13);
  --accent-tint: rgba(251, 113, 133, 0.14);
  --accent-tint-soft: rgba(251, 113, 133, 0.12);
  --accent-tint-strong: rgba(251, 113, 133, 0.28);
  --accent-title-1: #fda4af;
  --accent-title-2: #fb7185;
  --accent-now-1: rgba(251, 113, 133, 0.16);
  --accent-now-2: rgba(251, 113, 133, 0.04);
  --accent-now-3: rgba(251, 113, 133, 0.4);
}

[data-theme="mono"] {
  --bg: #0a0a0c;
  --surface: #17181b;
  --surface-2: #222327;
  --border: rgba(229, 231, 235, 0.14);
  --accent: #e5e7eb;
  --accent-bright: #f9fafb;
  --accent-ink: #1f2023;
  --accent-focus: rgba(229, 231, 235, 0.55);
  --accent-ring: rgba(229, 231, 235, 0.5);
  --accent-glow: rgba(229, 231, 235, 0.13);
  --accent-tint: rgba(229, 231, 235, 0.14);
  --accent-tint-soft: rgba(229, 231, 235, 0.12);
  --accent-tint-strong: rgba(229, 231, 235, 0.28);
  --accent-title-1: #f9fafb;
  --accent-title-2: #e5e7eb;
  --accent-now-1: rgba(229, 231, 235, 0.16);
  --accent-now-2: rgba(229, 231, 235, 0.04);
  --accent-now-3: rgba(229, 231, 235, 0.4);
}
