:root {
  --bg0: #060912;
  --bg1: #0a1530;
  --teal: #36e6c8;
  --blue: #4aa8ff;
  --purple: #9b6cff;
  --ink: #eaf2ff;
  --muted: #7e8edb;
  --glass: rgba(22, 34, 66, 0.42);
  --stroke: rgba(140, 175, 255, 0.22);
  --accent: 74, 168, 255;        /* per-track tint (set by app.js) */
}

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

html, body { height: 100%; }

body {
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg0);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* animated liquid background */
.bg {
  position: fixed;
  inset: -20% -20% -20% -20%;
  z-index: -2;
  background:
    radial-gradient(40% 50% at 20% 25%, rgba(54, 230, 200, 0.18), transparent 60%),
    radial-gradient(45% 55% at 80% 30%, rgba(155, 108, 255, 0.20), transparent 60%),
    radial-gradient(60% 60% at 50% 90%, rgba(74, 168, 255, 0.18), transparent 60%),
    var(--bg1);
  filter: blur(40px) saturate(1.2);
  animation: drift 24s ease-in-out infinite alternate,
             hue 110s ease-in-out infinite alternate;   /* slow ambient evolution */
}
@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1.05) rotate(0deg); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.12) rotate(6deg); }
}
@keyframes hue {
  0%   { filter: blur(40px) saturate(1.2) hue-rotate(-14deg); }
  100% { filter: blur(40px) saturate(1.2) hue-rotate(14deg); }
}

/* vignette (depth) + film grain (texture) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(125% 100% at 50% 30%, transparent 52%, rgba(3,6,14,0.6) 100%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 50; pointer-events: none;
  opacity: 0.045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* focus + hover affordances */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 8px; }
.tag { transition: transform .15s, background .2s; }
.tag:hover { transform: translateY(-1px); }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(18px, 5vw, 54px);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.logo {
  font-weight: 700; font-size: 24px; letter-spacing: 2px;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--purple));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(74,168,255,0.3);
}
.host { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); letter-spacing: 1px; }

.status { display: flex; align-items: center; gap: 12px; }
.listeners {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 0.5px;
  color: var(--muted);
}
.listeners[hidden] { display: none; }
.listeners .ic-ppl { width: 15px; height: 15px; fill: currentColor; opacity: 0.8; }
.listeners #listenerCount { color: var(--teal); font-weight: 500; }
.listeners .lsuf { opacity: 0.85; }
@media (max-width: 560px) { .listeners .lsuf { display: none; } }

.live {
  display: flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 2px;
  color: var(--muted); padding: 6px 12px; border: 1px solid var(--stroke);
  border-radius: 999px; background: rgba(10,16,34,0.6); backdrop-filter: blur(12px);
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #51607f; transition: 0.3s; }
.live.on { color: var(--teal); border-color: rgba(54,230,200,0.4); box-shadow: inset 0 0 16px rgba(54,230,200,0.12); }
.live.on .dot { background: var(--teal); box-shadow: 0 0 12px var(--teal); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* stage */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: stretch;
  padding: 0 clamp(18px, 5vw, 54px) 28px;
}
@media (max-width: 860px) { .stage { grid-template-columns: 1fr; } .side { order: 2; } }

/* player card */
.player {
  position: relative; overflow: hidden;
  border: 1px solid var(--stroke); border-top-color: rgba(180,205,255,0.30);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0) 40%),
    var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  padding: clamp(26px, 4vw, 48px);
  padding-bottom: clamp(30px, 4vw, 44px);
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: min(72vh, 560px);
  box-shadow: 0 30px 80px -40px rgba(0,0,0,0.8);
}
/* atmospheric bloom behind the orb */
.player::before {
  content: ""; position: absolute; z-index: 0; pointer-events: none;
  top: 6%; left: 50%; width: 62%; aspect-ratio: 1; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(var(--accent), 0.30), rgba(155,108,255,0.12) 45%, transparent 70%);
  filter: blur(60px); transition: background 1.6s ease;
}
.viz { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; opacity: 1; mix-blend-mode: screen; }
.now, .controls { position: relative; z-index: 1; }

