/* ============================================================
   የአመዳይ መጽሐፍ — Bible study desktop app
   ============================================================ */

/* ---------- 1. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui-font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
/* shown only once the title bar has shed its buttons — see section 19 */
.only-compact { display: none; }
svg { display: block; }
/* class-level `display` must never beat the hidden attribute */
[hidden] { display: none !important; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
kbd {
  font-family: var(--mono-font); font-size: 10px; letter-spacing: .02em;
  padding: 2px 5px; border-radius: 4px; background: var(--kbd-bg); color: var(--muted);
  border: 1px solid var(--line);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* ---------- 2. Tokens ---------- */
:root {
  --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Ethiopic",
             "Abyssinica SIL", Nyala, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --scripture-serif: "Noto Serif Ethiopic", "Abyssinica SIL", Nyala, "Iowan Old Style",
             "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --scripture-sans: var(--ui-font);
  --mono-font: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --scripture-font: var(--scripture-serif);
  --scripture-size: 17px;
  --scripture-leading: 1.78;
  --measure: 34rem;

  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 14px;
  --r-xl: 20px;

  --rail-w: 264px;
  --drawer-w: 420px;
  /* the docked drawer may never eat more than 60% of the window */
  --drawer-panel-w: min(var(--drawer-w), 60vw);
  --titlebar-h: 48px;
  --statusbar-h: 26px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --speed: 180ms;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --hl-yellow: #f3d34a;
  --hl-green:  #64c07a;
  --hl-blue:   #5aa7dd;
  --hl-pink:   #e07ab0;
}

/* ---------- 3. Themes ---------- */
[data-theme="light"] {
  --bg:        #f2efe9;
  --surface:   #ffffff;
  --surface-2: #f8f6f2;
  --sunken:    #eae6de;
  --ink:       #1c1815;
  --ink-soft:  #3d3630;
  --muted:     #79706a;
  --faint:     #a49b93;
  --line:      #e2dcd2;
  --line-soft: #efeae2;
  --accent:    #c1272d;
  --accent-ink:#ffffff;
  --accent-wash: #fdf1f0;
  --gold:      #b58432;
  --ok:        #1d7a4c;
  --warn:      #b4761a;
  --danger:    #c1272d;
  --kbd-bg:    #f1ede6;
  --shadow-sm: 0 1px 2px rgba(40,30,20,.07);
  --shadow-md: 0 6px 20px -6px rgba(40,30,20,.18);
  --shadow-lg: 0 24px 60px -20px rgba(30,22,14,.34);
  --scrim:     rgba(38,30,22,.42);
}
[data-theme="sepia"] {
  --bg:        #e8dfcb;
  --surface:   #f6efdd;
  --surface-2: #f0e7d2;
  --sunken:    #ded3ba;
  --ink:       #2c2415;
  --ink-soft:  #453a25;
  --muted:     #786a51;
  --faint:     #9d8f74;
  --line:      #d8cbae;
  --line-soft: #e5dac1;
  --accent:    #a8371f;
  --accent-ink:#fff8ed;
  --accent-wash: #f3e3d5;
  --gold:      #8f6a25;
  --ok:        #2b6b3f;
  --warn:      #97631a;
  --danger:    #a8371f;
  --kbd-bg:    #eadfc4;
  --shadow-sm: 0 1px 2px rgba(70,55,25,.10);
  --shadow-md: 0 6px 20px -6px rgba(70,55,25,.22);
  --shadow-lg: 0 24px 60px -20px rgba(60,45,20,.38);
  --scrim:     rgba(52,40,20,.44);
}
[data-theme="dark"] {
  --bg:        #0e1116;
  --surface:   #161b22;
  --surface-2: #1b212a;
  --sunken:    #0a0d12;
  --ink:       #e7e9ec;
  --ink-soft:  #c6cad1;
  --muted:     #8b949e;
  --faint:     #626b76;
  --line:      #262d38;
  --line-soft: #1e242d;
  --accent:    #ef4b4b;
  --accent-ink:#ffffff;
  --accent-wash: #241417;
  --gold:      #d8ad4e;
  --ok:        #3fb27a;
  --warn:      #d79b3a;
  --danger:    #ef4b4b;
  --kbd-bg:    #1d232c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 22px -6px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 60px -18px rgba(0,0,0,.75);
  --scrim:     rgba(3,6,10,.62);
}
[data-theme="ilalu"] {
  --bg:        #0b2416;
  --surface:   #0f3620;
  --surface-2: #12402689;
  --sunken:    #081c11;
  --ink:       #e2f0e7;
  --ink-soft:  #c8e2d3;
  --muted:     #90b9a1;
  --faint:     #6b937c;
  --line:      #1b4d32;
  --line-soft: #163f29;
  --accent:    #ef5a4c;
  --accent-ink:#ffffff;
  --accent-wash: #1a3a29;
  --gold:      #dfbb63;
  --ok:        #4cc487;
  --warn:      #e0a94b;
  --danger:    #ef5a4c;
  --kbd-bg:    #16452b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 22px -6px rgba(0,0,0,.55);
  --shadow-lg: 0 24px 60px -18px rgba(0,0,0,.7);
  --scrim:     rgba(4,18,10,.6);
}

/* reading preferences driven by data attributes on <html> */
[data-font="sans"]  { --scripture-font: var(--scripture-sans); }
[data-leading="snug"]   { --scripture-leading: 1.55; }
[data-leading="normal"] { --scripture-leading: 1.78; }
[data-leading="airy"]   { --scripture-leading: 2.05; }

/* ---------- 4. Boot screen ---------- */
.boot {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background: var(--bg);
}
.boot__inner { text-align: center; }
.boot__mark { width: 54px; height: 54px; margin: 0 auto 14px; opacity: .9; }
.boot__title { font-family: var(--scripture-serif); font-size: 21px; color: var(--ink); }
.boot__status { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.boot__status--error { color: var(--danger); max-width: 34rem; line-height: 1.6; }
.boot__status code {
  font-family: var(--mono-font); font-size: 12px; background: var(--sunken);
  padding: 2px 6px; border-radius: 4px; color: var(--ink);
}
.boot.is-gone { opacity: 0; pointer-events: none; transition: opacity 260ms var(--ease); }

/* ---------- 5. App frame ---------- */
.app {
  display: grid;
  grid-template-rows: var(--titlebar-h) minmax(0, 1fr) var(--statusbar-h);
  height: 100vh;
  height: 100dvh;
}
.workspace {
  position: relative;          /* floating rail and drawer anchor to this */
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 0px;
  min-height: 0;
  overflow: hidden;            /* an off-canvas panel must not widen the page */
  transition: grid-template-columns var(--speed) var(--ease);
}
/* Each pane names its own column. Without this, a rail or drawer that
   goes position:absolute leaves the grid flow and the reader slides
   into the empty column behind it. */
.rail   { grid-area: 1 / 1; }
.reader { grid-area: 1 / 2; }
.drawer { grid-area: 1 / 3; }
.workspace.is-drawer-open { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--drawer-panel-w); }
.workspace.is-rail-hidden { grid-template-columns: 0px minmax(0, 1fr) 0px; }
.workspace.is-rail-hidden.is-drawer-open { grid-template-columns: 0px minmax(0, 1fr) var(--drawer-panel-w); }

/* scrim behind a floating rail or drawer */
.panel-scrim {
  position: absolute; inset: 0; z-index: 84;
  background: var(--scrim); backdrop-filter: blur(1.5px);
  animation: fade var(--speed) var(--ease);
}

/* ---------- 6. Title bar ---------- */
.titlebar {
  display: flex; align-items: center; gap: 14px;
  padding-left: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
  user-select: none;
}
.titlebar button, .titlebar input, .titlebar select { -webkit-app-region: no-drag; }
.titlebar__brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.titlebar__logo { border-radius: 3px; }
.titlebar__name {
  font-family: var(--scripture-serif);
  font-size: 16px; font-weight: 600; letter-spacing: .01em;
  color: var(--accent); white-space: nowrap;
}
.titlebar__center { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.titlebar__actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
/* in a browser the Electron window buttons are hidden, and they were the
   only thing holding the right-hand pills off the edge */
.titlebar:has(.wincontrols[hidden]) .titlebar__actions { padding-right: max(12px, var(--safe-r)); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--ink-soft);
  font-size: 12.5px; font-weight: 500;
  transition: background var(--speed), border-color var(--speed), color var(--speed);
  white-space: nowrap;
}
.pill:hover { background: var(--sunken); border-color: var(--faint); color: var(--ink); }
.pill--icon { width: 30px; padding: 0; justify-content: center; }
.pill--version { font-weight: 600; color: var(--accent); background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.pill--version:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: var(--accent); }
.pill--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pill--accent:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; color: var(--accent-ink); }
.pill--search { min-width: 190px; color: var(--muted); }
.pill--search span { flex: 1; text-align: left; }
.pill[aria-pressed="true"], .pill.is-on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.pill__caret { width: 9px; height: 6px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }

.wincontrols { display: flex; align-self: stretch; margin-left: 4px; border-left: 1px solid var(--line); }
.wincontrols__btn {
  width: 44px; display: grid; place-items: center; color: var(--muted);
  transition: background var(--speed), color var(--speed);
}
.wincontrols__btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.wincontrols__btn:hover { background: var(--sunken); color: var(--ink); }
.wincontrols__btn--close:hover { background: var(--danger); color: #fff; }
.wincontrols[hidden] { display: none; }

/* ---------- 7. Popover (settings) ---------- */
.menu-anchor { position: relative; }
.popover {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 120;
  width: 274px; padding: 6px;
  max-height: calc(100dvh - var(--titlebar-h) - 20px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop var(--speed) var(--ease);
}
.popover--right { left: auto; right: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px) scale(.985); } }
.popover__section { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.popover__section:last-child { border-bottom: 0; }
.popover__section--tight { padding: 5px; display: grid; gap: 1px; }
.popover__h {
  font-size: 11px; font-weight: 700; color: var(--muted);
  margin-bottom: 9px; display: flex; justify-content: space-between; align-items: baseline;
}
.popover__h-am { font-weight: 500; color: var(--faint); font-size: 10.5px; }

.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.swatch {
  display: grid; justify-items: center; gap: 5px; padding: 7px 2px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  transition: border-color var(--speed), color var(--speed), background var(--speed);
}
.swatch:hover { border-color: var(--faint); color: var(--ink); }
.swatch.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-wash); }
.swatch__chip { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(128,128,128,.35); }
.swatch__chip--light { background: linear-gradient(135deg, #ffffff 50%, #f2efe9 50%); }
.swatch__chip--dark  { background: linear-gradient(135deg, #161b22 50%, #0e1116 50%); }
.swatch__chip--ilalu { background: linear-gradient(135deg, #0f3620 50%, #0b2416 50%); }
.swatch__chip--sepia { background: linear-gradient(135deg, #f6efdd 50%, #e8dfcb 50%); }

.stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-md); padding: 3px;
}
.stepper__btn {
  width: 40px; height: 28px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--ink-soft);
  transition: background var(--speed), color var(--speed);
}
.stepper__btn--lg { font-size: 15px; }
.stepper__btn:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.stepper__btn:disabled { opacity: .35; cursor: not-allowed; }
.stepper__sign { font-size: .75em; margin-left: 1px; }
.stepper__value { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }

.row-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0; font-size: 12.5px; color: var(--ink-soft);
}
.mini-select {
  height: 26px; padding: 0 6px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 12px; cursor: pointer;
}
.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.ghost-btn {
  display: block; width: 100%; text-align: left; padding: 8px 9px;
  border-radius: var(--r-sm); font-size: 12.5px; color: var(--ink-soft);
  transition: background var(--speed), color var(--speed);
}
.ghost-btn:hover { background: var(--sunken); color: var(--ink); }

/* ---------- 8. Rail ---------- */
.rail {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  transition: visibility 0s linear var(--speed);
}
.workspace.is-rail-hidden .rail { visibility: hidden; border-right: 0; }
.rail__search {
  display: flex; align-items: center; gap: 7px;
  margin: 10px 10px 8px; padding: 0 9px; height: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  color: var(--faint);
  transition: border-color var(--speed);
}
.rail__search:focus-within { border-color: var(--accent); }
.rail__search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 12.5px; color: var(--ink); }
.rail__search input::placeholder { color: var(--faint); }
.rail__clear { color: var(--faint); font-size: 16px; line-height: 1; padding: 0 2px; }
.rail__clear:hover { color: var(--accent); }

.segmented { display: flex; gap: 2px; margin: 0 10px 8px; padding: 2px; background: var(--sunken); border-radius: 8px; }
.segmented__btn {
  flex: 1; height: 26px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: background var(--speed), color var(--speed);
}
.segmented__btn:hover { color: var(--ink); }
.segmented__btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.segmented__am { font-weight: 500; opacity: .65; font-size: 10px; }

.rail__scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 10px; }
.rail__empty { padding: 20px 12px; font-size: 12px; color: var(--faint); text-align: center; }

.booklist__group {
  font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--faint);
  padding: 12px 10px 5px; text-transform: uppercase;
}
.book {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 9px; border-radius: 7px; text-align: left;
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.35;
  transition: background var(--speed), color var(--speed);
}
.book:hover { background: var(--sunken); color: var(--ink); }
.book.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.book.is-active .book__count { color: var(--accent-ink); opacity: .7; }
.book__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book__alt { display: block; font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.book.is-active .book__alt { color: var(--accent-ink); opacity: .72; }
.book__count { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.chapgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 3px; padding: 7px 6px 10px;
  margin: 2px 3px 6px;
  background: var(--sunken); border-radius: var(--r-md);
  animation: unfold var(--speed) var(--ease);
}
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }
.chapgrid__btn {
  height: 28px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
  transition: background var(--speed), color var(--speed);
}
.chapgrid__btn:hover { background: var(--surface); color: var(--ink); }
.chapgrid__btn.is-active { background: var(--accent); color: var(--accent-ink); }
.chapgrid__btn.has-mark { box-shadow: inset 0 -2px 0 var(--gold); }

.rail__foot { display: flex; gap: 2px; padding: 4px 10px 0; border-top: 1px solid var(--line); }
.rail__foottab {
  flex: 1; height: 28px; font-size: 11px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color var(--speed), border-color var(--speed);
}
.rail__foottab:hover { color: var(--ink); }
.rail__foottab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.rail__panel { max-height: 172px; overflow-y: auto; padding: 6px 8px 10px; }
.markrow {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 6px 8px; border-radius: 7px; text-align: left; font-size: 12px; color: var(--ink-soft);
  transition: background var(--speed);
}
.markrow:hover { background: var(--sunken); }
.markrow__ref { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.markrow__x { color: var(--faint); font-size: 14px; line-height: 1; opacity: 0; }
.markrow:hover .markrow__x { opacity: 1; }
.markrow__x:hover { color: var(--danger); }
.markrow__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex-shrink: 0; }
.rail__panel .empty-hint { font-size: 11.5px; color: var(--faint); padding: 14px 8px; text-align: center; line-height: 1.55; }

/* ---------- 9. Reader ---------- */
.reader { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; background: var(--bg); }
.reader__bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(8px);
}
.reader__spacer { flex: 1; }
.navbtn {
  height: 30px; min-width: 30px; padding: 0 8px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 12px; font-weight: 500;
  transition: background var(--speed), color var(--speed);
}
.navbtn:hover:not(:disabled) { background: var(--sunken); color: var(--ink); }
.navbtn:disabled { opacity: .3; cursor: not-allowed; }
.navbtn.is-on { color: var(--gold); }
.navbtn.is-on .ico { fill: var(--gold); stroke: var(--gold); }

