/* ============================================================
   Bible Reader — Web Edition  |  Dark Parchment Theme
   Palette mirrors the C++/ImGui desktop app (colors.h)
   ============================================================ */

/* ---------------------------------------------------------------------------
   Custom properties (palette from colors.h)
   --------------------------------------------------------------------------- */
:root {
  --bg-dark:       #1a1714;   /* COL_BG_DARK      0.10 0.09 0.08 */
  --bg-panel:      #211e1a;   /* sidebar / toolbar background    */
  --bg-hover:      #2d2820;   /* subtle hover bg                 */
  --bg-active:     #352e23;   /* active / selected bg            */

  --text-body:     #e5dece;   /* COL_TEXT_BODY    0.90 0.87 0.80 */
  --text-dim:      #8a8070;   /* COL_TEXT_DIM     0.54 0.50 0.44 */
  --text-faint:    #4d4540;   /* very faint / disabled           */

  --gold:          #b79451;   /* COL_VERSE_NUM    0.72 0.58 0.32 */
  --gold-bright:   #c8a84b;   /* COL_GOLD_FRAME   dropcap ring   */
  --gold-dim:      #8b6914;   /* dark gold for dropcap bg        */
  --gold-border:   #6b5010;   /* outer ring                      */

  --separator:     #3a3228;   /* line / border colour            */
  --scrollbar:     #3a3228;

  --sidebar-w:     240px;
  --toolbar-h:     48px;
  --parallel-w:    320px;
  --reader-max:    760px;
  --font-body:     'EB Garamond', Georgia, serif;
  --font-heading:  'Pirata One', cursive;
  --font-verse-num:'Crimson Pro', Georgia, serif;
  --font-ui:       'Roboto', system-ui, sans-serif;
  --font-hebrew:   'Noto Serif Hebrew', serif;
  --font-size:     18px;
  --line-height:   1.2;
}

/* ---------------------------------------------------------------------------
   Reset / base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size); scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: var(--line-height);
  background: var(--bg-dark);
  color: var(--text-body);
  display: flex;
  flex-direction: column;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* actual visible height, excludes browser chrome */
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------------------
   Scrollbars (Webkit)
   --------------------------------------------------------------------------- */
::-webkit-scrollbar            { width: 6px; }
::-webkit-scrollbar-track      { background: var(--bg-dark); }
::-webkit-scrollbar-thumb      { background: var(--scrollbar); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: var(--gold-border); }

/* ---------------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--separator);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease;
  will-change: transform;
  z-index: 90;
}

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 2rem;
}

.toolbar-trans {
  flex-shrink: 0;
}
.toolbar-trans .trans-select {
  width: auto;
  max-width: 160px;
}

.trans-select {
  background: var(--bg-dark);
  color: var(--text-body);
  border: 1px solid var(--separator);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}
.trans-select:focus { border-color: var(--gold-border); }

/* Testament tabs */
.testament-tabs {
  display: flex;
  border-bottom: 1px solid var(--separator);
}
.testament-tabs .tab {
  flex: 1;
  text-align: center;
  padding: 0.4rem 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.testament-tabs .tab:hover { color: var(--text-body); }
.testament-tabs .tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* Section heading — doubles as a collapse toggle when .collapsible */
.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.6rem 0.85rem 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  user-select: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color 0.12s;
}
.sidebar-section-head:hover { color: var(--gold); }
.sidebar-section-head.open  { color: var(--gold); }
.collapse-arrow { font-size: 0.55rem; opacity: 0.7; }

/* Book list */
.book-list {
  list-style: none;
  padding: 0 0 0.5rem;
}

.book-link {
  display: block;
  padding: 0.2rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
}
.book-link:hover {
  color: var(--text-body);
  background: var(--bg-hover);
}
.book-link.active {
  color: var(--gold);
  background: var(--bg-active);
  border-left-color: var(--gold);
}

/* ---------------------------------------------------------------------------
   Main layout
   --------------------------------------------------------------------------- */
.body-below {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Toolbar
   --------------------------------------------------------------------------- */
.toolbar {
  flex-shrink: 0;
  z-index: 100;
  height: var(--toolbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--separator);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
}

.sidebar-toggle {
  display: none;    /* shown on mobile */
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--text-body); }

