/* DJ Ramzy — OLED-dark streaming library. Mobile-first, safe-area aware. */
:root {
  --bg:        #08080F;
  --surface:   #12121F;
  --surface-2: #1B1B2C;
  --border:    #272740;
  --fg:        #F5F6FA;
  --fg-muted:  #9B9BB4;
  --accent:    #22C55E;
  --accent-ink:#04210F;

  --r-sm: 8px; --r-md: 14px; --r-lg: 22px; --r-full: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mini-h: 68px;
  --wrap: 1120px;

  --z-mini: 40; --z-np: 60; --z-sheet: 100;
  --ease-out: cubic-bezier(.22,.9,.3,1);
}

/* [hidden] must beat the display values set on components below — a class
   rule's `display` otherwise overrides the attribute. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg);
  font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; min-height: 100dvh;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body.sheet-open, body.np-open { overflow: hidden; }
main { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--sp-4) calc(var(--mini-h) + var(--safe-b) + var(--sp-7)); }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
      stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-sm); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }


/* ---------- light theme ----------
   Defined as a token swap so every component follows without change. The
   accent darkens on light backgrounds: #22C55E on white is about 1.9:1 and
   unreadable as text, while #15803D clears AA. */
:root[data-theme="light"],
:root[data-theme="auto"] {
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:        #FAFAFB;
    --surface:   #FFFFFF;
    --surface-2: #F1F2F6;
    --border:    #E3E5ED;
    --fg:        #14141F;
    --fg-muted:  #5A5C72;
    --accent:    #15803D;
    --accent-ink:#FFFFFF;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg:        #FAFAFB;
  --surface:   #FFFFFF;
  --surface-2: #F1F2F6;
  --border:    #E3E5ED;
  --fg:        #14141F;
  --fg-muted:  #5A5C72;
  --accent:    #15803D;
  --accent-ink:#FFFFFF;
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

/* Surfaces that were tuned for an OLED backdrop need re-tuning on light. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .topbar { background: rgba(250,250,251,.85); }
  :root:not([data-theme="dark"]) .miniplayer { background: rgba(255,255,255,.92); }
  :root:not([data-theme="dark"]) .nowplaying::before { background: radial-gradient(90% 60% at 50% 0%, rgba(21,128,61,.10), transparent 70%); }
  :root:not([data-theme="dark"]) .card-len { background: rgba(0,0,0,.62); color: #fff; }
  /* Both wordmarks are white-on-transparent, so they invert on light. */
  :root:not([data-theme="dark"]) .brand-logo,
  :root:not([data-theme="dark"]) .back-brand img { filter: invert(1); }
  :root:not([data-theme="dark"]) .sheet-scrim { background: rgba(20,20,31,.45); }
}
:root[data-theme="light"] .topbar { background: rgba(250,250,251,.85); }
:root[data-theme="light"] .miniplayer { background: rgba(255,255,255,.92); }
:root[data-theme="light"] .nowplaying::before { background: radial-gradient(90% 60% at 50% 0%, rgba(21,128,61,.10), transparent 70%); }
:root[data-theme="light"] .card-len { background: rgba(0,0,0,.62); color: #fff; }
/* Both wordmarks are white-on-transparent, so they invert on light. */
:root[data-theme="light"] .brand-logo,
:root[data-theme="light"] .back-brand img { filter: invert(1); }
:root[data-theme="light"] .sheet-scrim { background: rgba(20,20,31,.45); }
:root[data-theme="light"] .play-btn-lg { box-shadow: 0 6px 26px rgba(21,128,61,.28); }
:root[data-theme="light"] .car-banner {
  background: linear-gradient(120deg, rgba(21,128,61,.10), rgba(21,128,61,.03));
  border-color: rgba(21,128,61,.28);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: calc(var(--safe-t) + var(--sp-3)) var(--sp-4) var(--sp-3);
  background: rgba(8,8,15,.82); backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }
.ghost-icon { border: 1px solid var(--border); background: var(--surface); }

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
  color: var(--fg); font-size: .82rem; font-weight: 500; text-decoration: none;
  transition: background .18s var(--ease-out), transform .18s var(--ease-out);
}
.ghost-btn svg { width: 17px; height: 17px; }
.ghost-btn:active { transform: scale(.97); background: var(--surface-2); }
.ghost-btn.wide { width: 100%; }
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-5);
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--r-full);
  font-weight: 600; transition: transform .18s var(--ease-out), filter .18s var(--ease-out);
}
.primary-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.primary-btn:active { transform: scale(.97); filter: brightness(1.08); }
@media (max-width: 480px) { .hide-sm { display: none; } }

