/* Palette: Mist 60% (page), Mint 30% (cards, and the type in dark), Pine ink for text,
   Raspberry 10% (what is live: the seek fill, the level bars, the playing mark).
   Light first; [data-theme="dark"] swaps the tokens. Every tint below comes from the
   -rgb triplets, so a palette change is these lines only.
   Glass follows LIQUID_GLASS.md: clear fill, top sheen, a lip of light inside the top edge,
   darker thickness at the bottom. No 1px borders. */
:root {
  --base: #E4EDE9;   --base-rgb: 228 237 233;
  --ink: #0C1F19;    --ink-rgb: 12 31 25;
  --mint: #A6E9CF;   --mint-rgb: 166 233 207;
  --accent: #E8456F; --accent-rgb: 232 69 111;

  --card: var(--mint);            --card-ink-rgb: var(--ink-rgb);
  --on: var(--ink);               --on-ink: var(--mint);   /* the playing card */
  --bar: var(--accent);           /* level bars on the playing card */
  --sheen-rgb: 255 255 255;
  --shadow-rgb: 12 31 25;
  --strings: rgb(var(--ink-rgb) / 0.11);
  --wave-rgb: var(--ink-rgb);                /* the waves behind everything (app.js waves()) */

  --muted: rgb(var(--ink-rgb) / 0.7);
  --faint: rgb(var(--ink-rgb) / 0.42);
  --fill: rgb(var(--ink-rgb) / 0.05);
  --well: rgb(var(--ink-rgb) / 0.08);
  --lip: rgb(255 255 255 / 0.85);
  --edge-shade: rgb(var(--shadow-rgb) / 0.22);
  --glass: rgb(var(--base-rgb) / 0.85);
  --glass-dense: rgb(var(--base-rgb) / 0.92);   /* the player: card text must not read through */
  --track: rgb(var(--ink-rgb) / 0.14);
  --knob: #fff;

  --font: "SF Pro Text", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "SF Arabic", "Noto Sans Arabic", sans-serif;
  --font-title: "SF Pro Display", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "SF Arabic", "Noto Kufi Arabic", "Noto Sans Arabic", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Noto Sans Mono", Menlo, Consolas, monospace;
  /* inverted surface (what is live: the playing card, the full-screen card and its bar) */
  --inv-ink: var(--mint);  --inv-ink-rgb: var(--mint-rgb);
  --inv-base: #0C1F19;     --inv-base-rgb: 12 31 25;
  --inv-accent: var(--accent);
  /* now playing (full screen): the songs go to a column on the right, the playing card and the
     bar sit together in the middle of what is left, a little left of the page's centre */
  --vw: 100vw;             /* the viewport without its scrollbar (set by app.js) */
  --np-side: clamp(300px, 34vw, 500px);
  --np-gap: 40px;
  --np-cx: calc((var(--vw) - var(--np-side) - var(--np-gap)) / 2);
  --np-w: min(640px, var(--vw) - 2 * var(--pad) - var(--np-side) - var(--np-gap));
  --np-bar-h: 116px;
  --np-split: 10px;        /* card and bar are two pieces, this far apart */
  --np-bottom: max(clamp(20px, 7svh, 72px), env(safe-area-inset-bottom)); /* lifted off the bottom edge */
  --np-art: min(clamp(150px, 100svh - 500px, 320px), (var(--np-w) - 48px) / 2);
  --pad: clamp(16px, 4vw, 56px);
  --max: 1360px;
  --quart: cubic-bezier(0.25, 1, 0.5, 1);
  --apple: cubic-bezier(0.32, 0.72, 0, 1);   /* iOS sheet curve: a critically damped spring */
  --pop: cubic-bezier(0.3, 1.6, 0.5, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --base: #0B1311;   --base-rgb: 11 19 17;
  --ink: #A6E9CF;    --ink-rgb: 166 233 207;
  --accent: #FF6088; --accent-rgb: 255 96 136;
  --card: #14211C;                --card-ink-rgb: var(--mint-rgb);
  --on: var(--mint);              --on-ink: #0B1311;
  --bar: #0B1311;
  --sheen-rgb: 166 233 207;
  --shadow-rgb: 0 0 0;
  --strings: rgb(var(--mint-rgb) / 0.09);
  --wave-rgb: var(--mint-rgb);
  --lip: rgb(var(--mint-rgb) / 0.3);
  --edge-shade: rgb(0 0 0 / 0.55);
  --glass: rgb(20 33 28 / 0.84);
  --glass-dense: rgb(20 33 28 / 0.94);
  --track: rgb(var(--mint-rgb) / 0.16);
  --knob: var(--mint);
  --inv-ink: #0B1311;      --inv-ink-rgb: 11 19 17;
  --inv-base: var(--mint); --inv-base-rgb: var(--mint-rgb);
  --inv-accent: #0B1311;   /* raspberry on mint is too faint: the fill goes ink */
  color-scheme: dark;
}
@media (max-width: 820px) {
  :root { --np-cx: calc(var(--vw) / 2); --np-w: calc(var(--vw) - 32px); --np-art: clamp(110px, 36vw, 170px); --np-bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* Everything inside an inverted surface reads its tokens from here, so the controls,
   ranges and text need no second set of rules. */
.inv {
  --ink: var(--inv-ink);   --ink-rgb: var(--inv-ink-rgb);
  --base: var(--inv-base); --base-rgb: var(--inv-base-rgb);
  --accent: var(--inv-accent);
  --muted: rgb(var(--inv-ink-rgb) / 0.72);
  --faint: rgb(var(--inv-ink-rgb) / 0.45);
  --well: rgb(var(--inv-ink-rgb) / 0.1);
  --track: rgb(var(--inv-ink-rgb) / 0.2);
  --lip: rgb(var(--inv-ink-rgb) / 0.2);
  --knob: var(--inv-ink);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { background: var(--base); scrollbar-gutter: stable; }
/* now playing: the page holds still, only the songs column scrolls */
html.np, html.np body { overflow: hidden; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--base);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.3s ease, color 0.3s ease;
  /* nothing on the page is selectable, except what you type into */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { -webkit-user-drag: none; }
::selection { background: var(--ink); color: var(--base); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Background: waves across the page. Idle they breathe; while a song plays they carry its
   waveform and swell with the bass (app.js waves()). In now playing they go out of focus
   (blurred) and keep moving behind everything. */
.strings {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
/* the out-of-focus copy: drawn at a fifth of the size and stretched, which blurs it for free
   (a CSS blur over a moving full-screen canvas would cost a frame every few frames) */
.strings.soft { opacity: 0; }
html.np .strings { opacity: 0; }
html.np .strings.soft { opacity: 1; }

/* Glass */
.glass {
  border-radius: var(--r);
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.22), transparent 58%), var(--glass);
  -webkit-backdrop-filter: blur(3px) saturate(1.6);
  backdrop-filter: blur(3px) saturate(1.6);
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -1px 1px rgb(var(--sheen-rgb) / 0.12),
    inset 0 0 7px -3px var(--edge-shade),
    inset 0 -10px 16px -14px var(--edge-shade),
    0 18px 36px -24px rgb(var(--shadow-rgb) / 0.45);
}

/* Round controls (LIQUID_GLASS 12.5: grow to 1.1 on press, with overshoot) */
.round {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--muted);
  background: rgb(var(--ink-rgb) / 0.06);
  box-shadow: inset 0 1px 0.5px var(--lip), inset 0 -8px 12px -10px var(--edge-shade);
  transition: scale 0.35s var(--pop), color 0.16s ease, background-color 0.16s ease;
}
.round:hover { color: var(--ink); }
.round:active { scale: 1.1; }
.round svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.round svg.solid { fill: currentColor; stroke: none; }
.round svg.flip { scale: -1 1; }
.round .fill { fill: currentColor; stroke: none; }
.round[aria-pressed="true"], .round[data-mode="all"], .round[data-mode="one"] { color: var(--ink); background: rgb(var(--accent-rgb) / 0.16); }
.round .one { display: none; }
.round[data-mode="one"] .one { display: inline; }

/* Dock: floating glass bar. Its glass is a layer of its own (::before), so in now playing the
   glass and everything in it can leave while the theme button stays where it is. */
.dock {
  --r: 24px;
  position: sticky;
  top: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 300px auto;
  align-items: center;
  gap: 12px;
  width: min(100% - 2 * var(--pad), var(--max));
  height: 54px;
  margin: 12px auto 0;
  padding: 0 8px 0 22px;
  border-radius: var(--r);
  isolation: isolate;
}
.dock::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.22), transparent 58%), var(--glass);
  -webkit-backdrop-filter: blur(3px) saturate(1.6);
  backdrop-filter: blur(3px) saturate(1.6);
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -1px 1px rgb(var(--sheen-rgb) / 0.12),
    inset 0 0 7px -3px var(--edge-shade),
    inset 0 -10px 16px -14px var(--edge-shade),
    0 18px 36px -24px rgb(var(--shadow-rgb) / 0.45);
}
/* coming back it waits a beat, so the title has left the top first */
.dock::before, .dock > * { transition: opacity 0.28s ease 0.12s, translate 0.5s var(--apple) 0.12s; }
html.np-dock .dock { pointer-events: none; }
html.np-dock .dock::before, html.np-dock .dock > :not(#theme) { opacity: 0; translate: 0 -28px; transition-delay: 0s; }
html.np-dock #theme { pointer-events: auto; }
.host { font: 600 13px/1 var(--mono); color: var(--muted); white-space: nowrap; }

/* Library | YouTube: a well with a glass bead that glides to the chosen side
   (0.32 s quart, like the iOS tab bar). */
.modes {
  position: relative;
  display: flex;
  height: 38px;
  padding: 3px;
  border-radius: 19px;
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(var(--shadow-rgb) / 0.18), inset 0 -1px 0 rgb(var(--sheen-rgb) / 0.3);
}
.modes button {
  position: relative;
  z-index: 1;
  padding: 0 14px;
  border-radius: 16px;
  font: 600 13px/32px var(--font);
  color: var(--muted);
  transition: color 0.2s ease;
}
.modes button:hover, .modes [aria-pressed="true"] { color: var(--ink); }
.mbead {
  position: absolute;
  top: 3px;
  left: 0;
  width: 0;
  height: 32px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.5), transparent 70%), var(--glass-dense);
  box-shadow: inset 0 1px 0.5px var(--lip), inset 0 -6px 10px -8px var(--edge-shade), 0 2px 6px -2px rgb(var(--shadow-rgb) / 0.3);
  transition: translate 0.32s var(--quart), width 0.32s var(--quart);
}
.mbead.jump { transition: none; }

