/* ============================================================
   Radio — themes: night (default) / day / simple
   FX bus (set by visuals.js every frame):
     --fx-bass --fx-mid --fx-energy --fx-beat   (0..1)
   ============================================================ */

:root, html[data-theme="night"] {
  --bg: #0b0f1a;
  --bg-soft: #111827;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent1: #7c5cff;
  --accent2: #00d4ff;
  --grad: linear-gradient(135deg, var(--accent1), var(--accent2));
  --danger: #ff4d6d;
  --aurora1: rgba(124, 92, 255, 0.5);
  --aurora2: rgba(0, 212, 255, 0.42);
  --aurora3: rgba(255, 77, 109, 0.26);
  --aurora-opacity: 1;
  --viz1: #7c5cff;
  --viz2: #00d4ff;
  --viz-dim: 0;
  --topbar-bg: rgba(11, 15, 26, 0.75);
  --overlay-bg: rgba(8, 11, 20, 0.82);
  --track: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --row-hover: rgba(255, 255, 255, 0.045);
  --radius: 18px;
}

html[data-theme="day"] {
  --bg: #eef1f8;
  --bg-soft: #ffffff;
  --card: rgba(255, 255, 255, 0.75);
  --card-border: rgba(28, 36, 60, 0.1);
  --text: #1b2233;
  --muted: #5f6880;
  --accent1: #5b3df0;
  --accent2: #0083c4;
  --danger: #e5355c;
  --aurora1: rgba(255, 170, 120, 0.55);
  --aurora2: rgba(120, 180, 255, 0.5);
  --aurora3: rgba(255, 120, 180, 0.35);
  --aurora-opacity: 0.8;
  --viz1: #5b3df0;
  --viz2: #0083c4;
  --viz-dim: 0;
  --topbar-bg: rgba(238, 241, 248, 0.82);
  --overlay-bg: rgba(238, 241, 248, 0.86);
  --track: rgba(28, 36, 60, 0.12);
  --shadow: 0 14px 40px rgba(80, 90, 140, 0.18);
  --row-hover: rgba(28, 36, 60, 0.05);
}

