/* Colours. The accent (buttons, highlights, progress) is one hue, --hue, set
   from Settings; its lightness and chroma are tuned per theme so any hue reads
   on both backgrounds. Light theme by default, dark when the system is dark,
   unless Settings picks one (html[data-theme]). */
:root {
  --hue: 39;
  --bg: #f6f1e7;
  --surface: #fffaf1;
  --surface-2: #efe7d8;
  --ink: #23201b;
  --ink-2: #5d564b;
  --ink-3: #8a8173;
  --line: #e0d6c4;
  --accent: oklch(0.514 0.142 var(--hue));
  --accent-ink: #fff;
  --hl: oklch(0.859 0.079 calc(var(--hue) + 27));
  --hl-ink: oklch(0.202 0.029 calc(var(--hue) + 31));
  --para: oklch(0.514 0.142 var(--hue) / 0.07);
  --shadow: 0 -6px 24px rgba(60, 40, 10, 0.08);
  --sw-l: 0.514;
  --sw-c: 0.142;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ts: 1;                 /* text size scale, set from Settings */
  --player-total: calc(142px + env(safe-area-inset-bottom, 0px)); /* measured at runtime */
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171b;
    --surface: #1e1f24;
    --surface-2: #292a31;
    --ink: #ece7dd;
    --ink-2: #b5ad9f;
    --ink-3: #847d71;
    --line: #33343b;
    --accent: oklch(0.725 0.131 calc(var(--hue) + 7));
    --accent-ink: oklch(0.183 0.025 calc(var(--hue) + 12));
    --hl: oklch(0.432 0.096 calc(var(--hue) + 8));
    --hl-ink: oklch(0.971 0.02 calc(var(--hue) + 26));
    --para: oklch(0.725 0.131 calc(var(--hue) + 7) / 0.07);
    --shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
    --sw-l: 0.725;           /* accent lightness / chroma, for the colour swatches */
    --sw-c: 0.131;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #16171b;
    --surface: #1e1f24;
    --surface-2: #292a31;
    --ink: #ece7dd;
    --ink-2: #b5ad9f;
    --ink-3: #847d71;
    --line: #33343b;
    --accent: oklch(0.725 0.131 calc(var(--hue) + 7));
    --accent-ink: oklch(0.183 0.025 calc(var(--hue) + 12));
    --hl: oklch(0.432 0.096 calc(var(--hue) + 8));
    --hl-ink: oklch(0.971 0.02 calc(var(--hue) + 26));
    --para: oklch(0.725 0.131 calc(var(--hue) + 7) / 0.07);
    --shadow: 0 -6px 24px rgba(0, 0, 0, 0.35);
    --sw-l: 0.725;           /* accent lightness / chroma, for the colour swatches */
    --sw-c: 0.131;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: pan-x pan-y; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
/* Phones: one view at a time, and it scrolls the page itself, so iOS's
   tap-the-status-bar scroll-to-top works natively. Wide screens: list and text
   side by side, each scrolling in its own pane (media query below). */
#app { padding-bottom: var(--player-total); }
/* The bars at the top are fixed, not sticky: iOS drags a sticky bar down with the page when it bounces at the
   top, a fixed one stays put. The views leave room for them (heights measured in app.js). */
#list-view { padding-top: calc(env(safe-area-inset-top, 0px) + var(--list-bar-h, 63px)); min-width: 315px; }
#reader-view { padding-top: var(--reader-bar-h, 57px); }   /* narrower, the header buttons and chapter rows break up */
#app.show-list #reader-view,
#app.show-reader #list-view { display: none; }
/* keep text that scrolls up from showing under the status bar */
body::before {
  content: ""; position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px); background: var(--surface);      /* the headers' colour, behind the status bar */
}

/* the side-by-side layout: wide screens, unless set to a single pane */
@media (min-width: 960px) {
  :root:not(.single-pane), :root:not(.single-pane) body { height: 100%; overflow: hidden; }
  :root:not(.single-pane) body::before { content: none; }
  :root:not(.single-pane) #app {
    position: fixed;
    inset: 0 0 var(--player-total) 0;
    padding-bottom: 0;
    display: grid;
    grid-template-columns: var(--list-w, 400px) 1fr;   /* dragged with .list-resizer */
  }
  :root:not(.single-pane) #list-view, :root:not(.single-pane) #reader-view {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  :root:not(.single-pane) #app.show-list #reader-view, :root:not(.single-pane) #app.show-reader #list-view { display: block; }
  :root:not(.single-pane) #list-view { border-right: 1px solid var(--line); background: var(--surface); }
  :root:not(.single-pane) .list-bar, :root:not(.single-pane) .list-header, :root:not(.single-pane) .chapter-list { max-width: none; }
  :root:not(.single-pane) .back-btn { display: none; }
  :root:not(.single-pane) #reader-view .reader-top { padding-top: 8px; }   /* the pane already clears the status bar */
  :root:not(.single-pane) .list-bar, :root:not(.single-pane) .home-header, :root:not(.single-pane) .reader-top { position: sticky; left: auto; right: auto; }
}

/* ---------- home: the library ---------- */
/* One level above a book. html.at-home shows it and hides the book; the player
   stays (while something is loaded) so playback can be controlled from here. */
#home { display: none; padding: calc(env(safe-area-inset-top, 0px) + var(--home-bar-h, 57px)) 0 var(--player-total); }
html.at-home #home { display: block; }
html.at-home #app { display: none !important; }   /* also beats the wide layout's grid */
html.at-home.idle #player { display: none; }
.book-grid { max-width: 60rem; margin-left: auto; margin-right: auto; }
/* A phone turned to landscape has no room for the full player: back, play and forward become a small
   control in the middle of the header bar, on the library, the chapters and the text alike. */