.find {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  border-radius: 19px;
  background: var(--well);
  box-shadow: inset 0 1px 2px rgb(var(--shadow-rgb) / 0.18), inset 0 -1px 0 rgb(var(--sheen-rgb) / 0.3);
}
.find:focus-within { box-shadow: inset 0 1px 2px rgb(var(--shadow-rgb) / 0.18), 0 0 0 2px var(--ink); }
.find svg {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  pointer-events: none;
}
#filter {
  width: 100%;
  height: 100%;
  padding: 0 14px 0 37px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: none;
  color: var(--ink);
  font: 500 14px var(--font);
}
#filter::placeholder { color: var(--faint); }
#filter::-webkit-search-cancel-button { -webkit-appearance: none; }

/* Hero: the library's name, its numbers beside it */
main {
  position: relative;
  width: min(100% - 2 * var(--pad), var(--max));
  margin: 0 auto;
  padding: clamp(40px, 7vw, 104px) 0 200px;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px 56px;
  margin-bottom: clamp(36px, 5vw, 64px);
}
h1 {
  width: fit-content; /* hugs the words, so its move into the now-playing header scales right */
  max-width: 100%;
  margin: 0;
  padding-bottom: 0.04em;
  font: 700 clamp(64px, 12vw, 188px)/0.9 var(--font-title);
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}
.stats { display: flex; flex-direction: column; gap: 10px; min-width: 200px; margin: 0; padding: 0; list-style: none; }
.cap {
  --r: 22px;
  display: grid;
  grid-template-columns: 4.6rem auto;
  align-items: center;
  height: 44px;
  padding: 0 18px;
}
.cap i { font: 500 12px/1 var(--mono); font-style: normal; color: var(--muted); }
.cap b { font: 650 15px/1 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The field: floating song cards. Each card bobs on its own slow period and phase
   (set per song in app.js), so the field never moves in step. */
.field {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 40px 28px;
}
.card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  text-align: start;
  user-select: none;
  -webkit-user-select: none;
  animation: bob var(--t, 7s) ease-in-out var(--d, 0s) infinite alternate;
}
.card[hidden], .field[hidden] { display: none; }
.card:focus-visible { outline: none; }
.card:focus-visible .lift { outline: 2px solid var(--ink); outline-offset: 4px; }
@keyframes bob {
  from { translate: 0 calc(var(--o, 0px) - var(--y, 5px)); rotate: var(--r0, 0deg); }
  to { translate: 0 calc(var(--o, 0px) + var(--y, 5px)); rotate: var(--r1, 0deg); }
}
.lift {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 13px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.3), transparent 42%), var(--card);
  color: rgb(var(--card-ink-rgb));
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -1px 1px rgb(var(--sheen-rgb) / 0.2),
    inset 0 -12px 18px -16px var(--edge-shade),
    0 26px 34px -26px rgb(var(--shadow-rgb) / 0.55),
    0 4px 10px -4px rgb(var(--shadow-rgb) / 0.14);
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--s, 1));
  transition: transform 0.45s var(--quart), background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}