/* ---------- search ---------- */
.searchbar {
  position: sticky; top: calc(var(--safe-t) + 62px); z-index: 29;
  display: flex; align-items: center; gap: var(--sp-2);
  max-width: var(--wrap); margin: 0 auto var(--sp-2);
  padding: var(--sp-2) var(--sp-3); margin-inline: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-full);
}
.searchbar svg { width: 18px; height: 18px; color: var(--fg-muted); flex: none; }
.searchbar input {
  flex: 1; min-width: 0; min-height: 40px; border: 0; background: none; color: var(--fg);
  font: inherit; font-size: 16px; outline: none;   /* 16px avoids iOS zoom-on-focus */
}
.searchbar input::-webkit-search-cancel-button { display: none; }

/* ---------- stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2);
  padding: var(--sp-5) 0 var(--sp-4);
}
.stat { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.stat-n { font-size: clamp(1.1rem, 5vw, 1.6rem); font-weight: 800; letter-spacing: -.03em;
          font-variant-numeric: tabular-nums; }
.stat-l { font-size: .66rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- section head ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
                margin-bottom: var(--sp-3); }
.section-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.sort { position: relative; display: inline-flex; align-items: center; }
.sort select {
  appearance: none; min-height: 40px; padding: 0 var(--sp-6) 0 var(--sp-3);
  background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--r-full); font: inherit; font-size: .8rem; cursor: pointer;
}
.sort svg { position: absolute; right: var(--sp-3); width: 15px; height: 15px;
            pointer-events: none; color: var(--fg-muted); }

/* ---------- library grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-4) var(--sp-3); }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px){ .grid { grid-template-columns: repeat(5, 1fr); } }

.card {
  display: grid; gap: var(--sp-2); padding: 0; text-align: left;
  background: none; border: 0; border-radius: var(--r-md);
  transition: transform .18s var(--ease-out);
}
.card:active { transform: scale(.97); }
.card-artwrap { position: relative; aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden;
                background: var(--surface-2); }
.card-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-play {
  position: absolute; right: var(--sp-2); bottom: var(--sp-2);
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s var(--ease-out), transform .18s var(--ease-out);
}
.card-art-wrap:hover .card-play, .card:hover .card-play,
.card[aria-current="true"] .card-play { opacity: 1; transform: none; }
@media (hover: none) { .card-play { opacity: 1; transform: none; } }
.card-play svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.card-len {
  position: absolute; left: var(--sp-2); bottom: var(--sp-2);
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  background: rgba(0,0,0,.7); font-size: .68rem; font-variant-numeric: tabular-nums;
}
.card-resume { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.5); }
.card-resume span { display: block; height: 100%; background: var(--accent); }
.card-title { font-size: .84rem; font-weight: 600; line-height: 1.3; letter-spacing: -.01em;
              display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: .7rem; color: var(--fg-muted); display: flex; gap: var(--sp-2); align-items: center; }
.card-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; flex: none; }

.playing-bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 10px; }
.playing-bars i { width: 2.5px; background: var(--accent); border-radius: 1px; animation: eq .9s ease-in-out infinite; }
.playing-bars i:nth-child(1) { height: 40%; animation-delay: -.2s; }
.playing-bars i:nth-child(2) { height: 90%; animation-delay: -.5s; }
.playing-bars i:nth-child(3) { height: 60%; }
@keyframes eq { 0%,100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }

.empty { grid-column: 1 / -1; text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--fg-muted); }
.empty h3 { color: var(--fg); font-size: 1.05rem; margin: 0 0 var(--sp-2); }
.sk { aspect-ratio: 1; border-radius: var(--r-md);
      background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
      background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- mini player ---------- */
