/* Reader view */
.reader { flex: 1; display: none; flex-direction: column; min-height: 0; overflow: hidden; }
.reader.active { display: flex; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  background: var(--panel);
  font-size: 13px;
  flex-shrink: 0;
}
/* Hairline only under the topbar title row, soft enough not to read as a stray
   line, so the chrome is clearly delineated from the reading stage. The right
   padding reserves room for the fixed account avatar (top-right, global). */
.topbar { border-bottom: 1px solid var(--border-soft); padding-right: 60px; }
/* Back control reads as navigation, not an action button: borderless, the
   accent chevron leads, and it sits flush at the left edge. */
.back-btn { border-color: transparent; padding-left: 8px; }
.back-btn > svg { color: var(--accent-2); }
.back-btn:hover { border-color: var(--border-soft); }

/* ---------- Unified transport bar (one surface, desktop + mobile) ----------
   ONE responsive control row: ◀ word · Play · word ▶ · Hold · [− WPM + pill] ·
   More · Appearance. Identical structure at every width; only the sizing changes
   (the mobile media query in responsive.css grows the touch targets). Replaces
   the old split slim-bar + bottom-sheet pair, so there is one source of truth. */
.transportbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px max(20px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-right));
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.28);
  flex-shrink: 0;
}
/* Every bar control is the same quiet square chip; Play + the WPM pill + the
   right-hand summon buttons get their own treatment below. */
.tb-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; min-width: 44px; padding: 0 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border-soft); border-radius: var(--control-radius);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--tap), color var(--tap), border-color var(--tap), opacity var(--tap), transform var(--tap);
}
.tb-btn > svg { width: var(--control-icon); height: var(--control-icon); color: var(--muted); transition: color var(--tap); }
.tb-btn:hover { background: var(--elevate); border-color: var(--border); }
.tb-btn:hover > svg { color: var(--text); }
.tb-btn:active { transform: scale(0.96); }
.tb-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tb-btn:disabled { opacity: 0.4; pointer-events: none; }
/* Step buttons are icon-only squares. */
.tb-step { padding: 0; }
/* Play — the PRIMARY action: gold fill, a touch larger, label + icon. Fixed
   min-width so the Play/Pause label swap can't reflow the bar (which would shift
   the focus word). The shared #playBtn rule further below sets the gradient. */
.tb-play {
  min-width: 104px; height: 48px;
  background: var(--accent-2); color: var(--on-accent);
  border-color: transparent; font-weight: 700;
}
.tb-play > svg { color: var(--on-accent); }
.tb-play:hover { background: var(--accent-2-strong); border-color: transparent; }
.tb-play:hover > svg { color: var(--on-accent); }
/* Hold (soft-pause) — fills gold while engaged; dim + non-interactive when not
   reading (soft-pause is play-only). Icon-only. */
.tb-hold { padding: 0; }
.tb-hold.active {
  background: var(--accent-2); color: var(--on-accent); border-color: transparent;
}
.tb-hold.active > svg { color: var(--on-accent); }
/* WPM — the always-on speed dial: −/＋ pill around a live readout. The slider +
   number inputs are hidden mirrors (setWpm writes them); never shown. */