@media (orientation: landscape) and (max-height: 500px) {
  html.idle .player { display: none; }
  html .player {
    top: env(safe-area-inset-top, 0px); bottom: auto; left: 0; right: 0; height: 64px; padding: 0;
    background: none; border: 0; box-shadow: none; display: flex; justify-content: center; align-items: center;
    pointer-events: none;
  }
  html .player .now-playing, html .player .speed, html .player .scrub { display: none; }
  html .player .controls { pointer-events: auto; gap: 6px; }
  html .player .controls .icon-btn.play, html .player .controls .icon-btn.skip { width: 44px; height: 44px; }
  html .player .controls .icon-btn.play svg { width: 24px; height: 24px; }
  html .player .controls .icon-btn.skip svg { width: 32px; height: 32px; }
  html .player .controls .icon-btn.skip span { font-size: 10.5px; }
  html.at-home .home-header { padding-top: 4px; padding-bottom: 4px; box-sizing: border-box; height: 65px; }   /* the three top bars are 64px + a hairline, */
  .list-bar { padding-top: 12px; padding-bottom: 12px; box-sizing: border-box; height: 65px; }                  /* so the mini player has the same gap above and below */
  .reader-top { padding-top: calc(12px + env(safe-area-inset-top, 0px)); padding-bottom: 12px; box-sizing: border-box; min-height: 65px; }
  :root:not(.single-pane) #reader-view .reader-top { padding-top: 12px; }
}
.home-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 24px max(20px, env(safe-area-inset-right), calc((100% - 60rem) / 2 + 20px)) 8px max(20px, env(safe-area-inset-left), calc((100% - 60rem) / 2 + 20px));      /* full width (for the border), content in the 60rem column */
  border-bottom: 1px solid var(--line);
  /* the logo, name and Settings stay at the top while the books scroll */
  position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); z-index: 3;
  background: var(--surface);                /* as the player's */
}
.home-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.home-logo { width: 48px; height: 48px; flex: none; border-radius: 11px; }
.home-title { margin: 0; font-size: calc(30px * var(--ts)); }
.home-tag { margin: 2px 0 0; color: var(--ink-3); font-size: calc(13px * var(--ts)); }
.book-grid {
  list-style: none; margin: 0 auto; padding: 26px max(20px, env(safe-area-inset-right)) 28px max(20px, env(safe-area-inset-left));  /* clear of a landscape phone's notch, as the header */    /* room below the sticky header */
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 190px)); gap: 24px 16px;
  justify-content: start;
}
html.restoring #book-grid { visibility: hidden; }   /* until the library is back at its scroll position */
.book-tile { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.book-cover {
  display: block; width: 100%; height: auto;      /* a cover keeps its own proportions: never cropped */
  border-radius: 6px; background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 22px rgba(0, 0, 0, .2);
  transition: transform .15s ease, box-shadow .15s ease;
}
div.book-cover { aspect-ratio: 310 / 500; }     /* the stand-in for a book without a cover */
img.book-cover { aspect-ratio: auto 310 / 500; }  /* room for a cover before it has loaded, then its own proportions */
.book-tile .eyebrow { margin: 12px 0 3px; }
.book-name { margin: 0 0 5px; font-family: var(--serif); font-weight: 600; font-size: calc(17px * var(--ts)); line-height: 1.2; text-wrap: balance; }
.book-facts { margin: 0; color: var(--ink-2); font-size: calc(13px * var(--ts)); }
/* Narrow screens: a row per book, the text to the right of the cover, so the list is compact */
@media (max-width: 599px), (orientation: landscape) and (max-height: 500px) {
  .book-grid { grid-template-columns: 1fr; gap: 32px; }
  .book-tile {
    display: grid; grid-template-columns: 116px 1fr; grid-template-rows: auto auto auto auto 1fr;
    column-gap: 18px; align-items: start;
  }
  .book-tile .book-cover { grid-column: 1; grid-row: 1 / span 5; }
  .book-tile > :not(.book-cover) { grid-column: 2; }
  .book-tile .eyebrow { margin: 2px 0 4px; }
  .book-name { font-size: calc(20px * var(--ts)); margin-bottom: 6px; }
}
/* a phone turned sideways: the same tiles, two across */
@media (orientation: landscape) and (max-height: 500px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 24px; }
}
/* a focus ring in the accent colour, not the browser's blue (Settings opens with its first button focused) */
:where(button, a, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.book-tile:focus-visible { outline: none; }
.book-tile:focus-visible .book-cover { outline: 3px solid var(--accent); outline-offset: 3px; }
.book-tile:active .book-cover { transform: scale(.98); }
/* "Install Orapture": phones and tablets in a browser tab only */
.install-row {
  display: flex; align-items: center; gap: 10px;
  width: calc(100% - 40px); max-width: calc(60rem - 40px); margin: 16px auto 0; padding: 12px 6px 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.install-row[hidden] { display: none; }
.install-text { flex: 1; min-width: 0; }
.install-title { margin: 0 0 2px; font-weight: 600; font-size: calc(15px * var(--ts)); }
.install-sub { margin: 0; color: var(--ink-2); font-size: calc(13px * var(--ts)); line-height: 1.35; }
.text-btn.install-go { flex: none; border-color: var(--accent); color: var(--accent); font-weight: 600; }
.icon-btn.install-x { flex: none; width: 34px; height: 34px; color: var(--ink-3); }
.icon-btn.install-x svg { width: 18px; height: 18px; }
.install-body p { margin: 0 0 12px; line-height: 1.5; }
.install-steps { margin: 4px 0 14px; padding-left: 22px; line-height: 1.5; }
.install-steps li { margin: 10px 0; padding-left: 4px; }
.install-steps li::marker { color: var(--accent); font-weight: 600; }
.inline-ico { width: 1.15em; height: 1.15em; vertical-align: -0.22em; color: var(--accent); }
.install-note { color: var(--ink-2); font-size: calc(14px * var(--ts)); }
/* wide screens with the two-pane layout can't scroll the page: the library scrolls itself */
@media (min-width: 960px) {
  :root:not(.single-pane) #home { position: fixed; inset: 0 0 var(--player-total) 0; padding: env(safe-area-inset-top, 0px) 0 0; overflow-y: auto; overscroll-behavior: contain; }
}
/* the way back up from a book: an arrow, then a small logo, name and tag line (a tap on
   any of them goes up to the library) */
.list-brand { display: flex; align-items: center; gap: 2px; margin: 0 0 0 -10px; min-width: 0; }
/* the arrow, logo and name (and, on wide screens, the hide/show-list button) stay at the top while the
   chapters scroll */
.list-bar {
  position: fixed; left: 0; right: 0; top: env(safe-area-inset-top, 0px); z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: none; margin: 0;
  padding: 14px max(20px, env(safe-area-inset-right), calc((100% - 40rem) / 2 + 20px)) 8px max(20px, env(safe-area-inset-left), calc((100% - 40rem) / 2 + 20px));      /* full width (for the border), text in the 40rem column */
  border-bottom: 1px solid var(--line);
  background: var(--surface);                /* as the player's */
}
#textsize-btn.list-settings { position: relative; flex: none; }
@media (min-width: 960px) { #textsize-btn.list-settings { margin-right: 40px; } }   /* clear of the hide-the-list button */
@media (min-width: 960px) { :root:not(.single-pane) #textsize-btn.list-settings { display: none; } }   /* the text's bar has it */
.icon-btn.library-back { flex: none; width: 34px; height: 40px; border-radius: 8px; color: var(--accent); }
.library-back svg { width: 24px; height: 24px; }
.brand-link { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 0; border: 0; background: none; text-align: left; color: inherit; cursor: pointer; }
.brand-logo { width: 34px; height: 34px; flex: none; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
.brand-tag { overflow: hidden; text-overflow: ellipsis; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: calc(17px * var(--ts)); line-height: 1.1; }
.brand-tag { margin-top: 2px; color: var(--ink-3); font-size: calc(11px * var(--ts)); line-height: 1.2; }
.brand-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* ---------- chapter list ---------- */
.list-header { padding: 10px 20px 12px; }
/* the chapter screen keeps the text's column width, centred (not in the sidebar) */
.list-header, .chapter-list { max-width: 40rem; margin-left: auto; margin-right: auto; }
.eyebrow {
  margin: 0 0 6px;
  font-size: calc(12px * var(--ts));
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: calc(28px * var(--ts));
  line-height: 1.15;
  margin: 0 0 8px;
  text-wrap: balance;
}
.book-meta { margin: 0; color: var(--ink-2); font-size: calc(14px * var(--ts)); }
.offline-status { margin: 0; font-size: calc(13px * var(--ts)); color: var(--ink-3); }

.chapter-list { list-style: none; margin: 0 auto; padding: 4px 8px 84px; }   /* room for the "Back to the text" pill */
@media (min-width: 960px) { :root:not(.single-pane) .chapter-list { padding-bottom: 24px; } }
.chapter-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
}
.chapter-list li.current { background: var(--surface-2); }
.chapter-list li.cont .ch-main { margin-left: 14px; }      /* part 2, 3 ... of a long chapter */
.quick-list li.cont .q-title { padding-left: 14px; }
.ch-num {
  font-family: var(--serif);
  font-size: calc(20px * var(--ts));
  color: var(--ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.chapter-list li.current .ch-num { color: var(--accent); }
.ch-main { min-width: 0; cursor: pointer; }
.ch-title { font-family: var(--serif); font-size: calc(17px * var(--ts)); line-height: 1.25; margin: 0; }
.ch-meta { font-size: calc(12.5px * var(--ts)); color: var(--ink-3); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.ch-progress { flex: 0 0 48px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.ch-progress i { display: block; height: 100%; background: var(--accent); }
.ch-cached::before { content: "●"; color: var(--accent); font-size: calc(8px * var(--ts)); vertical-align: 2px; margin-right: 4px; }

.text-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: calc(13px * var(--ts));
  color: var(--ink-2);
  cursor: pointer;
}
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; }
.text-btn svg { width: 16px; height: 16px; }
.aa { font-family: var(--serif); font-weight: 600; letter-spacing: -0.02em; }
.aa small { font-size: 0.75em; }
.reader-top-actions { display: flex; gap: 8px; }
.round-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  cursor: pointer;
}
.round-btn svg { width: 18px; height: 18px; margin-left: 2px; }
.round-btn.is-playing svg { margin-left: 0; }
/* a chapter this listener can't play yet (app.js, "access"): a lock instead of Play */
li.locked .round-btn { background: rgba(127, 127, 127, .18); color: inherit; }
li.locked .round-btn svg { margin-left: 0; }

/* ---------- reader ---------- */
.reader-top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));   /* clear of a landscape phone's rounded corners */
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  container: rtop / inline-size;
  background: var(--surface);                /* the player's background and hairline, at the top */
  border-bottom: 1px solid var(--line);
}
.icon-btn.back-btn { display: flex; align-items: center; gap: 2px; width: auto; height: 40px; border-radius: 8px; padding: 6px 10px 6px 2px; font-size: calc(15px * var(--ts)); color: var(--accent); }
.reader {
  max-width: 40rem;
  margin: 0 auto;
  padding: 8px 22px 45vh;
  font-family: var(--serif);
  font-size: calc(20px * var(--ts));
  line-height: 1.7;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.reader-empty { color: var(--ink-3); text-align: center; margin-top: 30vh; font-family: var(--sans); font-size: calc(16px * var(--ts)); }
.reader h2 { font-size: calc(30px * var(--ts)); font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 18px 0 28px; text-wrap: balance; }
.reader p { margin: 0 0 1em; padding: 0 6px; margin-left: -6px; margin-right: -6px; border-radius: 6px; transition: background-color .3s; }
.reader p.cur-blk { background: var(--para); }
.reader p.quote { margin-left: 1.2em; font-size: 0.92em; color: var(--ink-2); font-style: italic; }
.reader p.quote .w.it { font-style: normal; }
.reader p.sep { text-align: center; color: var(--ink-3); letter-spacing: 0.5em; }
.w { cursor: pointer; border-radius: 4px; transition: background-color .08s, box-shadow .08s; }   /* together, or the ring shows alone for a moment */
.w.it { font-style: italic; }
.w.cur { background: var(--hl); color: var(--hl-ink); box-shadow: 0 0 0 2px var(--hl); }

/* ---------- player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 6px max(12px, env(safe-area-inset-left)) var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: minmax(40px, auto) minmax(30px, auto) 72px;
  grid-template-areas: "np speed" "scrub scrub" "controls controls";
  align-items: center;
  column-gap: 8px;
}
@media (min-width: 960px) {
  .player { padding-left: max(24px, calc(50% - 480px)); padding-right: max(24px, calc(50% - 480px)); }
}
.now-playing {
  grid-area: np;
  display: flex; align-items: baseline; gap: 8px;
  min-width: 0;
  background: none; border: none; padding: 6px 8px; margin-left: -8px;
  border-radius: 8px; cursor: pointer; text-align: left;
}
.np-num { font-family: var(--serif); color: var(--accent); font-size: calc(17px * var(--ts)); font-weight: 600; flex: none; }
.np-title { font-family: var(--serif); font-size: calc(17px * var(--ts)); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title.scrolling { text-overflow: clip; }
.np-title.scrolling .np-scroll { display: inline-block; will-change: transform; }
.np-caret { width: 16px; height: 16px; flex: none; color: var(--ink-3); align-self: center; }

.speed { grid-area: speed; display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 2px; }
.speed-val { min-width: 54px; height: 32px; padding: 0 4px; border: none; background: none; border-radius: 8px; text-align: center; font-size: calc(14px * var(--ts)); font-variant-numeric: tabular-nums; font-weight: 600; cursor: pointer; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  color: var(--ink);
  position: relative;
}
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.icon-btn.small { width: 32px; height: 32px; font-size: calc(20px * var(--ts)); line-height: 1; }
.icon-btn.skip svg { width: 30px; height: 30px; stroke-width: 1.7; }
.icon-btn.skip span { position: absolute; font-size: 13px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -38%); }
.controls .icon-btn.skip span { top: calc(50% + 1.6px); transform: translate(-50%, -50%); font-size: 12.5px; letter-spacing: -0.02em; }   /* in the circle's centre */

.scrub { grid-area: scrub; display: flex; align-items: center; gap: 10px; }
.time { font-size: calc(12px * var(--ts)); color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 44px; }
.time:last-child { text-align: right; }
#seek {
  flex: 1; -webkit-appearance: none; appearance: none; height: 22px; background: transparent; margin: 0; cursor: pointer;
  --pct: 0%;
}
#seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--pct), var(--line) var(--pct)); }
#seek::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--pct), var(--line) var(--pct)); }
#seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); margin-top: -5px; border: none; }
#seek::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: none; }

.controls { grid-area: controls; display: flex; justify-content: center; align-items: center; gap: clamp(24px, 9vw, 48px); }
.icon-btn.play { width: 58px; height: 58px; background: var(--accent); color: var(--accent-ink); }
.icon-btn.play svg { width: 28px; height: 28px; }
.icon-btn.play .i-pause, .playing .icon-btn.play .i-play { display: none; }
/* Chapter and skip buttons below the scrubber: icons and the "15" label scale
   with text sizes above 100% (never below); the tap area grows only as the icon
   needs it. The play/pause button stays fixed. */
/* ±15 s: the same size as play/pause, icon and number scaled to match */
.controls .icon-btn.skip { width: 58px; height: 58px; }
.controls .icon-btn.skip svg { width: 40px; height: 40px; stroke-width: 1.7; stroke-linecap: round; transform-origin: 50% 54.17%; }   /* turns on the circle's centre (12, 13) */
.playing .icon-btn.play .i-pause { display: block; }
/* waiting for the audio to start (streaming): a ring instead of the play / pause symbol */
.icon-btn.play .spinner { display: none; }
.spinner, .round-btn.is-buffering::after {
  box-sizing: border-box; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.buffering .icon-btn.play .spinner { display: block; }
.buffering .icon-btn.play .i-play, .buffering .icon-btn.play .i-pause { display: none; }
.round-btn { position: relative; }
.round-btn.is-buffering svg { visibility: hidden; }
.round-btn.is-buffering::after { content: ""; position: absolute; width: 22px; height: 22px; left: 9px; top: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sheets ---------- */
dialog.sheet {
  border: none; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(560px, 100vw);
  max-height: min(80vh, 760px);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  flex-direction: column;
  overflow: hidden;
}
dialog.sheet[open] { display: flex; overscroll-behavior: contain; }
dialog.sheet::backdrop { background: rgba(20, 15, 8, .45); }
@media (max-width: 600px) {
  dialog.sheet {
    margin: auto 0 0; width: 100vw; max-width: 100vw;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: var(--safe-b);
  }
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 12px 10px 22px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-family: var(--serif); font-size: calc(22px * var(--ts)); line-height: 1.2; }
.sheet-head .eyebrow { margin-bottom: 4px; }
.sheet-head .icon-btn { width: 40px; height: 40px; margin-top: -4px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 16px 22px; }
.summary-panel { display: flex; flex-direction: column; min-height: 0; }
/* previous / next chapter and close, together at the right of the sheet's header */
.head-actions { display: flex; align-items: flex-start; gap: 2px; flex: none; }
.head-actions .icon-btn { margin-top: -4px; }
#summary-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
#summary-dialog .sheet-head > div { min-width: 0; }
/* a sheet over the page: the page behind doesn't scroll (touch screens only: a mouse's scrollbar would jump) */
@media (pointer: coarse) {
  html:has(dialog[open]), html:has(dialog[open]) body { overflow: hidden; overscroll-behavior: none; }
}
.app-version { margin: 26px 0 0; text-align: center; font-size: calc(12px * var(--ts)); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sheet-foot { padding: 12px 22px 18px; border-top: 1px solid var(--line); }
.summary-body { font-family: var(--serif); font-size: calc(17.5px * var(--ts)); line-height: 1.6; }
.summary-body p { margin: 0 0 0.9em; }
.summary-body ul { margin: 0 0 0.5em; padding-left: 1.2em; }
.summary-body li { margin-bottom: 0.4em; }
.primary-btn { width: 100%; padding: 13px; border: none; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: calc(16px * var(--ts)); cursor: pointer; }

.quick-list { list-style: none; margin: 0; padding: 6px 10px 14px; }
.quick-list button {
  width: 100%; display: flex; gap: 12px; align-items: baseline;
  background: none; border: none; border-radius: 10px;
  padding: 11px 12px; text-align: left; cursor: pointer;
}
.quick-list .q-num { font-family: var(--serif); color: var(--ink-3); width: 22px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.quick-list .q-title { font-family: var(--serif); font-size: calc(17px * var(--ts)); flex: 1; }
.quick-list .q-dur { font-size: calc(12.5px * var(--ts)); color: var(--ink-3); }
.quick-list li.current button { background: var(--surface-2); }
.quick-list li.current .q-num, .quick-list li.current .q-title { color: var(--accent); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
  .spinner, .round-btn.is-buffering::after { animation-duration: 2.4s; }
}

.summary-body blockquote {
  margin: 0 0 0.6em;
  padding: 10px 14px 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 10px 10px 0;
}
.summary-body blockquote p { margin: 0 0 8px; font-style: italic; }
.summary-body .quote-play { font-family: var(--sans); font-size: calc(12.5px * var(--ts)); padding: 4px 10px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.summary-body .quote-play:disabled { color: var(--ink-3); border-color: var(--line); }
.summary-body p strong { font-family: var(--sans); font-size: calc(13px * var(--ts)); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.reader h3.subhead {
  font-family: var(--sans);
  font-size: calc(14px * var(--ts));
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 2.2em 0 0.9em;
}
.reader h3.subhead .w.cur { color: var(--hl-ink); }

/* ---------- floating pills: go back / resume auto-scroll ---------- */
.floaters {
  position: fixed; z-index: 6;
  left: 0; right: 0;
  bottom: calc(var(--player-total) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
@media (min-width: 960px) { :root:not(.single-pane):not(.at-home) .floaters { left: var(--list-w, 400px); } }
.pill {
  pointer-events: auto;
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 8px;
  max-width: 100%;
  padding: 10px 18px 10px 14px;
  border: none; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: calc(14px * var(--ts)); font-weight: 500;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  cursor: pointer;
  animation: pill-in .2s ease-out;
}
.pill svg { width: 18px; height: 18px; flex: none; }
.pill-text { display: flex; flex-direction: column; align-items: flex-start; text-align: left; line-height: 1.25; }
.pill-text small { font-size: calc(12px * var(--ts)); opacity: .75; }
.pill.undo { background: var(--accent); color: var(--accent-ink); }
.undo-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .35; transform-origin: left; }
.undo-timer.run { animation: undo-countdown 15s linear forwards; }
@keyframes undo-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes pill-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- history ---------- */
dialog.sheet.tall { height: min(85vh, 760px); }
.history-body { padding: 8px 10px 16px; }
.history-day { font-size: calc(12px * var(--ts)); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 14px 12px 4px; }
.history-item {
  width: 100%; display: grid; grid-template-columns: 34px 1fr; gap: 4px 10px;
  background: none; border: none; border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer;
}
.history-item:focus-visible { background: var(--surface-2); }
.history-item .h-num { grid-row: span 3; font-family: var(--serif); font-size: calc(20px * var(--ts)); color: var(--accent); text-align: center; }
.history-item .h-title { font-family: var(--serif); font-size: calc(16.5px * var(--ts)); font-weight: 600; line-height: 1.25; }
.history-item .h-meta { display: flex; align-items: center; gap: 8px; font-size: calc(12.5px * var(--ts)); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.history-item .h-bar { flex: 0 0 56px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.history-item .h-bar i { display: block; height: 100%; background: var(--accent); }
.history-item .h-snippet { font-family: var(--serif); font-style: italic; font-size: calc(14.5px * var(--ts)); color: var(--ink-2); line-height: 1.4; }
.history-empty { color: var(--ink-3); text-align: center; padding: 40px 20px; font-size: calc(15px * var(--ts)); }
.history-foot .text-btn { white-space: nowrap; flex: none; }
.history-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.history-note { font-size: calc(12.5px * var(--ts)); color: var(--ink-3); }

/* ---------- speed + text size sheets ---------- */
dialog.sheet.compact { width: min(440px, 100vw); }
.adjust-body { padding: 18px 22px 22px; }
.adjust-value { margin: 0 0 12px; text-align: center; font-size: calc(34px * var(--ts)); font-weight: 600; font-variant-numeric: tabular-nums; }
.adjust-row { display: flex; align-items: center; gap: 10px; }
.adjust-row .icon-btn.small { width: 40px; height: 40px; background: var(--surface-2); font-size: calc(22px * var(--ts)); }
.aa-small { font-family: var(--serif); font-size: 15px !important; }
.aa-large { font-family: var(--serif); font-size: 26px !important; }
.slider { flex: 1; -webkit-appearance: none; appearance: none; height: 28px; background: transparent; margin: 0; cursor: pointer; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line); }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); margin-top: -9px; border: 3px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); }
.presets { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.presets button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 6px 12px; font-size: calc(13.5px * var(--ts)); color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.presets button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.textsize-preview { font-family: var(--serif); font-size: calc(20px * var(--ts)); line-height: 1.6; margin: 18px 0 0; text-align: center;
  position: relative; z-index: 0; }   /* its own stack, so the preview highlight sits under the words */
.textsize-preview .w { cursor: default; }
.textsize-preview .w:hover { text-decoration: none; }

/* ---------- mispronunciation reports ---------- */
.report-label { margin-top: 26px; }
.report-count { margin: 0; text-align: center; font-size: calc(13.5px * var(--ts)); color: var(--ink-3); }
.report-actions { margin-top: 10px; }
.mispron-sentence { font-family: var(--serif); font-size: calc(17px * var(--ts)); line-height: 1.5; margin: 0 0 16px; color: var(--ink-2); }
.mispron-play {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: none; border: none; padding: 0 2px; margin: 0 -2px; border-radius: 6px;
  font: inherit; font-weight: 700; color: var(--accent); cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 4px;
}
.mispron-play svg { width: 1em; height: 1em; align-self: center; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mispron-play:active { background: var(--surface-2); }
.mispron-hint { margin: -10px 0 14px; font-size: calc(12.5px * var(--ts)); color: var(--ink-3); }
.mispron-body textarea {
  display: block; width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: max(16px, calc(15px * var(--ts)));   /* 16px or more: iOS doesn't zoom in */
  resize: vertical;
}
.mispron-body textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.signin-hint { margin: 0 0 14px; }
.signin-input {
  display: block; width: 100%; box-sizing: border-box; margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: max(16px, calc(15px * var(--ts)));
}
.signin-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.signin-code { letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.code-expires { margin: 8px 0 0; font-size: calc(12.5px * var(--ts)); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.signin-error { margin: 12px 0 0; color: var(--accent); font-size: calc(13.5px * var(--ts)); }
.mispron-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.mispron-actions .text-btn { padding: 8px 18px; font-size: calc(14.5px * var(--ts)); }
.text-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.text-btn.primary:disabled { opacity: .45; }

/* ---------- update button ---------- */
.text-btn.attention { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.text-btn.attention::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.text-btn:disabled { opacity: .6; cursor: default; }

/* ---------- flowing highlight ---------- */
.reader { position: relative; z-index: 0; }   /* stacking context so the pill sits under the text */
.hl-pill {
  position: absolute; left: 0; top: 0; z-index: -1;
  border-radius: 5px;
  background: var(--hl);
  pointer-events: none;
  will-change: translate, width;
  transition: translate .18s cubic-bezier(.25, .8, .35, 1), width .18s cubic-bezier(.25, .8, .35, 1);
}
.hl-pill.no-anim { transition: none; }
body[data-hl="flow"] .hl-pill { transition: translate .14s cubic-bezier(.25, .8, .35, 1); }   /* width follows the voice frame by frame */
body[data-hl="flow"] .hl-pill.no-anim { transition: none; }
body[data-hl="glide"] .w.cur, body[data-hl="flow"] .w.cur, body[data-hl="blob"] .w.cur { background: none; box-shadow: none; color: inherit; }
.adjust-label { margin: 22px 0 0; text-align: center; font-size: calc(12px * var(--ts)); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- bookmarks ---------- */
.text-btn.icon-only { padding-left: 8px; padding-right: 8px; display: inline-flex; align-items: center; }
.text-btn.icon-only svg { width: calc(17px * var(--ts)); height: calc(17px * var(--ts)); }
#bookmark-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#bookmark-btn[aria-pressed="true"] .bm-shape { fill: currentColor; }
#bookmark-btn .bm-plus { stroke-width: 2.6; stroke-linecap: round; }       /* the + beside the bookmark says "add" */
.reader-top #bookmark-btn svg, #bookmark-btn svg { width: calc(25px * min(var(--ts), 1.15)); }   /* the icon is 3:2 to make room for the + */
#bookmark-btn.icon-only { padding-inline: 9px; }
/* soft bars under the text, one per line: saved bookmarks, the one picked from
   the list, and the selection being made (drawn by refreshMarks in app.js) */
.mark-layer { position: absolute; inset: 0; z-index: -2; pointer-events: none; }
.mark-layer i { position: absolute; left: 0; top: 0; border-radius: 4px; }
.mk-saved { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.mk-focus { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.mk-sel { background: color-mix(in srgb, var(--accent) 30%, transparent); box-shadow: inset 0 -2px 0 var(--accent); }
body.selecting .reader .w { cursor: copy; }
.pill-row { display: flex; gap: 10px; pointer-events: none; }
.pill.pill-save { background: var(--accent); color: var(--accent-ink); }
.pill.pill-quiet { background: var(--surface); color: var(--ink); box-shadow: 0 6px 20px rgba(0,0,0,.25), inset 0 0 0 1px var(--line); }
.pill.net { background: var(--surface); color: var(--ink); box-shadow: 0 6px 20px rgba(0,0,0,.25), inset 0 0 0 1px var(--line); cursor: default; padding: 6px 4px 6px 14px; font-size: calc(13px * var(--ts)); }
.pill.net #net-text { white-space: pre-line; }
.pill.net svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill.net button { background: none; border: none; color: inherit; font-size: 22px; line-height: 1; padding: 4px 10px; cursor: pointer; opacity: .65; }
.pill.toast { cursor: default; padding: 8px 16px; font-size: calc(13px * var(--ts)); text-align: center; }
/* while a sheet is open, its notices and undo sit inside it (above the backdrop) */
.pill.in-sheet { position: fixed; z-index: 3; left: 0; right: 0; margin-inline: auto; width: max-content; max-width: calc(100% - 32px); bottom: calc(var(--safe-b) + 80px); }
/* a bookmark in the list looks like a key passage in the summary: the same card, type and button, with its
   note below it as the passages have theirs */
.bm-entry { margin: 0 0 14px; font-family: var(--serif); font-size: calc(17.5px * var(--ts)); line-height: 1.6; }
.bm-card { margin: 0 0 0.6em; padding: 10px 14px 10px 16px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.bm-card p { margin: 0 0 8px; }
.bm-meta { font-family: var(--sans); font-size: calc(11.5px * var(--ts)); line-height: 1.4; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bm-text { font-style: italic; }
.bm-note { display: block; width: 100%; margin: 0; padding: 0; text-align: left; white-space: pre-wrap; cursor: pointer; background: none; border: none;
  font: inherit; color: var(--ink); border-radius: 6px; }
.bm-note:active { background: var(--surface-2); }
.bm-addnote { margin: 0; padding: 4px 10px; font-size: calc(12.5px * var(--ts)); line-height: 1.4; }
.bm-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bm-card .quote-play { font-family: var(--sans); font-size: calc(12.5px * var(--ts)); line-height: 1.4; padding: 4px 10px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.icon-btn.bm-del { flex: none; width: 36px; height: 36px; color: var(--ink-3); }
.icon-btn.bm-del svg { width: 18px; height: 18px; }
.text-btn:disabled { opacity: .45; cursor: default; }
.summary-body blockquote.bm-quote { border-left-style: dashed; }
.summary-body .bm-label { display: flex; align-items: center; gap: 6px; font-style: normal; font-family: var(--sans); font-size: calc(11.5px * var(--ts)); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.summary-body .bm-label svg { width: 14px; height: 14px; }
/* the text's top bar holds four buttons: keep it on one line on phones. Settings, last, is an icon
   until the bar is wide enough for its label. */
.reader-top .btn-label { display: none; }
@container rtop (min-width: 560px) {
  .reader-top .btn-label { display: inline; }
  #reader-textsize-btn.icon-only { padding-inline: 12px; }
}
/* "Add Bookmark" needs more room: a phone in portrait never has it, one in landscape may */
.reader-top .bm-text { display: none; }
@container rtop (min-width: 720px) {
  .reader-top .bm-text { display: inline; }
  #bookmark-btn.icon-only { padding-inline: 12px; }
}
/* a phone in landscape is wide enough for the labels above but the mini player takes the middle of the bar:
   Settings and Add Bookmark stay icons, as in portrait */
@media (orientation: landscape) and (max-height: 500px) {
  .reader-top .btn-label, .reader-top .bm-text { display: none; }
  #reader-textsize-btn.icon-only { padding-inline: 8px; }
}
.reader-top .text-btn { font-size: calc(13px * min(var(--ts), 1.15)); }
.reader-top .text-btn.icon-only svg { width: calc(17px * min(var(--ts), 1.15)); height: calc(17px * min(var(--ts), 1.15)); }
@media (max-width: 440px) {
  .reader-top .back-btn span { display: none; }
  .reader-top .back-btn { padding-right: 4px; }
  .reader-top-actions { gap: 6px; }
}
/* chapter list header buttons in two rows: History, Bookmarks, Settings; then
   offline (with its status beside it) and Book summary, whose left edge
   alignBookSummary() lines up with the chapters' Summary buttons. */
.narrow-only { display: none; }
.header-actions { flex-direction: column; row-gap: 14px; }
.header-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.offline-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.second-row > * { flex-shrink: 0; }
@media (max-width: 600px) {
  .wide-only { display: none; }
  .narrow-only { display: inline; }
}
@media (min-width: 960px) {
  :root:not(.single-pane) .wide-only { display: none; }
  :root:not(.single-pane) .narrow-only { display: inline; }
}

/* key passages and bookmarks in the text: a tint under each line plus a line
   in the left margin, solid for passages and dashed for bookmarks (as in the
   summary) */
.mk-passage { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.mark-layer i.mk-edge { width: 0; border-radius: 0; border-left: 2.5px solid color-mix(in srgb, var(--accent) 75%, transparent); }
.mark-layer i.mk-edge.dashed { border-left-style: dashed; }

/* back / forward after jumps */
#jump-row .pill { min-width: 0; }
#jump-row .pill-text small { white-space: nowrap; }
#redo-btn .undo-timer { color: var(--ink-3); }

/* history: two recent places, then reading stats */
.history-section { font-size: calc(12px * var(--ts)); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 14px 12px 4px; }
.stats { display: grid; grid-template-columns: 1fr; gap: 10px 24px; margin: 6px 12px 8px; font-size: calc(14.5px * var(--ts)); }
.stats > div { display: grid; grid-template-columns: 8.5em 1fr; gap: 0 16px; }
.stats .when-date { display: none; }
@media (orientation: landscape) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .when-full { display: none; }
  .stats .when-date { display: inline; }
}
.stats dt { color: var(--ink-3); }
.stats dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
.stats dd small { display: block; color: var(--ink-3); font-size: calc(12.5px * var(--ts)); }

/* wide screens: drag the border between the chapter list and the text */
.list-resizer { display: none; }
@media (min-width: 960px) {
  :root:not(.single-pane) .list-resizer {
    display: block; position: absolute; top: 0; bottom: 0; z-index: 4;
    left: calc(var(--list-w, 400px) - 6px); width: 12px;
    cursor: col-resize; touch-action: none; outline: none;
  }
  .list-resizer::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
    background: transparent; transition: background-color .15s;
  }
  .list-resizer:hover::after, .list-resizer.dragging::after, .list-resizer:focus-visible::after { background: var(--accent); }
  body.resizing, body.resizing * { cursor: col-resize !important; user-select: none; -webkit-user-select: none; }
}

/* ---------- settings ---------- */
.settings-body { padding-top: 6px; }
.settings-body .adjust-label:first-child { margin-top: 6px; }
.settings-body .presets { margin-top: 10px; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.swatches button {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  background: oklch(var(--sw-l) var(--sw-c) var(--h));
}
.swatches button.on { box-shadow: 0 0 0 2px var(--ink); }
.hue-row { margin-top: 14px; }
.slider.hue::-webkit-slider-runnable-track {
  background: linear-gradient(to right, oklch(var(--sw-l) var(--sw-c) 0), oklch(var(--sw-l) var(--sw-c) 45), oklch(var(--sw-l) var(--sw-c) 90),
    oklch(var(--sw-l) var(--sw-c) 135), oklch(var(--sw-l) var(--sw-c) 180), oklch(var(--sw-l) var(--sw-c) 225), oklch(var(--sw-l) var(--sw-c) 270),
    oklch(var(--sw-l) var(--sw-c) 315), oklch(var(--sw-l) var(--sw-c) 360));
}
.slider.hue::-moz-range-track {
  background: linear-gradient(to right, oklch(var(--sw-l) var(--sw-c) 0), oklch(var(--sw-l) var(--sw-c) 90), oklch(var(--sw-l) var(--sw-c) 180),
    oklch(var(--sw-l) var(--sw-c) 270), oklch(var(--sw-l) var(--sw-c) 360));
}

/* update: in Settings, and flagged on the Settings button when there is one */
.settings-update { margin-top: 26px; }
.settings-update .text-btn { padding: 8px 16px; font-size: calc(14px * var(--ts)); }
/* Update / Reload App sits in the Settings header, between the title and the close button */
#textsize-dialog .sheet-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px; }
#textsize-dialog .sheet-head .icon-btn { margin-top: 0; }
#textsize-dialog .sheet-head #update-btn { justify-self: center; }
.head-gear { display: grid; place-items: center; width: 40px; height: 40px; margin: 0; color: var(--ink); }   /* the Settings title: a gear, the size of the close button */
#update-btn { padding: 6px 12px; font-size: calc(13px * min(var(--ts), 1.15)); white-space: nowrap; }
/* signed in: what was synced and who with, side by side, each centred in its own column */
.sync-cols { display: flex; justify-content: center; align-items: stretch; gap: 22px; margin-top: 10px; }
.sync-col { display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; text-align: center; }
.sync-col + .sync-col { padding-left: 22px; border-left: 1px solid var(--line); }   /* a hairline between them: the two texts read as one row */
/* a code was sent: its entry stays here until it's used or expires (the sheet can close, or the app reload, while the listener reads the email) */
.sync-pending { max-width: 300px; margin: 10px auto 0; text-align: center; }
.sync-pending .signin-input { text-align: center; }
.sync-note { margin: 12px 0 0; text-align: center; font-size: calc(12px * var(--ts)); color: var(--ink-3); overflow-wrap: anywhere; }
.sync-col > span { font-size: calc(13.5px * var(--ts)); color: var(--ink-3); overflow-wrap: anywhere; }
.sync-col .text-btn { padding: 6px 14px; font-size: calc(13.5px * var(--ts)); }
.update-flag { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
#textsize-btn.has-update, #reader-textsize-btn.has-update, #home-settings-btn.has-update { border-color: var(--accent); color: var(--accent); }
#textsize-btn.has-update .update-flag, #home-settings-btn.has-update .update-flag { display: inline-flex; }
/* the text's gear: the dot sits in the button's right padding (the gear moves
   left a little), so the button and the top bar keep their width */
/* the text's gear: 8 px wider while an update is waiting, the dot in that
   extra room; on narrow phones the top bar's gaps give up those 8 px */
#reader-textsize-btn { position: relative; }
#reader-textsize-btn.has-update { padding-right: 16px; }
#reader-textsize-btn.has-update .update-flag { display: block; position: absolute; right: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; }
@media (max-width: 440px) {
  .reader-top:has(#reader-textsize-btn.has-update) { padding-right: 10px; }
  .reader-top:has(#reader-textsize-btn.has-update) .reader-top-actions { gap: 4px; }
}

/* "Blob" highlight: Glide's colour and movement (with a softer, springier
   glide), drawn as a rounded shape whose edges and corners keep rippling
   (the SVG outline is redrawn each frame by blobFrame in app.js). */
.hl-pill .blob { display: none; }
body[data-hl="blob"] .hl-pill {
  background: transparent; border-radius: 0;
  transition: translate .55s cubic-bezier(.22, 1.25, .36, 1), width .55s cubic-bezier(.22, 1.25, .36, 1), height .4s ease;
}
body[data-hl="blob"] .hl-pill.no-anim { transition: none; }
body[data-hl="blob"] .hl-pill .blob {
  display: block; position: absolute; left: -6px; top: -6px;
  width: calc(100% + 12px); height: calc(100% + 12px); overflow: visible;
}
.hl-pill .blob, .hl-pill .blob path { stroke: none; }   /* not the icon outline style */
.hl-pill .blob path { fill: var(--hl); }

/* wide screens: hide / bring back the chapter list (top right of the list) */
.list-header { position: relative; }
.pane-toggle { display: none; }
@media (min-width: 960px) {
  .pane-toggle { display: grid; position: absolute; top: 12px; right: max(10px, calc((100% - 40rem) / 2 + 10px)); color: var(--ink-3); }
  .pane-toggle:hover { color: var(--accent); }
}
/* the same, from the text once the list is hidden: in the text's header, its right edge just left
   of the passage line (the 40rem text column's left edge + 22px padding - 13px; see refreshMarks) */
.reader-pane-btn { display: none; }
@media (min-width: 960px) {
  :root.single-pane .reader-pane-btn {
    /* (the second value keeps it clear of "‹ Chapters" at large text sizes in a narrow window) */
    display: grid; position: absolute; top: 50%; left: max(calc((100% - 40rem) / 2 + 9px - 6px), calc(84px + 62px * var(--ts)));
    transform: translate(-100%, -50%); color: var(--ink-3);
  }
  :root.single-pane .reader-pane-btn:hover { color: var(--accent); }
}
.pane-toggle .i-show, :root.single-pane .pane-toggle .i-hide { display: none; }
:root.single-pane .pane-toggle .i-show { display: block; }

/* update available: the border of the Settings buttons and Update / Reload App
   slowly brightens with a soft glow and fades back, every 10 seconds */
#textsize-btn.has-update, #reader-textsize-btn.has-update, #home-settings-btn.has-update, #update-btn.attention { animation: update-glow 10s ease-in-out infinite; }
@keyframes update-glow {
  /* both border colours as color-mix, so the browser fades between them */
  0%, 32%, 100% { border-color: color-mix(in srgb, var(--accent) 100%, white); box-shadow: 0 0 0 0 transparent; }
  16% {
    border-color: color-mix(in srgb, var(--accent) 45%, white);
    box-shadow: 0 0 7px 1px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}
#update-btn:disabled svg { animation: update-spin 1s linear infinite; }
@keyframes update-spin { to { rotate: 360deg; } }
#update-btn.attention::before { order: 1; }   /* the dot after the label, as on Settings */
/* the update dot pulses with its button's border */
#textsize-btn.has-update .update-flag, #reader-textsize-btn.has-update .update-flag, #home-settings-btn.has-update .update-flag, #update-btn.attention::before { animation: update-dot-glow 10s ease-in-out infinite; }
@keyframes update-dot-glow {
  0%, 32%, 100% { background-color: color-mix(in srgb, var(--accent) 100%, white); box-shadow: 0 0 0 0 transparent; }
  16% { background-color: color-mix(in srgb, var(--accent) 45%, white); box-shadow: 0 0 6px 2px color-mix(in srgb, var(--accent) 60%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  #textsize-btn.has-update, #reader-textsize-btn.has-update, #home-settings-btn.has-update, #update-btn.attention,
  #textsize-btn.has-update .update-flag, #reader-textsize-btn.has-update .update-flag, #home-settings-btn.has-update .update-flag, #update-btn.attention::before { animation: none; }
  #update-btn:disabled svg { animation: none; }
}


/* Hover styles only where there is a real pointer: on touch screens a tapped
   button would otherwise keep its hover look until something else is tapped. */
@media (hover: hover) and (pointer: fine) {
  .text-btn:hover { border-color: var(--ink-3); color: var(--ink); }
  .brand-link:hover .brand-name { color: var(--accent); }
  .book-tile:hover .book-cover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0, 0, 0, .25), 0 14px 28px rgba(0, 0, 0, .25); }
  .w:hover { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
  .now-playing:hover { background: var(--surface-2); }
  .speed-val:hover { background: var(--line); }
  .icon-btn:hover { background: var(--surface-2); }
  .icon-btn.small:hover { background: var(--line); }
  .icon-btn.play:hover { background: var(--accent); filter: brightness(1.08); }
  .quick-list button:hover { background: var(--surface-2); }
  .history-item:hover { background: var(--surface-2); }
  .icon-btn.bm-del:hover { color: var(--accent); }
  .icon-btn:disabled:hover { background: none; }
}

/* ±15 s: a skip (on screen, keyboard, or headphones / car / lock screen)
   lights the button at once, then the light fades while the arrow turns a
   full circle the way it points (1 s). Only that fade is animated, so hover
   on desktop stays instant like the other buttons. */
.controls .icon-btn.skip.pressed { background: var(--surface-2); }
.controls .icon-btn.skip.fade { transition: background-color 1s ease-out; }
#back15.spin svg { animation: skip-spin-back 1s cubic-bezier(.25, .8, .35, 1); }
#fwd15.spin svg { animation: skip-spin-fwd 1s cubic-bezier(.25, .8, .35, 1); }
@keyframes skip-spin-back { from { rotate: 0deg; } to { rotate: -360deg; } }
@keyframes skip-spin-fwd { from { rotate: 0deg; } to { rotate: 360deg; } }

/* ---------- pictures, equations, tables, verse, notes (books made from EPUBs) ---------- */
.reader figure.fig { margin: 1.2em 0; text-align: center; }
.reader figure.fig img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; }
.reader figcaption { margin-top: 6px; font-family: var(--sans); font-size: calc(14px * var(--ts)); color: var(--ink-2); }
.reader figcaption:empty { display: none; }
.reader .fig-note { display: block; font-style: italic; color: var(--ink-3); }
.reader img.eq { display: inline-block; max-width: 100%; vertical-align: middle; }   /* the real baseline offset is in each image's style */
.reader .eqblock { margin: 0.9em 0; text-align: center; overflow-x: auto; }
.reader .eqblock .w { display: inline-block; padding: 2px 6px; }
.reader .eqblock img.eq { vertical-align: baseline; font-size: 1.15em; }
.reader .tbl-wrap { margin: 1em 0; overflow-x: auto; }
.reader table { border-collapse: collapse; margin: 0 auto; font-size: 0.95em; }
.reader td, .reader th { padding: 4px 10px; border: 1px solid var(--line); vertical-align: middle; }
.reader th { font-weight: 600; }
.reader .a-r { text-align: right; }
.reader .a-c { text-align: center; }
.reader p.verse { margin-left: 1.2em; }
.reader span.ind { display: inline-block; }
.reader p.li { margin-left: 1.2em; }
.reader p.li .bullet { color: var(--ink-3); margin-left: -1em; display: inline-block; width: 1em; }
.reader p.footnote { font-size: 0.9em; color: var(--ink-2); }
.reader .fnref { font-family: var(--sans); font-size: 0.7em; color: var(--accent); margin-left: 1px; }
.reader .w.bd { font-weight: 600; }
.reader .w.math { white-space: nowrap; }   /* an equation and the comma after it stay together */
/* the equations are black line art: turn them white on the dark theme */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .reader img.eq { filter: invert(1); } }
:root[data-theme="dark"] .reader img.eq { filter: invert(1); }

/* a picture shown larger */
/* Fixed to the visible screen (inset 0, not 100vh): on iPhone Safari 100vh is the height with the address
   bar and toolbar tucked away, which pushed the bottom of the viewer behind them. */
#picture-dialog {
  position: fixed; inset: 0; margin: 0; border: 0; padding: 0;
  width: auto; height: auto; max-width: none; max-height: none;
  background: #000d; color: #fff;
}
#picture-dialog[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; }
#picture-dialog::backdrop { background: #000; }
#picture-close { justify-self: center; margin: 2px 0 calc(14px + env(safe-area-inset-bottom, 0px)); color: #fff; border-color: #fff8; }
#picture-box { overflow: auto; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); padding: max(14px, env(safe-area-inset-top, 0px)) 12px 10px; min-height: 0; -webkit-overflow-scrolling: touch; }
#picture-img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
/* a swipe is ours while the picture fits (it closes it); a zoomed picture is panned by the browser */
#picture-dialog, #picture-box { touch-action: none; }
#picture-dialog.zoomed #picture-box { touch-action: pan-x pan-y; }
#picture-img.zoomed { width: 200%; height: auto; justify-self: start; object-fit: initial; cursor: zoom-out; }
#picture-alt { margin: 0; padding: 8px 20px calc(10px + env(safe-area-inset-bottom, 0px)); font-family: var(--sans); font-size: 14px; color: #ddd; text-align: center; max-height: 22vh; max-height: 22dvh; overflow: auto; }
.reader figure.fig img { cursor: zoom-in; }

.book-resume { margin: 2px 0 0; font-family: var(--sans); font-size: 12.5px; color: var(--accent); }

.reader sup { font-size: 0.68em; line-height: 0; }

/* ---------- library filter ---------- */
.home-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.filter-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--surface); font-size: calc(11px * var(--ts)); font-weight: 600; line-height: 18px; text-align: center; }
.filter-count[hidden] { display: none; }
#home-filter-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
#home-filter-btn.active { border-color: var(--accent); color: var(--accent); }
.filter-empty { max-width: 60rem; margin: 40px auto; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); text-align: center; color: var(--ink-3); }
.filter-empty[hidden] { display: none; }
.filter-body { padding: 6px 12px 10px; }
.filter-row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 4px 10px 4px calc(10px + var(--depth, 0) * 22px); border-radius: 10px; cursor: pointer; font-size: calc(16px * var(--ts)); }
.filter-row:hover { background: var(--line); }
.filter-row.group { font-weight: 600; }
.filter-row input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); cursor: inherit; }
.filter-row.locked { color: var(--ink-3); cursor: default; }
.filter-row.locked:hover { background: none; }
.filter-row .n { margin-left: auto; color: var(--ink-3); font-size: calc(13px * var(--ts)); font-variant-numeric: tabular-nums; }
.filter-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.filter-summary { color: var(--ink-3); font-size: calc(13px * var(--ts)); }
#filter-clear { justify-self: end; }
.filter-foot .text-btn { padding: 8px 18px; }
/* a narrow screen: the home header's Settings is just the gear, so the brand and Filter fit */
@media (max-width: 480px) {
  .home-actions { gap: 6px; }
  .home-actions .btn-label { display: none; }
  #home-settings-btn { padding-inline: 10px; }
  .home-brand > div { min-width: 0; }
  .home-title { font-size: calc(26px * min(var(--ts), 1.15)); }
  .home-logo { width: 44px; height: 44px; }
}

/* the summary sheet's foot: Play Chapter beside Play Summary; while a summary is playing, a compact player */
.foot-btns { display: flex; gap: 10px; }
.foot-btns > * { box-sizing: border-box; }
/* Play Chapter and Play Summary look like the key passages' Play from here */
.foot-btns .text-btn { flex: 1 1 0; min-width: 0; justify-content: center; font-family: var(--sans); font-size: calc(14px * var(--ts)); padding: 10px 14px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.foot-btns [hidden] { display: none; }
.mini-player { flex: 1 1 0; padding: 0 14px; display: flex; align-items: center; justify-content: center; min-width: 0; }
.mini-player[hidden] { display: none; }
.mini-player .controls { gap: clamp(6px, 3vw, 16px); }
.mini-player .controls .icon-btn.play, .mini-player .controls .icon-btn.skip { width: 40px; height: 40px; }
.mini-player .controls .icon-btn.skip svg { width: 30px; height: 30px; }
.mini-player .icon-btn.play svg { width: 20px; height: 20px; }
.summary-panel { position: relative; }
#sum-follow { position: absolute; left: 50%; bottom: 84px; translate: -50% 0; }
#sum-follow[hidden] { display: none; }
.summary-body.listening .sw { cursor: pointer; }
/* the word being read in a playing summary: the regular reader's word highlight */
.summary-body .sw { border-radius: 4px; transition: background-color .08s, box-shadow .08s; }
.summary-body .sw.cur { background: var(--hl); color: var(--hl-ink); box-shadow: 0 0 0 2px var(--hl); }

/* the chapter list's first row: History is just its icon on narrow screens; Wikipedia sits at the right */
/* the Wikipedia sheet: the article fills it */
.wiki-body { flex: 1; min-height: 0; position: relative; background: var(--surface); }
.wiki-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.wiki-note { position: absolute; inset: 0; margin: 0; padding: 40px 24px; text-align: center; color: var(--ink-2); background: var(--surface); }
.wiki-note[hidden] { display: none; }

/* ---------- chapters page header, reader bar, search ---------- */
.list-bar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.list-brand { gap: 6px; }
.list-brand .text-btn svg, .list-bar-right .text-btn svg { width: 17px; height: 17px; }
.search-label { display: none; }
@media (orientation: landscape) and (min-width: 700px) { .search-label { display: inline; } }   /* narrower, the mini player needs the room */
#list-search-btn { padding-inline: 10px; }
@media (min-width: 960px) { :root:not(.single-pane) #list-search-btn { display: none; } }   /* the text's bar has it */
.list-header { container-type: inline-size; }
.title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.title-clip { flex: 1; min-width: 0; overflow: hidden; }
.title-clip h1 { margin: 0; will-change: transform; }
#wiki-btn { flex: none; margin-left: 0; }
.btn-line { display: flex; gap: 8px; min-width: 0; max-width: 100%; }
.btn-line > * { flex: none; }
.btn-line #book-summary-btn { margin-right: -24px; }   /* may reach into the header padding when lined up with the Summary buttons */
.btn-line #offline-btn { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.offline-group .offline-status { order: 2; flex-basis: 100%; }
@container (min-width: 520px) {
  .btn-line { display: contents; }
  .offline-group .offline-status { order: 2; flex-basis: auto; }
  .offline-group #history-btn { order: 3; }
  .offline-group #book-summary-btn { order: 4; }
}
@container (max-width: 399px) { .offline-group:has(#book-summary-btn:not([hidden])) .history-label { display: none; } }   /* with Book summary beside it, History is just its icon */
.reader-top-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.reader-top-left #reader-bookmarks-btn { padding-inline: 9px; }
@container rtop (min-width: 560px) { .reader-top-left #reader-bookmarks-btn { padding-inline: 12px; } }
#reader-search-btn { padding-inline: 9px; }
.head-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head-title .eyebrow { margin-bottom: 2px; }
.head-icon { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#bookmarks-foot[hidden] { display: none; }
.search-controls { padding: 12px 22px 8px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
#search-input { width: 100%; box-sizing: border-box; font: inherit; font-size: max(16px, calc(16px * var(--ts))); padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink); }
#search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-scope { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-scope[hidden], #scope-change[hidden], #search-pager[hidden] { display: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--ink-2); padding: 6px 12px; font-size: calc(13px * var(--ts)); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#scope-change { min-width: 0; max-width: 100%; }
#scope-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scope-change svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.search-status { margin: 0; min-height: 1.3em; font-size: calc(12.5px * var(--ts)); color: var(--ink-3); }
.search-hit { cursor: pointer; }
.search-hit .bm-text { font-style: normal; }
.search-hit mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: calc(13px * var(--ts)); color: var(--ink-2); }
@media (min-width: 960px) { :root:not(.single-pane) .list-brand #bookmarks-btn { display: none; } }   /* the text's bar has it */
@media (min-width: 960px) {
  /* the list is hidden: its show button sits in the bar beside the others */
  :root.single-pane .reader-top-left .reader-pane-btn { position: static; transform: none; }
}

/* a short window with the list and text side by side: the mini player is centred in the free space of the text's
   bar, between its left and right buttons (placeMiniControls in app.js sets --mini-center) */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 960px) {
  :root:not(.single-pane) .player .controls { position: absolute; left: var(--mini-center, 50%); top: 50%; transform: translate(-50%, -50%); }
}
/* the two panes' top bars are the same height, so the lines under them meet */
@media (min-width: 960px) and (min-height: 501px) {
  :root:not(.single-pane) .list-bar { padding-top: 8px; padding-bottom: 8px; height: 57px; box-sizing: border-box; }
  :root:not(.single-pane) #reader-view .reader-top { padding-top: 8px; padding-bottom: 8px; height: 57px; box-sizing: border-box; }
}
/* the library in a short window: when the mini player would run into them (fitHomeHeader in app.js), the name and
   tag line go, then Filter's and Settings' labels */
.home-header.hide-brand .home-brand > div { display: none; }
.home-header.hide-filter .filter-label { display: none; }
.home-header.hide-settings .btn-label { display: none; }
.search-field { position: relative; }
.search-field #search-input { padding-right: 42px; }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--ink-3); display: grid; place-items: center; cursor: pointer; }
.search-clear[hidden] { display: none; }
.search-clear svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search-clear:hover { color: var(--accent); }
#search-input::-webkit-search-cancel-button, #search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }   /* our own X */
/* the Abstract / Summary labels in a book's summary page */
.summary-body h3.sum-sec { margin: 22px 0 8px; font-family: var(--sans); font-size: calc(12px * var(--ts)); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.summary-body h3.sum-sec:first-child { margin-top: 4px; }