.toolbar-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-dim);
  transition: color 0.12s, background 0.12s;
  cursor: pointer;
}
.nav-btn:hover { color: var(--gold); background: var(--bg-hover); }
.nav-btn.disabled { color: var(--text-faint); cursor: default; }

.chapter-jump {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.ch-input {
  width: 2.6rem;
  text-align: center;
  background: var(--bg-dark);
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  padding: 0.2rem 0.3rem;
  outline: none;
  -moz-appearance: textfield;
}
.ch-input::-webkit-outer-spin-button,
.ch-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ch-input:focus { border-color: var(--gold-border); }
.ch-of {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--text-faint);
}

.layout-toggle {
  display: flex;
  border: 1px solid var(--separator);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.layout-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--separator);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, background 0.12s;
  line-height: 1;
}
.layout-btn:last-child { border-right: none; }
.layout-btn:hover { color: var(--text-body); background: var(--bg-hover); }
.layout-btn.active { color: var(--gold); background: var(--bg-active); }

.parallel-toggle {
  background: none;
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.parallel-toggle:hover { color: var(--text-body); border-color: var(--gold-border); }
.parallel-toggle.active { color: var(--gold); border-color: var(--gold); }

/* ---------------------------------------------------------------------------
   Reader area
   --------------------------------------------------------------------------- */
.reader {
  flex: 1;
  padding: 2.5rem 2rem 4rem;
  max-width: calc(var(--reader-max) + 4rem);
  margin: 0 auto;
  width: 100%;
}

/* Columnar layout (non-strongs translations) */
.reader.columns {
  max-width: 1200px;
  column-count: 2;
  column-gap: 3rem;
  column-rule: 1px solid var(--separator);
}

/* KJV + Strong's side-by-side original language */
#reader-wrap {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: flex-start;
  flex-wrap: wrap;
}
#reader-wrap > #reader-heading {
  flex: 0 0 100%;
  padding: 2.5rem 2rem 0;
  margin-bottom: 0;
}
#reader-wrap[data-strongs] > #reader .chapter-heading {
  display: none;
}
#reader-wrap.has-orig > #reader {
  max-width: none;
  margin: 0;
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--separator);
  padding-top: 1.5rem;
}
.reader-orig {
  display: none;
  flex: 1;
  min-width: 0;
  padding: 2.5rem 2rem 4rem;
}
.reader-orig.orig-visible {
  display: block;
  padding-top: 1.5rem;
  position: sticky;
  top: 0;
  height: calc(100dvh - var(--toolbar-h));
  overflow-y: auto;
  background: #1d1b16;
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge legacy */
}
.reader-orig.orig-visible::-webkit-scrollbar {
  display: none;               /* Chrome/Safari/Edge */
}
.orig-label {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  opacity: 0.6;
}
.orig-empty {
  color: var(--text-dim);
  opacity: 0.4;
}
@media (max-width: 768px) {
  #reader-wrap.has-orig {
    flex-direction: column;
  }
  #reader-wrap.has-orig > #reader {
    border-right: none;
    border-bottom: 1px solid var(--separator);
    width: 100%;
  }
}
.reader.columns .chapter-heading {
  column-span: all;
}
.reader.columns .bottom-nav {
  column-span: all;
}

/* Verse 0 section heading (e.g. Odes titles) */
.verse-heading {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-dim);
  font-style: italic;
  margin: 1.4rem 0 0.4rem;
  letter-spacing: 0.02em;
}

