:root {
  --bg: #07080d;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.10);
  --text: #f4f6fb;
  --muted: #99a2b3;
  --accent: #2ff3c4;
  --accent2: #2bb6ff;
  --radius: 26px;
  --pulse: 0;
  --font-display: 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ---------- animated background ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
}
.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
body.gl-active .blob, body.gl-active .flash, body.gl-active .vignette { display: none; }
/* GL path reacts to the beat purely via flow SPEED (in the shader) — no brightness
   or scale pumping. The geometric scale-pulse stays only on the CSS-blob fallback. */
body:not(.gl-active) .bg { transform: scale(calc(1 + var(--pulse, 0) * 0.025)); }
.blob {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  filter: blur(55px);
  opacity: calc(0.48 + var(--pulse, 0) * 0.28);
  transition: background 0.9s ease;
  will-change: transform;
}
.blob-a {
  background: radial-gradient(circle, var(--accent), transparent 64%);
  top: -20vmax; left: -14vmax;
  animation: drift-a 13s ease-in-out infinite alternate;
}
.blob-b {
  background: radial-gradient(circle, var(--accent2), transparent 64%);
  bottom: -24vmax; right: -16vmax;
  animation: drift-b 16s ease-in-out infinite alternate;
}
.blob-c {
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 55%, var(--accent2)), transparent 60%);
  width: 52vmax; height: 52vmax;
  top: 22%; left: 32%;
  animation: drift-c 11s ease-in-out infinite alternate;
}
.blob-d {
  background: radial-gradient(circle, var(--accent), transparent 62%);
  width: 50vmax; height: 50vmax;
  top: -8vmax; right: -6vmax;
  animation: drift-d 15s ease-in-out infinite alternate;
}
.blob-e {
  background: radial-gradient(circle, var(--accent2), transparent 62%);
  width: 54vmax; height: 54vmax;
  bottom: -12vmax; left: -8vmax;
  animation: drift-e 18s ease-in-out infinite alternate;
}
.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(120% 120% at 50% 40%, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
}
.scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay; opacity: 0.5;
}
.flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60% 50% at 50% 45%, color-mix(in srgb, var(--accent) 70%, var(--accent2)), transparent 70%);
  opacity: calc(var(--pulse, 0) * 0.22);
  mix-blend-mode: screen;
}
.noise {
  position: absolute; inset: -20%; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.06;
  mix-blend-mode: overlay;
  animation: grain 0.5s steps(3) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-4%, 3%); }
  66% { transform: translate(3%, -4%); }
  100% { transform: translate(-2%, -2%); }
}
@keyframes drift-a { from { transform: translate(0, 0) scale(1); } to { transform: translate(22vmax, 16vmax) scale(1.35); } }
@keyframes drift-b { from { transform: translate(0, 0) scale(1.25); } to { transform: translate(-20vmax, -14vmax) scale(0.95); } }
@keyframes drift-c { from { transform: translate(-14vmax, 10vmax) scale(0.85); } to { transform: translate(16vmax, -16vmax) scale(1.4); } }
@keyframes drift-d { from { transform: translate(0, 0) scale(1.15); } to { transform: translate(-18vmax, 20vmax) scale(0.9); } }
@keyframes drift-e { from { transform: translate(0, 0) scale(0.9); } to { transform: translate(18vmax, -12vmax) scale(1.3); } }