.miniplayer {
  position: fixed; left: var(--sp-2); right: var(--sp-2); z-index: var(--z-mini);
  bottom: calc(var(--safe-b) + var(--sp-2));
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-2);
  height: var(--mini-h); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  background: rgba(27,27,44,.9); backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
  max-width: var(--wrap); margin: 0 auto; animation: mini-in .3s var(--ease-out);
}
@keyframes mini-in { from { transform: translateY(120%); } to { transform: none; } }
.mini-open { display: grid; grid-template-columns: 52px 1fr; gap: var(--sp-3);
             align-items: center; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.mini-art { width: 52px; height: 52px; border-radius: 11px; object-fit: cover; background: var(--surface-2); }
.mini-meta { min-width: 0; display: block; }
.mini-title { display: block; font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { display: block; font-size: .74rem; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-progress { grid-column: 1 / -1; height: 2px; background: var(--surface-2); border-radius: 2px; }
.mini-progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; position: relative;
            min-width: 44px; min-height: 44px; background: none; border: 0; border-radius: var(--r-full);
            transition: transform .15s var(--ease-out), background .15s var(--ease-out); }
.icon-btn:active { transform: scale(.92); }
.play-btn { background: var(--accent); color: var(--accent-ink); }
.play-btn svg { stroke: none; fill: currentColor; }
.play-btn-lg { min-width: 72px; min-height: 72px; box-shadow: 0 6px 26px rgba(34,197,94,.34); }
.play-btn-lg svg { width: 30px; height: 30px; }
.skip-btn svg { width: 30px; height: 30px; fill: var(--fg); stroke: none; }
.skip-btn text { font-family: inherit; font-size: 7.6px; font-weight: 700; fill: var(--fg); stroke: none; }

/* ---------- now playing ---------- */
/* One way out, and it says where it goes. An arrow plus the wordmark reads as
   "back to DJ Ramzy" without needing to be learned. Earlier this screen had a
   grab handle that looked like a phone home bar, a chevron that looked like a
   dropdown, and a labelled button — three controls for one action. */
.np-head, .panel-head {
  position: sticky; top: 0; z-index: 2; flex: none;
  display: flex; align-items: center; align-self: stretch;
  padding: calc(var(--safe-t) + var(--sp-3)) var(--sp-3) var(--sp-3);
  margin: calc(var(--sp-3) * -1) 0 0;
  background: linear-gradient(to bottom, var(--bg) 74%, transparent);
}
.panel-head { margin: 0; border-bottom: 1px solid var(--border);
              background: var(--bg); padding-inline: var(--sp-4); }
.back-brand {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  min-height: 44px; padding: 0 var(--sp-3) 0 var(--sp-1);
  background: none; border: 0; border-radius: var(--r-full); color: var(--fg);
}
.back-brand svg { width: 22px; height: 22px; flex: none; }
.back-brand img { height: 24px; width: auto; display: block; }
.back-brand:active { opacity: .6; }
.nowplaying {
  position: fixed; inset: 0; z-index: var(--z-np);
  overscroll-behavior: contain; touch-action: pan-y;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-5);
  padding: calc(var(--safe-t) + var(--sp-3)) var(--sp-5) calc(var(--safe-b) + var(--sp-6));
  background: var(--bg); overflow-y: auto; animation: np-in .32s var(--ease-out);
}
@keyframes np-in { from { transform: translateY(100%); } to { transform: none; } }
.nowplaying::before { content: ''; position: absolute; inset: 0 0 auto; height: 55%; pointer-events: none;
  background: radial-gradient(90% 60% at 50% 0%, rgba(34,197,94,.13), transparent 70%); }
/* A bare chevron left people stuck on this view — and because it locks the
   page behind it, that reads as "the site will not scroll". Label it. */
/* The panel is a sheet, so it gets a sheet's affordances: a grab handle, a
   labelled way out, and the swipe-down gesture people already expect from
   every music app. A lone chevron read as decoration. */

.np-art { width: min(78vw, 320px); aspect-ratio: 1; border-radius: var(--r-lg); object-fit: cover;
          background: var(--surface-2); box-shadow: 0 24px 60px rgba(0,0,0,.6); flex: none; }
.np-meta { text-align: center; max-width: 34ch; }
.np-meta h2 { margin: 0 0 var(--sp-1); font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; }
.np-meta p { margin: 0; color: var(--fg-muted); font-size: .86rem; }
.np-scrub { width: 100%; max-width: 480px; }
.np-wave { display: block; width: 100%; height: 64px; cursor: pointer; touch-action: none; }
.np-times { display: flex; justify-content: space-between; margin-top: var(--sp-2); color: var(--fg-muted); font-size: .76rem; }
.tnum { font-variant-numeric: tabular-nums; }
.np-controls { display: flex; align-items: center; gap: var(--sp-6); }
.np-tracklist { width: 100%; max-width: 480px; color: var(--fg-muted); font-size: .84rem; }
.np-tracklist h3 { color: var(--fg); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 var(--sp-3); }
.np-tracklist ol { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-2); }

