@property --glow {
  syntax: "<color>";
  inherits: true;
  initial-value: #ffd43b;
}

:root {
  --bg: #0b0a08;
  --bg-2: #100e0b;
  --surface: #17140f;
  --surface-2: #211d16;
  --line: rgba(255, 236, 190, 0.08);
  --line-2: rgba(255, 236, 190, 0.15);
  --text: #f8f3e9;
  --muted: #a8a090;
  --faint: #6f6858;
  --banana: #ffd43b;
  --ink: #1b1504;
  --danger: #ff6b5e;
  --glow: #ffd43b;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
  transition: --glow 1.2s ease;
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.35; }
:focus-visible { outline: 2px solid var(--banana); outline-offset: 3px; }
svg { width: 100%; height: 100%; fill: currentColor; }
img { display: block; }
h1, h2, p { margin: 0; }

.hidden, [hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Ambient light that takes the current station's colour */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70vmax 50vmax at 0% 0%, color-mix(in srgb, var(--glow) 16%, transparent), transparent 70%),
    radial-gradient(50vmax 40vmax at 100% 10%, rgba(255, 212, 59, 0.06), transparent 70%);
}

/* ---------- Browse ---------- */

.app { min-height: 100dvh; }

.browse {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 18px) 16px calc(var(--safe-b) + 112px);
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--banana); color: var(--ink);
}
.brand-mark svg { width: 26px; height: 26px; }

.offline {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 999px;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent);
}


.search { position: relative; display: block; margin-top: 20px; }
.search svg { position: absolute; left: 16px; top: 50%; width: 20px; height: 20px; translate: 0 -50%; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; height: 52px;
  padding: 0 16px 0 46px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: color-mix(in srgb, var(--banana) 55%, transparent); box-shadow: 0 0 0 4px rgba(255, 212, 59, 0.12); }

.chips {
  display: flex; gap: 8px;
  margin: 14px -16px 0; padding: 2px 16px;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip[aria-pressed="true"] { background: var(--banana); border-color: transparent; color: var(--ink); }

.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.section-head span { color: var(--faint); font-size: 13px; font-weight: 600; }

/* Favorites rail */
.rail {
  display: flex; gap: 12px;
  margin: 0 -16px; padding: 4px 16px 8px;
  overflow-x: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-item { flex: none; width: 74px; display: grid; justify-items: center; gap: 8px; }
.rail-art {
  display: grid; place-items: center;
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--tile-bg, #fff);
  box-shadow: 0 0 0 1px var(--line-2);
  overflow: hidden;
  transition: box-shadow 0.3s, transform 0.3s var(--ease);
}
.rail-art img { width: 64%; height: 64%; object-fit: contain; max-width: var(--logo-max, 100%); max-height: var(--logo-max, 100%); }
.rail-item:active .rail-art { transform: scale(0.94); }
.rail-item[data-state="playing"] .rail-art,
.rail-item[data-state="buffering"] .rail-art { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--banana); }
.rail-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--muted); }

/* Station grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }

.tile { position: relative; animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 22ms); }
.tile-hit { display: grid; gap: 10px; width: 100%; text-align: left; }
.tile-hit:focus-visible { outline: none; }
.tile-hit:focus-visible .tile-art { box-shadow: 0 0 0 3px var(--banana); }

.tile-art {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 1;
  border-radius: 22px;
  background: var(--tile-bg, #fff);
  overflow: hidden;
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.8);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.tile-art .logo { width: 60%; height: 60%; object-fit: contain; max-width: var(--logo-max, 100%); max-height: var(--logo-max, 100%); }
.initials { display: none; font-family: var(--display); font-size: 28px; font-weight: 800; color: var(--ink); }
.no-logo .logo { display: none; }
.fills img[data-logo] { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.no-logo .initials { display: block; }

@media (hover: hover) {
  .tile-hit:hover .tile-art { transform: translateY(-4px); box-shadow: 0 22px 40px -18px rgba(0, 0, 0, 0.9); }
}
.tile-hit:active .tile-art { transform: scale(0.97); }

.hover-play {
  position: absolute; right: 10px; bottom: 10px;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--banana); color: var(--ink);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.hover-play svg { width: 20px; height: 20px; }
@media (hover: hover) {
  .tile:not([data-state="playing"], [data-state="buffering"]) .tile-hit:hover .hover-play { opacity: 1; transform: none; }
}

.tile[data-state="playing"] .tile-art,
.tile[data-state="buffering"] .tile-art {
  box-shadow: 0 0 0 3px var(--banana), 0 20px 50px -14px color-mix(in srgb, var(--banana) 45%, transparent);
}
.tile[data-state="failed"] .tile-art { box-shadow: 0 0 0 3px var(--danger); }

.tile-text { display: grid; gap: 2px; min-width: 0; padding-right: 4px; }
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.tile-genre, .tile-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.tile-status:empty { display: none; }
.tile:is([data-state="playing"], [data-state="buffering"], [data-state="failed"]) .tile-genre { display: none; }
.tile[data-state="playing"] .tile-status { color: var(--banana); font-weight: 600; }
.tile[data-state="failed"] .tile-status { color: var(--danger); font-weight: 600; }

/* Badge on the playing tile */
.badge {
  position: absolute; left: 10px; bottom: 10px;
  display: none; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: 999px;
  background: rgba(14, 12, 9, 0.82);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--banana);
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
}
.tile:is([data-state="playing"], [data-state="buffering"]) .badge { display: flex; }
.badge .spinner { display: none; }
.tile[data-state="buffering"] .badge .spinner { display: block; }
.tile[data-state="buffering"] .badge :is(.eq, b) { display: none; }
.badge b { font-weight: 800; }

.eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 3px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: eq 0.9s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-duration: 0.7s; animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-duration: 1.1s; animation-delay: -0.6s; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.fav {
  position: absolute; top: 10px; right: 10px;
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(14, 12, 9, 0.55);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #fff;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.fav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.fav[aria-pressed="true"] { color: var(--banana); }
.fav[aria-pressed="true"] svg { fill: currentColor; }
.fav:active { transform: scale(0.88); }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty-title { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* ---------- Player: compact dock (mobile) ---------- */

.player {
  position: fixed; z-index: 20;
  left: 10px; right: 10px; bottom: calc(var(--safe-b) + 10px);
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  height: 72px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 24px;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.75);
  transform: translateY(calc(100% + var(--safe-b) + 24px));
  transition: transform 0.5s var(--ease);
}
body.has-station .player { transform: none; }

.player-open-hit { position: absolute; inset: 0; border-radius: inherit; }
.player-close, .viz, .volume, .fav-big, .ring { display: none; }

.player-art { position: relative; z-index: 1; pointer-events: none; }
.art-tile {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--tile-bg, var(--surface));
  overflow: hidden;
}
.art-logo { width: 64%; height: 64%; object-fit: contain; max-width: var(--logo-max, 100%); max-height: var(--logo-max, 100%); }
.art-mark { width: 60%; height: 60%; color: var(--banana); }
.player:not([data-state="idle"]) .art-mark { display: none; }

.player-info { position: relative; z-index: 1; min-width: 0; pointer-events: none; }
.player-text { display: flex; flex-direction: column; min-width: 0; }
.player-title { order: -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.player-status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.player-meta { display: none; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.player[data-state="playing"] .status-dot { background: var(--banana); animation: pulse 1.6s ease-in-out infinite; }
.player[data-state="buffering"] .status-dot { background: var(--muted); animation: pulse 0.8s ease-in-out infinite; }
.player[data-state="failed"] .status-dot { background: var(--danger); }
.player[data-state="failed"] .player-status { color: var(--danger); }

.controls { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; }
.ctrl { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text); }
.ctrl svg { width: 24px; height: 24px; }
.player:not(.big) #prevBtn, .player:not(.big) #nextBtn { display: none; }
.ctrl-play { position: relative; width: 48px; height: 48px; background: var(--banana); color: var(--ink); transition: transform 0.2s var(--ease); }
.ctrl-play:active { transform: scale(0.92); }
.ctrl-play .spinner { position: absolute; inset: -4px; width: auto; height: auto; border-width: 2px; color: var(--banana); display: none; }
.player[data-state="buffering"] .ctrl-play .spinner { display: block; }

/* ---------- Player: big (desktop panel + mobile full screen) ---------- */

.player.big {
  display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 26px;
  height: auto;
  padding: calc(var(--safe-t) + 64px) 28px calc(var(--safe-b) + 40px);
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--glow) 30%, transparent), transparent 70%),
    var(--bg-2);
  -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: none;
}
.player.big .player-open-hit { display: none; }
.player.big .player-art { align-self: center; pointer-events: auto; }
.player.big .art-tile {
  width: min(72vw, 40vh, 340px); height: auto; aspect-ratio: 1;
  border-radius: 36px;
  box-shadow: 0 40px 90px -24px color-mix(in srgb, var(--glow) 60%, transparent), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: box-shadow 1.2s ease;
}
.player.big .art-logo { width: 58%; height: 58%; }
.player.big .ring {
  display: block; position: absolute; inset: 0;
  border-radius: 36px;
  border: 2px solid color-mix(in srgb, var(--glow) 70%, transparent);
  opacity: 0;
}
.player.big[data-state="playing"] .ring { animation: ring 2.8s ease-out infinite; }
.player.big[data-state="playing"] .ring-2 { animation-delay: 1.4s; }