/* Chapter heading */
.chapter-heading {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 400;
  color: var(--gold);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.chapter-label {
  display: block;
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-bottom: 1.8rem;
}

/* Verse paragraphs */
.verse-para {
  margin-bottom: 1em;
  text-align: justify;
  hyphens: auto;
  break-inside: avoid;
}
.reader[dir="rtl"] .verse-para {
  text-align: right;
  font-family: var(--font-hebrew);
  direction: rtl;
}

/* Verse number superscript */
.vnum {
  font-family: var(--font-verse-num);
  font-size: 0.62em;
  font-style: normal;
  font-weight: 600;
  color: var(--gold);
  vertical-align: super;
  line-height: 0;
  margin-right: 0.15em;
  cursor: pointer;
  user-select: none;
  padding: 0 2px;
  border-radius: 2px;
  transition: color 0.1s, background 0.1s;
}
.reader[dir="rtl"] .vnum { margin-right: 0; margin-left: 0.15em; }
.vnum:hover { color: var(--gold-bright); }
.vnum--active {
  color: var(--bg-dark);
  background: var(--gold);
}

/* Verse text inline span (for hover/select) */
.vtext { cursor: text; }

/* ---------------------------------------------------------------------------
   Dropcap — KJV chapter opening (verse 1)
   Styled to echo the ImGui gold-framed dropcap initial.
   --------------------------------------------------------------------------- */
.dropcap-wrap {
  display: block;
  overflow: hidden;   /* so text flows around the float */
}

.dropcap {
  float: left;
  font-family: var(--font-heading);
  font-size: 5.2em;
  line-height: 0.78;
  color: var(--bg-dark);
  background: linear-gradient(145deg, var(--gold-bright) 0%, var(--gold-dim) 100%);
  border: 2px solid var(--gold-bright);
  box-shadow:
    0 0 0 1px var(--gold-border),
    inset 0 1px 2px rgba(255,220,100,0.25);
  width: 1.05em;
  height: 1.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.06em 0.55rem 0.1rem 0;
  position: relative;
  text-shadow: 0 1px 1px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  /* Corner diamonds via box-shadow pseudo approach is tricky in pure CSS;
     the border + box-shadow gives the gold frame effect */
}
.dropcap:hover {
  border-color: #e8c86b;
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 8px 2px rgba(200,168,75,0.35),
    inset 0 1px 2px rgba(255,220,100,0.35);
}

/* ---------------------------------------------------------------------------
   Bottom navigation
   --------------------------------------------------------------------------- */
.bottom-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--separator);
}

.nav-btn-lg {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.nav-btn-lg:hover { color: var(--gold); border-color: var(--gold-border); background: var(--bg-hover); }
.nav-btn-lg.disabled { color: var(--text-faint); cursor: default; }

/* ---------------------------------------------------------------------------
   Parallel panel (slides in from the right)
   --------------------------------------------------------------------------- */
.parallel-panel {
  position: fixed;
  top: var(--toolbar-h);
  right: 0;
  bottom: 0;
  width: var(--parallel-w);
  background: var(--bg-panel);
  border-left: 1px solid var(--separator);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  will-change: transform;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}
.parallel-panel.open { transform: translateX(0); }

.parallel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.parallel-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--gold);
}
.parallel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.parallel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.1s;
}
.parallel-close:hover { color: var(--text-body); }
.parallel-copy {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
  font-family: var(--font-ui);
}
.parallel-copy:hover { color: var(--gold); background: var(--bg-hover); }
.parallel-bm {
  background: none;
  border: none;
  color: var(--text-dim);
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: color 0.1s, background 0.1s;
}
.parallel-bm:hover { color: var(--gold); background: var(--bg-hover); }
.parallel-bm.active { color: var(--gold); }

.parallel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem 2rem;
}

.parallel-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: var(--font-ui);
  margin-top: 0.5rem;
}
.loading {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-family: var(--font-ui);
}

.parallel-entry {
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--separator);
}
.parallel-entry:last-child { border-bottom: none; }

.parallel-trans {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.3rem;
}
.parallel-trans-link {
  color: inherit;
  text-decoration: none;
}
.parallel-trans-link:hover { text-decoration: underline; }
.parallel-text {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-body);
}
.parallel-text.missing { color: var(--text-faint); font-style: italic; }
.parallel-entry.rtl .parallel-text {
  font-family: var(--font-hebrew);
  direction: rtl;
  text-align: right;
}

/* ---------------------------------------------------------------------------
   Strong's word highlights + tooltip popover
   --------------------------------------------------------------------------- */
span[data-s] {
  cursor: help;
  border-bottom: 1px dotted var(--gold-border);
  transition: background 0.1s, border-color 0.1s;
}
span[data-s]:hover {
  background: rgba(183, 148, 81, 0.15);
  border-bottom-color: var(--gold);
}