/* ---------- subscribe sheet ---------- */
.sheet-scrim { position: fixed; inset: 0; z-index: var(--z-sheet); display: flex; align-items: flex-end;
               justify-content: center; background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
               animation: fade .2s var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: 100%; max-width: 520px; padding: var(--sp-3) var(--sp-5) calc(var(--safe-b) + var(--sp-5));
         background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0;
         display: grid; gap: var(--sp-4); animation: sheet-in .3s var(--ease-out); max-height: 90dvh; overflow-y: auto; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto var(--sp-2); }
.sheet h2 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.sheet p { margin: 0; color: var(--fg-muted); font-size: .88rem; }
.feed-row { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2); }
.feed-url { min-width: 0; min-height: 44px; padding: 0 var(--sp-3); background: var(--bg); color: var(--fg-muted);
            border: 1px solid var(--border); border-radius: var(--r-sm); font-size: .8rem;
            font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.app-links { display: grid; gap: var(--sp-2); }
.app-link { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-2);
            min-height: 56px; padding: var(--sp-3) var(--sp-4); background: var(--surface-2);
            border: 1px solid var(--border); border-radius: var(--r-md); color: var(--fg); text-decoration: none;
            transition: background .18s var(--ease-out), transform .18s var(--ease-out); }
.app-link:active { transform: scale(.98); background: var(--border); }
.app-link svg { width: 18px; height: 18px; color: var(--fg-muted); grid-row: span 2; }
.app-name { font-weight: 600; font-size: .92rem; }
.app-note { grid-column: 1; font-size: .74rem; color: var(--fg-muted); }
.sheet-note { font-size: .78rem; color: var(--fg-muted); }
.manual { border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.manual summary { cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--fg-muted);
                  min-height: 44px; display: flex; align-items: center; }
.manual p { margin: 0 0 var(--sp-3); }

@media (min-width: 720px) {
  .np-art { width: 320px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; }
}

/* The offline/car path is the most useful thing here, so it gets a real
   prompt rather than only an icon in the header. */
.car-banner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  width: 100%; margin-bottom: var(--sp-5); padding: var(--sp-3) var(--sp-4); text-align: left;
  background: linear-gradient(120deg, rgba(34,197,94,.14), rgba(34,197,94,.04));
  border: 1px solid rgba(34,197,94,.3); border-radius: var(--r-md); color: var(--fg);
  transition: transform .18s var(--ease-out), background .18s var(--ease-out);
}
.car-banner:active { transform: scale(.99); }
.car-banner > svg:first-child { width: 20px; height: 20px; color: var(--accent); }
.car-banner > svg:last-child { width: 16px; height: 16px; color: var(--fg-muted); }
.car-banner span { display: grid; gap: 1px; min-width: 0; }
.car-banner strong { font-size: .85rem; font-weight: 600; }
.car-banner span { font-size: .72rem; color: var(--fg-muted); line-height: 1.35; }

