:root {
  --bg: #0c0d10;
  --surface: rgb(24 26 31 / 0.72);
  --surface-2: rgb(255 255 255 / 0.08);
  --border: rgb(255 255 255 / 0.1);
  --text: #f4f5f7;
  --muted: #a3a9b2;
  --accent: #1ed760;
  --accent-text: #07120b;
  --tint: #1ed760;
  --trash: #f2545b;
  --mid: #f5a524;
  --peak: #1ed760;
  --skip: #7b8290;
  --radius: 20px;
  --shade: rgb(12 13 16 / 0.55);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f6;
    --surface: rgb(255 255 255 / 0.78);
    --surface-2: rgb(0 0 0 / 0.06);
    --border: rgb(0 0 0 / 0.08);
    --text: #121417;
    --muted: #59606b;
    --accent: #12a84a;
    --accent-text: #ffffff;
    --shade: rgb(243 244 246 / 0.55);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Blurred cover art behind everything, swapped per song */
.backdrop {
  position: fixed;
  inset: -15%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(70px) saturate(1.6);
  opacity: 0;
  transition: opacity 1.2s ease;
}
.backdrop.on { opacity: 0.6; }
.backdrop-shade {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--tint) 30%, transparent), transparent 70%),
    linear-gradient(to bottom, transparent, var(--shade) 40%, var(--bg) 100%);
}

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 64px; }
.center { text-align: center; padding-top: 14vh; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { color: var(--text); text-decoration: none; font-weight: 900; font-size: 20px; letter-spacing: -0.03em; }
.pill { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; backdrop-filter: blur(12px); }

.hero-word { font-size: clamp(48px, 14vw, 72px); font-weight: 900; letter-spacing: -0.05em; line-height: 1; margin: 0 0 16px; }

h1 { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; margin: 0 0 8px; }
h2 { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 36px 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  backdrop-filter: blur(16px);
}

.banner {
  background: color-mix(in srgb, var(--trash) 22%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--trash) 55%, transparent);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-weight: 600;
}

input, select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

label { display: block; margin: 16px 0; font-size: 15px; font-weight: 600; color: var(--muted); }
label input, label select { margin-top: 8px; }

button, .btn {
  display: inline-block;
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: 14px;
  padding: 14px 22px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { padding: 8px 14px; font-size: 14px; }
button:disabled { opacity: 0.5; cursor: default; }
button:active { transform: scale(0.97); }

.row { display: flex; gap: 10px; }
.row input { flex: 1; min-width: 0; }
.center .row { max-width: 380px; margin: 24px auto 0; }

/* Now playing */
.now { text-align: center; }
.cover {
  width: min(78vw, 340px);
  aspect-ratio: 1;
  margin: 4px auto 22px;
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 24px 60px -20px color-mix(in srgb, var(--tint) 70%, black), 0 8px 24px rgb(0 0 0 / 0.35);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.title { font-size: clamp(26px, 7vw, 34px); font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 6px; overflow-wrap: anywhere; }
.artist { font-size: 19px; font-weight: 700; margin: 0; }
.album { font-size: 15px; color: var(--muted); margin: 2px 0 0; }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin: 22px 0 0; overflow: hidden; }
.bar > div { height: 100%; background: var(--tint); width: 0; transition: width 0.5s linear; }
.times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.idle { padding: 48px 8px; color: var(--muted); font-size: 19px; font-weight: 600; text-align: center; }

/* Vote buttons */
.votes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.votes button {
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--border);
  min-height: 72px;
  padding: 0;
  font-size: 18px;
  font-weight: 900;
  border-radius: 16px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.votes.compact button { min-height: 52px; font-size: 15px; border-radius: 12px; }
.votes button[data-choice="trash"].on { background: var(--trash); border-color: var(--trash); color: #fff; }
.votes button[data-choice="mid"].on { background: var(--mid); border-color: var(--mid); color: #1b1300; }
.votes button[data-choice="peak"].on { background: var(--peak); border-color: var(--peak); color: #07120b; box-shadow: 0 0 28px -4px var(--peak); }
.votes button[data-choice="skip"].on { background: var(--skip); border-color: var(--skip); color: #fff; }
@media (max-width: 340px) { .votes:not(.compact) { grid-template-columns: repeat(2, 1fr); } }

.status { font-size: 14px; color: var(--muted); margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.rules { text-align: center; font-size: 14px; color: var(--muted); margin: 14px 0 0; }

/* Compact track rows */
.track { display: flex; gap: 14px; align-items: center; min-width: 0; text-align: left; }
.track img, .track .ph { width: 60px; height: 60px; border-radius: 10px; flex: none; background: var(--surface-2); object-fit: cover; }
.track .meta { min-width: 0; }
.track .name { font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track .sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.queue .track { padding: 8px 0; }
.queue .track + .track { border-top: 1px solid var(--border); }
.queue .track img, .queue .track .ph { width: 44px; height: 44px; border-radius: 8px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

.result { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.result.added, .result.already { color: var(--peak); }
.result.rejected, .result.too-few { color: var(--muted); }
.result.no-playlist, .result.add-failed { color: var(--mid); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.chip.trash { background: color-mix(in srgb, var(--trash) 35%, transparent); }
.chip.mid { background: color-mix(in srgb, var(--mid) 35%, transparent); }
.chip.peak { background: color-mix(in srgb, var(--peak) 35%, transparent); }

.empty { color: var(--muted); text-align: center; padding: 20px 0; }

/* Target playlist, always visible above the song */
.playlist { display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-bottom: 18px; color: var(--text); text-decoration: none; }
.playlist img, .playlist .ph { width: 52px; height: 52px; border-radius: 10px; flex: none; object-fit: cover; background: var(--surface-2); }
.playlist .ph { display: grid; place-items: center; font-weight: 900; color: var(--muted); }
.playlist .meta { min-width: 0; flex: 1; }
.playlist .label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.playlist .name { font-size: 19px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist .count { flex: none; text-align: right; font-size: 13px; color: var(--muted); }
.playlist .count b { display: block; font-size: 24px; line-height: 1; color: var(--tint); }
.playlist.none { justify-content: center; color: var(--mid); font-weight: 700; }

.end-vote { margin-top: 12px; }

.sp-link { color: inherit; text-decoration: none; }
.sp-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.host-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-color: color-mix(in srgb, var(--tint) 45%, var(--border));
}
.host-label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.host-label .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-bar .icon-btn { background: var(--surface-2); }
.host-badge {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
  background: var(--tint);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.top-actions .pill { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: none;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

/* Dialogs: a bottom sheet on phones, a centered panel on wide screens */
dialog.sheet {
  width: min(560px, 100%);
  max-height: 88vh;
  margin: auto auto 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
}
dialog.sheet::backdrop { background: rgb(0 0 0 / 0.55); backdrop-filter: blur(4px); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 24px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.sheet-head h1 { margin: 0; }

/* Stats */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.tile { background: var(--surface-2); border-radius: 16px; padding: 14px; }
.tile b { display: block; font-size: 30px; font-weight: 900; line-height: 1.1; }
.tile span { font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.tabs button { flex: 1; padding: 10px 0; font-size: 14px; background: var(--surface-2); color: var(--text); border-radius: 12px; }
.tabs button.on { background: var(--text); color: var(--bg); }
.stat-row { padding: 10px 0; border-top: 1px solid var(--border); }
.stat-row .chips { margin-top: 6px; }
.stat-row .heard { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--peak);
  color: #07120b;
  font-weight: 900;
  padding: 14px 20px;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.4);
  z-index: 10;
}