.crumb {
  display: inline-flex; align-items: baseline; gap: 7px;
  height: 30px; padding: 0 12px; border-radius: 8px;
  min-width: 0; flex: 0 1 auto;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color var(--speed), background var(--speed);
}
.crumb:hover { border-color: var(--faint); }
.crumb__book {
  font-family: var(--scripture-serif); font-size: 14.5px; font-weight: 600; color: var(--ink);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb__chapter, .crumb .pill__caret { flex-shrink: 0; }
.crumb__chapter { font-size: 12.5px; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.crumb .pill__caret { align-self: center; margin-left: 2px; }

.reader__scroll { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.reader__inner {
  display: grid; grid-template-columns: 1fr; gap: 26px;
  padding: 30px clamp(16px, 4vw, 54px) 20px;
  justify-content: center;
}
.reader__inner.is-parallel { grid-template-columns: 1fr 1fr; align-items: start; }

/* ---------- 10. Chapter typography ---------- */
.chapter { max-width: var(--measure); width: 100%; margin: 0 auto; }
.reader__inner.is-parallel .chapter { max-width: none; }

.chapter__head { margin-bottom: 22px; }
.chapter__version {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
  color: var(--accent); margin-bottom: 7px;
}
.chapter__title {
  font-family: var(--scripture-serif);
  font-size: clamp(22px, 2.6vw, 30px); font-weight: 600; line-height: 1.2;
  color: var(--ink); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.chapter__num {
  font-size: 1.28em; font-weight: 500; color: var(--accent);
  font-variant-numeric: lining-nums; letter-spacing: -.02em;
}
.chapter__alt { margin-top: 5px; font-size: 13px; color: var(--muted); font-family: var(--scripture-serif); }
.chapter__rule { height: 2px; margin-top: 14px; background: linear-gradient(90deg, var(--gold) 0 46px, var(--line) 46px); border-radius: 2px; }

.verses { font-family: var(--scripture-font); font-size: var(--scripture-size); line-height: var(--scripture-leading); color: var(--ink-soft); }

/* one verse per line */
.verse {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 5px 34px 5px 8px; margin: 1px 0 1px -8px;
  border-radius: var(--r-md); border: 1px solid transparent;
  color: inherit; font: inherit; cursor: text;
  transition: background 120ms linear, border-color 120ms linear;
}
.verse:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.verse.is-selected { background: color-mix(in srgb, var(--accent) 11%, transparent); border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.verse.is-focused { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.verse__n {
  font-family: var(--ui-font); font-size: .64em; font-weight: 700;
  color: var(--accent); vertical-align: .42em; margin-right: .5em;
  font-variant-numeric: tabular-nums; user-select: none;
}
.verse__t { }
.verse__t em, .verse__t .jesus { font-style: normal; }
[data-redletter="on"] .verse.is-jesus .verse__t { color: var(--accent); }
.verse__note {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center;
  color: var(--accent); opacity: 0; transition: opacity var(--speed), background var(--speed);
}
.verse:hover .verse__note, .verse__note:focus-visible { opacity: 1; }
.verse__note:hover { background: var(--accent); color: var(--accent-ink); }
.verse__note .ico { width: 13px; height: 13px; }

/* highlight colours */
.verse[data-hl="yellow"] { background: color-mix(in srgb, var(--hl-yellow) 26%, transparent); }
.verse[data-hl="green"]  { background: color-mix(in srgb, var(--hl-green)  24%, transparent); }
.verse[data-hl="blue"]   { background: color-mix(in srgb, var(--hl-blue)   24%, transparent); }
.verse[data-hl="pink"]   { background: color-mix(in srgb, var(--hl-pink)   24%, transparent); }
.verse[data-hl]:not([data-hl="none"]) { box-shadow: inset 3px 0 0 currentColor; }
.verse[data-hl="yellow"] { box-shadow: inset 3px 0 0 var(--hl-yellow); }
.verse[data-hl="green"]  { box-shadow: inset 3px 0 0 var(--hl-green); }
.verse[data-hl="blue"]   { box-shadow: inset 3px 0 0 var(--hl-blue); }
.verse[data-hl="pink"]   { box-shadow: inset 3px 0 0 var(--hl-pink); }
.verse.has-note::after {
  content: ""; position: absolute; top: 9px; right: 30px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--gold);
}

/* flowing paragraph layout */
.verses--flow { text-align: justify; hyphens: auto; }
.verses--flow .verse {
  display: inline; padding: 1px 2px; margin: 0; border-radius: 3px; border: 0;
}
.verses--flow .verse__note { display: none; }
.verses--flow .verse::after { display: none; }

.verses--empty { color: var(--faint); font-style: italic; text-align: center; padding: 40px 0; }

.reader__end {
  display: flex; justify-content: center; gap: 10px;
  padding: 10px 0 56px;
}
.endbtn {
  height: 34px; padding: 0 18px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  transition: border-color var(--speed), color var(--speed);
}
.endbtn:hover { border-color: var(--accent); color: var(--accent); }
.endbtn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.endbtn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-ink); }

/* ---------- 11. Selection bar ---------- */
.selbar {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: rise var(--speed) var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
.selbar__count { font-size: 12px; color: var(--muted); padding-left: 4px; }
.selbar__count b { color: var(--accent); font-variant-numeric: tabular-nums; }
.selbar__sep { width: 1px; height: 20px; background: var(--line); }
.selbar__colors { display: flex; gap: 4px; }
.hl-dot {
  width: 19px; height: 19px; border-radius: 50%;
  border: 1.5px solid rgba(128,128,128,.3);
  transition: transform 120ms var(--ease);
}
.hl-dot:hover { transform: scale(1.18); }
.hl-dot--yellow { background: var(--hl-yellow); }
.hl-dot--green  { background: var(--hl-green); }
.hl-dot--blue   { background: var(--hl-blue); }
.hl-dot--pink   { background: var(--hl-pink); }
.hl-dot--none   { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--faint) 3px 4px); }
.selbar__btn {
  height: 27px; padding: 0 11px; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.selbar__btn:hover { background: var(--sunken); color: var(--ink); }
.selbar__btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.selbar__btn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-ink); }
.selbar__btn--quiet { background: none; border-color: transparent; color: var(--muted); }

/* ---------- 12. Drawer ---------- */
.drawer {
  position: relative; min-width: 0; overflow: hidden;
  background: var(--surface); border-left: 1px solid var(--line);
  /* a closed drawer keeps its width animation but leaves the tab order */
  visibility: hidden;
  transition: visibility 0s linear var(--speed);
}
.workspace.is-drawer-open .drawer { visibility: visible; transition-delay: 0s; }
.drawer__grip { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; cursor: col-resize; z-index: 5; }
.drawer__grip:hover, .drawer__grip.is-dragging { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.drawer__inner { display: flex; flex-direction: column; height: 100%; width: 100%; min-width: min(320px, 100%); }
.drawer__tabs {
  display: flex; align-items: center; gap: 3px; padding: 7px 8px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.drawer__tab {
  flex: 1; height: 28px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted);
  transition: background var(--speed), color var(--speed);
}
.drawer__tab:hover { color: var(--ink); }
.drawer__tab.is-active { background: var(--accent); color: var(--accent-ink); }
.drawer__close { flex-shrink: 0; width: 26px; height: 26px; border-radius: 6px; color: var(--faint); font-size: 17px; line-height: 1; }
.drawer__close:hover { background: var(--sunken); color: var(--danger); }
.drawer__body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.drawer__blank { display: grid; place-content: center; gap: 12px; height: 100%; padding: 30px; text-align: center; }
.drawer__blank h3 { font-family: var(--scripture-serif); font-size: 17px; color: var(--ink); }
.drawer__blank p { font-size: 12.5px; color: var(--muted); line-height: 1.65; max-width: 25ch; margin: 0 auto; }

/* ---------- 13. Quick note ---------- */
.qn, .ind { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.qn__head, .ind__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 13px 14px 11px; border-bottom: 1px solid var(--line);
}
.qn__eyebrow, .ind__eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--faint); }
.qn__title h2, .ind__title h2 {
  font-family: var(--scripture-serif); font-size: 15.5px; font-weight: 600; color: var(--ink);
  margin-top: 2px; line-height: 1.3; word-break: break-word;
}
.qn__title, .ind__title { min-width: 0; }
.qn__headActions, .ind__headActions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