/* ---------- filter chips ---------- */
.filters {
  display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-1);
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 var(--sp-4);
  background: var(--surface); color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--r-full);
  font-size: .78rem; font-weight: 500; white-space: nowrap;
  transition: background .16s var(--ease-out), color .16s var(--ease-out), transform .16s var(--ease-out);
}
.chip:active { transform: scale(.96); }
.chip-on { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

/* ---------- view toggle ---------- */
.section-head { flex-wrap: wrap; }
.section-head h2 { margin-right: auto; }
.view-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border);
               border-radius: var(--r-full); padding: 3px; }
.seg { display: grid; place-items: center; min-width: 38px; min-height: 34px;
       background: none; border: 0; border-radius: var(--r-full); color: var(--fg-muted);
       transition: background .16s var(--ease-out), color .16s var(--ease-out); }
.seg svg { width: 17px; height: 17px; }
.seg-on { background: var(--surface-2); color: var(--fg); }

/* ---------- list view ---------- */
.list { display: grid; gap: var(--sp-1); grid-template-columns: 1fr; }
.row {
  display: grid; grid-template-columns: 56px 1fr auto auto; align-items: center;
  gap: var(--sp-3); width: 100%; text-align: left; padding: var(--sp-2);
  background: none; border: 0; border-radius: var(--r-md);
  transition: background .16s var(--ease-out);
}
.row:active, .row[aria-current="true"] { background: var(--surface); }
.row-artwrap { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden;
               background: var(--surface-2); }
.row-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-body { min-width: 0; display: grid; gap: 2px; }
.row-title { font-size: .9rem; font-weight: 600; letter-spacing: -.01em;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: .72rem; color: var(--fg-muted); display: flex; gap: var(--sp-2); align-items: center; }
.row-tags { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.tag { font-size: .62rem; padding: 1px var(--sp-2); border-radius: var(--r-full);
       background: var(--surface-2); color: var(--fg-muted); border: 1px solid var(--border); }
.row-len { font-size: .76rem; color: var(--fg-muted); }
.row-play { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
            background: var(--accent); color: var(--accent-ink); }
.row-play svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
@media (max-width: 420px) { .row-len { display: none; } }

/* ---------- mobile hardening ---------- */
/* Nothing interactive below 44px: chips and the view toggle were 34-38px. */
.chip { min-height: 44px; }
.seg { min-height: 40px; min-width: 44px; }
.view-toggle { padding: 2px; }
.sort select { min-height: 44px; }
.manual summary { min-height: 44px; }

/* Never let a long title or the filter row push the page sideways.
   `clip` rather than `hidden`: setting overflow-x to `hidden` forces the other
   axis from `visible` to `auto`, which makes html AND body scroll containers.
   Desktop tolerates the nesting; on iOS it commonly leaves the page unable to
   scroll at all. `clip` trims the overflow without creating a scroll box. */
body { max-width: 100%; overflow-x: clip; }
.card-title, .row-title, .mini-title, .np-meta h2 { overflow-wrap: anywhere; }

/* Very narrow phones: four stats in a row become unreadable, so wrap to two. */
@media (max-width: 400px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3) var(--sp-2); }
  .topbar { gap: var(--sp-2); padding-inline: var(--sp-3); }
  .brand-logo { height: 28px; }
  main { padding-inline: var(--sp-3); }
  .searchbar { margin-inline: var(--sp-3); }
}
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
}

/* Landscape on a phone: the now-playing view must not need scrolling to
   reach the transport controls. */
@media (orientation: landscape) and (max-height: 520px) {
  .nowplaying {
    display: grid; grid-template-columns: auto 1fr; align-items: center;
    gap: var(--sp-4) var(--sp-5); padding-block: var(--sp-3);
  }
    .np-art { width: min(30vh, 190px); grid-row: span 3; }
  .np-meta { text-align: left; }
  .np-controls { gap: var(--sp-5); }
  .np-tracklist { display: none; }
}