.np-label, .h-label {
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  letter-spacing: 3px; color: var(--muted);
}
.np-label { margin-bottom: 2px; opacity: 0.85; }
.title {
  font-size: clamp(34px, 6vw, 60px); font-weight: 700; line-height: 1.02;
  margin: 14px 0 12px; letter-spacing: -1.5px;
}
/* mood / style tags */
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-family: "JetBrains Mono", monospace; font-size: 11px; letter-spacing: 0.5px;
  padding: 5px 11px; border-radius: 999px; text-transform: lowercase;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(74,168,255,0.14), rgba(155,108,255,0.10));
  color: #bcd4ff;
}
.sub { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.badge {
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(74, 168, 255, 0.10); color: var(--blue);
}
.badge.ghost { background: transparent; color: var(--muted); border-color: transparent; padding: 0; }
.dur-sep { color: var(--muted); opacity: 0.5; }

/* controls */
.controls { display: flex; align-items: center; gap: 22px; margin-top: 24px; }
.play {
  width: 66px; height: 66px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  display: grid; place-items: center; flex: none;
  box-shadow:
    0 10px 30px -8px var(--blue),
    0 0 0 1px rgba(255,255,255,0.10) inset,
    0 0 40px -6px rgba(54,230,200,0.5);
  transition: transform 0.15s;
}
.play:hover { transform: scale(1.06); }
body.playing .play { animation: pulseGlow 2.4s ease-in-out infinite; }
@keyframes pulseGlow {
  50% { box-shadow: 0 10px 30px -8px var(--blue), 0 0 0 1px rgba(255,255,255,0.10) inset, 0 0 56px -2px rgba(54,230,200,0.65); }
}
.play:active { transform: scale(0.96); }
.play svg { width: 30px; height: 30px; fill: #03101f; }
.play .ic-pause { display: none; }
body.playing .play .ic-play { display: none; }
body.playing .play .ic-pause { display: block; }

.vol { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 220px; }
.vol .ic-vol { width: 22px; height: 22px; fill: var(--muted); flex: none; cursor: pointer; transition: opacity .2s, fill .2s; }
.vol .ic-vol:hover { fill: var(--teal); }
.vol input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  border-radius: 4px; background: rgba(120,160,255,0.25); outline: none;
}
.vol input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal); cursor: pointer; box-shadow: 0 0 10px var(--teal);
}
.vol input::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: var(--teal); cursor: pointer; }

/* visualizer mode picker + fullscreen */
.viz-ctl { margin-left: auto; display: flex; align-items: center; gap: 10px; position: relative; }
.iconbtn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--stroke); background: rgba(120,160,255,0.08);
  display: grid; place-items: center; cursor: pointer; color: var(--muted);
  transition: transform .15s, color .2s, background .2s, border-color .2s;
}
.iconbtn:hover { color: var(--teal); background: rgba(54,230,200,0.12); transform: translateY(-1px); }
.iconbtn.active { color: var(--teal); border-color: rgba(54,230,200,0.40); }
.iconbtn svg { width: 17px; height: 17px; fill: currentColor; }
.ic-fsclose { display: none; }
body.fs .ic-fsopen { display: none; }
body.fs .ic-fsclose { display: block; }

.viz-menu {
  position: absolute; bottom: 44px; right: 0; z-index: 6;
  min-width: 184px; max-height: 56vh; overflow-y: auto; padding: 6px;
  border: 1px solid var(--stroke); border-radius: 14px;
  background: rgba(11, 21, 44, 0.94); backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 22px 56px -22px rgba(0,0,0,0.85);
  display: flex; flex-direction: column; gap: 2px;
}
.viz-menu[hidden] { display: none; }
.viz-menu .mtitle {
  font-family: "JetBrains Mono", monospace; font-size: 9px; letter-spacing: 2px;
  color: var(--muted); text-transform: uppercase; padding: 6px 12px 4px;
}
.viz-menu button {
  text-align: left; padding: 8px 12px; border-radius: 9px;
  border: none; background: transparent; color: #c2d2f5; cursor: pointer;
  font-family: "JetBrains Mono", monospace; font-size: 12px; letter-spacing: 0.3px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.viz-menu button:hover { background: rgba(120,160,255,0.12); color: var(--ink); }
.viz-menu button[aria-checked="true"] { color: var(--teal); }
.viz-menu button[aria-checked="true"]::after { content: "●"; font-size: 8px; }

/* fullscreen — just the equalizer (native :fullscreen drives .isfs via JS; faux fallback uses the same class) */
.player.isfs {
  position: fixed; inset: 0; z-index: 60; border-radius: 0; min-height: 100vh;
  padding: 0; background: var(--bg0); border: none;
}
.player.isfs::before { display: none; }
.player.isfs .viz { mix-blend-mode: normal; }
.player.isfs .now {
  position: absolute; left: 26px; bottom: 24px; z-index: 2; margin: 0; transition: opacity .4s;
}
.player.isfs .now .np-label, .player.isfs .now .np-prompt,
.player.isfs .now .tags, .player.isfs .now .sub { display: none; }
.player.isfs .now .title {
  font-size: 18px; font-weight: 500; opacity: 0.5; margin: 0; letter-spacing: 0;
}
.player.isfs .controls {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); margin: 0; z-index: 2;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--stroke);
  background: rgba(10,18,40,0.55); backdrop-filter: blur(18px); gap: 16px; transition: opacity .4s;
}
.player.isfs .controls .hint, .player.isfs .vol { display: none; }
.player.isfs.uihide .controls, .player.isfs.uihide .now { opacity: 0; pointer-events: none; }
.player.isfs.uihide { cursor: none; }