/* light that follows the pointer across the card */
.lift::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 0%), rgb(var(--sheen-rgb) / 0.32), transparent 62%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
@media (hover: hover) {
  .card:hover .lift { --s: 1.04; }
  .card:hover .lift::after { opacity: 1; }
}
.card:active .lift { --s: 0.97; transition-duration: 0.12s; }

.art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  object-fit: cover;
  background: rgb(var(--card-ink-rgb) / 0.1);
}
.art.blank { display: grid; place-items: center; font: 700 56px/1 var(--font-title); color: rgb(var(--card-ink-rgb) / 0.35); }
/* YouTube results: the video frame, 16:9 (crops the bars off 4:3 thumbnails) */
.art.wide { aspect-ratio: 16 / 9; }
.name {
  margin: 11px 4px 0;
  overflow: hidden;
  font: 700 19px/1.45 var(--font-title);
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card[dir="rtl"] .name { letter-spacing: 0; }
.alt {
  margin: 0 4px;
  overflow: hidden;
  font: 500 13px/1.4 var(--font);
  color: rgb(var(--card-ink-rgb) / 0.72);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card[dir="rtl"] .alt { text-align: right; }
.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 18px;
  margin: 7px 4px 0;
  font: 500 12px/1.4 var(--font);
  color: rgb(var(--card-ink-rgb) / 0.72);
}
.feat { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dur { flex: none; margin-inline-start: auto; font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; }

/* level bars: only on the playing card, fed with the music's bands */
.bars { display: none; flex: none; align-items: flex-end; gap: 2px; height: 14px; margin-inline-start: auto; }
.bars i {
  width: 3px;
  height: calc(3px + var(--l, 0) * 11px);
  border-radius: 2px;
  background: var(--bar);
}
.bars i:nth-child(1) { --l: var(--l0); }
.bars i:nth-child(2) { --l: var(--l1); }
.bars i:nth-child(3) { --l: var(--l2); }
.bars i:nth-child(4) { --l: var(--l3); }

.card.on .lift {
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.1), transparent 42%), var(--on);
  color: var(--on-ink);
}
.card.on .alt, .card.on .meta { color: color-mix(in srgb, var(--on-ink) 75%, transparent); }
.card.on .dur { display: none; }
.card.on .bars { display: inline-flex; }
.card.on.paused .bars i { height: 3px; transition: height 0.3s ease; }
/* no Web Audio (iOS: it would stop the music when the phone locks): the bars sway on their own */
.no-levels .card.on:not(.paused) .bars i { animation: sway 0.8s ease-in-out infinite alternate; }
.no-levels .card.on .bars i:nth-child(2) { animation-duration: 0.55s; animation-delay: -0.2s; }
.no-levels .card.on .bars i:nth-child(3) { animation-duration: 0.7s; animation-delay: -0.5s; }
.no-levels .card.on .bars i:nth-child(4) { animation-duration: 0.45s; animation-delay: -0.1s; }
@keyframes sway { from { height: 3px; } to { height: 13px; } }
.card.bad { opacity: 0.45; }