/* Honour the system's larger text sizes without breaking the layout. */
@media (min-width: 0px) {
  .card-title { -webkit-line-clamp: 3; }
}

/* Remaining sub-44px targets: the segmented view buttons and the search field. */
.seg { min-height: 44px; }
.searchbar input { min-height: 44px; }
.searchbar { padding-block: var(--sp-1); }

/* ---------- install prompt ---------- */
.install-banner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  width: 100%; margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--fg);
  transition: transform .18s var(--ease-out), background .18s var(--ease-out);
}
.install-banner:active { transform: scale(.99); background: var(--surface-2); }
.install-banner > svg { width: 20px; height: 20px; color: var(--accent); }
.install-banner span { display: grid; gap: 1px; min-width: 0; }
.install-banner strong { font-size: .85rem; font-weight: 600; }
.install-banner em { font-size: .72rem; color: var(--fg-muted); font-style: normal; line-height: 1.35; }
.install-go {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 var(--sp-4); border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink); font-size: .78rem; font-weight: 600;
}

/* Card captions must not wrap — a three-line caption under every tile made the
   grid read as clutter. The list view carries the full detail. */
.card-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- favorites ---------- */
/* The heart sits outside the card's own button element, so tapping it cannot
   also start playback. */
.card-wrap { position: relative; display: grid; }

.fav {
  position: absolute; left: var(--sp-2); top: var(--sp-2);
  display: inline-flex; align-items: center; gap: 3px;
  min-width: 36px; min-height: 36px; padding: 0 var(--sp-2);
  border: 0; border-radius: var(--r-full);
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  color: #fff; transition: transform .16s var(--ease-out), background .16s var(--ease-out);
}
.fav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.fav-on { background: var(--accent); color: var(--accent-ink); }
.fav-on svg { fill: currentColor; }
.fav:active { transform: scale(.88); }
.fav-n { font-size: .68rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* List rows position the heart on the right instead. */
.row-wrap { position: relative; }
.row-wrap .row { padding-right: 52px; }
.row-wrap .fav { left: auto; right: var(--sp-2); top: 50%; transform: translateY(-50%); }
.row-wrap .fav:active { transform: translateY(-50%) scale(.88); }

.chip-fav { display: inline-flex; align-items: center; gap: var(--sp-1); }
.chip-fav svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.chip-fav.chip-on svg { fill: currentColor; }

/* With transitions detected the skip buttons move between tracks, so the
   fixed-seconds numerals inside them would be a lie. */
.has-marks .skip-btn svg text { display: none; }

/* Seeking to another track can take seconds over a phone connection. Saying so
   is the difference between "loading" and "broken". */
.buffering .play-btn-lg { position: relative; }
.buffering .play-btn-lg::after {
  content: ''; position: absolute; inset: -6px;
  border: 3px solid transparent; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.buffering .np-wave { opacity: .5; }
@media (prefers-reduced-motion: reduce) {
  .buffering .play-btn-lg::after { animation: none; border-top-color: transparent; border-color: var(--accent); opacity: .5; }
}

/* ---------- tracklist cues ---------- */
.cues { list-style: decimal; padding-left: 1.6em; display: grid; gap: var(--sp-1); }
.cues li::marker { color: var(--fg-muted); font-size: .76rem; }
.cue {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-3); align-items: baseline;
  width: 100%; min-height: 44px; padding: var(--sp-2) var(--sp-2);
  margin-left: calc(var(--sp-2) * -1);
  background: none; border: 0; border-radius: var(--r-sm); text-align: left;
  color: var(--fg-muted); transition: background .16s var(--ease-out), color .16s var(--ease-out);
}
.cue:active { background: var(--surface); }
.cue-t { font-size: .74rem; color: var(--fg-muted); flex: none; }
.cue-l { font-size: .84rem; line-height: 1.35; }
.cue-on { color: var(--fg); background: var(--surface); }
.cue-on .cue-t { color: var(--accent); font-weight: 700; }
.cue-on .cue-l { font-weight: 600; }
.cue-plain { display: block; padding: var(--sp-2) 0; font-size: .84rem; }

/* ---------- browse panel ---------- */
/* Same shape as the player: brand mark top-left that goes home, close on the
   right. Every full-screen view in the app is laid out this way. */
.panel {
  position: fixed; inset: 0; z-index: var(--z-np);
  display: flex; flex-direction: column;
  background: var(--bg); animation: np-in .28s var(--ease-out);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + var(--sp-3)) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border); flex: none;
}
.panel-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--sp-4) var(--sp-4) calc(var(--mini-h) + var(--safe-b) + var(--sp-6));
  max-width: var(--wrap); width: 100%; margin: 0 auto;
}
.panel-title { margin: 0 0 var(--sp-4); font-size: 1.4rem; font-weight: 800; letter-spacing: -.03em; }