.player.big .player-info { display: flex; align-items: center; gap: 16px; pointer-events: auto; }
.player.big .player-text { flex: 1; gap: 4px; }
.player.big .player-title { order: 0; font-family: var(--display); font-size: clamp(28px, 3.2vw, 38px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.player.big .player-status { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.player.big .player-meta { display: block; color: var(--muted); font-size: 15px; }

.fav-big { place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--text); }
.player.big .fav-big { display: grid; }
.fav-big svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.fav-big[aria-pressed="true"] { color: var(--banana); border-color: color-mix(in srgb, var(--banana) 40%, transparent); }
.fav-big[aria-pressed="true"] svg { fill: currentColor; }

.player.big .viz { display: flex; align-items: center; gap: 2px; height: 40px; }
.viz i {
  flex: 1; max-width: 4px; height: 100%; border-radius: 2px; margin-inline: auto;
  background: color-mix(in srgb, var(--glow) 55%, var(--text));
  opacity: 0.5;
  transform: scaleY(0.08);
  transition: transform 0.6s var(--ease);
}
.player[data-state="playing"] .viz i { animation: viz var(--d, 1s) ease-in-out infinite alternate; animation-delay: var(--o, 0s); opacity: 0.9; }

.player.big .controls { justify-content: center; gap: 26px; }
.player.big .ctrl { width: 56px; height: 56px; }
.player.big .ctrl svg { width: 30px; height: 30px; }
.player.big .ctrl-play { width: 78px; height: 78px; box-shadow: 0 16px 40px -10px color-mix(in srgb, var(--banana) 60%, transparent); }
.player.big .ctrl-play svg { width: 34px; height: 34px; }

/* Mobile full-screen sheet */
body.player-open { overflow: hidden; }
body.player-open .player {
  inset: 0; border-radius: 0; border: 0;
  transform: none;
  animation: sheet 0.4s var(--ease);
}
body.player-open .player-close {
  display: grid; place-items: center;
  position: absolute; top: calc(var(--safe-t) + 12px); left: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}
body.player-open .player-close svg { width: 26px; height: 26px; }

/* ---------- Layout breakpoints ---------- */

@media (min-width: 600px) {
  .browse { padding-inline: 32px; }
  .chips, .rail { margin-inline: -32px; padding-inline: 32px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .player:not(.big) { left: 50%; right: auto; width: min(560px, calc(100% - 32px)); translate: -50% 0; }
}

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: minmax(380px, 32vw) minmax(0, 1fr); }
  .player, .player.big {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto;
    height: 100dvh;
    border: 0; border-right: 1px solid var(--line); border-radius: 0;
    transform: none;
    padding: 48px clamp(28px, 3vw, 48px);
  }
  .browse { padding: 44px clamp(28px, 4vw, 56px) 72px; }
  .chips { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; }
  .rail { margin-inline: 0; padding-inline: 0; gap: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 30px 22px; }
  .player.big .art-tile { width: min(26vw, 50vh, 380px); }
}

@media (hover: hover) and (pointer: fine) {
  .player.big .volume { display: flex; align-items: center; gap: 12px; align-self: center; width: min(100%, 260px); color: var(--muted); }
  .volume svg { width: 20px; height: 20px; flex: none; }
  .volume input {
    flex: 1; height: 4px; margin: 0;
    appearance: none; -webkit-appearance: none;
    border-radius: 2px;
    background: linear-gradient(var(--banana), var(--banana)) 0 / calc(var(--v, 1) * 100%) 100% no-repeat, var(--line-2);
    cursor: pointer;
  }
  .volume input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
  .volume input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
}

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes spin { to { rotate: 1turn; } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes eq { from { transform: scaleY(0.25); } to { transform: scaleY(1); } }
@keyframes viz { from { transform: scaleY(0.12); } to { transform: scaleY(var(--h, 0.8)); } }
@keyframes ring { 0% { opacity: 0.7; transform: scale(1); } 100% { opacity: 0; transform: scale(1.18); } }

@keyframes sheet { from { opacity: 0; transform: translateY(32px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
