/* ==========================================================================
   Papers, as Audio — mobile-first player
   Palette: deep charcoal-navy surfaces + a single coral accent.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg:        #0d1017;
  --bg-grad:   radial-gradient(1200px 700px at 50% -10%, #1a2131 0%, #0d1017 55%);
  --surface:   #171c26;
  --surface-2: #1f2531;
  --line:      rgba(255,255,255,.08);
  --line-2:    rgba(255,255,255,.16);
  --text:      #ecf0f6;
  --muted:     #93a0b5;
  --faint:     #66738b;

  --accent:      #ff3d68;
  --accent-2:    #ff7a97;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(255,61,104,.16);
  --ok:          #45d483;

  --shadow:   0 20px 55px rgba(0,0,0,.55);
  --shadow-s: 0 6px 20px rgba(0,0,0,.35);

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 24px;

  --top-h: 128px;
  --mini-h: 66px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.22,.61,.36,1);
  --dur: .34s;
}

/* light theme — system preference (unless dark is pinned) or manual */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg:        #f4f6fa;
    --bg-grad:   radial-gradient(1000px 600px at 50% -15%, #ffffff 0%, #eef1f7 60%);
    --surface:   #ffffff;
    --surface-2: #e9edf5;
    --line:      rgba(15,22,36,.09);
    --line-2:    rgba(15,22,36,.18);
    --text:      #111722;
    --muted:     #5c6880;
    --faint:     #8b95a9;
    --accent:      #e01b4b;
    --accent-2:    #ff5c80;
    --accent-soft: rgba(224,27,75,.12);
    --shadow:   0 18px 45px rgba(16,22,34,.16);
    --shadow-s: 0 4px 16px rgba(16,22,34,.10);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f4f6fa;
  --bg-grad:   radial-gradient(1000px 600px at 50% -15%, #ffffff 0%, #eef1f7 60%);
  --surface:   #ffffff;
  --surface-2: #e9edf5;
  --line:      rgba(15,22,36,.09);
  --line-2:    rgba(15,22,36,.18);
  --text:      #111722;
  --muted:     #5c6880;
  --faint:     #8b95a9;
  --accent:      #e01b4b;
  --accent-2:    #ff5c80;
  --accent-soft: rgba(224,27,75,.12);
  --shadow:   0 18px 45px rgba(16,22,34,.16);
  --shadow-s: 0 4px 16px rgba(16,22,34,.10);
}

/* ── base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font: 400 16px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: clip;            /* belt and braces: never scroll sideways */
  padding-left: var(--sal);
  padding-right: var(--sar);
}
body.no-scroll { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.015em; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
svg.sprite { display: none; }
/* must beat the display values set on .btn-install, .search-clear, .mini … */
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: currentColor; display: block; flex: none; }
.hidden { display: none !important; }

::selection { background: var(--accent-soft); }

/* ── top bar ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--sat) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-row, .searchrow, .library, .foot { max-width: 720px; margin-inline: auto; }
.topbar-row { display: flex; align-items: center; gap: 12px; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark { border-radius: 9px; flex: none; box-shadow: var(--shadow-s); }
.brand-text { min-width: 0; }
.brand h1 {
  font-size: 17px; line-height: 1.15; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.brand h1 em { font-style: normal; color: var(--accent); }
.brand-sub {
  font-size: 11.5px; color: var(--faint); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--muted);
  transition: background .16s, color .16s, transform .12s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.lg { width: 44px; height: 44px; color: var(--text); }
.icon-btn.txt { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.icon-btn.txt small { font-size: 12px; }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }

.btn-install {
  display: flex; align-items: center; gap: 5px;
  height: 36px; padding: 0 12px 0 9px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 650; letter-spacing: -.01em;
  box-shadow: 0 4px 14px var(--accent-soft);
}
.btn-install .ic { width: 16px; height: 16px; }
.btn-install:active { transform: scale(.95); }

.pill {
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
  padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line-2);
  color: var(--muted);
}
.pill-warn { color: #ffb15c; border-color: rgba(255,177,92,.4); background: rgba(255,177,92,.1); }

/* search */
.searchrow { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  height: 42px; padding: 0 10px 0 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--faint);
  transition: border-color .16s, background .16s;
}
.search:focus-within { border-color: var(--accent); background: var(--surface-2); }
.search .ic { width: 18px; height: 18px; }
.search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  font-size: 15px; color: var(--text);
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--faint); }
.search-clear .ic { width: 14px; height: 14px; }