.browse-tabs {
  display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4);
  overflow-x: auto; scrollbar-width: none; padding-bottom: var(--sp-1);
}
.browse-tabs::-webkit-scrollbar { display: none; }

.browse-list { display: grid; gap: var(--sp-1); }
.browse-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 52px; padding: var(--sp-2) var(--sp-3); text-align: left;
  background: none; border: 0; border-radius: var(--r-md); color: var(--fg);
  transition: background .16s var(--ease-out);
}
.browse-row:active { background: var(--surface); }
.browse-name { font-size: .92rem; font-weight: 600; min-width: 0;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browse-count { font-size: .74rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.browse-row svg { width: 16px; height: 16px; color: var(--fg-muted); }
.browse-empty { padding: var(--sp-6) var(--sp-3); color: var(--fg-muted); font-size: .88rem; text-align: center; }

/* ---------- bottom navigation ---------- */
/* Three places to be, always reachable by thumb. The header icons were fine
   for actions but wrong for navigation — you should never have to hunt for
   where you are. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: var(--sp-1) var(--sp-2) calc(var(--safe-b) + var(--sp-1));
  background: rgba(8,8,15,.94); backdrop-filter: blur(18px) saturate(1.3);
  border-top: 1px solid var(--border);
}
:root[data-theme="light"] .tabbar { background: rgba(250,250,251,.95); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .tabbar { background: rgba(250,250,251,.95); }
}
.tab {
  display: grid; justify-items: center; gap: 2px;
  min-height: 52px; padding: var(--sp-1) 0;
  background: none; border: 0; color: var(--fg-muted); font-size: .64rem; font-weight: 600;
  letter-spacing: .02em; transition: color .16s var(--ease-out);
}
.tab svg { width: 22px; height: 22px; }
.tab-on { color: var(--accent); }
.tab-on svg { stroke-width: 2.1; }

/* The mini player stacks above the bar rather than under it. */
.miniplayer { bottom: calc(var(--safe-b) + 62px); }
main { padding-bottom: calc(var(--mini-h) + var(--safe-b) + 92px); }
.panel-body { padding-bottom: calc(var(--mini-h) + var(--safe-b) + 92px); }

/* ---------- collection shelves ---------- */
.shelves { display: grid; gap: var(--sp-6); margin-bottom: var(--sp-7); }
.shelf-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.shelf-title { margin: 0; font-size: 1.02rem; font-weight: 700; letter-spacing: -.02em; }
.shelf-blurb { font-size: .72rem; color: var(--fg-muted); }
.shelf-all {
  flex: none; background: none; border: 0; color: var(--accent);
  font-size: .74rem; font-weight: 600; min-height: 32px; padding: 0 var(--sp-1);
}
/* A rail rather than a grid: a shelf should suggest there is more sideways. */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 42vw;
  gap: var(--sp-3); overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: none; padding-bottom: var(--sp-2);
  margin-inline: calc(var(--sp-4) * -1); padding-inline: var(--sp-4);
}
.rail::-webkit-scrollbar { display: none; }
.rail > .card-wrap { scroll-snap-align: start; }
@media (min-width: 560px) { .rail { grid-auto-columns: 30vw; } }
@media (min-width: 860px) { .rail { grid-auto-columns: 21vw; } }
@media (min-width: 1100px){ .rail { grid-auto-columns: 200px; } }