.tb-wpm {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: auto; flex: 0 0 auto;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill); padding: 2px;
}
.tb-wpm-mirror { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tb-wpm-read {
  display: inline-flex; align-items: baseline; gap: var(--space-1);
  padding: 0 6px; color: var(--text);
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.tb-wpm-unit { font-size: 11px; font-weight: 600; color: var(--muted); }
.tb-wpm-nudge {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%;
  background: transparent; border: 0; color: var(--accent-2-strong);
  font-size: 20px; font-weight: 700; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--tap), transform var(--tap);
}
.tb-wpm-nudge:hover { background: var(--elevate); }
.tb-wpm-nudge:active { transform: scale(0.9); }
.tb-wpm-nudge:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* More summon affordance sits at the right end. */
.tb-more { padding: 0 14px; }
/* The Appearance summon button is hidden off-bar (the More sheet forwards to it).
   Kept in the DOM so wireReaderSettingsSheet can bind it by id. */
.visually-hidden-affordance {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.topbar .title {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.topbar .stats { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress {
  height: 3px;
  /* Transparent track — only the filled portion shows, so an unread book doesn't
     render as a stray grey hairline across the top of the reading area. */
  background: transparent;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.progress > div {
  position: absolute;
  inset: 0 auto 0 0;
  /* Silver fill — progress is achievement, not action; matches the catalogue's
     .ds-track > .fill so the reader bar reads the same as the home/library bars. */
  background: linear-gradient(90deg, var(--progress-dim), var(--progress-light));
  width: 0%;
  transition: width .1s linear;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 6px rgba(182, 192, 208, 0.22);
}

.stage {
  flex: 1;
  display: grid;
  /* 3-row grid: spacer | word | spacer/context. Word vertically centred. */
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  justify-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  user-select: none;
  cursor: pointer;
  position: relative;
}
.word-area {
  grid-row: 2;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.word {
  font-size: calc(var(--chunk-size, 70) * 1px);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--reading-font, "Literata"), Georgia, "Times New Roman", serif;
  display: flex;
  align-items: baseline;
  /* line-height 1 clipped descenders (g/y/p) under the stage's overflow:hidden;
     1.25 gives the glyph box room so nothing is cut off. */
  line-height: 1.25;
  white-space: nowrap;
}
.word .pre { color: var(--text); }
.word .orp { color: var(--orp); }
.word .post { color: var(--text); }
.word .upcoming {
  color: var(--preview-ink);
  font-weight: normal;
  white-space: pre;
}
/* Press feedback for the whole-stage play/pause tap target: dim only the focus
   word so the user gets acknowledgement without touching the centring geometry. */
.stage:active .word { transition: opacity var(--tap); opacity: .85; }
/* Lookahead as its own centred line below the focus word. Used on mobile, where
   the inline .upcoming is suppressed (it would shove the focus word off-screen).
   This element sits in .word-area but OUTSIDE #wordEl, so the ORP-centring
   transform never shifts it. */
.upcoming-line {
  display: none;
  color: var(--preview-ink);
  font-weight: normal;
  text-align: center;
  max-width: 100%;
}
/* Inline numeric readout next to a control's label (WPM, Size, …). */
.ctrl-val {
  color: var(--muted);
  font-weight: normal;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.crosshair {
  position: relative;
}
.word .orp { position: relative; }
.word .orp::before, .word .orp::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 1px;
  height: 14px;
  background: var(--orp);
  opacity: 0.55;
  transform: translateX(-0.5px);
  pointer-events: none;
}
.word .orp::before { top: -20px; }
.word .orp::after { bottom: -20px; }
/* Two book columns flank the focus word in paused mode. They are placed in
   grid rows 1 and 3 so the big word in row 2 stays vertically centred at the
   exact same position regardless of column content. Both columns are hidden
   in play mode (innerHTML cleared + display:none via .stage:not(.paused)). */
.context-above,
.context {
  align-self: stretch;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  color: var(--muted);
  font-size: calc(var(--reading-size, 18) * 1px);
  line-height: 1.75;
  /* offsetTop / offsetParent must resolve to the scroller so the centring math
     in render.js measures element offsets *within* the scroller. */
  position: relative;
}
.context-above {
  grid-row: 1;
  /* Past text sits at the visual bottom of the upper region — the most-recent
     past words are right above the big focus word. When content overflows the
     container, the margin-top:auto trick collapses and the scrollbar works
     normally so the user can scroll UP to see earlier text. (Flex with
     justify-content:flex-end is broken for upward overflow in most browsers.) */
  display: flex;
  flex-direction: column;
}
.context-above > *:first-child {
  margin-top: auto;
}
.context {
  grid-row: 3;
  display: block;
}
/* Hide both columns while playing: the big word is the only thing on stage.
   visibility (NOT display:none) so the columns KEEP their layout while hidden:
   the spans stay in the DOM during playback (book-column.js), and a display
   flip would throw that layout away and force a full ~4,000-span relayout of
   justified reading-font text inside the pause keystroke. With visibility the
   pause pays only the O(delta) incremental relayout. Geometry is identical
   either way — the stage's 1fr/auto/1fr grid tracks size independently of the
   columns' content, and hidden elements receive no clicks. */
.stage:not(.paused) .context-above,
.stage:not(.paused) .context {
  visibility: hidden;
}
/* small line above the main word with the words that just passed */
.preview-past {
  color: var(--preview-ink);
  font-size: 13px;
  text-align: center;
  margin-bottom: 24px;
  max-width: 760px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 18px;
}
.preview-past.hidden { display: none; }

/* Bionic reading: bold the first half of each word */

/* Paused: full-document scrollable book columns (above + below focus word). Warm
   off-white ink (not cool grey) so the page reads like paper, not a screen. */
.stage.paused .context-above,
.stage.paused .context {
  color: var(--read-ink);
  text-align: left;
  font-family: var(--reading-font, "Literata"), Georgia, "Times New Roman", serif;
  line-height: 1.62;
  padding: 8px 0;
}
.stage.paused .context-above p,
.stage.paused .context p {
  /* As wide as the Width setting allows, but never past the viewport — so it can
     fill a big monitor without overflowing a phone. (Was a hard 1400px cap.) */
  max-width: min(calc(var(--book-width, 680) * 1px), 96vw);
  margin: 0 auto 1em;
  text-indent: 1.4em;
  padding: 0 16px;
}
.stage.paused .context-above p:first-child,
.stage.paused .context p:first-child { text-indent: 0; }
.stage.paused .context-above .w,
.stage.paused .context .w { cursor: pointer; padding: 0 1px; border-radius: 3px; }
.stage.paused .context-above .w:hover,
.stage.paused .context .w:hover { background: var(--orp-soft); }

/* ---------- Paged reading mode (js/render/pager.js) ----------
   A full-stage overlay that supersedes the RSVP word + scroll columns. The
   .pager-flow is a CSS multi-column flow sized so one column == the box width;
   the engine translateX-es it page by page. The box clips the overflow columns. */
.pager {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  cursor: pointer;
  /* The reading page sits on the same blue-black surface as the book view. */
  background: var(--bg);
  /* Isolate the pager's layout + raster from the rest of the stage. Paint
     containment matches the overflow:hidden clip that's already here, and it
     lets the compositor bound page-turn rasterisation to the pager box instead
     of re-painting the whole multi-page flow strip. */
  contain: layout paint style;
}
/* In paged mode: show the pager, hide every RSVP/scroll surface so the big word
   never peeks through and the stage geometry doesn't fight the overlay. */
.stage.read-paged .pager { display: block; }
.stage.read-paged .word-area,
.stage.read-paged .context,
.stage.read-paged .context-above,
.stage.read-paged .preview-past,
.stage.read-paged .scroller { display: none; }

/* ---------- Continuous-scroll reading mode (js/render/scroll.js) ----------
   One vertically scrollable column of the book; the cursor follows the scroll. */
.scroller {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  cursor: text;
  background: var(--bg);
  color: var(--read-ink);
  font-family: var(--reading-font, "Literata"), Georgia, "Times New Roman", serif;
  font-size: calc(var(--reading-size, 18) * 1px);
  line-height: var(--reading-leading, 1.62);
  text-align: var(--reading-align, justify);
  -webkit-hyphens: auto;
  hyphens: auto;
  padding-block: 30px 64px;
}
.stage.read-scroll .scroller { display: block; }
.stage.read-scroll .word-area,
.stage.read-scroll .context,
.stage.read-scroll .context-above,
.stage.read-scroll .preview-past,
.stage.read-scroll .pager { display: none; }
/* Capped, centred measure (matches the paged view); gutter held on a phone. */
.scroller p { width: min(660px, calc(100% - 36px)); margin: 0 auto 0.85em; text-indent: 1.4em; }
.scroller p:first-child { text-indent: 0; }
.scroller .sw { padding: 0 0.5px; border-radius: 3px; cursor: pointer; }
.scroller .sw:hover { background: var(--orp-soft); }

/* Scroll-mode chrome: the same footer line as the paged view (time left in
   chapter/book at the assumed pace), pinned over the bottom of the scroller
   with the matching gradient fade. Pointer-events none so it never blocks the
   scroll or word taps beneath it. */
.scroll-chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  justify-content: flex-end;
  /* Align with the scroller's centred text measure (min(660px, 100% - 36px)). */
  padding: 18px max(18px, calc((100% - 660px) / 2)) 14px;
  font-size: 12px;
  color: var(--faint);
  font-family: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(0deg, var(--bg) 40%, transparent);
  pointer-events: none;
}
.stage.read-scroll .scroll-chrome { display: flex; }
.scroll-timeleft { color: var(--accent-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.pager-flow {
  position: relative;
  height: 100%;
  /* No horizontal padding here: each page column must stay exactly the box
     width so the engine's pageStep (boxWidth + gap) matches the real column
     advance. The READABLE MEASURE is capped on the paragraphs instead (centred,
     max ~660px), which holds line length sane on wide screens without touching
     the one-column-per-page geometry. */
  padding-block: 30px 64px;
  padding-inline: 0;
  color: var(--read-ink);
  font-family: var(--reading-font, "Literata"), Georgia, "Times New Roman", serif;
  font-size: calc(var(--reading-size, 18) * 1px);
  line-height: var(--reading-leading, 1.62);
  text-align: var(--reading-align, justify);
  -webkit-hyphens: auto;
  hyphens: auto;
  /* Fill each page column top-to-bottom before starting the next (default
     "balance" would even out columns and break the page geometry). */
  column-fill: auto;
  will-change: transform;
  transition: transform .28s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Capped, centred measure (keeps the gutter on a phone too via the calc floor). */
.pager-flow p { width: min(660px, calc(100% - 36px)); margin: 0 auto 0.85em; text-indent: 1.4em; }
.pager-flow p:first-child { text-indent: 0; }
.pager-flow .pw { padding: 0 0.5px; }

/* ---------- Book-quality typography polish (all reading surfaces) ----------
   Proper serif kerning + ligatures (Literata supports them) so the prose reads
   like a typeset book, not a web paragraph; a smarter line-breaker that reduces
   the loose lines / "rivers" and stranded short last-lines that plain justify
   leaves on a narrow phone column; and hyphenation limits so words only break
   when it actually helps (min 6 chars, 3 before / 3 after) — no ugly 2-letter
   fragments. Applies to the RSVP focus word, the paused book columns, and the
   paged + scroll views alike. Pure rendering quality; no layout/setting change. */
.word, .context, .context-above, .scroller, .pager-flow {
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}
.scroller, .pager-flow {
  -webkit-hyphenate-limit-chars: 6 3 3;
  hyphenate-limit-chars: 6 3 3;
}
.scroller p, .pager-flow p, .context, .context-above {
  text-wrap: pretty;
}

/* Chrome: chapter · page X of Y · time-left, pinned to the bottom of the page,
   fading out when the reader taps the centre to dismiss it. */
.pager-chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  /* Align the chrome's gutters with the capped text measure above. */
  padding: 10px max(24px, calc((100% - 660px) / 2)) 14px;
  font-size: 12px;
  color: var(--faint);
  font-family: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(0deg, var(--bg) 40%, transparent);
  pointer-events: none; /* taps fall through to the zones; controls re-enable below */
  transition: opacity var(--tap);
}
.pager.chrome-hidden .pager-chrome { opacity: 0; }
.pager-chapter {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.pager-meta { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager-dot { margin: 0 6px; opacity: 0.6; }
.pager-timeleft { color: var(--accent-2); }


.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ctrl label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.ctrl input[type=number] {
  width: 80px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  font: inherit;
}
.pill {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  color: var(--muted);
  font-size: 12px;
}
.kbd {
  display: inline-block;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  font: 11px ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  background: var(--panel-2);
}
.spacer { flex: 1; }
/* TERTIARY / UTILITY — a compact, quiet neutral pill. ONE radius (--radius-pill)
   across every .small-btn so the utility chips share the segmented-control's pill
   language. Keeps the 32px height-lock so reader-topbar icons never shift the row. */
.small-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  /* Fixed height + line-height so the inline SVG icons can't change the button
     height and ripple a row-shift up to the focus word. */
  line-height: 1;
  height: 32px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tap), border-color var(--tap), color var(--tap);
}
.small-btn:hover { background: var(--elevate); color: var(--text); border-color: transparent; }
.small-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-2-soft); }
/* Icons sit a touch quieter than the label, then both lift on hover/active. */
.small-btn > svg { color: var(--muted); transition: color var(--tap); }
.small-btn:hover > svg { color: var(--text); }
.small-btn.toggle.active {
  background: var(--accent-2-soft);
  border-color: var(--accent-2);
  color: var(--text);
}
.small-btn.toggle.active > svg { color: var(--accent-2); }
/* Play is the PRIMARY action — accent gradient so it reads as the one thing to
   press. Fixed min-width keeps the bar from reflowing as the label toggles
   Play/Pause (which would shift the focus word vertically). Sizing comes from
   .tb-play (transport bar); this only paints the gradient + shadow. */
#playBtn {
  background: linear-gradient(180deg, var(--accent-2-strong), var(--accent-2));
  color: var(--on-accent);
  border: none;
  box-shadow: var(--shadow-sm);
}
#playBtn > svg { color: var(--on-accent); }
#playBtn:hover { background: linear-gradient(180deg, var(--accent-2-strong), var(--accent-2)); border: none; filter: brightness(1.06); }
#playBtn:hover > svg { color: var(--on-accent); }

/* ---------- Reader settings: a SUMMONED bottom sheet (DESIGN-SYSTEM §2b) ----------
   The reader SETTINGS (position, sizes, modes, chunk, lookahead, phrase jump)
   are a summoned, dismissible bottom sheet — NOT inline reader chrome — so a
   closed sheet returns the reading space. Only Play + transport + WPM +
   "Settings" affordance show by default. The sheet is modeled on the Add sheet
   (#add-sheet): backdrop + grip + swipe/Esc/backdrop dismiss (one dismiss model,
   §2.4). .adv just holds the controls; the sheet is the surface. */
#readerSettingsBackdrop {
  position: fixed; inset: 0; z-index: 48;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base, 240ms) var(--ease-standard, ease);
}
body.settings-open #readerSettingsBackdrop { opacity: 1; pointer-events: auto; }

.reader-settings-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 49;
  max-height: 80dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  border-top: 1px solid var(--border);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.55);
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform var(--spring);
}
body.settings-open .reader-settings-sheet { transform: translateY(0); }