/* right column */
.side { display: flex; flex-direction: column; gap: 20px; min-height: 0; }
.card {
  border: 1px solid var(--stroke); border-top-color: rgba(180,205,255,0.30);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0) 40%),
    var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  padding: 22px; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px -44px rgba(0,0,0,0.8);
}
.about { flex: 1; }                /* fill the sidebar now that RECENTLY PLAYED is gone */
.about-text { font-size: 14px; line-height: 1.55; color: #c2d2f5; margin-top: 12px; }
.stats { display: flex; gap: 10px; margin-top: auto; padding-top: 20px; }  /* stats pinned to bottom */
.stat {
  flex: 1; display: flex; flex-direction: column; gap: 3px; align-items: center;
  padding: 14px 6px; border-radius: 14px; background: rgba(120,160,255,0.06);
  border: 1px solid var(--stroke);
}
.stat .sv {
  font-weight: 700; font-size: 26px; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--teal), var(--blue)); -webkit-background-clip: text;
  background-clip: text; color: transparent;
  text-shadow: 0 0 18px rgba(74,168,255,0.25);
}
.stat .sl { font-family: "JetBrains Mono", monospace; font-size: 9px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-top: 2px; }

/* footer */
.foot {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 18px; font-family: "JetBrains Mono", monospace;
  font-size: 11px; color: var(--muted); letter-spacing: 1px;
}
.foot .sep { opacity: 0.4; }

/* ---- generation-prompt caption ---- */
.np-prompt {
  font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: #9fb2e8;
  margin: 0 0 16px; letter-spacing: 0.2px; max-width: 40ch;
}
.np-prompt:empty { display: none; }
.np-prompt::before { content: "✦ "; color: var(--teal); }

/* ---- share button ---- */
.share {
  margin-left: auto; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--stroke); background: rgba(120,160,255,0.08);
  display: grid; place-items: center; cursor: pointer; color: var(--muted);
  transition: transform .15s, color .2s, background .2s;
}
.share svg { width: 16px; height: 16px; fill: currentColor; }
.share:hover { color: var(--teal); background: rgba(54,230,200,0.12); transform: translateY(-1px); }
.share:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(10,16,34,0.92); border: 1px solid var(--stroke); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: .3s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- first-run idle cue (invite to play) ---- */
body.idle .play { animation: invite 2s ease-in-out infinite; }
@keyframes invite {
  0%, 100% { box-shadow: 0 10px 30px -8px var(--blue), 0 0 0 1px rgba(255,255,255,0.1) inset, 0 0 40px -6px rgba(54,230,200,0.5); }
  50%      { box-shadow: 0 10px 30px -8px var(--blue), 0 0 0 1px rgba(255,255,255,0.1) inset, 0 0 60px 0 rgba(54,230,200,0.85); }
}

/* ---- mobile ergonomics ---- */
@media (max-width: 560px) {
  .vol { display: none; }              /* phones use hardware volume */
  .play { width: 72px; height: 72px; }
  .play svg { width: 32px; height: 32px; }
  .stage { gap: 20px; }
}

/* ---- respect reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .bg { animation: none; }
  body.playing .play, body.idle .play { animation: none; }
  .live.on .dot { animation: none; }
}

/* ---- track-change enter animation ---- */
.now.changing .title    { animation: npIn .5s ease both; }
.now.changing .np-prompt { animation: npIn .5s ease .05s both; }
.now.changing .tags     { animation: npIn .5s ease .10s both; }
@keyframes npIn {
  from { opacity: 0; transform: translateY(10px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* ---- first-run hint ---- */
.hint {
  font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--muted);
  letter-spacing: 0.3px; opacity: 0; transition: opacity .5s; pointer-events: none;
}
body.idle .hint { opacity: 0.7; }
.hint kbd {
  font-family: inherit; font-size: 10px; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--stroke); background: rgba(120,160,255,0.10); color: #bcd4ff;
}
@media (prefers-reduced-motion: reduce) {
  .now.changing .title, .now.changing .np-prompt, .now.changing .tags { animation: none; }
}

/* ---- connecting / buffering indicator + long-title safety ---- */
.live.busy { color: #ffcf5a; border-color: rgba(255,207,90,0.4); }
.live.busy .dot { background: #ffcf5a; box-shadow: 0 0 12px #ffcf5a; animation: pulse 0.7s infinite; }
.title { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