.strongs-popup {
  display: none;
  position: absolute;
  z-index: 500;
  max-width: 300px;
  min-width: 180px;
  background: var(--bg-panel);
  border: 1px solid var(--gold-border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.55);
  pointer-events: auto;
  font-family: var(--font-ui);
  line-height: 1.45;
}

.sp-num {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.15rem;
}
.sp-lemma {
  font-family: 'Noto Serif Hebrew', var(--font-body);
  font-size: 1.05rem;
  color: var(--text-body);
  margin-bottom: 0.1rem;
}
.sp-bsb {
  font-size: 0.9rem;
  color: var(--gold);
  font-style: italic;
  margin-bottom: 0.1rem;
}
.sp-translit {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.1rem;
}
.sp-parsing {
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.75;
  margin-bottom: 0.2rem;
}
.sp-def {
  font-size: 0.8rem;
  color: var(--text-body);
}

/* ---------------------------------------------------------------------------
   Error / utility
   --------------------------------------------------------------------------- */
.error-msg {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: #c06060;
  background: rgba(192,60,60,0.1);
  border: 1px solid rgba(192,60,60,0.25);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

/* ---------------------------------------------------------------------------
   Overflow menu (mobile ⋯ button)
   --------------------------------------------------------------------------- */
.inline-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.overflow-wrap {
  display: none;   /* shown only on mobile via media query */
  position: relative;
  flex-shrink: 0;
}
.overflow-btn {
  background: none;
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.overflow-btn:hover { color: var(--text-body); border-color: var(--gold-border); }

.overflow-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  min-width: 200px;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  gap: 0.5rem;
  flex-direction: column;
}
.overflow-menu.open { display: flex; }

.overflow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.overflow-label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Mobile / responsive
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --parallel-w: min(320px, 90vw); }
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--toolbar-h);
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .toolbar { padding: 0 0.6rem; gap: 0.4rem; }
  .toolbar-trans { display: none; }

  .toolbar-title { font-size: 0.85rem; }

  .inline-controls { display: none; }
  .overflow-wrap   { display: block; }
  #btn-columns { display: none; }
  body:not(.pager-compat) #layout-row-m { display: none; }

  .overflow-trans { width: 100%; }

  .reader { padding: 1.5rem 1rem 3rem; }

  #reader-wrap > #reader-heading { padding: 1.5rem 1rem 0; }

  .chapter-heading { font-size: 1.7rem; }
}

/* ---------------------------------------------------------------------------
   Paginated book mode — mobile e-reader layout
   Activated by body.book-paged; never touches desktop or interlinear/strongs
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
  body.book-paged .main {
    overflow: hidden;
  }
  body.book-paged #reader-wrap {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }
  body.book-paged #reader {
    height: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    column-fill: auto;
    max-width: none;
    margin: 0;
    padding-top: 1.5rem;
    padding-bottom: 0;    /* padding-bottom on the element is eaten by overflow-y:hidden */
    padding-inline: 1.2rem;
    scrollbar-width: none;
    touch-action: none; /* JS handles all paging; block native scroll */
    cursor: default;
  }
  /* Spacer at end of last column so the final line is never clipped */
  body.book-paged #reader::after {
    content: '';
    display: block;
    height: 2.5rem;
  }
  body.book-paged #reader::-webkit-scrollbar { display: none; }
  /* RTL readers: force LTR scroll container so scrollLeft is predictable,
     then restore RTL on direct children so Hebrew text still renders correctly */
  body.book-paged #reader[dir="rtl"] { direction: ltr; }
  body.book-paged #reader[dir="rtl"] > * { direction: rtl; }
  body.book-paged .bottom-nav { display: none; }

  /* Right-edge gradient — hints that more pages remain */
  .pager-edge {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, var(--bg-dark));
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.4s;
    will-change: opacity;
  }
  body.book-paged .pager-has-next .pager-edge { opacity: 0.7; }

  /* Page position indicator, e.g. "3 / 9" */
  .pager-indicator {
    display: none;
    position: absolute;
    bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    right: 1.1rem;
    font-size: 0.65rem;
    font-family: var(--font-ui);
    color: var(--text-dim);
    opacity: 0.75;
    pointer-events: none;
    user-select: none;
    letter-spacing: 0.04em;
    z-index: 3;
  }
  body.book-paged .pager-indicator { display: block; }
}

