/* Reader v2. Apple Books + Apple Music: SF Pro for the interface, New York (ui-serif) for the book.
   Library and sheets follow the system appearance; the reader follows its own theme (Original, Quiet,
   Paper, Night). Themes change colours only, never layout, so switching never re-paginates. */

:root {
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --ui-d: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Charter, Georgia, serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --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);

  /* system UI, light */
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --cell: #ffffff;
  --label: #000000;
  --label2: #6e6e73;
  --label3: #aeaeb2;
  --sep: rgba(60, 60, 67, .2);
  --fill: rgba(120, 120, 128, .16);
  --fill2: rgba(118, 118, 128, .1);
  --tint: #bd520e;
  --on-tint: #ffffff;
  --danger: #d70015;
  --green: #34c759;
  --nav-mat: rgba(250, 250, 250, .8);
  --pop: rgba(252, 252, 252, .9);
  --seg-on: #ffffff;
  --sheet-bg: #f2f2f7;
  --cover-shadow: 0 1px 1.5px rgba(0, 0, 0, .14), 0 8px 18px -8px rgba(0, 0, 0, .32);
}
html[data-ui="dark"] {
  --bg: #000000;
  --bg-grouped: #000000;
  --cell: #1c1c1e;
  --label: #ffffff;
  --label2: #98989d;
  --label3: #5a5a5f;
  --sep: rgba(84, 84, 88, .55);
  --fill: rgba(118, 118, 128, .3);
  --fill2: rgba(118, 118, 128, .2);
  --tint: #ff9f0a;
  --on-tint: #000000;
  --danger: #ff453a;
  --green: #30d158;
  --nav-mat: rgba(22, 22, 24, .78);
  --pop: rgba(44, 44, 46, .9);
  --seg-on: #636366;
  --sheet-bg: #1c1c1e;
  --cover-shadow: 0 1px 1.5px rgba(0, 0, 0, .5), 0 8px 20px -8px rgba(0, 0, 0, .7);
}
html[data-ui="dark"] .sheet .group, html[data-ui="dark"] .sheet .aa-size { --cell: #2c2c2e; }

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background: var(--bg);
  color-scheme: light dark;
}
body {
  margin: 0;
  min-height: 100dvh;
  font: 17px/1.3 var(--ui);
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
:where(button, label.btn-fill) {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
:where(button):disabled { opacity: .4; cursor: default; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 8px; }
input, textarea, select { font-size: 17px; }
svg[data-icon] {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
svg[data-icon] .f { fill: currentColor; stroke: none; }
svg[data-icon] text.t { font: 700 7px var(--ui); fill: currentColor; stroke: none; letter-spacing: -.02em; }
/* press feedback on pointer-down (the `scale` property composes with any positioning transform) */
.press { transition: scale 140ms var(--ease), opacity 140ms var(--ease); }
.press:active { scale: .96; opacity: .62; transition-duration: 60ms; }
#probe {
  position: fixed; top: 0; left: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ---------------------------------------------------------------- library */
#library { min-height: 100dvh; padding-bottom: calc(48px + var(--sab)); }
#library.under { visibility: hidden; }
.nav { position: fixed; z-index: 5; top: 0; left: 0; right: 0; padding-top: var(--sat); }  /* below the reader (10) */
.nav::before {
  content: ""; position: absolute; inset: 0;
  background: var(--nav-mat);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 .5px 0 var(--sep);
  opacity: 0; transition: opacity 220ms var(--ease);
}
.nav.solid::before { opacity: 1; }
.nav-in {
  position: relative; height: 52px; max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 max(8px, var(--sar)) 0 max(16px, var(--sal));
}
.nav-title {
  position: absolute; left: 50%; top: 50%;
  font: 600 17px/1 var(--ui); white-space: nowrap;
  opacity: 0; transform: translate(-50%, -30%); transition: opacity 200ms var(--ease), transform 220ms var(--ease);
  pointer-events: none;
}
.nav.solid .nav-title { opacity: 1; transform: translate(-50%, -50%); }
.nav-actions { display: flex; gap: 2px; }
.nbtn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--tint); border-radius: 22px; }
.nbtn svg { width: 25px; height: 25px; stroke-width: 1.7; }
#b-add svg { stroke-width: 2.2; }

.lib-body {
  max-width: 1240px; margin: 0 auto;
  padding: calc(var(--sat) + 52px) max(20px, var(--sar)) 0 max(20px, var(--sal));
}
.large-title { font: 700 34px/41px var(--ui-d); letter-spacing: .011em; margin: 0 0 18px; }
#lib-title-end { height: 1px; margin-top: -19px; margin-bottom: 18px; }

/* Continue card */
#continue { margin: 0 0 34px; }
.cont {
  display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 18px; align-items: end;
  padding: 16px; border-radius: 18px; background: var(--fill2);
}
.cont-cover { display: block; width: 100%; }
.cont-body { display: flex; flex-direction: column; min-width: 0; padding-bottom: 2px; }
.cont-eyebrow { font: 600 13px/18px var(--ui); color: var(--tint); }
.cont-title {
  font: 700 21px/25px var(--ui-d); letter-spacing: .01em; margin: 2px 0 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cont-sub { font: 400 15px/20px var(--ui); color: var(--label2); margin: 0 0 10px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; margin-bottom: 14px; }
.bar i { display: block; height: 100%; background: var(--tint); transform-origin: 0 50%; border-radius: 2px; }
.btn-fill {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 22px; border-radius: 23px;
  background: var(--tint); color: var(--on-tint); font: 600 17px/1 var(--ui);
  align-self: flex-start;
}
.btn-fill svg { width: 17px; height: 17px; }
.btn-fill.wide { width: 100%; height: 50px; border-radius: 14px; margin-top: 14px; }
.btn-fill.busy { opacity: .6; pointer-events: none; }

/* Grid */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; }
.sec-head h2 { font: 700 22px/28px var(--ui-d); letter-spacing: .01em; margin: 0; }
#shelf-count { font: 400 15px var(--ui); color: var(--label2); }
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 22px; align-items: end;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 800px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 30px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cell { min-width: 0; }
.cell-cover { display: block; width: 100%; }
.cell-meta { display: flex; align-items: center; justify-content: space-between; height: 40px; margin-top: 4px; }
.cell-pct { font: 400 13px var(--ui); color: var(--label2); font-variant-numeric: tabular-nums; }
.cell-more { width: 44px; height: 44px; margin-right: -12px; display: grid; place-items: center; color: var(--label2); }
.cell-more svg { width: 22px; height: 22px; }

/* Covers: real (EPUB) or generated (title-hash colour, serif title) */
.cover {
  position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: 4px; overflow: hidden;
  background: var(--fill); box-shadow: var(--cover-shadow);
  container-type: inline-size; isolation: isolate;
}
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover::before {  /* spine and page edge light, like a real cover */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .2) 0, rgba(255, 255, 255, .16) 1.6%, rgba(255, 255, 255, 0) 4.5%, rgba(0, 0, 0, .05) 6%, rgba(0, 0, 0, 0) 9%);
}
.cover::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: inherit; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .14); pointer-events: none; }
.cover.gen {
  color: #fff;
  background:
    radial-gradient(120% 70% at 85% 0%, hsl(var(--h) 40% 46% / .55), transparent 60%),
    linear-gradient(165deg, hsl(var(--h) 32% 34%), hsl(calc(var(--h) + 24) 36% 19%));
}
.gen-in { position: absolute; inset: 10% 10% 9% 12%; display: flex; flex-direction: column; justify-content: space-between; align-items: center; text-align: center; }
.gen-t {
  font: 600 13.2cqw/1.08 var(--serif); letter-spacing: -.005em; overflow-wrap: anywhere; hyphens: auto;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}