/* The grip is the drag-to-dismiss handle (wireup.js), matching the Add sheet:
   a touch-only hit area around the visible pill; touch-action:none lets the drag
   own the vertical gesture cleanly. */
.reader-settings-sheet .sheet-grip {
  position: relative;
  height: 26px; margin: -4px auto 4px;
  display: block; width: 100%;
  cursor: grab; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.reader-settings-sheet .sheet-grip:active { cursor: grabbing; }
.reader-settings-sheet .sheet-grip::before {
  content: ""; position: absolute; left: 50%; top: 11px; transform: translateX(-50%);
  width: 40px; height: 4px; border-radius: 999px; background: var(--border);
}
.reader-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.reader-settings-head h3 { margin: 0; font-size: 16px; font-weight: 650; }

.adv {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.adv .ctrl { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
.adv .ctrl > label { min-width: 84px; }
.adv .ctrl input[type=range] { flex: 1; min-width: 120px; }

/* Grouped, priority-ordered panel: labelled sections (Reading speed & flow /
   Text & layout / Find in book), each a column; a hairline divides them. The
   numeric rows inside #grp* are DsStepper components (js/ds/stepper.js). */
.adv-group { display: flex; flex-direction: column; gap: 14px; }
.adv-group + .adv-group { border-top: 1px solid var(--border-soft); padding-top: 16px; }
.adv-group-title { margin: 0; }
.adv-steppers { display: flex; flex-direction: column; gap: 18px; }
.adv-effects { flex-wrap: wrap; }

/* Read-mode + words-at-once segmented view-switchers fill the row like a field. */
.adv .ctrl #readModeSeg,
.adv .ctrl #chunkSeg { flex: 1; min-width: 180px; display: flex; }
.adv .ctrl #readModeSeg .seg-item,
.adv .ctrl #chunkSeg .seg-item { flex: 1; }

/* The More sheet's Navigate + Find rows wrap their button clusters; the seg rows
   above already fill the row. Keep the nav/find clusters tidy on a narrow sheet. */
.more-nav, .more-find { flex: 1; flex-wrap: wrap; gap: 8px; }
.more-find #phraseJumpInput { flex: 1; min-width: 140px; }

/* Reading-font disclosure: a field-styled button that summons the choice list. */
.adv .ctrl-disclosure {
  flex: 1; min-width: 140px;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
  color: var(--text); font: inherit; cursor: pointer;
  transition: border-color var(--tap, 140ms);
}
.adv .ctrl-disclosure:hover { border-color: var(--accent-2); }
.adv .ctrl-disclosure:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ctrl-disclosure-value { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctrl-disclosure-chevron {
  flex: 0 0 auto; width: 8px; height: 8px;
  border-right: 2px solid var(--faint); border-top: 2px solid var(--faint);
  transform: rotate(45deg);
}
.adv .meta-row { padding-top: 4px; border-top: 1px solid var(--border-soft); }

/* ---------- Desktop form: a CENTERED, max-width floating panel ----------
   On a wide screen the full-bleed mobile bottom sheet stretched controls across
   the whole window (segmented rows edge-to-edge; steppers stranded mid-row with a
   stub slider and a sea of empty space on the left). A reading-settings panel is
   not a phone sheet here — constrain it to a comfortable column, centered, so every
   row is a tidy full-width row of that column. */
@media (min-width: 641px) {
  .reader-settings-sheet {
    left: 50%;
    right: auto;
    width: min(620px, 94vw);
    bottom: 28px;
    max-height: min(78dvh, 760px);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 14px 24px 24px;
    transform: translate(-50%, calc(100% + 48px));
  }
  body.settings-open .reader-settings-sheet { transform: translate(-50%, 0); }
  /* Every control fills the panel column: label hard-left, value cluster hard-right,
     slider full-width beneath — consistent with the segmented rows above. */
  .adv-steppers { align-items: stretch; }
  .adv-steppers .ds-stepper { width: 100%; max-width: none; }
  .ds-stepper-head { width: 100%; }
}

.meta-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--faint);
  font-size: 12px;
}
.meta-row b { color: var(--muted); font-weight: 500; }

.chapters-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  /* Vertical scroll stays native; horizontal (swipe-right-to-close) is ours. */
  touch-action: pan-y;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 10;
  padding: 20px;
}
.chapters-panel.open { transform: translateX(0); }
/* Chapters-panel close — now a DsIconButton (.ds-icon-btn in markup); the 44px
   target / box / hover come from .ds-icon-btn. Only its absolute placement
   inside the panel lives here. */
.panel-close {
  position: absolute;
  top: 4px;
  right: 4px;
}
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 9;
}
.panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.chapters-panel h3 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.chapter-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  border-left: 2px solid transparent;
  margin-bottom: 4px;
}
.chapter-item:hover { background: var(--panel-2); }
.chapter-item.current {
  background: var(--panel-2);
  border-left-color: var(--orp);
}
.chapter-item .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}


/* "Followed the sync" chip (reader-follow.js): the open reader advanced to a
   furthest position read on another device. Quiet diagnostic voice — muted
   pill, top-centre over the stage, self-fades. Never a toast, never a modal. */
.sync-chip {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s;
  z-index: 5;
}
.sync-chip.show { opacity: 1; }