.mini-btn {
  height: 26px; padding: 0 9px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.mini-btn:hover { background: var(--sunken); color: var(--ink); }
.mini-btn--primary { background: var(--ok); border-color: var(--ok); color: #fff; }
.mini-btn--primary:hover { background: color-mix(in srgb, var(--ok) 85%, #000); color: #fff; }
.mini-btn--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: none; }
.mini-btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.mini-btn:disabled { opacity: .4; cursor: not-allowed; }
.mini-btn.is-saved { background: var(--ok); border-color: var(--ok); color: #fff; }

.qn__toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.qn__group { display: flex; gap: 2px; align-items: center; }
.qn__group + .qn__group { margin-left: 4px; padding-left: 6px; border-left: 1px solid var(--line); }
.tool {
  min-width: 26px; height: 26px; padding: 0 5px; border-radius: 6px;
  display: grid; place-items: center; font-size: 12px; color: var(--muted);
  transition: background var(--speed), color var(--speed);
}
.tool:hover { background: var(--sunken); color: var(--ink); }
.tool.is-active { background: var(--accent); color: var(--accent-ink); }

.qn__editorWrap { flex: 1; min-height: 0; display: flex; }
.qn__editor {
  flex: 1; overflow-y: auto; padding: 18px 18px 40px;
  font-family: var(--scripture-font); font-size: 15px; line-height: 1.72;
  color: var(--ink); outline: none; background: var(--surface);
}
.qn__editor:empty::before, .qn__editor.is-empty::before {
  content: attr(data-placeholder); color: var(--faint); pointer-events: none;
}
.qn__editor h2 { font-size: 19px; font-weight: 600; margin: 18px 0 6px; font-family: var(--scripture-serif); }
.qn__editor h3 { font-size: 16px; font-weight: 600; margin: 14px 0 5px; }
.qn__editor p { margin: 0 0 10px; }
.qn__editor ul { list-style: disc; padding-left: 22px; margin: 0 0 10px; }
.qn__editor ol { list-style: decimal; padding-left: 22px; margin: 0 0 10px; }
.qn__editor pre { background: var(--sunken); padding: 10px 12px; border-radius: var(--r-md); font-family: var(--mono-font); font-size: 12.5px; overflow-x: auto; }
.qn__editor blockquote {
  border-left: 3px solid var(--accent); padding-left: 13px; margin: 12px 0;
  color: var(--ink-soft);
}
.qn__editor .scripture-block {
  border-left: 3px solid var(--accent); padding: 4px 0 4px 13px; margin: 14px 0;
  background: var(--accent-wash); border-radius: 0 var(--r-md) var(--r-md) 0;
}
.qn__editor .scripture-block h4 {
  font-size: 12.5px; font-weight: 700; color: var(--accent); margin: 0 0 5px;
  font-family: var(--ui-font); letter-spacing: .01em;
}
.qn__editor .scripture-block p { font-size: .94em; margin: 0 0 4px; }
.qn__editor .scripture-block sup { font-size: .66em; font-weight: 700; opacity: .6; margin-right: 3px; }
.qn__editor a { color: var(--accent); }
.qn__editor hr { border: 0; border-top: 1px dashed var(--line); margin: 18px 0; }

.qn__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-top: 1px solid var(--line); background: var(--surface-2);
}
.qn__meta { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.qn__footActions { display: flex; gap: 5px; }

/* ---------- 14. Inductive study ---------- */
.dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: breathe 1.8s infinite; }
@keyframes breathe { 50% { opacity: .35; } }

.ind__progress { display: flex; gap: 2px; padding: 0 14px 10px; }
.ind__progress span { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background var(--speed); }
.ind__progress span.is-done { background: var(--ok); }

.ind__tabs { display: flex; gap: 3px; padding: 0 10px 9px; }
.ind__tab {
  flex: 1; height: 30px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.ind__tab:hover { color: var(--ink); border-color: var(--faint); }
.ind__tab.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ind__tabnum {
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; background: var(--sunken); color: var(--muted);
}
.ind__tab.is-active .ind__tabnum { background: rgba(255,255,255,.22); color: #fff; }

.ind__body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 20px; }
.ind__intro {
  padding: 10px 12px; margin-bottom: 14px; border-radius: var(--r-md);
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
  font-size: 12px; line-height: 1.6; color: var(--ink-soft);
}
.ind__intro b { color: var(--accent); }
.field { margin-bottom: 14px; }
.field__label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px;
}
.field__am { font-weight: 500; color: var(--faint); font-size: 10.5px; }
.field__input, .field__area {
  width: 100%; padding: 8px 10px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 12.8px; line-height: 1.6; outline: none;
  transition: border-color var(--speed), background var(--speed);
}
.field__area { resize: vertical; min-height: 66px; font-family: inherit; }
.field__input:focus, .field__area:focus { border-color: var(--accent); background: var(--surface); }
.field__input::placeholder, .field__area::placeholder { color: var(--faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.recorder { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; margin-bottom: 14px; background: var(--surface-2); }
.recorder__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.recorder__head h4 { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.recorder__head p { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.recbtn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  height: 28px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.recbtn:hover { border-color: var(--accent); color: var(--accent); }
.recbtn.is-live { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.recbtn__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.recbtn.is-live .recbtn__dot { background: #fff; animation: breathe 1.2s infinite; }

.wordtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.wordtable th {
  text-align: left; font-size: 10px; font-weight: 700; color: var(--muted);
  padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.wordtable th:last-child, .wordtable td:last-child { text-align: right; }
.wordtable td { padding: 5px 8px; border-bottom: 1px solid var(--line-soft); }
.wordtable tr:last-child td { border-bottom: 0; }
.wordtable__word { font-weight: 600; color: var(--ink); }
.wordtable__bar { display: block; height: 3px; border-radius: 2px; background: var(--accent); margin-top: 3px; opacity: .55; }
.wordtable__n { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.tiny-btn {
  width: 20px; height: 20px; border-radius: 5px; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--muted); margin-left: 2px;
  transition: background var(--speed), color var(--speed);
}
.tiny-btn:hover { background: var(--sunken); color: var(--ink); }
.tiny-btn--x:hover { background: var(--danger); color: #fff; }
.recorder__empty {
  border: 1px dashed var(--line); border-radius: var(--r-md); padding: 16px 12px;
  text-align: center; font-size: 11.5px; color: var(--faint); line-height: 1.6;
}
.ind__foot { padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.ind__foot h5 { font-size: 10px; font-weight: 700; color: var(--faint); margin-bottom: 7px; }
.chiprow { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  height: 24px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 11px; font-weight: 600; color: var(--ink-soft);
  transition: border-color var(--speed), color var(--speed);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }
.chip__x { color: var(--faint); font-size: 13px; line-height: 1; }
.chip__x:hover { color: var(--danger); }

/* ---------- 15. Modals ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 200;
  background: var(--scrim); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fade var(--speed) var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 440px; max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: lift var(--speed) var(--ease);
}
@keyframes lift { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal--wide { max-width: 720px; }
.modal--tall { height: 80vh; }
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal__head h2 { font-family: var(--scripture-serif); font-size: 17px; font-weight: 600; color: var(--ink); }
.modal__head p { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.modal__x { width: 28px; height: 28px; border-radius: 7px; color: var(--faint); font-size: 18px; line-height: 1; flex-shrink: 0; }
.modal__x:hover { background: var(--sunken); color: var(--danger); }
.modal__body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal__body--flush { padding: 8px; }
.modal__foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 13px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.btn {
  height: 34px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.btn:hover { background: var(--sunken); color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-ink); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { background: color-mix(in srgb, var(--ok) 85%, #000); color: #fff; }

.text-input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 13.5px; outline: none; transition: border-color var(--speed), background var(--speed);
}
.text-input:focus { border-color: var(--accent); background: var(--surface); }
.form-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.55; }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 8px; }

.choice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 12px 14px; margin-bottom: 7px; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--surface-2); text-align: left;
  transition: border-color var(--speed), background var(--speed);
}
.choice:last-child { margin-bottom: 0; }
.choice:hover { border-color: var(--accent); background: var(--surface); }
.choice.is-active { border-color: var(--accent); background: var(--accent-wash); }
.choice__label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.choice__sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.choice__mark { font-size: 11px; font-weight: 700; color: var(--accent); flex-shrink: 0; }

.noterow {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: var(--r-md);
  transition: background var(--speed);
}
.noterow:hover { background: var(--surface-2); }
.noterow__main { flex: 1; min-width: 0; text-align: left; }
.noterow__title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noterow__meta { font-size: 11px; color: var(--faint); margin-top: 2px; }
.noterow__kind {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 6px; border-radius: 4px;
  background: var(--sunken); color: var(--muted); flex-shrink: 0;
}
.noterow__kind--ind { background: var(--accent-wash); color: var(--accent); }
.noterow__del { opacity: 0; color: var(--faint); font-size: 12px; padding: 4px 6px; border-radius: 5px; }
.noterow:hover .noterow__del { opacity: 1; }
.noterow__del:hover { background: var(--danger); color: #fff; }

.empty-state { text-align: center; padding: 42px 20px; }
.empty-state h3 { font-family: var(--scripture-serif); font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.empty-state p { font-size: 12.5px; color: var(--muted); line-height: 1.65; max-width: 30ch; margin: 0 auto; }

.kbdlist { display: grid; gap: 1px; }
.kbdrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 4px; font-size: 12.5px; color: var(--ink-soft); }
.kbdrow + .kbdrow { border-top: 1px solid var(--line-soft); }
.kbdgroup { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--faint); padding: 14px 4px 5px; }
.kbdgroup:first-child { padding-top: 2px; }

/* ---------- 16. Search & palette ---------- */
.finder {
  width: 100%; max-width: 660px; max-height: 78vh;
  display: flex; flex-direction: column; align-self: start; margin-top: 7vh;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: lift var(--speed) var(--ease);
}
.finder__bar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.finder__bar .ico { width: 17px; height: 17px; color: var(--faint); flex-shrink: 0; }
.finder__input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; color: var(--ink); }
.finder__input::placeholder { color: var(--faint); }
.finder__scope { display: flex; gap: 4px; padding: 9px 14px; border-bottom: 1px solid var(--line-soft); background: var(--surface-2); flex-wrap: wrap; align-items: center; }
.scopebtn {
  height: 25px; padding: 0 10px; border-radius: 7px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); border: 1px solid transparent;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.scopebtn:hover { color: var(--ink); }
.scopebtn.is-active { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }
.finder__hint { margin-left: auto; font-size: 11px; color: var(--faint); }
.finder__results { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.finder__status { padding: 34px 20px; text-align: center; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.progressbar { height: 3px; border-radius: 2px; background: var(--sunken); overflow: hidden; margin: 14px auto 0; max-width: 220px; }
.progressbar span { display: block; height: 100%; background: var(--accent); transition: width 120ms linear; }

.hit { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: var(--r-md); transition: background var(--speed); }
.hit:hover, .hit.is-cursor { background: var(--surface-2); }
.hit.is-cursor { box-shadow: inset 2px 0 0 var(--accent); }
.hit__ref { font-size: 11.5px; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.hit__text { font-family: var(--scripture-font); font-size: 13.5px; line-height: 1.62; color: var(--ink-soft); }
.hit__text mark { background: color-mix(in srgb, var(--hl-yellow) 45%, transparent); color: var(--ink); border-radius: 2px; padding: 0 1px; }
.hit__group { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--faint); padding: 12px 12px 4px; }

.cmd { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: var(--r-md); text-align: left; transition: background var(--speed); }
.cmd:hover, .cmd.is-cursor { background: var(--surface-2); }
.cmd.is-cursor { box-shadow: inset 2px 0 0 var(--accent); }
.cmd__icon { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--sunken); color: var(--muted); flex-shrink: 0; font-size: 12px; }
.cmd__label { flex: 1; min-width: 0; font-size: 13px; color: var(--ink); }
.cmd__sub { font-size: 11px; color: var(--faint); margin-top: 1px; }

/* ---------- 17. Status bar & toasts ---------- */
.statusbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  border-top: 1px solid var(--line); background: var(--surface);
  font-size: 11px; color: var(--muted);
}
.statusbar__spacer { flex: 1; }
.statusbar__item--hint { color: var(--faint); }
.statusbar__item b { color: var(--ink-soft); }

.toasts {
  position: fixed; right: 18px; top: calc(var(--titlebar-h) + 12px); z-index: 300;
  display: grid; gap: 8px; justify-items: end; pointer-events: none;
}
.toast { pointer-events: auto; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 11px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); font-size: 12.5px; color: var(--ink);
  animation: slidein var(--speed) var(--ease);
}
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }
.toast.is-out { opacity: 0; transform: translateX(16px); transition: all var(--speed) var(--ease); }
.toast__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.toast--warn .toast__dot { background: var(--warn); }
.toast--error .toast__dot { background: var(--danger); }
.toast__action { font-size: 12px; font-weight: 700; color: var(--accent); margin-left: 4px; }

/* ---------- 18. Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: content-box; border: 3px solid transparent; }

/* ============================================================
   19. Responsive
   Four states, in order of narrowing:
     ≥1181px  desk      everything docked, nothing hidden
     ≤1180px  compact   drawer floats over the reader, rail button appears
     ≤900px   overlay   rail floats too, behind a scrim
     ≤640px   handheld  drawer goes full screen, chrome thins out
   ============================================================ */

/* the rail button only earns its place once something can be collapsed */
.titlebar__railbtn { display: none; flex-shrink: 0; }

/* ---------- ≤1180px — the drawer stops squeezing the reader ---------- */
@media (max-width: 1180px) {
  .titlebar__railbtn { display: inline-flex; }

  .workspace.is-drawer-open,
  .workspace.is-rail-hidden.is-drawer-open { grid-template-columns: var(--rail-w) minmax(0, 1fr) 0px; }
  .workspace.is-rail-hidden.is-drawer-open { grid-template-columns: 0px minmax(0, 1fr) 0px; }

  .drawer {
    position: absolute; grid-area: auto; top: 0; right: 0; bottom: 0; z-index: 86;
    width: min(var(--drawer-w), 86vw);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--speed) var(--ease), visibility 0s linear var(--speed);
  }
  .workspace.is-drawer-open .drawer {
    transform: none; visibility: visible; transition-delay: 0s, 0s;
  }
}

/* ---------- ≤900px — the rail floats as well ---------- */
@media (max-width: 900px) {
  :root { --rail-w: 0px; }

  .rail {
    position: absolute; grid-area: auto; top: 0; left: 0; bottom: 0; z-index: 88;
    width: min(290px, 78vw);
    padding-left: var(--safe-l);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--speed) var(--ease), visibility 0s linear var(--speed);
  }
  .workspace.is-rail-open .rail {
    transform: none; visibility: visible; transition-delay: 0s, 0s;
  }
  /* the rail is off-canvas here, so the desktop collapse state means nothing */
  .workspace.is-rail-hidden { grid-template-columns: 0px minmax(0, 1fr) 0px; }
  .rail__panel { max-height: 30vh; }

  .reader__inner.is-parallel { grid-template-columns: 1fr; gap: 20px; }
  .reader__inner.is-parallel .chapter { max-width: var(--measure); }

  .pill--search { min-width: 0; width: 30px; padding: 0; justify-content: center; }
  .pill--search span, .pill--search kbd { display: none; }
  .titlebar { gap: 9px; padding-left: calc(9px + var(--safe-l)); }
  .titlebar__center { gap: 6px; }
  .titlebar__actions { gap: 6px; }

  .modal--wide { max-width: 100%; }
  .modal--tall { height: auto; max-height: 86vh; }
}

/* ---------- ≤640px — handheld ---------- */
@media (max-width: 640px) {
  :root { --titlebar-h: 52px; --statusbar-h: 0px; --measure: none; }

  .statusbar { display: none; }
  .titlebar__name { display: none; }
  .only-compact { display: grid; }

  /* these three move into the settings popover */
  #btnParallel, #btnLibrary { display: none; }
  #btnNewNote { width: 34px; padding: 0; justify-content: center; font-size: 0; }
  #btnNewNote::before { content: "+"; font-size: 19px; font-weight: 500; line-height: 1; }

  /* the drawer becomes a sheet over the whole workspace */
  .drawer { width: 100%; border-left: 0; }
  .drawer__grip { display: none; }
  .drawer__tabs { padding: 9px 10px; }
  .drawer__tab { height: 36px; font-size: 13px; }
  .drawer__close { width: 36px; height: 36px; font-size: 21px; }

  .reader__inner { padding: 20px max(14px, var(--safe-l)) 16px max(14px, var(--safe-r)); gap: 18px; }
  .reader__bar { padding: 7px max(8px, var(--safe-r)) 7px max(8px, var(--safe-l)); gap: 3px; }
  .navbtn--label span { display: none; }
  .navbtn--label { min-width: 34px; padding: 0 6px; }
  .reader__end { padding: 10px 0 calc(40px + var(--safe-b)); }

  /* the settings popover can no longer hang off its anchor */
  .popover {
    position: fixed; top: calc(var(--titlebar-h) + 6px); right: 8px; left: auto;
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100dvh - var(--titlebar-h) - 18px); overflow-y: auto;
  }

  /* selection bar becomes a bottom sheet that wraps onto two rows */
  .selbar {
    position: fixed; left: 0; right: 0; bottom: 0; transform: none;
    flex-wrap: wrap; justify-content: center; row-gap: 7px;
    padding: 10px 12px calc(10px + var(--safe-b));
    border-radius: 16px 16px 0 0; border-width: 1px 0 0;
    animation: rise-flat var(--speed) var(--ease);
  }
  @keyframes rise-flat { from { opacity: 0; transform: translateY(14px); } }
  .selbar__sep { display: none; }
  .selbar__count { width: 100%; text-align: center; padding: 0; }
  .selbar__colors { width: 100%; justify-content: center; gap: 10px; }
  .hl-dot { width: 30px; height: 30px; }
  .selbar__btn { height: 36px; flex: 1 1 auto; min-width: 84px; }
  .selbar__btn--quiet { flex: 0 0 auto; min-width: 0; }
  /* keep the last verses reachable above the sheet */
  body.has-selection .reader__scroll { padding-bottom: 148px; }

  /* modals and the finder sit on the bottom edge, phone-style */
  .scrim { padding: 0; place-items: end stretch; }
  .modal, .finder {
    max-width: none; width: 100%;
    max-height: 90dvh; margin-top: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-width: 1px 0 0;
    padding-bottom: var(--safe-b);
    animation: sheet var(--speed) var(--ease);
  }
  @keyframes sheet { from { opacity: 0; transform: translateY(24px); } }
  .modal--tall { height: 90dvh; }
  .modal__foot { border-radius: 0; flex-wrap: wrap; }
  .modal__foot .btn { flex: 1 1 auto; }
  .finder { align-self: end; }
  .finder__hint { display: none; }

  .toasts { left: 12px; right: 12px; justify-items: stretch; }
  .toast { max-width: none; }

  .field-row { grid-template-columns: 1fr; }
  .qn__toolbar { padding: 7px 8px; }
  .qn__editor { padding: 16px 14px 40px; }
  .swatches { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- ≤380px — the last squeeze ---------- */
@media (max-width: 380px) {
  .titlebar { gap: 6px; padding-left: calc(6px + var(--safe-l)); }
  .titlebar__logo { display: none; }
  .pill--version { padding: 0 8px; font-size: 12px; }
  #btnPrint { display: none; }
  .reader__inner { padding-left: max(11px, var(--safe-l)); padding-right: max(11px, var(--safe-r)); }
}

/* ---------- short windows (phone in landscape) ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --titlebar-h: 42px; --statusbar-h: 0px; }
  .statusbar { display: none; }
  .reader__inner { padding-top: 14px; }
  .rail__panel, .rail__foot { display: none; }
  .modal, .finder { max-height: 96dvh; }
}

/* ---------- touch: bigger targets, no hover-only controls ---------- */
@media (pointer: coarse) {
  .pill, .navbtn { height: 36px; }
  .pill--icon, .pill--search { width: 36px; }
  .crumb { height: 36px; }
  .book { padding: 10px 9px; }
  .chapgrid { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px; }
  .chapgrid__btn { height: 40px; font-size: 13px; }
  .segmented__btn, .rail__foottab, .drawer__tab { height: 34px; }
  .markrow, .noterow { padding: 11px 10px; }
  .mini-btn, .recbtn, .chip { height: 34px; }
  .tool { min-width: 34px; height: 34px; font-size: 14px; }
  .modal__x, .drawer__close { width: 34px; height: 34px; }
  .scopebtn { height: 32px; }

  /* nothing may hide behind :hover on a touch screen */
  .markrow__x, .noterow__del { opacity: 1; }
  .verse__note { opacity: .5; width: 34px; height: 34px; }
  .verse__note .ico { width: 15px; height: 15px; }
  .verse { padding-right: 40px; }
  .verses--flow .verse { padding-right: 2px; }
  .verse:hover { background: none; }

  /* iOS zooms the page for any field under 16px */
  .rail__search input, .text-input, .field__input, .field__area, .mini-select, .finder__input {
    font-size: 16px;
  }
  .rail__search { height: 38px; }
  .mini-select { height: 32px; }
  .text-input { height: 44px; }
}

/* ---------- 20. Print ---------- */
@media print {
  body { overflow: visible; background: #fff; }
  .titlebar, .rail, .reader__bar, .drawer, .statusbar, .selbar, .reader__end, .boot { display: none !important; }
  .app { display: block; height: auto; }
  .workspace { display: block; }
  .reader__scroll { overflow: visible; }
  .reader__inner { padding: 0; display: block; }
  .chapter { max-width: none; color: #000; }
  .verse { break-inside: avoid; color: #000; }
  .verse__note { display: none; }
}

/* ---------- 21. Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