.gen-a { font: 600 6.4cqw/1.25 var(--ui); letter-spacing: .1em; text-transform: uppercase; opacity: .82; }
.gen-a::before { content: ""; display: block; width: 18cqw; height: 1px; background: currentColor; opacity: .55; margin: 0 auto 4.5cqw; }

.empty { text-align: center; padding: 14vh 24px 0; color: var(--label2); }
.empty svg { width: 54px; height: 54px; stroke-width: 1.4; color: var(--label3); }
.empty-title { font: 600 20px/25px var(--ui-d); color: var(--label); margin: 12px 0 6px; }
.empty-sub { font: 400 15px/21px var(--ui); max-width: 320px; margin: 0 auto; }
.drop-hint {
  position: fixed; inset: 12px; z-index: 25; border-radius: 22px; border: 2px dashed var(--tint);
  background: color-mix(in srgb, var(--bg) 82%, transparent); display: grid; place-items: center;
  font: 600 20px var(--ui-d); color: var(--tint); opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease);
}
body.drop-over .drop-hint { opacity: 1; }

/* ---------------------------------------------------------------- reader themes (colours only) */
#reader {
  --pg: #ffffff; --ink: #141414; --ink2: #6e6e73;
  --hl: rgba(255, 159, 10, .3); --sel: rgba(255, 159, 10, .28);
  --mat: rgba(250, 250, 250, .82); --mat-ink: #000000; --mat-ink2: #6e6e73; --mat-hair: rgba(0, 0, 0, .13);
  --tint: #bd520e; --on-tint: #ffffff; --fill: rgba(120, 120, 128, .18);
  --read-font: var(--serif); --read-size: 19px; --read-lh: 1.5;
}
#reader[data-theme="paper"] {
  --pg: #f4ecd8; --ink: #33291f; --ink2: #705f4a;
  --hl: rgba(214, 118, 18, .26); --sel: rgba(214, 118, 18, .24);
  --mat: rgba(240, 230, 206, .86); --mat-ink: #2a2118; --mat-ink2: #705f4a; --mat-hair: rgba(60, 40, 10, .16);
  --tint: #9c4a0c; --on-tint: #ffffff; --fill: rgba(112, 95, 74, .18);
}
#reader[data-theme="quiet"] {
  --pg: #48484a; --ink: #e5e5e7; --ink2: #c7c7cc;
  --hl: rgba(255, 159, 10, .36); --sel: rgba(255, 159, 10, .34);
  --mat: rgba(66, 66, 69, .86); --mat-ink: #f2f2f7; --mat-ink2: #c7c7cc; --mat-hair: rgba(255, 255, 255, .12);
  --tint: #ffb340; --on-tint: #000000; --fill: rgba(235, 235, 245, .18);
}
#reader[data-theme="night"] {
  --pg: #000000; --ink: #d0d0d5; --ink2: #98989d;
  --hl: rgba(255, 159, 10, .34); --sel: rgba(255, 159, 10, .32);
  --mat: rgba(30, 30, 32, .82); --mat-ink: #f2f2f7; --mat-ink2: #98989d; --mat-hair: rgba(255, 255, 255, .1);
  --tint: #ff9f0a; --on-tint: #000000; --fill: rgba(235, 235, 245, .16);
}