/* Selection: a tick on every card's cover; a chosen card gets the accent ring and a filled tick */
.check {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.32);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.85), 0 2px 6px rgb(0 0 0 / 0.25);
  opacity: 0;
  scale: 0.6;
  pointer-events: none;
  transition: opacity 0.2s ease, scale 0.35s var(--pop), background-color 0.15s ease;
}
.check svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 0.12s ease; }
html.selecting .check { opacity: 1; scale: 1; }
.card.sel .check { background: var(--accent); box-shadow: 0 2px 8px rgb(var(--accent-rgb) / 0.45); }
.card.sel .check svg { opacity: 1; }
.card.sel .lift {
  box-shadow:
    0 0 0 3px var(--accent),
    inset 0 1px 0.5px var(--lip),
    0 26px 34px -26px rgb(var(--shadow-rgb) / 0.55);
}
html.selecting .card { cursor: default; }

/* the bar of actions for the chosen songs: grows from the middle like the player, just above it */
.selbar {
  --r: 26px;
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 21;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  height: 52px;
  padding: 0 7px 0 20px;
  border-radius: var(--r);
  translate: -50% 0;
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.24), transparent 58%), var(--glass-dense);
  -webkit-backdrop-filter: blur(3px) saturate(1.6);
  backdrop-filter: blur(3px) saturate(1.6);
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -10px 16px -14px var(--edge-shade),
    0 18px 36px -20px rgb(var(--shadow-rgb) / 0.5);
  user-select: none;
  -webkit-user-select: none;
  scale: 0.32 1;
  opacity: 0;
  pointer-events: none;
  transition: scale 0.32s var(--quart), opacity 0.2s ease, bottom 0.32s var(--quart);
}
.selbar > * { transition: opacity 0.2s ease 0.12s; }
html:not(.selecting) .selbar > * { opacity: 0; transition-delay: 0s; }
html.selecting .selbar { scale: 1; opacity: 1; pointer-events: auto; }
body:has(.player.in) .selbar { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 72px + 12px); }
.sel-count { margin-right: 8px; font: 600 14px/1 var(--font); white-space: nowrap; font-variant-numeric: tabular-nums; }
.selbar button {
  height: 38px;
  padding: 0 14px;
  border-radius: 19px;
  font: 600 14px/1 var(--font);
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.16s ease, background-color 0.16s ease, scale 0.35s var(--pop), opacity 0.2s ease;
}
.selbar button:hover { color: var(--ink); background: rgb(var(--ink-rgb) / 0.06); }
.selbar button:active { scale: 1.06; }
.selbar button:disabled { opacity: 0.35; pointer-events: none; }
.selbar .sel-main { color: var(--base); background: var(--ink); }
.selbar .sel-main:hover { color: var(--base); background: var(--ink); }
.selbar .sel-warn { color: var(--accent); }
.selbar .sel-danger { color: var(--accent); }
/* armed: the first click asks, the second deletes (within 3 s) */
.selbar .sel-danger[data-armed], .selbar .sel-danger[data-armed]:hover { color: #fff; background: var(--accent); }
.selbar .short { display: none; }
.selbar [hidden] { display: none; }
.lists .selbtn { margin-inline-start: auto; padding: 0 15px; }
.lists .selbtn[aria-pressed="true"] { color: var(--ink); }

/* a cover on its way into a playlist */
.flyer {
  position: fixed;
  z-index: 40;
  margin: 0;
  object-fit: cover;
  pointer-events: none;
  box-shadow: 0 12px 28px -10px rgb(var(--shadow-rgb) / 0.55);
  will-change: transform, opacity;
}

/* A result while it downloads is live, so it inverts like the playing card; a bar along
   the bottom fills with the download. */
.card.busy .lift {
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.1), transparent 42%), var(--on);
  color: var(--on-ink);
}
.card.busy .alt, .card.busy .meta { color: color-mix(in srgb, var(--on-ink) 75%, transparent); }
.prog {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 6px;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: color-mix(in srgb, var(--on-ink) 22%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.prog::before {
  content: "";
  display: block;
  width: var(--pct, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--bar);
  transition: width 0.6s var(--quart);
}
.card.busy .prog { opacity: 1; }
/* waiting, starting and converting have no percentage: the bar breathes */
.card.indef .prog::before { width: 100%; animation: breathe 1.1s ease-in-out infinite alternate; }
@keyframes breathe { from { opacity: 0.35; } to { opacity: 1; } }
.st { flex: none; margin-inline-start: auto; font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; }
.card.got .st { color: rgb(var(--card-ink-rgb)); font-weight: 700; }

.note { margin: 0; padding: 36px 0; color: var(--muted); }

/* Player: floating glass capsule. It opens from the middle the first time a song is
   chosen (0.32 s quart), like the dynamic island. */
.player {
  --r: 30px;
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto minmax(0, 1.25fr) 132px;
  grid-template-areas: "art meta ctl seek vol";
  align-items: center;
  gap: 18px;
  width: min(100% - 2 * var(--pad), 1040px);
  height: 72px;
  padding: 9px 22px 9px 9px;
  translate: -50% 0;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  transition: scale 0.32s var(--quart), opacity 0.2s ease, color 0.3s ease;
}
/* the surface is its own layer, so it can reshape (FLIP) without stretching the controls */
.player .p-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--glass-dense);
  background-image: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.24), transparent 58%);
  transition: background-color 0.2s ease, border-radius 0.35s ease;
}
.player:not(.in) { scale: 0.32 1; opacity: 0; pointer-events: none; }
.player > :not(.p-bg) { transition: opacity 0.2s ease 0.14s; }
.player:not(.in) > :not(.p-bg) { opacity: 0; transition-delay: 0s; }
.p-art, .p-meta { cursor: pointer; }
/* text and surface change colour at the same pace, so the bar never shows mint on mint */
.p-meta b, .p-meta span, .t, .round, .vol-btn { transition: color 0.2s ease, scale 0.35s var(--pop), background-color 0.2s ease; }