@media (max-width: 480px) {
  :root { --parallel-w: 100vw; }
  .parallel-panel {
    top: 0;
    border-left: none;
  }
}

/* ---------------------------------------------------------------------------
   Interlinear view
   --------------------------------------------------------------------------- */
.interlinear-verse {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--separator);
  break-inside: avoid;
}

.interlinear-vnum {
  flex: 0 0 2rem;
  text-align: right;
  padding-top: 0.15em;
  font-size: 0.8em;
  line-height: 1.75;
}

.interlinear-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.interlinear-eng {
  color: var(--text-body);
  line-height: 1.75;
}

.interlinear-grk {
  color: var(--text-dim);
  font-size: 0.95em;
  line-height: 1.7;
}

.interlinear-heb {
  font-family: var(--font-hebrew);
  color: var(--text-dim);
  font-size: 1.05em;
  line-height: 1.9;
  text-align: right;
}

/* BSB interlinear word cells — the original tongue set above its English meaning */
.interlinear-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.4rem;
  padding: 0.4rem 0 0.25rem;
  border-top: 1px solid var(--separator);
}
.interlinear-words[dir="rtl"] {
  flex-direction: row-reverse;
}
.il-word {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  min-width: 1.8rem;
  text-align: center;
}
.il-word[data-s] {
  cursor: pointer;
  transition: background 0.12s;
}
.il-word[data-s]:hover { background: var(--bg-hover); }
.il-orig {
  font-size: 1.1em;
  line-height: 1.5;
  color: var(--text-body);
}
.interlinear-words[dir="rtl"] .il-orig {
  font-family: var(--font-hebrew);
  font-size: 1.2em;
  line-height: 1.7;
}
.il-translit {
  font-size: 0.67em;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.35;
  direction: ltr;
  unicode-bidi: isolate;
}
.il-gloss {
  font-size: 0.72em;
  font-family: var(--font-ui);
  color: var(--text-body);
  opacity: 0.8;
  line-height: 1.35;
  direction: ltr;
  unicode-bidi: isolate;
}
.il-snum {
  font-size: 0.6em;
  font-family: var(--font-ui);
  color: var(--gold);
  opacity: 0.5;
  line-height: 1.4;
  direction: ltr;
  unicode-bidi: isolate;
}
.il-word[data-s]:hover .il-snum { opacity: 1; }

/* ---------------------------------------------------------------------------
   Toolbar search button
   --------------------------------------------------------------------------- */
.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.toolbar-btn:hover { color: var(--gold); background: var(--bg-hover); }
.toolbar-btn.bookmarked { color: var(--gold); }

/* ---------------------------------------------------------------------------
   Bookmarks panel
   --------------------------------------------------------------------------- */
.bm-wrap { position: relative; flex-shrink: 0; }

.bm-panel {
  position: fixed;
  top: var(--toolbar-h);
  right: 0.5rem;
  width: 268px;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-top: none;
  border-radius: 0 0 6px 6px;
  z-index: 300;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.bm-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px 7px;
  border-bottom: 1px solid var(--separator);
}
.bm-panel-title {
  font: 500 11px/1 var(--font-ui);
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.bm-panel-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 17px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.12s;
}
.bm-panel-close:hover { color: var(--text-body); }

.bm-cur-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 11px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--separator);
  color: var(--text-dim);
  font: 12.5px/1.3 var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.bm-cur-btn:hover { background: var(--bg-hover); color: var(--text-body); }
.bm-cur-btn.active { color: var(--gold); }
.bm-cur-btn svg { flex-shrink: 0; }

.bm-list { max-height: 290px; overflow-y: auto; }

.bm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  cursor: pointer;
  border-bottom: 1px solid var(--separator);
  transition: background 0.12s;
}
.bm-item:last-child { border-bottom: none; }
.bm-item:hover { background: var(--bg-hover); }

.bm-item-icon { color: var(--gold); flex-shrink: 0; display: flex; }