/* ---------- glass ---------- */
.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  box-shadow: 0 30px 90px -30px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  color: var(--accent);
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 55%, transparent));
  transition: color 0.6s ease;
  flex: none;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.13em;
  font-size: 0.92rem;
  white-space: nowrap;
}
.brand-name i { font-style: normal; color: var(--muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.react-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: none; border-radius: 9px;
  background: transparent; color: var(--accent);
  cursor: pointer; opacity: 0.85;
  transition: opacity 0.2s, color 0.3s, background 0.2s;
}
.react-btn:hover { opacity: 1; background: var(--panel); }
.react-btn.off { color: var(--muted); opacity: 0.45; }

.live {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600;
  font-size: 0.72rem; letter-spacing: 0.18em;
  color: var(--muted);
  flex: none;
}
.live::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #ff4d5e; box-shadow: 0 0 10px #ff4d5e;
  animation: pulse 1.8s ease-in-out infinite;
  order: 9;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.vu { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.vu i {
  width: 3px; height: 25%; border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: height 0.09s linear;
}

/* ---------- stage / player ---------- */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: clamp(10px, 3vh, 28px) 16px; }
.player {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-width: 0;
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 38px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 40px 120px -40px color-mix(in srgb, var(--accent) 45%, transparent),
              0 30px 90px -30px rgba(0, 0, 0, 0.7),
              inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: box-shadow 0.8s ease;
}

/* ---------- station arrows ---------- */
.nav-arrow {
  position: absolute; top: 16px;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  z-index: 3;
  transition: transform 0.2s, background 0.2s, border-color 0.3s, box-shadow 0.3s;
}
.nav-prev { left: 16px; }
.nav-next { right: 16px; }
.nav-arrow:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 8px 24px -10px color-mix(in srgb, var(--accent) 60%, transparent);
  transform: translateY(-1px);
}
.nav-arrow:active { transform: scale(0.94); }

/* ---------- visualizer + emblem (logo <-> play, no tile) ---------- */
.emblem-wrap {
  position: relative;
  width: min(280px, 70vw); height: min(280px, 70vw);
  margin: 0 auto;
  display: grid; place-items: center;
}
.viz { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.emblem {
  position: relative;
  width: 64%; height: 64%;
  border: none; background: none; padding: 0;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.3s ease;
}
.emblem:hover { transform: translateY(-3px) scale(1.03); }
.emblem:active { transform: scale(0.97); }
body.playing .emblem { animation: bob 4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* logo / monogram / play share one spot and cross-fade */
.emblem-logo, .emblem-glyph, .emblem-play {
  position: absolute;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.emblem-logo {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
  opacity: 0; transform: scale(0.6);
}
.emblem:not(.has-logo) .emblem-logo { display: none; }
.emblem.has-logo .emblem-glyph { display: none; }
.emblem-glyph {
  font-family: var(--font-display); font-weight: 700;
  font-size: 3.4rem; line-height: 1; letter-spacing: -0.02em;
  color: var(--accent);
  text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: 0; transform: scale(0.55);
}
.emblem-play {
  width: 46%; height: 46%;
  color: var(--accent);
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 70%, transparent));
  transform: translateX(4%);
}
/* stopped -> play icon; playing -> logo (or monogram) */
body.playing .emblem-logo, body.playing .emblem-glyph { opacity: 1; transform: scale(1); }
body.playing .emblem-play { opacity: 0; transform: scale(1.4); }
/* dark monochrome logos (e.g. Opus): invert to light so they read on the dark card */
.emblem.logo-light .emblem-logo { filter: invert(1) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4)); }

