/* Folio: audiobook player. Colours come from the book's look tokens (spec 6A.1), cross-faded by lighting.js. */

@property --bg      { syntax: '<color>'; inherits: true; initial-value: #0f1113; }
@property --surface { syntax: '<color>'; inherits: true; initial-value: #181b1f; }
@property --ink     { syntax: '<color>'; inherits: true; initial-value: #ecedee; }
@property --muted   { syntax: '<color>'; inherits: true; initial-value: #a0a5aa; }
@property --accent  { syntax: '<color>'; inherits: true; initial-value: #e0a871; }
@property --glow    { syntax: '<color>'; inherits: true; initial-value: #dd8c3c; }

:root {
  --lt: .6s;
  transition: --bg var(--lt) ease, --surface var(--lt) ease, --ink var(--lt) ease,
              --muted var(--lt) ease, --accent var(--lt) ease, --glow var(--lt) ease;
  --raised: color-mix(in srgb, var(--surface) 88%, var(--ink));
  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --hover: color-mix(in srgb, var(--ink) 7%, transparent);
  --on-accent: color-mix(in srgb, var(--bg) 92%, #000);
  --r: 14px;
  --gutter: 16px;
  --player-h: 128px;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --read: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", Georgia, serif;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; --on-accent: #fff; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }

/* ---------- atmosphere layers: under the content, never over controls ---------- */
#texture, #light, #vignette { position: fixed; inset: 0; pointer-events: none; }
#texture { z-index: 0; opacity: 0; mix-blend-mode: soft-light; transition: opacity 1.2s ease; }
#light {
  z-index: 0; opacity: 0; transition: opacity 1.5s ease;
  background: radial-gradient(60vmax 50vmax at 22% 8%, color-mix(in srgb, var(--glow) 16%, transparent), transparent 70%);
}
#light.drift { animation: drift 140s ease-in-out infinite alternate; }
#light.paused { animation-play-state: paused; }
@keyframes drift { from { background-position: 0 0; transform: translate3d(0,0,0); } to { transform: translate3d(14vw, 6vh, 0); } }
#vignette { z-index: 1; }
#vignette .v { position: absolute; inset: 0; opacity: 0; transition: opacity 1.5s ease; }
#vignette.pulse { animation: breathe var(--pulse-dur, 1.2s) ease-in-out infinite alternate; }
@keyframes breathe { from { opacity: 1; } to { opacity: var(--pulse-depth, .85); } }

#app { position: relative; z-index: 2; min-height: 100vh; padding-bottom: calc(var(--player-h) + 24px); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; }
.brand-mark rect { fill: var(--accent); } .brand-mark path { fill: var(--bg); }
.brand-mark { width: 26px; height: 26px; }
.crumbs { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.crumbs a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { opacity: .5; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: var(--raised); color: var(--muted); white-space: nowrap;
}
.pill.accent { background: color-mix(in srgb, var(--accent) 20%, var(--surface)); color: var(--ink); }
.pill.demo { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--ink); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--hover); }
.icon-btn:disabled { opacity: .5; pointer-events: none; }
.chip-btn {
  height: 32px; min-width: 48px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600;
}
.chip-btn:hover { background: var(--raised); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--raised); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn svg { width: 20px; height: 20px; }

/* ---------- views ---------- */
#view { outline: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px var(--gutter) 0; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.section-title { font-size: 20px; font-weight: 700; margin: 32px 0 14px; }
.muted { color: var(--muted); }
.greeting { font-size: clamp(26px, 5vw, 36px); font-weight: 750; letter-spacing: -.01em; }

/* covers: hand-made art from the API when a book has it (.has-img), else generated from the book's palette */
.cover {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 90% at 18% 0%, color-mix(in srgb, var(--c-glow) 70%, transparent), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--c-accent) 35%, transparent), transparent 65%),
    linear-gradient(160deg, var(--c-surface), var(--c-bg));
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.55), inset 0 0 0 1px rgba(255,255,255,.06);
  color: var(--c-ink);
}
.cover::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .55; mix-blend-mode: soft-light;
  background-image: var(--c-tex, none); background-size: 180px;
}
.cover-art { position: absolute; inset: 0; padding: 12% 11%; display: flex; flex-direction: column; justify-content: flex-end; }
.cover-title { font-family: var(--read); font-size: clamp(15px, 2.2vw, 22px); font-weight: 600; line-height: 1.12; text-wrap: balance; }
.cover-author { margin-top: 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .78; }
.cover-rule { width: 28%; height: 2px; background: var(--c-accent); margin-bottom: 12px; border-radius: 2px; }
.cover-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .45s ease;
}
.cover-img.loaded { opacity: 1; }
/* With art: the generated card becomes a veil over the picture (::after = palette glow, ::before = texture).
   On hover/focus the veil expands outward and thins, and the title drifts down, both to 50%, never lower. */