.bm-item-info { flex: 1; min-width: 0; }
.bm-item-ref {
  font: 13px/1.3 var(--font-ui);
  color: var(--text-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-item-meta {
  font: 11px/1.4 var(--font-ui);
  color: var(--text-dim);
}

.bm-item-del {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 17px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.12s;
}
.bm-item:hover .bm-item-del { opacity: 1; }
.bm-item-del:hover { color: var(--text-body); }

.bm-empty {
  padding: 18px 12px;
  color: var(--text-dim);
  font: 12.5px/1.6 var(--font-ui);
  text-align: center;
}
.bm-empty small { font-size: 11px; opacity: 0.7; }

/* Verse number with an active bookmark */
.vnum.vnum-bm { background: rgba(183,148,81,0.15); }

@media (max-width: 480px) {
  .bm-panel { width: calc(100vw - 1rem); right: 0.5rem; }
}

/* ---------------------------------------------------------------------------
   Search overlay
   --------------------------------------------------------------------------- */
#search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
}
#search-overlay[hidden] { display: none; }

.search-card {
  width: 680px;
  max-width: calc(100vw - 2rem);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}

.search-mag { color: var(--text-dim); flex-shrink: 0; }

#search-q {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  min-width: 0;
}
#search-q::placeholder { color: var(--text-faint); }

.search-esc {
  font-size: 0.68rem;
  color: var(--text-faint);
  background: var(--bg-hover);
  border: 1px solid var(--separator);
  border-radius: 3px;
  padding: 0.12rem 0.4rem;
  font-family: var(--font-ui);
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
.search-esc:hover { color: var(--text-dim); }

.search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 1rem;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
  gap: 1rem;
  min-height: 2.2rem;
}

.search-filters {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.sf {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  padding: 0.18rem 0.5rem;
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.sf:hover { color: var(--text-body); }
.sf.active {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--bg-active);
}

.search-trans-sel {
  background: var(--bg-hover);
  border: 1px solid var(--separator);
  border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  padding: 0.18rem 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
}
.search-trans-sel:focus { border-color: var(--gold-border); color: var(--text-body); }

.search-status {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.search-prompt {
  padding: 2.5rem 2rem;
  color: var(--text-faint);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}
.search-prompt em { color: var(--text-dim); font-style: italic; }
.search-none { color: var(--text-dim); }

.sr-group { border-bottom: 1px solid var(--separator); }
.sr-group:last-child { border-bottom: none; }

.sr-book-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  z-index: 1;
}

.sr-book-count {
  font-weight: normal;
  color: var(--text-faint);
  font-size: 0.68rem;
}

.sr-verse {
  display: flex;
  gap: 0.8rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: background 0.1s;
  align-items: baseline;
}
.sr-verse:hover { background: var(--bg-hover); }
.sr-verse:active { background: var(--bg-active); }

.sr-ref {
  font-family: var(--font-verse-num);
  font-size: 0.82rem;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 3rem;
}

.sr-text {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text-body);
  line-height: 1.5;
}

.sr-text mark {
  background: rgba(183,148,81,0.22);
  color: var(--gold-bright);
  border-radius: 2px;
  padding: 0 1px;
}

.search-cap-note {
  padding: 0.75rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: center;
  margin: 0;
  border-top: 1px solid var(--separator);
}

@media (max-width: 520px) {
  #search-overlay { padding-top: 0; align-items: flex-start; }
  .search-card    { width: 100%; max-width: 100%; border-radius: 0 0 8px 8px; max-height: 75vh; }
}

/* ---------------------------------------------------------------------------
   Concordance panel — all occurrences of a Strong's number
   Rendered inside .reader-orig (the right column in columns mode)
   --------------------------------------------------------------------------- */
.conc-prompt {
  color: var(--text-dim);
  font-size: 0.82em;
  font-style: italic;
  text-align: center;
  padding: 2.5rem 1.5rem;
  opacity: 0.45;
  line-height: 1.5;
}
.conc-header {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 0.6rem;
}
.conc-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1em;
  line-height: 1;
  padding: 0 0.1rem;
  opacity: 0.45;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.conc-clear:hover { opacity: 1; }