/* Now playing: the bar narrows under the big card, its cover and title move right with it,
   and the seek and volume drop to a second row below the buttons. Inverted like the card, and
   a piece of its own: round on every corner, a small gap above it, so nothing hard meets. */
.player.np {
  left: calc(var(--np-cx) - var(--np-w) / 2);
  bottom: var(--np-bottom);
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-rows: 48px 30px;
  grid-template-areas: "art meta ctl" "seek seek vol";
  gap: 10px 16px;
  width: var(--np-w);
  height: var(--np-bar-h);
  padding: 14px 20px 14px 14px;
  translate: none;
}
.player.np .p-bg {
  background-color: var(--base);
  background-image: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.1), transparent 50%);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -10px 16px -14px rgb(0 0 0 / 0.5),
    0 30px 50px -28px rgb(var(--shadow-rgb) / 0.6);
}
.player.np .p-art { width: 48px; height: 48px; border-radius: 18px; }
.player.np .p-vol { display: flex; }
.player.np .round:not(.big) { background: rgb(var(--ink-rgb) / 0.08); box-shadow: none; }

.p-art {
  grid-area: art;
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 21px;
  object-fit: cover;
  background: var(--well);
}
.p-art[src=""], .p-art:not([src]) { visibility: hidden; }
.p-meta { grid-area: meta; display: flex; flex-direction: column; min-width: 0; }
/* both lines start at the left, whatever their script, so they read as one block */
.p-meta b, .p-meta span { overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.p-meta b { font: 700 16px/1.4 var(--font-title); }
.p-meta span { font: 500 13px/1.4 var(--font); color: var(--muted); }
.p-ctl { grid-area: ctl; display: flex; align-items: center; gap: 8px; }
.round.big {
  width: 48px;
  height: 48px;
  color: var(--base);
  background: var(--ink);
  box-shadow: inset 0 1px 0.5px rgb(var(--sheen-rgb) / 0.4), inset 0 -8px 12px -8px rgb(0 0 0 / 0.4), 0 6px 14px -8px rgb(var(--shadow-rgb) / 0.6);
}
.round.big:hover { color: var(--base); }
.round.big svg { width: 20px; height: 20px; }
.round.big .i-pause, .player.playing .round.big .i-play { display: none; }
.player.playing .round.big .i-pause { display: block; }

.p-seek { grid-area: seek; display: flex; align-items: center; gap: 10px; min-width: 0; }
.t { flex: none; min-width: 2.8em; font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.t:last-child { text-align: right; }
.p-vol { grid-area: vol; display: flex; align-items: center; gap: 6px; }
.vol-btn { display: grid; place-items: center; flex: none; width: 28px; height: 28px; color: var(--muted); }
.vol-btn:hover { color: var(--ink); }
.vol-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.vol-btn .mute, .vol-btn[aria-pressed="true"] .wave { display: none; }
.vol-btn[aria-pressed="true"] .mute { display: inline; }

/* Range: a well, filled up to --p in raspberry, with a small white bead as the knob */
.range {
  --p: 0%;
  flex: 1;
  min-width: 0;
  height: 22px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.range:focus-visible { outline-offset: 2px; }
.range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--track) var(--p));
}
.range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
.range::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.range::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4px;
  border: 0;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 4px rgb(var(--shadow-rgb) / 0.35), inset 0 -2px 3px rgb(var(--shadow-rgb) / 0.12);
  transition: scale 0.25s var(--pop);
  -webkit-appearance: none;
  appearance: none;
}
.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 4px rgb(var(--shadow-rgb) / 0.35);
}
.range:active::-webkit-slider-thumb { scale: 1.25; }