@keyframes spin-emblem {
  0% { transform: rotate(-180deg) scale(0.7); opacity: 0.2; }
  100% { transform: rotate(0) scale(1); opacity: 1; }
}
.emblem.swap { animation: spin-emblem 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
.emblem.swap .emblem-logo, .emblem.swap .emblem-glyph, .emblem.swap .emblem-play {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* ---------- now-playing block (slides on station change) ---------- */
.np { width: 100%; min-width: 0; transition: opacity 0.22s ease, transform 0.22s ease; }
.np.leave-left { opacity: 0; transform: translateX(-26px); }
.np.leave-right { opacity: 0; transform: translateX(26px); }
.np.enter-left { opacity: 0; transform: translateX(-26px); transition: none; }
.np.enter-right { opacity: 0; transform: translateX(26px); transition: none; }

.freq {
  font-family: var(--font-display);
  font-size: 0.72rem; letter-spacing: 0.2em;
  color: color-mix(in srgb, var(--accent) 75%, #ffffff);
  font-variant-numeric: tabular-nums;
  min-height: 1em; margin: 16px 0 6px; opacity: 0.85;
  transition: color 0.6s ease;
}
.station-name {
  margin: 0;
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.station-tagline {
  margin: 6px 0 0;
  font-size: 0.72rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 70%, var(--muted));
  transition: color 0.6s ease;
}
.track { margin-top: 22px; min-height: 62px; width: 100%; min-width: 0; }
.track-title {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.05rem, 3.6vw, 1.32rem); line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.track-artist {
  margin-top: 7px; color: var(--muted); font-size: 0.92rem;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.track.bump { animation: bump 0.42s ease both; }
@keyframes bump { 0% { opacity: 0; transform: translateY(9px); } 100% { opacity: 1; transform: translateY(0); } }

body.talk .track-title { font-style: italic; }
.track-artist.on-air {
  color: var(--accent);
  letter-spacing: 0.16em; font-size: 0.74rem; text-transform: uppercase;
}

/* ---------- progress + times ---------- */
.progress {
  position: relative; width: 100%; height: 5px; margin-top: 26px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.10); overflow: hidden;
}
.progress-fill {
  position: absolute; inset: 0; right: auto; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: width 0.18s linear;
}
.times {
  width: 100%; margin-top: 10px;
  display: flex; justify-content: space-between;
  font-size: 0.74rem; font-variant-numeric: tabular-nums; color: var(--muted);
}

/* ---------- volume (in card) ---------- */
.player-volume {
  width: 100%; margin-top: 22px;
  display: flex; align-items: center; gap: 12px;
}
.vol-btn {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px;
  border: none; border-radius: 10px;
  background: var(--panel); color: var(--text);
  cursor: pointer; opacity: 0.9; transition: opacity 0.2s, background 0.2s;
}
.vol-btn:hover { opacity: 1; background: var(--panel-strong); }
.vol-btn .slash { display: none; }
.vol-btn[data-level="mute"] .wave { display: none; }
.vol-btn[data-level="mute"] .slash { display: block; }
.vol-btn[data-level="low"] .wave2 { display: none; }

.vol-slider {
  --fill: 80%;
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 5px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(90deg, var(--accent), var(--accent2)) no-repeat, rgba(255, 255, 255, 0.14);
  background-size: var(--fill) 100%, 100% 100%;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%; background: #fff; border: none; cursor: pointer;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.vol-slider::-moz-range-thumb { width: 15px; height: 15px; border-radius: 50%; background: #fff; border: none; cursor: pointer; }

/* Mobile browsers ignore JS-set audio volume, so the slider does nothing there — hide it. */
body.is-mobile .player-volume { display: none; }

/* ---------- queue (next + recently played) ---------- */
.queue {
  width: 100%; max-width: 460px; margin: 0 auto;
  text-align: center; font-size: 0.72rem; color: var(--muted);
}
.q-next b { font-weight: 500; color: var(--text); }
.q-next span {
  font-family: var(--font-display); font-weight: 600;
  letter-spacing: 0.16em; font-size: 0.6rem;
  color: color-mix(in srgb, var(--accent) 75%, var(--muted));
  margin-right: 7px;
}
.q-recent { margin-top: 6px; opacity: 0.4; display: flex; flex-direction: column; gap: 2px; }
.q-recent .q-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- station dots ---------- */
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; max-width: 300px; padding: 0 16px; }
.dots button {
  width: 8px; height: 8px; padding: 0; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22); cursor: pointer;
  transition: background 0.3s, transform 0.2s, width 0.3s, box-shadow 0.3s;
}
.dots button:hover { background: rgba(255, 255, 255, 0.5); transform: scale(1.3); }
.dots button.active {
  width: 22px; border-radius: 5px;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* ---------- credit ---------- */
.credit {
  text-align: center; max-width: 640px; margin: 0 auto;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom));
  font-size: 0.62rem; line-height: 1.5; letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.22); transition: color 0.3s ease;
}
.credit:hover { color: rgba(255, 255, 255, 0.42); }

/* ---------- small / short screens ---------- */
@media (max-width: 400px) {
  .player { padding: 20px 18px; }
  .nav-arrow { top: 12px; width: 38px; height: 38px; }
  .nav-prev { left: 12px; }
  .nav-next { right: 12px; }
  .station-name { font-size: 1.5rem; }
  .brand-name { font-size: 0.85rem; }
}
@media (max-height: 700px) {
  .emblem-wrap { width: min(212px, 56vw); height: min(212px, 56vw); }
  .emblem-glyph { font-size: 2.6rem; }
  .freq { margin-top: 10px; }
  .track { margin-top: 14px; }
  .progress { margin-top: 18px; }
  .player-volume { margin-top: 16px; }
  .q-recent { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .vu i, body.playing .emblem, .emblem.swap, .track.bump, .np, .noise { animation: none; transition: none; }
}