.cover.has-img::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 18% 0%, color-mix(in srgb, var(--c-glow) 70%, transparent), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, color-mix(in srgb, var(--c-accent) 35%, transparent), transparent 65%),
    linear-gradient(160deg, var(--c-surface), var(--c-bg));
  opacity: .92; transform-origin: 50% 55%;
  /* thinner through the middle, where the palette's colour is weakest, so the art reads through */
  -webkit-mask-image: radial-gradient(75% 70% at 55% 50%, rgba(0,0,0,.58), #000 95%);
  mask-image: radial-gradient(75% 70% at 55% 50%, rgba(0,0,0,.58), #000 95%);
  transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1);
}
.cover.has-img::before { z-index: 2; transition: opacity .6s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.cover.has-img .cover-art { z-index: 3; transition: opacity .5s ease, transform .6s cubic-bezier(.2,.7,.2,1); }
.cover.has-img .cover-img { transition: opacity .45s ease, transform .9s cubic-bezier(.2,.7,.2,1); }
@media (hover: hover) {
  .card:hover .cover.has-img::after, .hero .cover.has-img:hover::after { opacity: .5; transform: scale(1.22); }
  .card:hover .cover.has-img::before, .hero .cover.has-img:hover::before { opacity: .28; transform: scale(1.22); }
  .card:hover .cover.has-img .cover-art, .hero .cover.has-img:hover .cover-art { opacity: .5; transform: translateY(8px); }
  .card:hover .cover.has-img .cover-img.loaded, .hero .cover.has-img:hover .cover-img.loaded { transform: scale(1.03); }
}
.card:focus-visible .cover.has-img::after { opacity: .5; transform: scale(1.22); }
.card:focus-visible .cover.has-img::before { opacity: .28; transform: scale(1.22); }
.card:focus-visible .cover.has-img .cover-art { opacity: .5; transform: translateY(8px); }
/* Small covers carry no title, so the art itself is the identity: always shown, under a 50% veil. */
.cover-xs.has-img::after, .resume-card .cover.has-img::after, .reader-head .cover.has-img::after { opacity: .5; }
.cover-xs.has-img::before, .resume-card .cover.has-img::before, .reader-head .cover.has-img::before { opacity: .28; }
@media (prefers-reduced-motion: reduce) { .cover.has-img::after, .cover.has-img::before, .cover.has-img .cover-art, .cover.has-img .cover-img { transform: none !important; } }
.cover-xs { width: 48px; height: 48px; border-radius: 8px; flex: none; }
.cover-xs .cover-art { display: none; }
.cover-xl .cover-title { font-size: clamp(22px, 4vw, 34px); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 22px 18px; }
.card { display: block; padding: 10px; margin: -10px; border-radius: var(--r); transition: background .2s; }
@media (hover: hover) { .card:hover { background: var(--hover); } }
.card .meta { margin-top: 10px; }
.card .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .pill { margin-top: 6px; }

.shelf { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.resume-card { display: flex; gap: 12px; align-items: center; padding: 8px; padding-right: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.resume-card:hover { background: var(--raised); }
.resume-card .cover { width: 64px; flex: none; }
.resume-card .cover-art { display: none; }
.resume-card .t { font-weight: 650; }
.resume-card .s { font-size: 13px; color: var(--muted); }
.bar { height: 3px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------- book page ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 240px) 1fr; gap: 28px; align-items: end; padding-top: 12px; position: relative; isolation: isolate; }
/* the cover's own colours bleed softly behind the hero, Spotify-style */
.hero-glow {
  position: absolute; z-index: -1; left: -10%; top: -40%; width: 70%; height: 160%; pointer-events: none;
  background: var(--glow-img) center / cover no-repeat; filter: blur(70px) saturate(1.3); opacity: .38;
  mask-image: radial-gradient(closest-side, #000 30%, transparent);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent);
}
:root[data-theme="light"] .hero-glow { opacity: .28; }
@media (prefers-reduced-transparency: reduce) { .hero-glow { display: none; } }
.hero h1 { font-size: clamp(30px, 6vw, 54px); font-weight: 800; letter-spacing: -.02em; margin: 6px 0 8px; text-wrap: balance; }
.hero .by { font-size: 15px; }
.hero .stats { color: var(--muted); font-size: 14px; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.big-play {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--accent); color: var(--on-accent);
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform .15s;
}
.big-play:hover { transform: scale(1.04); }
.big-play svg { width: 28px; height: 28px; }
.synopsis { max-width: 68ch; color: var(--muted); font-size: 14px; margin-top: 18px; }
.cast { display: flex; flex-wrap: wrap; gap: 8px; }
.cast .member { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }

.tracks { list-style: none; margin: 0; padding: 0; }
.track {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  min-height: 60px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
@media (hover: hover) { .track:hover { background: var(--hover); } }
.track .num { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.track .ti { font-weight: 600; }
.track .sub { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.track .dur { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.track.playing .ti, .track.playing .num { color: var(--accent); }
.track.later .ti { color: color-mix(in srgb, var(--ink) 78%, var(--muted)); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .5; display: inline-block; }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: var(--accent); border-radius: 1px; animation: eq 1s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.4s; } .eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { from { height: 30%; } to { height: 100%; } }
.paused .eq i { animation-play-state: paused; }

/* ---------- reader ---------- */
.reader { max-width: 760px; margin: 0 auto; padding: 20px var(--gutter) 40px; }
.reader-head { display: flex; gap: 16px; align-items: center; margin-bottom: 26px; }
.reader-head .cover { width: 72px; flex: none; }
.reader-head .cover-art { display: none; }
.reader-head h1 { font-size: clamp(22px, 4vw, 30px); font-weight: 750; letter-spacing: -.01em; }
.reader-head .badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.reader-tools { margin-left: auto; display: flex; gap: 4px; }

.transcript { font-family: var(--read); font-size: clamp(18px, 2.4vw, 20px); line-height: 1.75; }
.para { margin: 0 0 1.1em; content-visibility: auto; contain-intrinsic-size: auto 5em; }
.ln { border-radius: 4px; cursor: pointer; transition: background-color .35s ease, color .35s ease; box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: 1px 0; }
@media (hover: hover) { .ln:hover { background: var(--hover); } }
.ln.dlg { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c) 75%, transparent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.ln.now { background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent); }
.ln.past { color: color-mix(in srgb, var(--ink) 80%, var(--muted)); }
.who {
  font-family: var(--ui); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--c); margin-right: 6px; vertical-align: 2px; white-space: nowrap;
}
.who.unsure::after { content: "?"; }
.head { font-family: var(--ui); font-weight: 750; letter-spacing: -.01em; margin: 1.6em 0 .8em; display: block; }
.head.lvl-0 { font-size: 1.5em; } .head.lvl-1 { font-size: 1.3em; } .head.lvl-2 { font-size: 1.15em; color: var(--muted); }
.style-letter, .style-poem { display: block; border-left: 3px solid var(--line); padding-left: 1em; font-style: italic; white-space: pre-line; }
.cue-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; margin: 0 4px; vertical-align: 3px;
  border-radius: 999px; font: 600 11px/1 var(--ui); color: var(--muted); background: var(--raised); user-select: none;
}
.cue-chip svg { width: 12px; height: 12px; }
.cue-chip.fired { color: var(--ink); background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.hide-cues .cue-chip { display: none; }
.jump-back {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 18px); z-index: 6;
  box-shadow: 0 10px 28px -12px rgba(0,0,0,.6);
}
.chapter-end { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-family: var(--ui); }

.notice {
  font-family: var(--ui); border-radius: var(--r); padding: 18px 20px; margin-bottom: 28px;
  background: var(--surface); border: 1px solid var(--line);
}
.notice h2 { font-size: 17px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.notice p { margin: 6px 0; color: var(--muted); font-size: 14px; }
.notice .actions { margin-top: 14px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 12vh var(--gutter); max-width: 520px; margin: 0 auto; }
.empty h1 { font-size: 26px; margin-bottom: 10px; }
.empty p { color: var(--muted); }
.empty .actions { justify-content: center; }

/* ---------- player bar ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px var(--gutter) max(10px, env(safe-area-inset-bottom));
  box-shadow: 0 -18px 40px -24px rgba(0,0,0,.6);
}
.scrub { display: flex; align-items: center; gap: 10px; }
.time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 40px; }
.time:last-child { text-align: right; }
.wave-wrap { position: relative; flex: 1; min-width: 0; }
#wave { display: block; width: 100%; height: 40px; cursor: pointer; touch-action: none; }
.scrub-tip {
  position: absolute; bottom: calc(100% + 6px); transform: translateX(-50%); pointer-events: none;
  background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; font-size: 12px; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis;
}
.player-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 4px; }
.np { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-text { min-width: 0; }
.np-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport { display: flex; align-items: center; gap: 4px; }
.play-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; margin: 0 6px;
  display: grid; place-items: center; background: var(--ink); color: var(--surface); transition: transform .12s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 26px; height: 26px; }
.player-side { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.buffering { position: absolute; left: 0; right: 0; top: -2px; height: 2px; overflow: hidden; }
.buffering span { display: block; width: 30%; height: 100%; background: var(--accent); animation: load 1.1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* ---------- sheets: mixer popover and prompt dialog ---------- */
.sheet {
  border: 1px solid var(--line); border-radius: 18px; padding: 20px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.7);
  width: min(380px, calc(100vw - 32px));
}
#mixer { position: fixed; inset: auto var(--gutter) calc(var(--player-h) + 10px) auto; margin: 0; max-height: calc(100vh - var(--player-h) - 80px); overflow: auto; }
.modal::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
#mixer::backdrop { background: transparent; }
.sheet h2 { font-size: 17px; margin-bottom: 4px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.sheet .group { padding: 12px 0; border-top: 1px solid var(--line); }
.sheet .group:first-of-type { border-top: 0; }
.sheet .glabel { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.slider-row { display: grid; grid-template-columns: 84px 1fr 42px; align-items: center; gap: 10px; min-height: 40px; }
.slider-row label { font-weight: 600; font-size: 14px; }
.slider-row output { text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slider-row.off label, .slider-row.off output { opacity: .45; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
.seg { display: flex; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.seg button { flex: 1; height: 34px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch-row .l { font-weight: 600; font-size: 14px; }
.switch-row .d { font-size: 12px; color: var(--muted); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal { margin: auto; }
.modal .actions { justify-content: flex-end; margin-top: 18px; }
.choice { display: grid; gap: 10px; margin-top: 14px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--player-h) + 22px); z-index: 20;
  background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 14px; box-shadow: 0 16px 40px -16px rgba(0,0,0,.6); max-width: calc(100vw - 32px);
}
body:not(.has-player) .toast, body:not(.has-player) .jump-back { bottom: 24px; }
body:not(.has-player) #app { padding-bottom: 32px; }

/* ---------- small screens: one column, one-handed ---------- */
@media (max-width: 720px) {
  :root { --player-h: 150px; }
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .hero .cover { max-width: 220px; width: 62vw; margin: 0 auto; }
  .hero-text { text-align: center; }
  .hero .actions { justify-content: center; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .player-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
  .np .cover-xs { width: 40px; height: 40px; }
  .hide-sm { display: none; }
  .transport .icon-btn { width: 44px; }
  .play-btn { width: 50px; height: 50px; }
  .np-sub { font-size: 12px; }
  .crumbs { display: none; }
  .reader-tools .btn-label { display: none; }
  #mixer { inset: auto 8px calc(var(--player-h) + 8px) 8px; width: auto; }
  .player-row .transport { gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01s !important; }
  :root { transition-duration: .4s !important; }
  #vignette .v { transition-duration: .4s !important; }
}
@media (prefers-contrast: more) {
  #vignette, #texture, #light { display: none; }
  .ln.past { color: var(--ink); }
}

/* ---------- locked screen (spec 7.0): one quiet field ---------- */
body.locked .topbar-actions, body.locked .player { display: none !important; }
.lock { min-height: calc(100vh - 140px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px var(--gutter); }
.lock-mark { width: 52px; height: 52px; margin-bottom: 10px; }
.lock-label { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lock-input {
  width: min(340px, 100%); height: 52px; padding: 0 18px; border-radius: 14px; text-align: center; font-size: 18px; letter-spacing: .08em;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.lock-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.lock-go { width: min(340px, 100%); }
.lock-msg { min-height: 1.5em; margin: 0; color: var(--muted); font-size: 14px; }