/* ---------------------------------------------------------------- reader: page */
#reader { position: fixed; inset: 0; z-index: 10; background: var(--pg); color: var(--ink); overflow: hidden; }
#reader.veiled { visibility: hidden; }
#pager {
  position: absolute; inset: 0; overflow: hidden; contain: strict;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: text; user-select: text;
}
.strip { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.win { position: absolute; top: 0; left: 0; width: var(--win-w, 300vw); height: 100%; overflow: hidden; overflow: clip; pointer-events: none; }
.track { pointer-events: auto; }
.track {
  position: absolute; left: 0; top: var(--pg-top, 64px);
  width: var(--pg-w, 100vw); height: var(--pg-h, 70vh);
  padding: 0 var(--pg-m, 24px);
  column-count: var(--pg-cols, 1); column-gap: calc(var(--pg-m, 24px) * 2); column-fill: auto;
  font-family: var(--read-font); font-size: var(--read-size); line-height: var(--read-lh);
  color: var(--ink);
  font-kerning: normal; font-variant-ligatures: common-ligatures; text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-nums proportional-nums;
  overflow-wrap: break-word; orphans: 2; widows: 2;
  hanging-punctuation: first;
  -webkit-touch-callout: default;
}
.track ::selection { background: var(--sel); }
.track p { margin: 0; }
.track .para { text-indent: 1.4em; }
.track .para.first, .track .para.h, .track .hd, .track .dropcap { text-indent: 0; }
.track .para.h { margin: 1.15em 0 .45em; font-weight: 600; break-after: avoid; }
.track .para.h.caps { font-size: .84em; letter-spacing: .07em; font-weight: 600; }
.ch-head { text-align: center; padding-top: var(--head-pad, 80px); margin-bottom: 2.1em; break-inside: avoid; }
.ch-head::after { content: ""; display: block; width: 2.4em; height: 1px; margin: 1.5em auto 0; background: var(--ink2); opacity: .45; }
.hd1 { font: 600 .72em/1.4 var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--ink2); margin-bottom: 1em; }
.hd1.num { font: 300 3.1em/1 var(--read-font); letter-spacing: 0; color: var(--ink); margin-bottom: .32em; font-variant-numeric: lining-nums; }
.hd1.solo { font-size: .9em; letter-spacing: .22em; color: var(--ink); margin-bottom: 0; }
.hd2 { font-size: 1.6em; line-height: 1.2; font-weight: 500; letter-spacing: -.004em; margin-bottom: .45em; text-wrap: balance; }
.hd2.caps { font-size: 1.08em; line-height: 1.45; letter-spacing: .11em; font-weight: 500; }
.hd3 { font-style: italic; color: var(--ink2); font-size: .95em; }
.dropcap .dc {
  float: left; font-size: 3.2em; line-height: .84; font-weight: 400;
  padding: .075em .045em 0 0; margin-left: -.02em; color: var(--ink);
}
.w.now {
  background: var(--hl); border-radius: .2em;
  box-shadow: 0 0 0 .12em var(--hl);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.end { height: 0; }

/* margins: chapter title + page number, quiet */
.margin-top {
  position: absolute; z-index: 2; left: 0; right: 0; top: var(--sat); height: 48px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 2px var(--pg-m, 24px) 0;
  font: 500 12px/1 var(--ui); letter-spacing: .02em; color: var(--ink2);
  font-variant-numeric: tabular-nums; pointer-events: none;
  transition: opacity 200ms var(--ease);
}
#m-ch { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#m-pg { flex: none; }
body.chrome .margin-top { opacity: 0; }

/* top bar (chrome) */
.topbar {
  position: absolute; z-index: 5; top: 0; left: 0; right: 0;
  height: calc(var(--sat) + 48px); padding: var(--sat) max(4px, var(--sar)) 0 max(4px, var(--sal));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--mat);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 .5px 0 var(--mat-hair);
  color: var(--mat-ink);
  transform: translate3d(0, -104%, 0); opacity: 0;
  transition: transform 240ms var(--ease), opacity 180ms var(--ease);
}
body.chrome .topbar { transform: none; opacity: 1; }
.tb-btn { height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--tint); border-radius: 22px; }
.tb-btn svg { width: 24px; height: 24px; stroke-width: 1.9; }
.tb-btn.back { padding: 0 10px 0 4px; gap: 1px; font: 400 17px/1 var(--ui); }
.tb-btn.back svg { width: 24px; height: 24px; stroke-width: 2.3; }
.tb-btn.aa span { font: 500 19px/1 var(--ui-d); letter-spacing: -.01em; }
.tb-title {
  position: absolute; left: 50%; top: calc(var(--sat) + 24px); transform: translate(-50%, -50%);
  max-width: calc(100% - 360px); font: 600 15px/1.2 var(--ui); color: var(--mat-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
@media (max-width: 640px) { .tb-title { display: none; } }
.tb-actions { display: flex; gap: 0; }

/* Back to voice */
.pill {
  position: absolute; z-index: 6; left: 50%;
  bottom: calc(max(var(--sab), 12px) + 82px);
  height: 44px; padding: 0 18px 0 13px; border-radius: 22px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 15px/1 var(--ui); color: var(--on-tint); background: var(--tint);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .45);
  transform: translate3d(-50%, 14px, 0); opacity: 0; visibility: hidden;
  transition: transform 240ms var(--ease), opacity 160ms var(--ease), visibility 0s linear 240ms;
}
.pill svg { width: 19px; height: 19px; stroke-width: 2.2; }
.pill.on { transform: translate3d(-50%, 0, 0); opacity: 1; visibility: visible; transition: transform 300ms var(--ease), opacity 180ms var(--ease), visibility 0s; }

/* mini player: a floating material capsule */
.mini {
  position: absolute; z-index: 6; left: 0; right: 0; margin: 0 auto;
  bottom: calc(max(var(--sab), 12px) + 8px);
  width: min(calc(100% - 24px), 460px); height: 60px; border-radius: 30px;
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 48px; align-items: center; column-gap: 12px;
  padding: 0 6px 0 16px;
  background: var(--mat);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35), 0 0 0 .5px var(--mat-hair);
  color: var(--mat-ink); cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: none;
  transition: scale 160ms var(--ease);
}
.mini:active { scale: .985; }
.mini-art { width: 32px; height: 48px; }
.mini-art .cover { height: 100%; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.mini-text { min-width: 0; }
.mini-t1 { font: 600 15px/19px var(--ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-t2 { font: 400 13px/17px var(--ui); color: var(--mat-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.mini-t2 button, .np-render button { color: var(--tint); font-weight: 600; }
.mini-play { width: 48px; height: 48px; border-radius: 24px; display: grid; place-items: center; color: var(--mat-ink); }
.mini-play svg { width: 28px; height: 28px; }
.mini-prog { position: absolute; left: 28px; right: 28px; bottom: 5px; height: 2px; border-radius: 1px; background: var(--fill); overflow: hidden; pointer-events: none; }
.mini-prog i { display: block; height: 100%; background: var(--mat-ink); opacity: .7; transform-origin: 0 50%; transform: scaleX(0); }
[data-play].buffering svg { animation: breathe 1.4s var(--ease) infinite; }
@keyframes breathe { 50% { opacity: .35; } }

/* ---------------------------------------------------------------- scrims, sheets */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .38); opacity: 0; touch-action: none; }
.scrim.light { background: rgba(0, 0, 0, .06); }
#np-scrim { z-index: 29; }
#scrim { z-index: 39; }
.grabber { display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--label3); margin: 0 auto; opacity: .7; }

.sheet {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; margin: 0 auto;
  width: min(100%, 620px);
  height: calc(100dvh - var(--sat) - 12px); max-height: 860px;
  display: flex; flex-direction: column;
  background: var(--sheet-bg); color: var(--label);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px -14px rgba(0, 0, 0, .35);
  transform: translate3d(0, 110%, 0);
}
.sheet.compact { height: auto; max-height: calc(100dvh - var(--sat) - 12px); }
.sheet-grip { flex: none; padding-top: 6px; touch-action: none; cursor: grab; }
.sheet-head { position: relative; height: 50px; display: flex; align-items: center; justify-content: center; padding: 0 56px; }
.sheet-head h2 { font: 600 17px/1.2 var(--ui); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-x { position: absolute; right: 6px; top: 3px; width: 44px; height: 44px; display: grid; place-items: center; }
.sheet-x svg { width: 30px; height: 30px; padding: 8px; border-radius: 15px; background: var(--fill); color: var(--label2); stroke-width: 2.4; }
.sheet-body {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 2px max(16px, var(--sar)) calc(28px + var(--sab)) max(16px, var(--sal));
}
.sheet.compact .sheet-body { flex: none; }

/* grouped lists (iOS settings style) */
.group-label { font: 400 13px/18px var(--ui); text-transform: uppercase; letter-spacing: .02em; color: var(--label2); margin: 22px 16px 7px; }
.group-label:first-child { margin-top: 8px; }
.group { background: var(--cell); border-radius: 12px; padding: 12px 16px; margin: 0 0 8px; }
.group.list { padding: 0; overflow: hidden; }
.lbl { display: block; font: 400 13px/18px var(--ui); color: var(--label2); margin: 14px 0 6px; }
.group > .lbl:first-child { margin-top: 2px; }
.rv { float: right; color: var(--label); font-variant-numeric: tabular-nums; }
.field {
  display: block; width: 100%; font: 400 17px/22px var(--ui); color: var(--label);
  background: var(--fill2); border: 0; border-radius: 10px; padding: 11px 12px; margin: 0;
  -webkit-appearance: none; appearance: none;
}
.field::placeholder { color: var(--label3); }
textarea.field { resize: vertical; min-height: 120px; line-height: 1.4; }
select.field {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.add-pane .field + .field, .add-pane .field { margin-bottom: 10px; }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fill); margin: 6px 0 10px; }
.seg button { flex: 1; min-height: 44px; border-radius: 8px; font: 500 15px/1.1 var(--ui); color: var(--label); padding: 0 6px; transition: background-color 160ms var(--ease); }
.seg button.on { background: var(--seg-on); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 44px; font: 400 17px/1.3 var(--ui); cursor: pointer; }
.switch input {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; margin: 0; cursor: pointer;
  width: 51px; height: 31px; border-radius: 16px; background: var(--fill); transition: background-color 200ms var(--ease);
}
.switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 3px 1px rgba(0, 0, 0, .06);
  transition: transform 220ms var(--ease);
}
.switch input:checked { background: var(--green); }
.switch input:checked::before { transform: translateX(20px); }
.note { font: 400 13px/18px var(--ui); color: var(--label2); margin: 8px 0 0; }
.note.warn { color: var(--danger); }
.note.center { text-align: center; margin: 12px 8px 0; }
.note code, .code { font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace; color: var(--label); word-break: break-all; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  font: 600 17px/1 var(--ui); color: var(--tint); background: var(--fill2);
}
.btn.small { min-height: 44px; font-size: 15px; padding: 0 14px; }
.btn.primary { background: var(--tint); color: var(--on-tint); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; margin-top: 16px; background: var(--cell); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rng { width: 100%; accent-color: var(--tint); margin: 4px 0; height: 28px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 20px 0 4px; }
.export-line { font: 400 13px/18px var(--ui); color: var(--label2); margin-top: 10px; }
.export-line a { color: var(--tint); font-weight: 600; }
.empty-title { font: 600 19px/24px var(--ui-d); margin: 4px 0; }
.row-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 16px; font: 400 17px var(--ui); text-align: left; }
.row-btn.danger { color: var(--danger); }
.row-btn svg { width: 22px; height: 22px; }

/* chapters */
.chap { display: flex; align-items: stretch; }
.chap + .chap { box-shadow: inset 0 .5px 0 var(--sep); }
.chap-t { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 11px 4px 12px 16px; text-align: left; }
.chap-name { font: 400 17px/22px var(--ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chap-meta { font: 400 13px/18px var(--ui); color: var(--label2); margin-top: 1px; }
.chap-meta b { color: var(--tint); font-weight: 600; }
.chap-bar { display: block; height: 3px; border-radius: 2px; background: var(--fill); overflow: hidden; margin-top: 7px; }
.chap-bar i { display: block; height: 100%; background: var(--label3); transform-origin: 0 50%; }
.chap.cur .chap-name { font-weight: 600; }
.chap.cur .chap-bar i { background: var(--tint); }
.chap > .icon-btn { align-self: center; margin-right: 6px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--label2); border-radius: 22px; }
.icon-btn svg { width: 21px; height: 21px; }

/* Aa */
.aa-size {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 52px; border-radius: 12px; background: var(--cell); margin: 4px 0 16px; overflow: hidden;
}
.aa-step { height: 52px; display: grid; place-items: center; font-family: var(--serif); color: var(--label); }
.aa-size-val { font: 500 13px/1 var(--ui); color: var(--label2); padding: 0 14px; font-variant-numeric: tabular-nums; min-width: 64px; text-align: center; box-shadow: inset .5px 0 0 var(--sep), inset -.5px 0 0 var(--sep); height: 28px; display: grid; place-items: center; }
.aa-themes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.aa-theme { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 4px 0; }
.sw {
  width: 100%; max-width: 78px; aspect-ratio: 1.3; border-radius: 14px; display: grid; place-items: center;
  font: 500 23px/1 var(--serif); box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .16);
  transition: box-shadow 160ms var(--ease);
}
.sw-original { background: #ffffff; color: #141414; }
.sw-quiet { background: #48484a; color: #e5e5e7; }
.sw-paper { background: #f4ecd8; color: #33291f; }
.sw-night { background: #000000; color: #d0d0d5; box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .22); }
.aa-theme.on .sw { box-shadow: 0 0 0 2.5px var(--sheet-bg), 0 0 0 4.5px var(--tint); }
.aa-tl { font: 400 13px/1 var(--ui); color: var(--label2); }
.aa-theme.on .aa-tl { color: var(--label); font-weight: 600; }
.group.slim { padding: 4px 16px; }
.switch small { display: block; font: 400 13px/17px var(--ui); color: var(--label2); margin-top: 1px; }
.font-strip { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; margin: 14px -16px 12px; padding: 0 16px; scroll-padding: 16px; touch-action: pan-x; }
.font-strip::-webkit-scrollbar { display: none; }
.font-pill { flex: none; height: 44px; padding: 0 16px; border-radius: 22px; background: var(--cell); color: var(--label); font-size: 17px; box-shadow: inset 0 0 0 .5px var(--sep); }
.font-pill.on { box-shadow: inset 0 0 0 2px var(--tint); }
#aa-spacing button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.lsp { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.font-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 50px; padding: 0 16px; font-size: 19px; color: var(--label); text-align: left; }
.font-row + .font-row { box-shadow: inset 0 .5px 0 var(--sep); }
.font-row svg { width: 20px; height: 20px; color: var(--tint); stroke-width: 2.4; visibility: hidden; }
.font-row.on svg { visibility: visible; }
#aa-spacing { margin-bottom: 4px; }

/* ---------------------------------------------------------------- Now Playing */
.np {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; margin: 0 auto;
  top: calc(var(--sat) + 10px); width: min(100%, 560px);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 0 max(24px, var(--sar)) calc(18px + var(--sab)) max(24px, var(--sal));
  background: var(--bg); color: var(--label);
  border-radius: 14px 14px 0 0; overflow: hidden;
  box-shadow: 0 -10px 40px -14px rgba(0, 0, 0, .4);
  touch-action: none; -webkit-user-select: none; user-select: none;
  transform: translate3d(0, 110%, 0);
}
.np-top { position: relative; flex: none; height: 44px; display: flex; align-items: center; justify-content: center; }
.np-top .grabber { position: absolute; top: 6px; left: 0; right: 0; }
.np-close { position: absolute; left: -10px; top: 0; width: 44px; height: 44px; display: grid; place-items: center; color: var(--label2); }
.np-close svg { width: 26px; height: 26px; stroke-width: 2.2; }
.np-art { flex: 1 1 auto; min-height: 120px; display: flex; align-items: center; justify-content: center; padding: 6px 0 18px; }
.np-art .cover { width: auto; height: 100%; max-height: 330px; max-width: 64vw; box-shadow: 0 2px 4px rgba(0, 0, 0, .14), 0 24px 44px -18px rgba(0, 0, 0, .5); border-radius: 6px; }
.np-meta { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.np-titles { min-width: 0; width: 100%; }
.np-ch { font: 700 22px/27px var(--ui-d); letter-spacing: .01em; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np-book { font: 400 17px/22px var(--ui); color: var(--label2); margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-mood { flex: none; min-height: 26px; display: inline-flex; align-items: center; gap: 6px; font: 600 12px/1 var(--ui); color: var(--label2); padding: 6px 10px; border-radius: 13px; background: var(--fill2); opacity: 0; transition: opacity 300ms var(--ease); text-transform: lowercase; }
.p-mood.on { opacity: 1; }
.p-mood .who { color: var(--label); text-transform: none; }
.p-mood .pips { display: inline-flex; gap: 2px; }
.p-mood .pips i { width: 4px; height: 4px; border-radius: 2px; background: var(--label3); }
.p-mood .pips i.f { background: var(--tint); }
body.no-marks .p-mood { display: none; }
.scrub { flex: none; padding: 10px 0 0; touch-action: none; cursor: pointer; }
.scrub-track { height: 7px; border-radius: 4px; background: var(--fill); overflow: hidden; transition: transform 200ms var(--ease); }
.scrub.active .scrub-track { transform: scaleY(1.6); }
.scrub-fill { display: block; height: 100%; background: var(--label); opacity: .62; transform-origin: 0 50%; transform: scaleX(0); }
.scrub-times { display: flex; justify-content: space-between; margin-top: 8px; font: 500 12px/1 var(--ui); color: var(--label2); font-variant-numeric: tabular-nums; min-height: 12px; }
.np-ctl { flex: none; display: flex; align-items: center; justify-content: space-between; margin: 22px -6px 20px; }
.ctl { width: 56px; height: 56px; display: grid; place-items: center; color: var(--label); border-radius: 28px; }
.ctl svg { width: 32px; height: 32px; }
.ctl#b-back15 svg, .ctl#b-fwd15 svg { width: 34px; height: 34px; stroke-width: 1.6; }
.ctl.big { width: 76px; height: 76px; }
.ctl.big svg { width: 50px; height: 50px; }
.np-row { flex: none; display: flex; justify-content: space-around; gap: 4px; }
.chip { min-width: 64px; height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 12px; color: var(--label2); font: 500 11px/1 var(--ui); }
.chip svg { width: 22px; height: 22px; }
.chip#b-speed span { font: 700 17px/22px var(--ui); color: var(--label2); }
.chip#b-speed::after { content: "Speed"; font: 500 11px/1 var(--ui); }
.chip.on { color: var(--tint); }
.np-render { flex: none; font: 400 12px/16px var(--ui); color: var(--label2); text-align: center; margin: 12px 0 0; min-height: 16px; }
.np-render.warn { color: var(--danger); }

/* menu (speed, sleep) */
.menu {
  position: fixed; z-index: 60; min-width: 210px; padding: 5px 0; border-radius: 14px;
  background: var(--pop); color: var(--label);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: 0 12px 40px -10px rgba(0, 0, 0, .38), 0 0 0 .5px var(--sep);
  transform: scale(.55); opacity: 0;
  transition: transform 260ms cubic-bezier(.25, 1.15, .4, 1), opacity 140ms var(--ease);
}
.menu.on { transform: none; opacity: 1; }
.mi { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 44px; padding: 0 16px; font: 400 17px/1 var(--ui); text-align: left; }
.mi + .mi { box-shadow: inset 0 .5px 0 var(--sep); }
.mi.on { font-weight: 600; }
.mi svg { width: 18px; height: 18px; stroke-width: 2.4; }

/* toast, zoom */
.toast {
  position: fixed; z-index: 70; left: 50%; top: calc(var(--sat) + 10px);
  max-width: min(calc(100vw - 32px), 440px); padding: 12px 18px; border-radius: 20px;
  background: var(--pop); color: var(--label);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .35), 0 0 0 .5px var(--sep);
  font: 500 15px/1.35 var(--ui); text-align: center;
  transform: translate3d(-50%, -10px, 0); opacity: 0;
  transition: transform 260ms var(--ease), opacity 200ms var(--ease);
  pointer-events: none;
}
.toast.on { transform: translate3d(-50%, 0, 0); opacity: 1; }
.zoom { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.zoom .zoom-cover { position: absolute; margin: 0; transform-origin: 0 0; border-radius: 4px; box-shadow: none; aspect-ratio: auto; visibility: visible !important; }

/* ---------------------------------------------------------------- desktop */
@media (min-width: 960px) {
  .margin-top { height: 64px; }
  .topbar { height: calc(var(--sat) + 56px); }
  .tb-title { top: calc(var(--sat) + 28px); }
  .mini { bottom: calc(max(var(--sab), 12px) + 20px); height: 64px; border-radius: 32px; }
  .pill { bottom: calc(max(var(--sab), 12px) + 100px); }
  .cont { grid-template-columns: 132px minmax(0, 1fr); max-width: 640px; padding: 20px; gap: 24px; }
  .large-title { margin-bottom: 22px; }
  .np { top: calc(var(--sat) + 40px); border-radius: 16px 16px 0 0; }
}
@media (hover: hover) and (pointer: fine) {
  .tb-btn:hover, .nbtn:hover, .icon-btn:hover, .ctl:hover, .chip:hover, .mini-play:hover, .sheet-x:hover, .np-close:hover { background: var(--fill2); }
  .mi:hover, .row-btn:hover, .font-row:hover, .chap-t:hover { background: var(--fill2); }
  .cell-cover:hover .cover { box-shadow: 0 1px 2px rgba(0, 0, 0, .16), 0 14px 26px -10px rgba(0, 0, 0, .38); }
}

/* ---------------------------------------------------------------- accessibility */
@media (prefers-reduced-motion: reduce) {
  .press, .press:active, .topbar, .pill, .menu, .toast, .nav::before, .nav-title, .mini { transition-duration: 1ms !important; }
  .menu { transform: none; }
  [data-play].buffering svg { animation: none; opacity: .5; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .mini, .menu, .toast, .nav::before { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .topbar, .mini { background: var(--pg); }
  .nav::before { background: var(--bg); }
  .menu, .toast { background: var(--cell); }
}
@media (prefers-contrast: more) {
  .topbar, .mini { box-shadow: 0 0 0 1px var(--ink2); }
}