.btn-quiet {
  flex: none; height: 42px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: color .16s, border-color .16s;
}
.btn-quiet:hover { color: var(--text); border-color: var(--line-2); }
.btn-quiet:active { transform: scale(.96); }
.btn-quiet[disabled] { opacity: .45; pointer-events: none; }

/* ── library ────────────────────────────────────────────────────────────── */
.library {
  padding: 14px 16px calc(var(--mini-h) + var(--sab) + 28px);
}

/* continue listening */
.continue {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 13px;
  padding: 13px; margin-bottom: 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
  text-align: left; width: 100%;
}
.continue::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, var(--accent-soft), transparent 58%);
  pointer-events: none;
}
.continue-art {
  width: 62px; height: 62px; border-radius: 14px; object-fit: cover; flex: none;
  background: var(--surface-2);
}
.continue-main { flex: 1; min-width: 0; position: relative; z-index: 1; }
.continue-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent);
}
.continue-title {
  font-size: 15px; font-weight: 650; line-height: 1.25; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.continue-sub {
  font-size: 12px; color: var(--muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.continue-play {
  width: 48px; height: 48px; border-radius: 50%; flex: none; position: relative; z-index: 1;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 18px var(--accent-soft);
}
.continue-play .ic { width: 24px; height: 24px; margin-left: 2px; }
.continue-play:active { transform: scale(.93); }

/* group headings */
.group-head {
  position: sticky; top: var(--top-h); z-index: 20;
  display: flex; align-items: baseline; gap: 8px;
  margin: 22px -16px 6px; padding: 8px 16px 7px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.group-head:first-child { margin-top: 0; }
.group-head b { color: var(--faint); font-weight: 600; letter-spacing: .04em; }

/* rows */
.row {
  position: relative; width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px 10px 10px; border-radius: var(--r);
  min-height: 68px;
  transition: background .16s;
}
.row + .row { margin-top: 2px; }
.row:hover { background: var(--surface); }
.row:active { background: var(--surface-2); }
.row.is-current { background: var(--accent-soft); }
.row.is-current .row-title { color: var(--accent); }

.row-art {
  position: relative; width: 50px; height: 50px; flex: none;
  border-radius: 12px; overflow: hidden; background: var(--surface-2);
}
.row-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.is-broken { visibility: hidden; }
.row-art .n {
  position: absolute; inset: auto 0 0 0; height: 18px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 14.5px; font-weight: 600; line-height: 1.28; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-sub {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 4px; font-size: 11.5px; color: var(--faint);
}
.row-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.row-sub .done { color: var(--ok); font-weight: 600; }
.row-sub .dl { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.row-sub .dl .ic { width: 11px; height: 11px; }
.bar {
  margin-top: 6px; height: 3px; border-radius: 99px;
  background: var(--line-2); overflow: hidden;
}
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.badge-new {
  flex: none; align-self: flex-start; margin-top: 3px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .09em;
  padding: 3px 6px; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink);
}
.row-end { flex: none; width: 34px; display: grid; place-items: center; color: var(--faint); }
.row-end .ic { width: 17px; height: 17px; }
.row-end.ok { color: var(--ok); }

/* skeletons */
.sk { display: flex; align-items: center; gap: 12px; padding: 10px; min-height: 68px; }
.sk-b { background: var(--surface); border-radius: 8px; animation: pulse 1.5s var(--ease) infinite; }
.sk-art { width: 50px; height: 50px; border-radius: 12px; flex: none; }
.sk-main { flex: 1; }
.sk-l1 { height: 12px; width: 76%; }
.sk-l2 { height: 9px; width: 36%; margin-top: 9px; }
@keyframes pulse { 0%,100% { opacity: .5 } 50% { opacity: 1 } }

.empty {
  text-align: center; padding: 56px 20px; color: var(--muted);
}
.empty b { display: block; font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty .btn-wide { margin-top: 18px; }

.foot {
  text-align: center; font-size: 11.5px; color: var(--faint); padding: 26px 16px 0;
}

/* ── mini player ────────────────────────────────────────────────────────── */
.mini {
  position: fixed; z-index: 50;
  left: calc(8px + var(--sal)); right: calc(8px + var(--sar));
  bottom: calc(8px + var(--sab));
  height: var(--mini-h);
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 8px;
  border-radius: 18px; overflow: hidden;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(170%) blur(22px);
  -webkit-backdrop-filter: saturate(170%) blur(22px);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  animation: miniIn .34s var(--ease);
}
@keyframes miniIn { from { transform: translateY(120%); opacity: 0 } }
.mini[hidden] { display: none; }
.mini-line {
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--line-2);
}
.mini-line i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.mini-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  text-align: left; height: 100%; padding: 0;
}
.mini-art { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.mini-meta { min-width: 0; display: block; }
.mini-title {
  display: block; font-size: 13.5px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-sub {
  display: block; font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-ctrl { display: flex; align-items: center; gap: 2px; flex: none; }

/* ── now playing sheet ──────────────────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 70;
  color-scheme: dark;
  --text: #f2f5fa; --muted: #b4bfd0; --faint: #8d98ab;
  --surface: rgba(255,255,255,.10); --surface-2: rgba(255,255,255,.16);
  --line: rgba(255,255,255,.12); --line-2: rgba(255,255,255,.22);
  color: var(--text);
  background: #0a0d13;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
  overflow: hidden;
  touch-action: none;
}
.sheet.is-open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.sheet.is-dragging { transition: none; }

.sheet-bg {
  position: absolute; inset: -12%;
  background-size: cover; background-position: center;
  filter: blur(34px) saturate(150%);
  transform: scale(1.12); opacity: .55;
}
.sheet-scrim {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(10,13,19,.15), rgba(10,13,19,.75) 62%),
    linear-gradient(180deg, rgba(10,13,19,.35) 0%, rgba(10,13,19,.88) 55%, #0a0d13 100%);
}
.sheet-body {
  position: relative; z-index: 1;
  height: 100%;
  display: flex; flex-direction: column;
  padding: calc(var(--sat) + 6px) 22px calc(var(--sab) + 18px);
}

.sheet-grab {
  display: flex; align-items: center; gap: 10px; flex: none;
  height: 48px; margin: 0 -6px;
  touch-action: none;
}
.sheet-eyebrow {
  flex: 1; text-align: center;
  font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted);
}
.sheet-badge {
  min-width: 40px; text-align: right; padding-right: 6px;
  font-size: 11.5px; font-weight: 700; color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.cover-wrap {
  flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center;
  padding: 8px 0 14px;
}
.cover {
  max-width: 100%; max-height: 100%;
  width: min(100%, 340px); aspect-ratio: 1; object-fit: cover;
  border-radius: 22px;
  background: rgba(255,255,255,.06);
  box-shadow: 0 26px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08) inset;
}

.np-meta { flex: none; margin-bottom: 16px; }
.np-series {
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.np-title {
  font-size: 21px; line-height: 1.22; letter-spacing: -.02em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* chapter bar (in-lecture section markers) */
.chapbar { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.chapbar[hidden] { display: none; }
.chip {
  flex: 1; min-width: 0; height: 34px; padding: 0 12px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; font-weight: 600;
}
.chip .ic { width: 14px; height: 14px; flex: none; opacity: .8; }
.chip-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:active, .chip-ic:active { transform: scale(.96); }
.chip-ic {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
}
.chip-ic .ic { width: 18px; height: 18px; }
.chip-ic[disabled] { opacity: .35; pointer-events: none; }

/* chapter list panel — slides over the sheet */
.chaplist {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column;
  background: rgba(12,15,22,.9);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  padding: calc(var(--sat) + 8px) 12px calc(var(--sab) + 12px);
  transform: translateY(100%); visibility: hidden;
  transition: transform .3s var(--ease), visibility 0s linear .3s;
}
.chaplist.is-open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.chaplist-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 0 4px 10px 12px; border-bottom: 1px solid var(--line);
}
.chaplist-head h3 { flex: 1; font-size: 15px; }
.chaplist-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y;
  padding: 8px 0 4px;
}
.chap {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 9px 12px; border-radius: 12px;
  color: var(--text); font-size: 14px; line-height: 1.3;
}
.chap:hover { background: var(--surface); }
.chap-n { flex: none; width: 22px; font-size: 11.5px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.chap-t { flex: 1; min-width: 0; }
.chap-s { flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chap.is-on { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.chap.is-on .chap-n, .chap.is-on .chap-s { color: var(--accent-2); }
.chap.is-past { color: var(--muted); }

/* scrubber */
.scrub-wrap { flex: none; }
.scrub-rail { position: relative; }
.ticks {
  position: absolute; left: 8px; right: 8px; top: 50%;
  transform: translateY(-50%); height: 6px; pointer-events: none;
}
.ticks i {
  position: absolute; top: 0; width: 2px; height: 6px; margin-left: -1px;
  background: rgba(8,11,17,.6); border-radius: 1px;
}
.scrub {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 30px;
  background: transparent; outline: none; margin: 0;
  touch-action: none; cursor: pointer;
}
.scrub::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(90deg,
    var(--accent) 0 calc(var(--p, 0) * 1%),
    rgba(255,255,255,.22) calc(var(--p, 0) * 1%) 100%);
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%; margin-top: -4.5px;
  background: #fff; border: 0;
  box-shadow: 0 0 0 5px rgba(255,61,104,.22), 0 2px 8px rgba(0,0,0,.5);
  transition: transform .14s var(--ease);
}
.scrub:active::-webkit-slider-thumb, .scrub.is-scrubbing::-webkit-slider-thumb { transform: scale(1.35); }
.scrub::-moz-range-track { height: 6px; border-radius: 99px; background: rgba(255,255,255,.22); }
.scrub::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
.scrub::-moz-range-thumb {
  width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 5px rgba(255,61,104,.22);
}
.times {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  margin-top: -2px;
}
.times .t-total { color: var(--faint); font-size: 11px; }

/* transport */
.transport {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  margin: 18px 0 20px;
}
.tr {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  transition: transform .12s var(--ease), background .16s, opacity .16s;
}
.tr .ic { width: 26px; height: 26px; }
.tr:active { transform: scale(.9); background: var(--surface); }
.tr[disabled] { opacity: .3; pointer-events: none; }
.tr.play {
  width: 70px; height: 70px;
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 30px rgba(255,61,104,.38);
}
.tr.play .ic { width: 32px; height: 32px; }
.tr.play:active { background: var(--accent); transform: scale(.94); }

/* tools */
.tools {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 2px 6px; border-radius: 14px; min-height: 58px;
  color: var(--muted); transition: color .16s, background .16s;
}
.tool:hover { background: var(--surface); }
.tool:active { transform: scale(.95); }
.tool[disabled] { opacity: .35; pointer-events: none; }
.tool.is-on { color: var(--accent-2); }
.tool-ic {
  position: relative; width: 26px; height: 26px;
  display: grid; place-items: center;
}
.tool-rate { font-size: 14.5px; font-weight: 700; letter-spacing: -.02em; }
.tool-l {
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ring {
  position: absolute; inset: -6px; width: 38px; height: 38px;
  transform: rotate(-90deg); opacity: 0; transition: opacity .2s;
}
.ring circle { fill: none; stroke-width: 2.6; }
.ring-bg { stroke: rgba(255,255,255,.16); }
.ring-fg {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 97.39; stroke-dashoffset: 97.39;
  transition: stroke-dashoffset .2s linear;
}
.tool.is-busy .ring { opacity: 1; }
.tool.is-busy .ring-fg { stroke-dashoffset: calc(97.39 - 97.39 * var(--dl, 0)); }
.tool.is-done { color: var(--ok); }

/* ── transcript reader ──────────────────────────────────────────────────── */
.reader {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg); background-image: var(--bg-grad);
  display: flex; flex-direction: column;
  transform: translateY(100%); visibility: hidden;
  transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.reader.is-open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.reader-top {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--sat) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.reader-head { flex: 1; min-width: 0; }
.reader-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.reader-head h2 {
  font-size: 14px; line-height: 1.25; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader-tools { display: flex; gap: 2px; flex: none; }
.reader-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px 20px calc(var(--mini-h) + var(--sab) + 40px);
  font-size: var(--reader-font, 17px); line-height: 1.68;
  max-width: 720px; width: 100%; margin-inline: auto;
  color: var(--text);
}
.reader-body > *:first-child { margin-top: 0; }
.reader-body h1 { font-size: 1.55em; line-height: 1.22; margin: 1.4em 0 .5em; letter-spacing: -.02em; }
.reader-body h2 { font-size: 1.28em; line-height: 1.28; margin: 1.5em 0 .45em; letter-spacing: -.015em; }
.reader-body h3 { font-size: 1.1em; margin: 1.3em 0 .4em; color: var(--accent); }
.reader-body p { margin: 0 0 1.05em; }
.reader-body ul, .reader-body ol { margin: 0 0 1.05em; padding-left: 1.3em; }
.reader-body li { margin-bottom: .4em; }
.reader-body a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.reader-body blockquote {
  margin: 1.2em 0; padding: 2px 0 2px 16px;
  border-left: 3px solid var(--accent); color: var(--muted);
}
.reader-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
  background: var(--surface); padding: .15em .4em; border-radius: 6px;
}
.reader-body pre {
  background: var(--surface); border: 1px solid var(--line);
  padding: 14px; border-radius: var(--r); overflow-x: auto; font-size: .82em; line-height: 1.5;
}
.reader-body pre code { background: none; padding: 0; }
.reader-body img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.reader-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.reader-body table { width: 100%; border-collapse: collapse; font-size: .9em; margin-bottom: 1.05em; display: block; overflow-x: auto; }
.reader-body th, .reader-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.reader-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.reader-note { color: var(--muted); text-align: center; padding: 40px 10px; }

/* ── picker / modal ─────────────────────────────────────────────────────── */
.picker {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(5,7,11,.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .22s var(--ease), visibility 0s linear .22s;
}
.picker.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.picker-card {
  width: 100%; max-width: 520px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px 18px calc(var(--sab) + 18px);
  box-shadow: var(--shadow);
  transform: translateY(14px);
  transition: transform .26s var(--ease);
  max-height: 86vh; overflow-y: auto;
}
.picker.is-open .picker-card { transform: translateY(0); }
.picker-card h3 { font-size: 15px; margin-bottom: 14px; }
.picker-opts { display: flex; flex-direction: column; gap: 2px; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; min-height: 46px; padding: 10px 12px;
  border-radius: 12px; font-size: 15px; color: var(--text);
  transition: background .14s;
}
.opt:hover { background: var(--surface-2); }
.opt.is-on { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.opt .ic { width: 18px; height: 18px; }
.btn-wide {
  width: 100%; height: 46px; margin-top: 14px; border-radius: 13px;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 15px;
}
.btn-wide:active { transform: scale(.98); }

.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.keys li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); padding: 5px 0; }
.keys li span { margin-left: auto; text-align: right; }
kbd {
  font: 600 11.5px/1 "Inter", system-ui, sans-serif;
  padding: 5px 7px; border-radius: 7px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2);
}

/* ── toasts ─────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; z-index: 120;
  left: 12px; right: 12px; bottom: calc(var(--mini-h) + var(--sab) + 18px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  max-width: 460px; width: fit-content;
  padding: 11px 14px; border-radius: 13px;
  background: #1c222e; color: #eef1f7; border: 1px solid rgba(255,255,255,.12);
  box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.35;
  pointer-events: auto;
  animation: toastIn .26s var(--ease);
}
.toast.is-out { animation: toastOut .22s var(--ease) forwards; }
.toast b { color: var(--accent-2); font-weight: 650; }
.toast button {
  flex: none; color: var(--accent-2); font-weight: 650; font-size: 13.5px;
  padding: 2px 4px;
}
@keyframes toastIn { from { transform: translateY(14px); opacity: 0 } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0 } }

/* ── desktop ────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  .brand h1 { font-size: 19px; }
  .library { padding-top: 22px; }
  .mini {
    left: 50%; right: auto; transform: translateX(-50%);
    width: min(720px, calc(100vw - 48px));
    bottom: calc(18px + var(--sab));
    border-radius: 20px;
  }
  @keyframes miniIn { from { transform: translateX(-50%) translateY(120%); opacity: 0 } }
  .sheet {
    inset: auto 24px 24px auto;
    top: 24px; width: min(430px, 42vw);
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: var(--shadow);
    transform: translateY(calc(100% + 32px));
  }
  .sheet-body { padding: 14px 24px 22px; }
  .cover { width: min(100%, 300px); }
  .reader { inset: 0; }
  .reader-body { padding-top: 34px; font-size: calc(var(--reader-font, 17px) + 1px); }
  .picker { align-items: center; }
  .picker-card { border-radius: var(--r-lg); padding-bottom: 18px; margin: 20px; }
  .toasts { bottom: 24px; }
  .row { padding-right: 10px; }
  .hide-phone { display: grid; }
}
@media (max-width: 899px) {
  .hide-phone { display: none; }
}
/* phones: the install button becomes a coral "+" so the title keeps its room */
@media (max-width: 460px) {
  .btn-install span { display: none; }
  .btn-install { width: 36px; padding: 0; justify-content: center; }
  .btn-install .ic { width: 18px; height: 18px; }
}
@media (max-width: 380px) {
  .np-title { font-size: 19px; }
  .tr.play { width: 64px; height: 64px; }
  .searchrow .btn-quiet { padding: 0 11px; }
}

/* short phones: shrink the artwork rather than clipping the transport */
@media (max-height: 700px) {
  .cover { width: min(100%, 210px); }
  .np-title { font-size: 19px; }
  .transport { margin: 12px 0 14px; }
}

/* ── motion ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* keyboard focus only */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
:focus:not(:focus-visible) { outline: none; }
