:root { --text-size: 1.25em; }

/* Make the `hidden` attribute always win. Without this, any element that
   also has an author rule setting `display` (e.g. `.chapter-nav{display:flex}`,
   `.controls{display:grid}`) stays visible despite `el.hidden = true`, because
   normal-priority author CSS overrides the browser's built-in
   `[hidden]{display:none}` regardless of selector specificity or source order.
   This was already worked around ad hoc for .help-modal; this rule fixes it
   globally instead of requiring a [hidden] override per component. */
[hidden] { display: none !important; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #faf7f2;
  color: #2b2b2b;
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════════════
 * HOME PAGE (library view) — books/stories catalog
 * ════════════════════════════════════════════════════════════════ */
#libraryView { padding-bottom: 40px; }

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid #e6e0d6;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.brand-icon { width: 36px; height: 36px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 1.25em; font-weight: 700; color: #2b6777; }
.brand-sub  { font-size: 0.68em; color: #999; font-style: italic; margin-top: 1px; }

.search-wrap {
  flex: 1;
  display: flex;
  max-width: 560px;
  border: 1px solid #e6e0d6;
  border-radius: 8px;
  overflow: hidden;
  background: #faf7f2;
}
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 12px;
  font-size: 0.9em;
  outline: none;
  min-width: 0;
  font-family: inherit;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}
.tbtn {
  background: #2b6777;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tbtn:hover { background: #1f4d59; }
.tbtn .icon-svg { display: block; flex-shrink: 0; }
.tbtn.ghost { background: none; color: #2b6777; border: 1px solid #2b6777; }
.tbtn.ghost:hover { background: #eef6f7; }
.sort-select {
  border: 1px solid #e6e0d6;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.85em;
  background: #fff;
  color: #2b2b2b;
  cursor: pointer;
  font-family: inherit;
}

/* ── View tabs (Books / Stories — desktop only) ──────────── */
.view-tabs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 20px 0;
  display: flex;
}
.view-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 8px 4px;
  margin-right: 22px;
  font-size: 1em;
  font-weight: 600;
  color: #999;
  cursor: pointer;
}
.view-tab.active { color: #2b6777; border-bottom-color: #2b6777; }

/* ── Filter panel ─────────────────────────────────────────── */
.filter-panel {
  position: relative;
  max-width: 1280px;
  margin: 10px auto 0;
  padding: 16px 44px 16px 20px;
  background: #fff;
  border: 1px solid #e6e0d6;
  border-radius: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}
.filter-panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.1em;
  cursor: pointer;
  color: #aaa;
}
.filter-panel-close:hover { color: #555; }
.filter-panel-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  font-size: 0.95em;
  color: #2b6777;
}
.filter-group h4 {
  margin: 0 0 8px;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}
.filter-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88em;
  margin-bottom: 6px;
  cursor: pointer;
}
.filter-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e6e0d6;
  border-radius: 6px;
  font-size: 0.88em;
  background: #faf7f2;
  font-family: inherit;
}
.filter-actions { display: flex; align-items: flex-end; gap: 8px; }
.filter-actions button { font-size: 0.85em; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
.filter-actions .apply { background: #2b6777; color: #fff; border: none; }
.filter-actions .clear { background: none; border: 1px solid #e6e0d6; color: #999; }

/* ── Main container ───────────────────────────────────────── */
.home-main { max-width: 1280px; margin: 0 auto; padding: 20px 20px 90px; }

.home-topline {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px 16px;
  margin-bottom: 14px;
}
.legend-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef6f7;
  color: #2b6777;
  border: none;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.info-dot { opacity: 0.7; }

/* ── Search / filter "you're looking at a filtered view" indicators ── */
.search-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff3e6;
  color: #8a4b00;
  border: 1px solid #f0d4b0;
  border-radius: 14px;
  padding: 5px 6px 5px 12px;
  font-size: 0.78em;
  flex-shrink: 0;
}
.search-indicator button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1em;
  padding: 2px 4px;
}
.active-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.clear-filters-chip {
  background: none;
  border: 1px solid #2b6777;
  color: #2b6777;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.clear-filters-chip:hover { background: #eef6f7; }
.filter-chips { display: flex; gap: 6px; }
.filter-chip {
  background: #eef6f7;
  color: #2b6777;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 0.78em;
  white-space: nowrap;
  flex-shrink: 0;
}

.empty-msg { color: #888; font-size: 0.9em; padding: 30px 0; text-align: center; }

/* ── RWT badges (shared by book cards + story rows) ──
   full    = solid accent, confident
   partial = pale accent tint, same hue but low-contrast ("some, not all")
   none    = pale grey, barely-there — never omitted, always all three shown
*/
.rwt { display: inline-flex; gap: 3px; }
.rwt-chip {
  width: 20px; height: 20px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68em;
  font-weight: 700;
}
.rwt-chip.full    { background: #2b6777; color: #fff; }
.rwt-chip.partial { background: #cfe8ec; color: #2b6777; }
.rwt-chip.none    { background: #f0ede6; color: #ddd7cc; }

/* ── Books grid ───────────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 24px;
}
.book-card { cursor: pointer; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.book-cover-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.14);
  transition: transform .15s, box-shadow .15s;
  aspect-ratio: 2 / 3;
  background: #ddd;
}
.book-card:hover .book-cover-wrap {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.22);
}
.book-cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-recent-flag {
  position: absolute;
  top: 6px; left: 6px;
  background: #b15a00;
  color: #fff;
  font-size: 0.62em;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}
.book-rwt-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
  padding: 16px 6px 6px;
  display: flex;
  justify-content: center;
}
.book-meta { margin-top: 8px; }
.book-title { font-size: 0.92em; font-weight: 600; line-height: 1.3; }
.book-author { font-size: 0.8em; color: #888; margin-top: 1px; }
.book-count { font-size: 0.74em; color: #999; margin-top: 3px; }

/* ── Stories table (desktop) ─────────────────────────────── */
.stories-table-wrap { background: #fff; border: 1px solid #e6e0d6; border-radius: 10px; overflow: hidden; }
.stories-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.stories-table th {
  text-align: left;
  padding: 12px 14px;
  background: #faf7f2;
  border-bottom: 1px solid #e6e0d6;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.stories-table th:hover { color: #2b6777; }
.stories-table th.sorted { color: #2b6777; }
.stories-table th .arrow { font-size: 0.9em; margin-left: 3px; opacity: 0.6; }
.stories-table td { padding: 12px 14px; border-bottom: 1px solid #e6e0d6; vertical-align: middle; }
.stories-table tr:last-child td { border-bottom: none; }
.stories-table tbody tr { cursor: pointer; }
.stories-table tbody tr:hover { background: #eef6f7; }
.story-title-cell { font-weight: 600; }
.story-title-bn { font-weight: 400; font-size: 0.85em; color: #888; margin-top: 2px; }
.story-book-cell { display: flex; align-items: center; gap: 6px; color: #888; font-size: 0.95em; }
.story-book-thumb { width: 18px; height: 26px; object-fit: cover; border-radius: 2px; flex-shrink: 0; }
.buy-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #b15a00;
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}
.buy-link:hover { text-decoration: underline; }

/* ── Stories list (mobile cards) ─────────────────────────── *
 * Two lines of text (title, book·author·year·buy) beside the cover thumb.
 * R/W/T badges float in the card's top-right corner (there's room for it in
 * a single-row card) and are allowed to sit over the title if it's long.
 * ─────────────────────────────────────────────────────────── */
.stories-list { display: none; flex-direction: column; gap: 10px; }
.story-row-card {
  position: relative;
  background: #fff;
  border: 1px solid #e6e0d6;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.story-row-thumb {
  width: 44px;
  height: 62px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.story-row-rwt-overlay {
  position: absolute;
  top: 8px;
  right: 10px;
  display: flex;
  gap: 2px;
}
.story-row-rwt-overlay .rwt-chip { width: 16px; height: 16px; border-radius: 3px; font-size: 0.55em; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.story-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.story-row-title { font-weight: 600; font-size: 0.95em; }
.story-row-title .story-title-bn { display: block; margin-top: 1px; }
.story-row-sub { font-size: 0.78em; color: #888; }
.story-row-sub .buy-link { margin-left: 2px; }

/* ── Modals (Disclaimer / More / RWT legend) ─────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 26px;
  position: relative;
}
.modal-box h3 { margin: 0 0 12px; color: #2b6777; }
.modal-box p { margin: 0 0 8px; color: #555; font-size: 0.9em; line-height: 1.5; }
.modal-placeholder { font-style: italic; color: #999; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 1.1em; cursor: pointer; color: #aaa; }
.modal-close:hover { color: #555; }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid #eee;
  padding: 12px 4px;
  font-size: 0.95em;
  color: #2b2b2b;
  cursor: pointer;
}
.menu-item:hover { color: #2b6777; }

/* ── More popover (mobile) — pulls up from the bottom-right corner above
   the More nav button, like a native action sheet, instead of a centered
   modal. Transparent backdrop just catches outside taps to close it. ── */
.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: transparent;
}
.more-popover {
  position: fixed;
  right: 10px;
  bottom: calc(var(--bottom-nav-h) + 10px);
  z-index: 91;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  min-width: 170px;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.16s ease;
}
.more-popover.open { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }
.more-popover .menu-item { border-top: none; padding: 12px 16px; }

/* ── Bottom nav (mobile, Kindle-style) ───────────────────── */
:root { --bottom-nav-h: 58px; }
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: #fff;
  border-top: 1px solid #e6e0d6;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-inner { display: flex; height: 100%; }
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  padding: 8px 2px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #888;
  cursor: pointer;
  font-size: 0.65em;
}
.bottom-nav button .icon { font-size: 1.35em; line-height: 1; }
/* Mirrors the desktop .view-tab.active treatment (color + underline) so it's
   equally clear which tab (Books/Stories) is currently active — only
   data-view buttons ever get .active (see setHomeView in app.js), Search/
   Filter/More are momentary actions, not a "where am I" state. */
.bottom-nav button[data-view] { position: relative; }
.bottom-nav button[data-view].active { color: #2b6777; font-weight: 700; }
.bottom-nav button[data-view].active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: #2b6777;
}

/* ── Mobile search: slim bar above the bottom nav (not a full-screen sheet),
   so results stay visible behind it as the reader types. Stays open/pinned
   with the query showing as long as a search is active — see syncMobileSearchBar()
   in app.js — with Clear (✕) both emptying the query and sliding it away. ── */
.mobile-search-overlay {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--bottom-nav-h);
  background: #faf7f2;
  border-top: 1px solid #e6e0d6;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  z-index: 25; /* below bottom-nav (30) so the nav is never covered */
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.mobile-search-overlay.open { transform: translateY(0); opacity: 1; }
.mobile-search-overlay .row { display: flex; gap: 8px; }
.mobile-search-overlay input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e6e0d6;
  border-radius: 8px;
  font-size: 0.95em;
  font-family: inherit;
}
.mobile-search-overlay button.cancel {
  background: none;
  border: none;
  color: #2b6777;
  font-weight: 700;
  font-size: 1.15em;
  padding: 0 6px;
}

@media (min-width: 769px) {
  .stories-table-wrap { display: block; }
  .stories-list { display: none !important; }
  /* Mobile-only slim search bar: JS shows/hides it purely from search state
     (see syncMobileSearchBar in app.js), with no viewport check of its own —
     force it off on desktop regardless of that state. */
  .mobile-search-overlay { display: none !important; }
}

@media (max-width: 768px) {
  .topbar-inner { padding: 8px 12px; gap: 8px; }
  .brand-icon { width: 28px; height: 28px; }
  .brand-name { font-size: 1.05em; }
  .brand-sub { font-size: 0.62em; }
  .search-wrap { display: none; } /* replaced by the Search icon in the bottom nav */
  .topbar-actions .tbtn span.label { display: none; }
  .topbar-actions .tbtn { padding: 8px 10px; }
  .tbtn.ghost { display: none; } /* Disclaimer moves into the "More" sheet on mobile */

  .view-tabs { display: none; } /* view switch happens via the bottom nav on mobile */

  .home-main { padding: 14px 12px 84px; }

  .filter-panel {
    position: fixed; inset: 0; z-index: 95;
    border-radius: 0; margin: 0; max-height: 100vh; overflow-y: auto;
    grid-template-columns: 1fr;
    padding-top: 46px;
  }

  /* RWT icon + active-filter chips share one row; search indicator lives in
     the slim mobile search bar instead (see .mobile-search-overlay) */
  .home-topline { margin-bottom: 10px; }
  .search-indicator { display: none; }

  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .book-title { font-size: 0.85em; }

  .stories-table-wrap { display: none; }
  .stories-list { display: flex !important; }

  .bottom-nav { display: block; }
}

/* ── Reader: toolbar — left icon | centered title | right controls ── */
.controls {
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  background: #faf7f2;
  padding: 7px 14px;
  min-height: 46px; /* room for the two-line book/chapter title in .ctrl-center */
  border-bottom: 1px solid #ddd;
  z-index: 5;
}

/* Left: back button */
.ctrl-left { display: flex; flex-shrink: 0; }

/* Bare icon buttons — no box, just the teal icon */
.icon-nav {
  color: #2b6777;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
  flex-shrink: 0;
}
.icon-nav:hover { opacity: 0.6; }
.icon-nav svg   { fill: currentColor; display: block; }
.icon-nav svg * { fill: currentColor !important; }

/* Center: title absolutely centered relative to the full toolbar width.
   Two stacked lines — book title, then (when applicable) the current
   chapter/story title — nudged slightly above true vertical center via
   `top: 46%` so the (larger) book title reads as the anchor line. */
.ctrl-center {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 200px); /* keeps title clear of left/right controls */
  text-align: center;
  pointer-events: none; /* clicks pass through to controls beneath */
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.tbar-title-bn, .tbar-title-rom, .tbar-title-en {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tbar-title-bn  { font-family: 'Noto Sans Bengali', 'Nirmala UI', sans-serif; color: #2b2b2b; }
.tbar-title-rom { font-family: Georgia, 'Palatino Linotype', serif; color: #555; }
.tbar-title-en  { font-family: Georgia, 'Palatino Linotype', serif; color: #555; }
.tbar-booktitle { font-size: 0.95em; font-weight: 600; }
.tbar-subtitle  { font-size: 0.72em; opacity: 0.72; margin-top: 1px; }

/* Right: script mode + toggles + font + help */
.ctrl-right {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  margin-left: auto; /* push to the right edge */
}

/* Gear icon: desktop hidden, mobile visible.
   Not a .ctrl button, so no specificity conflict with button.ctrl display rule. */
.mobile-menu-btn { display: none; }

/* footer-nav-row: visible on both mobile and desktop when multi-page */

/* Muted style for features not yet available for this title — pale and
   low-contrast on purpose, so it reads as disabled at a glance */
button.ctrl.unavailable {
  background: #e6e6e3;
  color: #aaaaaa;
  font-style: italic;
  cursor: default;
}
button.ctrl.unavailable:hover { background: #e6e6e3; }
/* Cancel .script-group's opacity:0.5 dimming so the English button looks
   identical to the standalone Gloss button when both are "unavailable" */
.script-group .ctrl.unavailable { opacity: 1; }

/* Settings panel: desktop = inline flex; mobile = fixed dropdown with animation */
.settings-panel {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

/* Script mode radio-style group */
.script-group { display: flex; }
.script-group .ctrl {
  border-radius: 0;
  opacity: 0.5;
  padding: 4px 10px;
}
/* edge-left/edge-right are assigned in JS (applyCapabilityUI) instead of
   :first-child/:last-child because those structural selectors ignore the
   [hidden] attribute — with a button hidden, the visible edge button would
   otherwise keep a square corner. */
.script-group .ctrl.edge-left  { border-radius: 6px 0 0 6px; }
.script-group .ctrl.edge-right { border-radius: 0 6px 6px 0; }
.script-group .ctrl.active      { opacity: 1; }

/* Shared button styles */
button.ctrl, a.ctrl {
  background: #2b6777;
  color: white;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  white-space: nowrap;
  display: inline-block;
}
button.ctrl:hover, a.ctrl:hover { background: #1f4d59; }
button.ctrl.off { background: #aaa; }

/* Help button */
.ctrl-help {
  font-weight: bold;
  padding: 5px 10px;
}

.fontsize-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.fontsize-group button {
  background: #fff;
  border: 1px solid #ccc;
  color: #2b6777;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85em;
}
.fontsize-group button:hover { background: #eef6f7; }
.fontsize-label { font-size: 0.75em; color: #777; margin: 0 3px; min-width: 32px; text-align: center; }

/* ── Reader layout: arrows + reading column ──────────────── */
.reader-layout {
  display: flex;
  align-items: flex-start;
}

/* ── Pagination arrows ────────────────────────────────────── *
 *                                                             *
 * The ‹ and › buttons sit on the left and right of the       *
 * reading column and are hidden (HTML hidden attribute) when  *
 * the entire story fits on one page, disabled (opacity 0.18) *
 * at the first / last page, and fully enabled otherwise.     *
 *                                                             *
 * Visibility and disabled state are set in updateArrows()    *
 * in app.js after every page render.                         *
 * ─────────────────────────────────────────────────────────── */
/* Side arrows removed — navigation via footer buttons + keyboard ← → */
.page-arrow { display: none; }

/* ── Reading column — full width between arrows ──────────── */
.reading-col {
  flex: 1;
  min-width: 0;
  padding: 16px 0 100px;
}

/* ════════════════════════════════════════════════════════════
 * PAGINATION LAYOUT — CRITICAL, DO NOT CHANGE WITHOUT READING
 * ════════════════════════════════════════════════════════════
 *
 * The DOM-based pagination in app.js (findPageEnd / storyOverflows)
 * depends entirely on this layout to produce a #story container with
 * a fixed, known pixel height and overflow:hidden. Here is how it
 * is constructed and why every rule matters:
 *
 * 1. body[data-view="reader"] → height:100vh, overflow:hidden
 *    The body becomes exactly one screen tall with no scrollbar.
 *    This is the foundation — everything else sizes relative to it.
 *
 * 2. #readerView → flex column, height:100vh, overflow:hidden
 *    The reader fills the body. Flex column = toolbar + layout stacked.
 *
 * 3. .controls → flex-shrink:0
 *    Toolbar takes its natural height and does not flex. Remaining
 *    vertical space goes entirely to .reader-layout below it.
 *
 * 4. .reader-layout → flex:1, min-height:0, align-items:stretch
 *    Expands to fill all space below the toolbar.
 *    align-items:stretch makes .reading-col fill the full height.
 *    min-height:0 is required on flex children to allow shrinking
 *    below their content size (browser default is min-height:auto).
 *
 * 5. .reading-col → height:100%, flex column, overflow:hidden
 *    The column between the arrows. Flex column stacks storyHead +
 *    contentView. overflow:hidden clips any residual overflow.
 *
 * 6. #contentView → flex:1, min-height:0, flex column, overflow:hidden
 *    Expands to fill all space below storyHead. Contains #story.
 *
 * 7. .story → flex:1, min-height:0, overflow:hidden  ← KEY
 *    This is the element whose height the pagination measures.
 *    flex:1 gives it all available vertical space in the column.
 *    min-height:0 lets it shrink properly.
 *    overflow:hidden clips content that doesn't fit — visually hiding
 *    any overflow that the pagination measurement detected.
 *
 * HOW storyOverflows() USES THIS:
 *   getBoundingClientRect() on #story gives the exact pixel rectangle
 *   of the visible area. getBoundingClientRect() on the last rendered
 *   word/sentence span gives its actual position. If that element's
 *   bottom > container bottom → vertical overflow (single column).
 *   If that element's left >= container right → horizontal overflow
 *   (3rd CSS column in the 2-column layout below).
 *
 * IF YOU CHANGE THIS LAYOUT:
 *   Any change that alters the computed height of #story will change
 *   where page breaks fall. That is fine as long as the DOM-based
 *   measurement still works (i.e. #story has a non-zero clientHeight
 *   and overflow:hidden). What must NOT happen:
 *   • Do not add overflow:auto/scroll to #story (breaks measurement)
 *   • Do not remove overflow:hidden from #story (content won't clip)
 *   • Do not give #story a fixed pixel height that ignores the viewport
 *   • Do not hide #story's parent before calling renderCurrentPage()
 * ════════════════════════════════════════════════════════════ */
body[data-view="reader"] {
  height: 100vh;
  overflow: hidden;
}
body[data-view="reader"] #readerView {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-view="reader"] .controls {
  position: relative; /* body doesn't scroll, no need for sticky */
  flex-shrink: 0;
}
body[data-view="reader"] .reader-layout {
  flex: 1;
  min-height: 0;
  align-items: stretch; /* reading-col stretches full height */
}
body[data-view="reader"] .page-arrow {
  align-self: center; /* vertically centre the arrows */
  flex-shrink: 0;
}
body[data-view="reader"] .reading-col {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 0 78px; /* clear the two-row fixed footer (~79 px tall) */
  box-sizing: border-box;
}
body[data-view="reader"] #storyHead { flex-shrink: 0; }
body[data-view="reader"] #contentView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body[data-view="reader"] .story {
  flex: 1;       /* fills all remaining vertical space */
  min-height: 0; /* allows flex child to shrink below content size */
  overflow: hidden; /* clips overflow — pagination keeps content within bounds */
}
/* ── TOC (chaptered works) ───────────────────────────────── */
.toc-title { font-size: 1em; margin: 0 0 10px; padding: 0 20px; }
.toc-list  { padding-left: 2.2em; }
.toc-list li { margin: 8px 0; }
.toc-list a  { color: #2b6777; text-decoration: none; }
.toc-list a:hover { text-decoration: underline; }

/* ── Story/chapter list modal (chapterListModal) ─────────────
   Reskinned as a proper card list — number chip, title (in the reader's
   current script), RWT badges — instead of a bare bulleted link list. */
.chapter-list-content {
  max-width: 440px;
  width: 92%;
  max-height: 76vh;
  padding: 22px 22px 16px;
  display: flex;
  flex-direction: column;
}
.chapter-list-content h3 { flex-shrink: 0; padding: 0 4px; }
.chapter-list-content .toc-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  overflow-y: auto;
}
.chapter-list-content .toc-item { margin: 0; border-bottom: 1px solid #efeae0; }
.chapter-list-content .toc-item:last-child { border-bottom: none; }
.chapter-list-content .toc-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-radius: 7px;
  color: #2b2b2b;
  text-decoration: none;
  transition: background 0.15s ease;
}
.chapter-list-content .toc-item a:hover { background: #f6f2ea; text-decoration: none; }
.chapter-list-content .toc-item-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f0ede6;
  color: #999;
  font-size: 0.72em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chapter-list-content .toc-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95em;
}
.chapter-list-content .toc-item.active a { background: #eaf3f4; }
.chapter-list-content .toc-item.active .toc-item-num { background: #2b6777; color: #fff; }
.chapter-list-content .toc-item.active .toc-item-title { color: #2b6777; font-weight: 700; }
.chapter-list-content .rwt { flex-shrink: 0; }
.chapter-list-content .rwt-chip { width: 18px; height: 18px; font-size: 0.62em; }

/* ── Story text ──────────────────────────────────────────── *
 *                                                             *
 * PAGINATION-RELEVANT PROPERTIES — read before changing:     *
 *                                                             *
 * column-count: 2                                            *
 *   Desktop layout has two columns. The pagination overflow  *
 *   check in storyOverflows() handles this specifically:     *
 *   content that doesn't fit fills a virtual 3rd column to  *
 *   the right, which is clipped by overflow:hidden on        *
 *   .story. The last element in that 3rd column has          *
 *   left >= container.right, which is the overflow signal.  *
 *                                                             *
 * column-fill: auto                                          *
 *   CRITICAL. 'auto' fills column 1 top-to-bottom first,   *
 *   then column 2. 'balance' (browser default) would split  *
 *   content equally between columns, which would change the  *
 *   overflow behavior and break storyOverflows() detection. *
 *                                                             *
 * @media (max-width: 768px) → column-count: 1               *
 *   On mobile there is only one column. Overflow goes        *
 *   downward (vertical), detected by                         *
 *   eRect.bottom > cRect.bottom. storyOverflows() checks    *
 *   both directions so this switch is handled automatically. *
 *                                                             *
 * box-sizing: border-box                                     *
 *   Padding is included in the element's measured width/     *
 *   height. getBoundingClientRect() returns the border box,  *
 *   so content must also be measured within the same box.   *
 * ─────────────────────────────────────────────────────────── */
.story {
  font-size: var(--text-size);
  font-family: Georgia, 'Bookerly', 'Palatino Linotype', serif;
  background: #fff;
  padding: 28px 40px;
  line-height: 1.75;
  user-select: text;
  column-count: 2;
  column-gap: 52px;
  column-rule: 1px solid #e6e0d6;
  column-fill: auto;   /* fill left column first, then right — NO balancing */
  text-align: justify;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  /* Single column on mobile — overflow goes vertically, still detected correctly */
  .story { column-count: 1; padding: 16px 20px; }

  /* Gear button: visible on mobile */
  .mobile-menu-btn { display: flex; }

  /* Settings panel: animated dropdown from below toolbar */
  .settings-panel {
    position: fixed;
    top: 0;            /* overridden by JS on open */
    left: 0;
    right: 0;
    background: #faf7f2;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 0 14px;   /* vertical padding transitions with max-height */
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    z-index: 6;
    /* Collapse animation */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.32s ease, opacity 0.25s ease, padding 0.32s ease;
  }
  .settings-panel.open {
    max-height: 160px;
    opacity: 1;
    padding: 10px 14px;
  }


  /* Show floating panel when JS adds .open */
  .slider-panel.open { display: flex; }

  /* Toolbar title: less horizontal room on mobile (icons take more of the bar) */
  .ctrl-center { max-width: calc(100% - 120px); }
}
.bn { font-family: 'Noto Sans Bengali', 'Nirmala UI', sans-serif; }

/* Story paragraphs — source.md block structure */
.story p {
  margin: 0 0 0.85em;
}
.story p.par-center {
  text-align: center;
  font-style: italic;
}
.story p.par-heading {
  font-size: 1.1em;
  font-weight: bold;
  text-align: center;
  margin: 1.4em 0 0.6em;
  font-style: normal;
}

/* Inline chapter/story title injected at a segment boundary (see
   maybeInjectSegmentTitle in app.js) — distinct from par-heading, which
   comes from a story's own source.md markdown headings. break-before:column
   only takes effect when JS's findPageEnd has already decided to extend a
   page across the boundary (empty 2nd column on desktop) — it never creates
   an empty column, it just places this element at the top of the next one.
   No mobile-specific rule needed: findPageEnd hard-stops at every segment
   boundary on narrow screens, so this element is always the first thing
   rendered on its page there. */
.story p.par-segtitle {
  font-size: 1.35em;
  font-weight: 800;
  text-align: center;
  margin: 2.2em 0 0.8em;
  font-style: normal;
}
@media (min-width: 769px) {
  .story p.par-segtitle {
    break-before: column;
    break-inside: avoid;
  }
}

/* English mode: inline flowing prose (no per-sentence line break) */
.en-sentence { /* inline by default — sentences flow as continuous prose */ }

/* ── Bengali / Roman word spans ──────────────────────────── *
 *                                                             *
 * PAGINATION-RELEVANT — these rules directly affect word     *
 * height, which determines how many words fit per page.      *
 * Any change here WILL change page boundaries.              *
 *                                                             *
 * Each word is a .word span (inline-block) containing up to  *
 * three child spans stacked vertically:                      *
 *   .gloss     (top)    — English meaning, hidden by default *
 *   .main-text (middle) — Bengali or Roman script            *
 *   .below-bn  (bottom) — Bengali below Roman, hidden default*
 *                                                             *
 * display: inline-block (not inline-flex)                    *
 *   Required so text-align:justify on the parent <p> can    *
 *   distribute word spans across the line. inline-flex would *
 *   prevent justification from working.                      *
 *                                                             *
 * Space text nodes between spans (inserted in renderPageContent
 *   in app.js) provide soft-wrap opportunities between        *
 *   inline-block elements for the justification algorithm.   *
 *                                                             *
 * .show-gloss .word and .show-below-bn .word                *
 *   These increase the bottom margin / padding when extra    *
 *   rows are visible, making each word taller. Taller words  *
 *   = fewer words per page. This is why toggling gloss or   *
 *   below-bn calls rebuildFromAnchor() in app.js — the page  *
 *   geometry has changed and must be remeasured.             *
 * ─────────────────────────────────────────────────────────── */
.word {
  display: inline-block;
  text-align: center;      /* centres gloss / main / below-bn within the box */
  vertical-align: top;
  margin: 0 0 2px 0;
  cursor: pointer;
  padding: 0 3px;
  border-radius: 4px;
}
/* Extra margin/padding when gloss or below-bn row is visible — increases
   word height and therefore reduces how many words fit per page.          */
.show-gloss    .word { margin: 0 0 12px 0; padding: 2px 6px; }
.show-below-bn .word { margin: 0 0 3px 0;  padding: 0 3px; }
.word:hover { background: #eef6f7; }

/* Plain-text (no bengali.json) word wrapper — NOT interactive (no click/
   hover, unlike .word), exists purely so storyOverflows() in app.js has a
   genuine single-fragment leaf to measure instead of a whole <p> that can
   itself fragment across the two-column layout. Do not merge with .word —
   that class carries click/hover/gloss affordances this text has no data
   for. Do not drop the inline-block wrapping either — see the long comment
   in renderPageContent's plain-text branch for what breaks without it. */
.plain-word { display: inline-block; }

/* .gloss is hidden by default; shown when parent has .show-gloss.
   Adds a row above .main-text, increasing word-box height.       */
.gloss {
  display: none;
  font-size: 0.55em;
  color: #b15a00;
  line-height: 1.3;
  white-space: nowrap;
  font-style: italic;
}
.show-gloss .gloss { display: block; }
.main-text { display: block; white-space: nowrap; }
/* .below-bn is hidden by default; shown when parent has .show-below-bn.
   Adds a row below .main-text, increasing word-box height.              */
.below-bn {
  display: none;
  font-size: 0.55em;
  color: #2b6777;
  white-space: nowrap;
  line-height: 1.3;
  font-family: 'Noto Sans Bengali', 'Nirmala UI', sans-serif;
}
.show-below-bn .below-bn { display: block; }
.sentence-end { margin-right: 4px; }

/* ── Fixed bottom footer — two-row: nav + info ───────────── */
.reader-footer {
  --bg: #faf7f2;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #faf7f2;
  border-top: 1px solid #ddd;
  padding: 4px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 5;
}

/* Row 1: ‹ [scrubber] › */
.footer-nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-page-btn {
  background: none;
  border: none;
  font-size: 3em;
  line-height: 1;
  color: #b0a898;
  cursor: pointer;
  padding: 0 10px;
  border-radius: 6px;
  flex-shrink: 0;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-page-btn:hover:not(:disabled) { color: #2b6777; background: #eef6f7; }
.footer-page-btn:disabled { opacity: 0.22; cursor: default; }
.footer-page-btn:disabled:hover { background: none; }

/* ⊙ scrubber toggle: desktop hidden, mobile visible */
#sliderToggleBtn { display: none; }

/* Progress scrubber (desktop inline) */
#progressSlider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 18px; /* matches thumb diameter — track centers inside, no transform needed */
  background-color: transparent; /* some browsers paint a native white input
    background even with appearance:none — without this it shows as a white
    bar behind the 6px gradient track, against the footer's cream backdrop */
  background-image: linear-gradient(to right, #2b6777 0%, #e0d6ca 0%);
  background-size: 100% 6px;   /* gradient is only 6px tall... */
  background-position: left center; /* ...and sits at the vertical center */
  background-repeat: no-repeat;
  outline: none;
  cursor: pointer;
  min-width: 40px;
  padding: 0;
  margin: 0;
  align-self: center;
}
#progressSlider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}
#progressSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2b6777;
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}
#progressSlider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #e0d6ca;
}
#progressSlider::-moz-range-progress {
  height: 6px;
  border-radius: 3px 0 0 3px;
  background: #2b6777;
}
#progressSlider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2b6777;
  border: none;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
}

/* Row 2: Location … | N% complete */
.footer-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.76em;
  color: #888;
  font-family: Georgia, serif;
  font-style: italic;
  padding: 0 2px;
}

/* ── Chrome fade: header + footer disappear together ─────── *
 * Both .controls and .reader-footer fade after 3 s of no     *
 * interaction. On desktop, hovering either reveals both.     *
 * On mobile, tapping either reveals both.                    *
 * Navigation (keyboard / footer buttons) does NOT re-show   *
 * the chrome — only direct mouse/touch on the chrome does.  */
#readerControls,
#readerFooter   { transition: opacity 0.7s ease; }
#readerControls.chrome-faded,
#readerFooter.chrome-faded { opacity: 0.07; }

/* ── Floating scrubber panel (mobile only) ───────────────── */
.slider-panel {
  display: none; /* always hidden on desktop even if JS removes .open */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 96px; /* sits just above the fixed footer */
  background: rgba(250, 247, 242, 0.97);
  border-top: 1px solid #ddd;
  padding: 14px 24px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  z-index: 6;
  align-items: center;
}
#progressSliderPanel {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background-color: transparent;
  background-image: linear-gradient(to right, #2b6777 0%, #e0d6ca 0%);
  outline: none;
  cursor: pointer;
  margin: 0;
}
#progressSliderPanel::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; background: transparent;
}
#progressSliderPanel::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #2b6777;
  cursor: pointer;
  margin-top: -10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
#progressSliderPanel::-moz-range-track {
  height: 6px; border-radius: 3px; background: #e0d6ca;
}
#progressSliderPanel::-moz-range-progress {
  height: 6px; border-radius: 3px 0 0 3px; background: #2b6777;
}
#progressSliderPanel::-moz-range-thumb {
  width: 26px; height: 26px;
  border-radius: 50%; background: #2b6777;
  border: none; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* ── Slider drag-preview balloon ─────────────────────────────
   Shown only while a progress slider is actively being dragged (see
   showSliderBalloon/hideSliderBalloon in app.js). left/top are set in JS
   from the active slider's own bounding rect, so position:fixed here is
   just "float above everything, ignore normal document flow" — no
   position:relative ancestor needed. Must not set `display` here (see
   the [hidden] + unconditional-display gotcha in CLAUDE.md) — the
   default block display is fine since [hidden] already covers hiding it. */
.slider-balloon {
  position: fixed;
  z-index: 20;
  background: #2b6777;
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: Georgia, serif;
  font-size: 0.82em;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.slider-balloon::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #2b6777;
}
.slider-balloon-name {
  font-weight: 700;
  max-width: min(70vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slider-balloon-pct {
  opacity: 0.85;
  font-style: italic;
  white-space: nowrap;
}

/* Word hover/click affordance suppressed when no popup data available (defect 4) */
.no-popup .word { cursor: default; }
.no-popup .word:hover { background: none; }

/* ── Help modal ──────────────────────────────────────────── */
.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-modal[hidden] { display: none; }
.help-content {
  background: #fff;
  border-radius: 10px;
  padding: 26px 30px 22px;
  max-width: 460px;
  width: 90%;
  position: relative;
  font-size: 0.9em;
  line-height: 1.65;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.help-content h3 { margin: 0 0 12px; font-size: 1em; color: #2b6777; }
.help-content p  { margin: 0 0 10px; color: #444; }
.help-content p:last-child { margin-bottom: 0; }
.help-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.1em;
  cursor: pointer;
  color: #aaa;
}
.help-close:hover { color: #555; }

/* ── Status / error banner ───────────────────────────────── */
.status {
  max-width: 720px;
  margin: 16px auto;
  padding: 10px 14px;
  background: #fff3e6;
  border: 1px solid #f0d4b0;
  border-radius: 6px;
  color: #8a4b00;
  font-size: 0.9em;
}

/* ── Toast notification ──────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 106px; /* above the two-row footer */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,30,30,0.88);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.82em;
  font-family: Georgia, serif;
  font-style: italic;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; }
/* Start hidden */
.toast { opacity: 0; }

/* ── Word popup ──────────────────────────────────────────── */
#popup {
  display: none;
  position: fixed;
  background: #2b2b2b;
  color: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  max-width: 320px;
  font-size: 0.95em;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
#popup .close { position: absolute; top: 4px; right: 8px; cursor: pointer; color: #ccc; }
#popup .label { color: #8fd3e8; font-size: 0.8em; display: block; margin-bottom: 4px; }

#selTranslateBtn {
  display: none;
  position: fixed;
  background: #d97706;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  z-index: 40;
}

/* ── Mobile footer overrides — MUST stay at end of file ─────
 * The base footer rules (#sliderToggleBtn, .footer-info-row, etc.) appear
 * above in source order. A media query earlier in the file would be
 * overridden by those base rules despite matching — source order wins
 * when specificity is equal. Placing this block last guarantees the
 * mobile overrides win. */
@media (max-width: 768px) {
  /* ── Single-row footer: nav centered, info labels overlaid ── */
  .reader-footer {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    padding: 6px 10px;
    gap: 0;
  }

  /* Info row: taken out of flex flow via absolute positioning so it cannot
     stack as a second row. Labels stretch edge-to-edge, anchored by the
     same 10px side padding as the footer itself. */
  .footer-info-row {
    position: absolute;
    left: 10px;
    right: 10px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    font-size: 11px;
    padding: 0;
  }

  #footerProgress, #footerPage {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  /* Nav row: sole natural flex child, centered by parent justify-content */
  .footer-nav-row { flex: 0 0 auto; gap: 4px; }

  /* Compact buttons */
  .footer-page-btn { font-size: 2.2em; padding: 0 8px; }

  /* ⊙ toggle: align-self:stretch grows it to the full nav-row height so the
     SVG centers on the same axis as the < > glyphs; font-size:0 collapses
     whitespace text nodes that would otherwise add phantom height */
  #sliderToggleBtn { display: flex; align-items: center; align-self: stretch; font-size: 0; padding: 0 6px; }
  #sliderToggleBtn svg { width: 20px; height: 20px; display: block; }

  /* Hide desktop inline scrubber */
  #progressSlider { display: none; transform: none; }

  /* Single-row footer is ~47px; trim padding and set white background so the
     reading column doesn't leave a visible beige gap above the footer. */
  body[data-view="reader"] .reading-col { padding-bottom: 56px; background: #fff; }
}