.conc-key {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.85em;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.conc-lemma {
  font-size: 1.1em;
  color: var(--text-body);
  margin-bottom: 0.15rem;
}
.conc-h .conc-lemma, .conc-header .conc-h ~ .conc-lemma {
  font-family: var(--font-hebrew, serif);
  direction: rtl;
  font-size: 1.2em;
}
.conc-translit {
  font-size: 0.78em;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.25rem;
}
.conc-def {
  font-size: 0.8em;
  color: var(--text-dim);
  line-height: 1.4;
}
.conc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0 0.5rem;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 0.4rem;
}
.conc-count {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.7em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.7;
}
.conc-list { }
.conc-book-section + .conc-book-section { margin-top: 0.1rem; }
.conc-book-head {
  display: flex;
  align-items: center;
  gap: 0.35em;
  font-family: var(--font-ui, sans-serif);
  font-size: 0.68em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.5rem 0.3rem 0.2rem;
  opacity: 0.75;
  cursor: pointer;
  user-select: none;
  border-radius: 3px;
}
.conc-book-head:hover { opacity: 1; background: var(--bg-hover); }
.conc-book-toggle {
  font-size: 0.65em;
  line-height: 1;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.conc-book-toggle::before { content: '\25BE'; }
.conc-book-section.collapsed .conc-book-toggle { transform: rotate(-90deg); }
.conc-book-section.collapsed .conc-book-rows { display: none; }
.conc-book-count {
  margin-left: auto;
  font-size: 0.85em;
  opacity: 0.55;
  letter-spacing: 0;
}
.conc-toggle-all {
  display: inline-flex;
  gap: 0.2rem;
  margin-left: 0.4rem;
}
.conc-exp-btn {
  background: none;
  border: 1px solid var(--separator);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.72em;
  color: var(--text-dim);
  padding: 0 0.3rem;
  line-height: 1.5;
  opacity: 0.65;
}
.conc-exp-btn:hover { opacity: 1; }
.conc-row {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  padding: 0.22rem 0.25rem;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1.35;
  transition: background 0.1s;
}
.conc-row:hover { background: var(--bg-hover); }
.conc-ref {
  flex-shrink: 0;
  color: var(--gold);
  font-family: var(--font-verse-num, serif);
  font-size: 0.78em;
  min-width: 2.8em;
  opacity: 0.9;
}
.conc-word {
  flex-shrink: 0;
  color: var(--text-body);
  font-size: 1em;
}
.conc-word.conc-h {
  font-family: var(--font-hebrew, serif);
  direction: rtl;
  font-size: 1.05em;
}
.conc-translit-small {
  color: var(--text-dim);
  font-size: 0.72em;
  font-style: italic;
  flex-shrink: 0;
}
.conc-gloss {
  color: var(--text-dim);
  font-size: 0.78em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#conc-top-float {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  background: var(--bg-panel);
  border: 1px solid var(--separator);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--gold);
  opacity: 0.75;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
#conc-top-float.visible { display: flex; }
#conc-top-float:hover { opacity: 1; }
.conc-page-loading {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.72em;
  color: var(--text-dim);
  opacity: 0.6;
  text-align: center;
  padding: 0.6rem 0;
}
.conc-loading, .conc-error {
  font-family: var(--font-ui, sans-serif);
  font-size: 0.8em;
  color: var(--text-dim);
  padding: 1rem 0;
  text-align: center;
}

/* ---------------------------------------------------------------------------
   Reader fade-in — fired whenever chapter content is swapped
   --------------------------------------------------------------------------- */
@keyframes reader-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.reader-fadein {
  animation: reader-fadein 0.25s ease-out forwards;
}

/* ---------------------------------------------------------------------------
   Verse highlight — fired when navigating from a search result
   --------------------------------------------------------------------------- */
@keyframes verse-flash {
  0%   { background: rgba(183,148,81,0.30); }
  100% { background: transparent; }
}
.verse-hl {
  border-radius: 3px;
  animation: verse-flash 2.2s ease-out forwards;
}

/* Persistent word highlight — set when navigating from a concordance result */
.word-hl {
  background: rgba(183, 148, 81, 0.22);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(183, 148, 81, 0.38);
  color: var(--gold-bright);
}
/* On interlinear word cells, colour only the original script; leave gloss/translit unchanged */
.il-word.word-hl {
  border-radius: 4px;
  color: inherit;
}
.il-word.word-hl .il-orig { color: var(--gold-bright); }