/* ---- now playing ---------------------------------------------------------------------------
   The page re-lays itself out (html.np) and every piece moves to its new place (app.js, FLIP):
   the dock slides up and away, the title goes to the top with the numbers beside it, the songs
   move to a column on the right that scrolls, and the playing card lands in the middle of what
   is left, right on top of the bar: cover on the right, title on the left and bigger. */

html.np main {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--np-side);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "hero hero" "lists songs" ". songs";
  column-gap: var(--np-gap);
  width: auto;
  max-width: none;
  margin: 0;
  padding: 22px var(--pad) 0;
}
html.np .hero { grid-area: hero; align-items: center; margin-bottom: 14px; padding-right: 56px; /* the theme button stays top right */ }
html.np h1 { font-size: clamp(44px, 6.4vw, 92px); }
/* the numbers sit on the theme button's line: the dock's middle, 12 + 54 / 2 = 39 px from the top,
   which is main's 22 px padding + half a 34 px capsule */
html.np .stats { flex-direction: row; align-self: start; gap: 8px; min-width: 0; }
html.np .cap { --r: 17px; height: 34px; padding: 0 14px; grid-template-columns: auto auto; gap: 10px; }
html.np .lists { grid-area: lists; align-self: start; margin: 0; }
html.np .note { display: none; }
/* the other songs: a column on the right that scrolls, fading at its edges */
html.np #field, html.np #results {
  grid-area: songs;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  align-content: start;
  gap: 26px 16px;
  min-height: 0;
  /* the column's clipping edge sits on the screen edge, not beside the playing box, so cards
     sliding in are never cut by an invisible wall */
  margin: 0 calc(-1 * var(--pad)) 0 -10px;
  padding: 14px var(--pad) 40px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(transparent, #000 18px, #000 calc(100% - 40px), transparent);
  mask-image: linear-gradient(transparent, #000 18px, #000 calc(100% - 40px), transparent);
}
html.np .name { font-size: 16px; }

.stage { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.stage[hidden] { display: none; }
/* The big card: its own surface layer (.fs-bg), the words on the left, the cover on the right.
   Each of the three flies separately from the grid card it came from. */
.fs-card {
  --r: 30px;              /* the bar's radius: two pieces of one set */
  position: fixed;
  left: calc(var(--np-cx) - var(--np-w) / 2);
  bottom: calc(var(--np-bottom) + var(--np-bar-h) + var(--np-split));
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--np-art);
  column-gap: 20px;
  width: var(--np-w);
  height: calc(var(--np-art) + 28px);
  padding: 14px 14px 14px 24px;
  pointer-events: auto;
}
.fs-card:focus { outline: none; }
.fs-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--r);
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.12), transparent 40%), var(--base);
  box-shadow:
    inset 0 1px 0.5px var(--lip),
    inset 0 -10px 16px -14px rgb(0 0 0 / 0.45),
    0 24px 50px -30px rgb(var(--shadow-rgb) / 0.5);
}
.fs-text { position: relative; z-index: 1; /* over the cover while both travel */ display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: 4px 0 6px; }
.fs-tools { display: flex; gap: 8px; }
.fs-tools .round { background: rgb(var(--ink-rgb) / 0.08); box-shadow: none; }
.fs-words { display: flex; flex-direction: column; min-width: 0; transition: opacity 0.16s ease; }
.fs-name {
  display: -webkit-box;
  overflow: hidden;
  font: 700 clamp(30px, 3.6vw, 52px)/1.15 var(--font-title);
  letter-spacing: -0.02em;
  text-align: left;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.fs-name:dir(rtl) { letter-spacing: 0; line-height: 1.35; }
.fs-alt { margin-top: 6px; overflow: hidden; font: 500 15px/1.4 var(--font); color: var(--muted); text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.fs-art {
  display: block;
  width: var(--np-art);
  height: var(--np-art);
  border-radius: 24px;
  object-fit: cover;
  background: var(--well);
  transition: opacity 0.16s ease;
}
.fs-art.swap, .fs-words.swap { opacity: 0; }
#fsAdd[aria-expanded="true"] { color: var(--ink); background: rgb(var(--ink-rgb) / 0.16); }

/* Add to playlist: a glass sheet above the + button */
.pop {
  --r: 22px;
  position: fixed;
  z-index: 34;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(280px, calc(100vw - 32px));
  max-height: min(420px, 60svh);
  padding: 6px;
  background-color: var(--glass-dense);
  pointer-events: auto;
}
.pop[hidden] { display: none; }
.pop-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.pop-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 16px;
  text-align: start;
  font: 600 14px/1.3 var(--font);
}
.pop-item:hover { background: rgb(var(--ink-rgb) / 0.06); }
.pop-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-item i { font: 500 12px/1 var(--mono); font-style: normal; color: var(--muted); }
.pop-item svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.pop-item[aria-pressed="true"] svg { opacity: 1; }
.pop-new {
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 16px;
  outline: none;
  background: var(--well);
  color: var(--ink);
  font: 500 14px var(--font);
}
.pop-new::placeholder { color: var(--faint); }
.pop-new:focus-visible { box-shadow: 0 0 0 2px var(--ink); }

/* ---- playlists row (Library) ---------------------------------------------------------------
   All, then each playlist; a glass bead glides to the one shown. */
.lists {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 30px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  user-select: none;
  -webkit-user-select: none;
}
.lists::-webkit-scrollbar { display: none; }
.lists[hidden] { display: none; }
.lists button {
  position: relative;
  z-index: 1;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 15px;
  border-radius: 18px;
  font: 600 14px/1 var(--font);
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s ease;
}
.lists button:hover, .lists button[aria-pressed="true"] { color: var(--ink); }
.lists button i { font: 500 12px/1 var(--mono); font-style: normal; color: var(--faint); }
.lists .icon { width: 36px; padding: 0; justify-content: center; }
.lists svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lists .danger[data-armed] { color: #fff; background: var(--accent); }
.lists input {
  flex: none;
  width: 180px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 18px;
  outline: none;
  background: var(--well);
  color: var(--ink);
  font: 600 14px var(--font);
  box-shadow: 0 0 0 2px var(--ink);
}
.lbead {
  position: absolute;
  top: 4px;
  left: 0;
  width: 0;
  height: 36px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgb(var(--sheen-rgb) / 0.4), transparent 70%), var(--glass);
  box-shadow: inset 0 1px 0.5px var(--lip), inset 0 -6px 10px -8px var(--edge-shade), 0 3px 8px -4px rgb(var(--shadow-rgb) / 0.35);
  transition: translate 0.32s var(--quart), width 0.32s var(--quart);
}
.lbead.jump { transition: none; }
.card.lifted { visibility: hidden; }
html.moving .glass, html.moving .dock::before, html.moving .p-bg { -webkit-backdrop-filter: none; backdrop-filter: none; }
.ghost { position: fixed; z-index: 26; margin: 0; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.np .card.lifted { display: none; } /* "the rest of the songs": the playing one is the big card */

.toast {
  position: fixed;
  left: 50%;
  top: 80px;
  z-index: 40;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 12px 20px;
  border-radius: 22px;
  translate: -50% 0;
  background: var(--accent);
  color: #fff;
  font: 600 14px/1.3 var(--font);
  text-align: center;
}

/* Touch: no hover tilt; the system buttons set the volume (iOS ignores the page's). */
@media (hover: none) {
  .p-vol, .player.np .p-vol { display: none; }
  .player { grid-template-columns: 54px minmax(0, 1fr) auto minmax(0, 1.25fr); grid-template-areas: "art meta ctl seek"; }
  .player.np { grid-template-areas: "art meta ctl" "seek seek seek"; }
}

@media (max-width: 900px) {
  .player {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    grid-template-areas: "art meta ctl" "seek seek seek";
    gap: 6px 12px;
    height: 92px;
    padding: 8px 12px 6px 8px;
  }
  .p-art { width: 48px; height: 48px; border-radius: 18px; }
  .p-vol, #shuffle, #repeat { display: none; }
  body:has(.player.in) .selbar { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 92px + 12px); }
  .p-seek { padding: 0 4px; }
  main { padding-bottom: 220px; }
}

@media (max-width: 720px) {
  .dock { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; padding: 0 8px; }
  .host { display: none; }
  .modes button { padding: 0 11px; }
  .selbar { padding: 0 5px 0 14px; gap: 2px; }
  .selbar button { padding: 0 10px; font-size: 13px; }
  .sel-count { margin-right: 4px; font-size: 13px; }
  .selbar .long { display: none; }
  .selbar .short { display: inline; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .stats { flex-direction: row; flex-wrap: wrap; min-width: 0; gap: 6px; }
  .cap { --r: 17px; height: 34px; padding: 0 14px; grid-template-columns: auto auto; gap: 10px; }
  .cap b { font-size: 14px; }
  .field { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 14px; }
  .lift { padding: 8px 8px 11px; border-radius: 24px; }
  .art { border-radius: 17px; }
  .name { font-size: 17px; }
  .p-ctl { gap: 4px; }
  .p-ctl .round:not(.big) { background: none; box-shadow: none; }
}

@media (max-width: 820px) {
  /* now playing on a phone: title and numbers on top, the other songs in a row that scrolls
     sideways, the card and the bar together at the bottom */
  html.np main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "hero" "lists" "songs";
    padding-bottom: calc(var(--np-bottom) + var(--np-bar-h) + var(--np-split) + var(--np-art) + 40px);
  }
  html.np .hero { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  html.np #field, html.np #results {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 132px;
    align-content: center;
    margin: 0 calc(-1 * var(--pad));
    padding: 10px var(--pad) 18px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--pad), #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 var(--pad), #000 calc(100% - 40px), transparent);
  }
  .fs-card { padding: 12px 12px 12px 18px; column-gap: 14px; }
  .fs-name { font-size: 26px; }
  .fs-alt { font-size: 13px; }
}

/* Squircles: the same radius reads smaller as a superellipse, so the radii grow. Last in
   the file so it wins over the rules above. */
@supports (corner-shape: squircle) {
  .glass, .dock, .dock::before, .lift, .art, .find, .p-art, .cap, .toast, .fs-bg, .fs-art, .pop, .pop-item, .pop-new, .lists button { corner-shape: squircle; }
  .fs-art { border-radius: 34px; }
  .lift { border-radius: 40px; }
  .art { border-radius: 30px; }
  .player, .fs-card { --r: 40px; }
  .p-art { border-radius: 26px; }
  @media (max-width: 720px) {
    .lift { border-radius: 32px; }
    .art { border-radius: 23px; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; translate: 0 var(--o, 0px); }
  .lift, .player, .player > *, .find, .round, body, .mbead, .lbead, .dock::before, .dock > *, .strings, .selbar, .selbar > *, .check { transition: none; }
  .card.indef .prog::before { animation: none; }
}