html[data-theme="simple"] {
  --bg: #101216;
  --bg-soft: #181a20;
  --card: #15181e;
  --card-border: #262b36;
  --text: #dfe3ea;
  --muted: #8b93a3;
  --accent1: #aab3c5;
  --accent2: #d6dbe6;
  --danger: #ff4d6d;
  --aurora-opacity: 0;
  --viz1: #7d8698;
  --viz2: #b9c1cf;
  --viz-dim: 1;
  --topbar-bg: rgba(16, 18, 22, 0.88);
  --overlay-bg: rgba(13, 15, 18, 0.88);
  --track: #262b36;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --row-hover: rgba(255, 255, 255, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.45s ease, color 0.45s ease;
}
a { color: var(--accent2); text-decoration: none; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- aurora background (reacts to audio energy) ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora b {
  position: absolute; border-radius: 50%;
  filter: blur(90px); will-change: transform;
  opacity: calc(var(--aurora-opacity, 1) * (0.5 + var(--fx-bass, 0) * 0.9));
}
.aurora .a1 {
  width: 58vw; height: 58vw; top: -18%; right: -12%;
  background: radial-gradient(circle, var(--aurora1), transparent 62%);
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora .a2 {
  width: 50vw; height: 50vw; bottom: -20%; left: -14%;
  background: radial-gradient(circle, var(--aurora2), transparent 62%);
  animation: drift2 31s ease-in-out infinite alternate;
}
.aurora .a3 {
  width: 34vw; height: 34vw; top: 34%; left: 32%;
  background: radial-gradient(circle, var(--aurora3), transparent 60%);
  animation: drift3 22s ease-in-out infinite alternate;
  opacity: calc(var(--aurora-opacity, 1) * (0.25 + var(--fx-energy, 0) * 1.1));
}
@keyframes drift1 { to { transform: translate(-14%, 20%) scale(1.18); } }
@keyframes drift2 { to { transform: translate(16%, -16%) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-12%, -14%) scale(1.3); } }
html[data-theme="simple"] .aurora { display: none; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px clamp(16px, 4vw, 40px);
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar-bg); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  transition: background 0.45s ease;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 19px; letter-spacing: 0.3px; min-width: 0; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 10px; background: var(--grad);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: 0 0 calc(6px + var(--fx-energy, 0) * 22px) color-mix(in srgb, var(--accent1) 60%, transparent);
}
.brand-icon svg { width: 20px; height: 20px; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--card-border); color: var(--muted);
}
.pill svg { width: 14px; height: 14px; }
.live-pill { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.live-dot {
  width: calc(8px + var(--fx-beat, 0) * 4px); height: calc(8px + var(--fx-beat, 0) * 4px);
  border-radius: 50%; background: var(--danger);
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 60%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}

/* ---------- theme switcher ---------- */
.theme-switch {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 999px;
}
.theme-switch button {
  width: 30px; height: 26px; border-radius: 999px; border: none; cursor: pointer;
  background: none; color: var(--muted); display: grid; place-items: center;
  transition: color 0.2s, background 0.2s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active {
  color: #fff;
  background: var(--grad);
}
html[data-theme="simple"] .theme-switch button.active { background: var(--accent1); color: #101216; }
.theme-switch svg { width: 14px; height: 14px; }

/* ---------- layout ---------- */
.main {
  max-width: 1060px; margin: 0 auto; padding: 26px clamp(14px, 4vw, 40px) 40px;
  display: flex; flex-direction: column; gap: 22px;
  position: relative; z-index: 1;
}

.blocks {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px;
}
.block { padding: 18px 18px 12px; }
.block h2 {
  margin: 0 0 10px; font-size: 12.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.4px; color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.block h2::before {
  content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--grad);
  flex-shrink: 0;
}
html[data-theme="simple"] .block h2::before { background: var(--accent1); }
.block-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: none; }
.block .empty { padding: 18px 6px; font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: background 0.45s ease, border-color 0.45s ease;
}

/* ---------- player ---------- */
.player-card {
  padding: 26px; display: flex; gap: 26px; position: relative;
  box-shadow: 0 0 calc(24px + var(--fx-bass, 0) * 90px)
      color-mix(in srgb, var(--accent1) calc(5% + var(--fx-bass, 0) * 22%), transparent),
    var(--shadow);
}
@media (max-width: 620px) { .player-card { flex-direction: column; align-items: center; text-align: center; } }

.cover-wrap { position: relative; flex-shrink: 0; }
.cover {
  width: clamp(180px, 24vw, 250px); height: clamp(180px, 24vw, 250px);
  border-radius: 16px; overflow: hidden; position: relative;
  background: var(--bg-soft); box-shadow: var(--shadow);
  z-index: 1;
}
.cover-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--grad); color: rgba(255, 255, 255, 0.9); font-size: 52px; font-weight: 700;
}
html[data-theme="simple"] .cover-fallback { color: #101216; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

#fxBg.fx-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
html[data-theme="simple"] #fxBg.fx-bg { display: none; }

/* ---------- previous / next mini cards ---------- */
.mini-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
@media (max-width: 680px) { .mini-row { grid-template-columns: 1fr; } }
.mini { padding: 13px 16px; min-width: 0; }
.mini-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.3px; color: var(--muted); margin-bottom: 6px;
}
.mini-label svg { width: 13px; height: 13px; }
.mini-title {
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-sub {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-empty { font-size: 13px; color: var(--muted); padding: 3px 0; }

.player-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.chips-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media (max-width: 620px) { .chips-row { justify-content: center; } }
.genre-chip {
  align-self: flex-start; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  padding: 5px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent1) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent1) 42%, transparent);
  color: color-mix(in srgb, var(--accent1) 72%, var(--text));
}
html[data-theme="night"] .genre-chip { color: #b8a5ff; }
@media (max-width: 620px) { .genre-chip { align-self: center; } }
.bpm-chip {
  font-size: 12px; font-weight: 700; letter-spacing: 0.6px;
  padding: 5px 11px; border-radius: 999px; font-variant-numeric: tabular-nums;
  background: var(--card); border: 1px dashed var(--card-border); color: var(--muted);
  opacity: 0.55; transition: opacity 0.4s, border-color 0.4s, color 0.4s;
}
.bpm-chip.ready {
  opacity: 1; color: var(--accent2);
  border: 1px solid color-mix(in srgb, var(--accent2) 45%, transparent);
  border-style: solid;
}
.song-title {
  margin: 12px 0 4px; font-size: clamp(20px, 3vw, 27px); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.song-artist { color: var(--muted); font-size: 16px; margin-bottom: 18px; min-height: 20px; }

.progress-block { margin-bottom: 18px; }
.progress {
  height: 7px; border-radius: 999px; background: var(--track);
  overflow: hidden; cursor: default;
}
.progress-fill {
  height: 100%; width: 0%; background: var(--grad); border-radius: inherit;
  transition: width 0.4s linear;
  box-shadow: 0 0 calc(5px + var(--fx-energy, 0) * 16px)
    color-mix(in srgb, var(--accent2) calc(30% + var(--fx-energy, 0) * 55%), transparent);
}
.progress-times { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

.player-actions { display: flex; align-items: center; gap: 12px; }
@media (max-width: 620px) { .player-actions { justify-content: center; } }

.btn-like {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; font-size: 15px; font-weight: 700;
  background: var(--card); border: 1px solid var(--card-border); color: var(--text);
  transition: transform 0.12s ease, border-color 0.2s, box-shadow 0.2s;
}
.btn-like:hover { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn-like:active { transform: scale(0.94); }
.btn-like svg { width: 21px; height: 21px; fill: none; stroke: var(--muted); stroke-width: 1.8; transition: all 0.2s; }
.btn-like.liked svg { fill: var(--danger); stroke: var(--danger); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--danger) 60%, transparent)); }
.btn-like.liked {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  box-shadow: 0 0 calc(14px + var(--fx-beat, 0) * 22px) color-mix(in srgb, var(--danger) 25%, transparent);
}
.btn-like.pop svg { animation: heartpop 0.35s ease; }
@keyframes heartpop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

.btn-icon {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--card); border: 1px solid var(--card-border); color: var(--text);
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
#muteBtn .ic-off { display: none; }
#muteBtn.muted .ic-on { display: none; }
#muteBtn.muted .ic-off { display: block; }
#muteBtn.muted { color: var(--muted); border-style: dashed; }

/* ---------- lists / blocks ---------- */
.song-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }

.genre-cloud {
  display: flex; flex-wrap: wrap; gap: 10px 8px; align-items: center; align-content: flex-start;
  padding: 6px 0 10px; min-height: 60px;
}
.g-tag {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 11px;
  border-radius: 999px; font-weight: 700; line-height: 1.15;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s;
}
.g-tag:hover {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent1) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent1) 40%, transparent);
}
.g-tag b { font-size: 11px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.song-list { list-style: none; margin: 0; padding: 0; }
.song-row {
  display: flex; align-items: center; gap: 13px;
  padding: 9px 10px; border-radius: 12px;
}
.song-row:hover { background: var(--row-hover); }
.song-rank {
  width: 30px; text-align: center; font-weight: 800; font-size: 15px; color: var(--muted);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.song-row:nth-child(1) .song-rank,
.song-row:nth-child(2) .song-rank,
.song-row:nth-child(3) .song-rank { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="simple"] .song-row:nth-child(-n+3) .song-rank { background: none; color: var(--text); }
.song-meta { flex: 1; min-width: 0; }
.song-row-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-genre { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--muted); }
.song-likes { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.song-likes svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.song-likes.liked { color: var(--danger); }
.song-likes.liked svg { fill: currentColor; stroke: currentColor; }
.row-like { background: none; border: none; cursor: pointer; padding: 4px; display: inline-flex; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- footer ---------- */
.footer {
  max-width: 1060px; margin: 0 auto; padding: 0 20px 30px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--muted); font-size: 13px;
  position: relative; z-index: 1;
}

/* ---------- tune-in overlay ---------- */
.tunein-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--overlay-bg); backdrop-filter: blur(10px);
  display: grid; place-items: center; padding: 20px;
}
.tunein-card { text-align: center; position: relative; z-index: 1; }
.tunein-logo {
  width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 24px; background: var(--grad);
  display: grid; place-items: center; color: #fff; box-shadow: 0 20px 60px color-mix(in srgb, var(--accent1) 40%, transparent);
}
html[data-theme="simple"] .tunein-logo { color: #101216; }
.tunein-logo svg { width: 42px; height: 42px; }
.tunein-card h1 { margin: 0 0 22px; font-size: 30px; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 14px 32px; border-radius: 999px; border: none;
  background: var(--grad); color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 14px 40px color-mix(in srgb, var(--accent1) 40%, transparent);
  transition: transform 0.12s ease;
}
html[data-theme="simple"] .btn-primary { color: #101216; }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary svg { width: 22px; height: 22px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(90px);
  background: var(--bg-soft); border: 1px solid var(--card-border); color: var(--text);
  padding: 11px 20px; border-radius: 12px; font-size: 14px; z-index: 100;
  transition: transform 0.3s ease; box-shadow: var(--shadow);
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- fx: heart burst / song swap ---------- */
.heart-burst {
  position: fixed; z-index: 90; pointer-events: none; color: var(--danger);
  transform: translate(-50%, -50%) scale(var(--sc, 1));
  animation: heartUp 0.95s cubic-bezier(0.17, 0.67, 0.35, 1) forwards;
}
.heart-burst svg { width: 18px; height: 18px; fill: currentColor; }
@keyframes heartUp {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(calc(var(--sc, 1) * 0.5)); }
  30% { opacity: 0.9; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% - 110px)) scale(var(--sc, 1));
  }
}

.player-info.swap .chips-row,
.player-info.swap .song-title,
.player-info.swap .song-artist {
  animation: swapIn 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.player-info.swap .song-title { animation-delay: 0.05s; }
.player-info.swap .song-artist { animation-delay: 0.11s; }
@keyframes swapIn {
  from { opacity: 0; transform: translateY(16px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .aurora b { animation: none; }
  .player-info.swap .chips-row,
  .player-info.swap .song-title,
  .player-info.swap .song-artist { animation: none; }
  .live-dot { animation: none; }
}
