/* ═══════════════════════════════════════════════════════════
   The Holy Bible — a quiet reader
   Parchment, moss, gold leaf, and light through a canopy.
   ═══════════════════════════════════════════════════════════ */

/* ── Palette ─────────────────────────────────────────────── */
:root {
  --vellum:        #efe6d2;
  --vellum-warm:   #e7dcc3;
  --vellum-deep:   #dccfb1;
  --vellum-edge:   #cbbb98;

  --ink:           #332c21;
  --ink-soft:      #6a604e;
  --ink-faint:     #8d8270;

  --moss:          #55684c;
  --moss-deep:     #3a4a37;
  --forest:        #26332a;

  --gold:          #a3823c;
  --gold-bright:   #c6a45c;
  --gold-pale:     #e0cb96;

  --field:         #ded1b4;
  --rule:          rgba(112, 96, 63, .26);
  --rule-soft:     rgba(112, 96, 63, .14);

  --shade-1: rgba(74, 60, 34, .09);
  --shade-2: rgba(74, 60, 34, .16);
  --shade-3: rgba(52, 42, 24, .26);
  --lift:    rgba(255, 252, 243, .85);

  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
           "Hoefler Text", "Times New Roman", Georgia, serif;
  --sans:  ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --read: 1.0625rem;
  --leaf-w: 40rem;
  --lib-w: 17.5rem;
  --head-h: 4.25rem;

  --ease: cubic-bezier(.32, .72, .3, 1);
  color-scheme: light;
}

/* ── Night: the forest after dusk ────────────────────────── */
[data-theme="night"] {
  --vellum:        #1b211c;
  --vellum-warm:   #202721;
  --vellum-deep:   #171d18;
  --vellum-edge:   #0f140f;

  --ink:           #ded2b8;
  --ink-soft:      #a49a83;
  --ink-faint:     #7d7462;

  --moss:          #8aa47c;
  --moss-deep:     #6f8a63;
  --forest:        #c3d3b4;

  --gold:          #c6a45c;
  --gold-bright:   #e2c383;
  --gold-pale:     #6b5730;

  --field:         #232b24;
  --rule:          rgba(198, 164, 92, .26);
  --rule-soft:     rgba(198, 164, 92, .13);

  --shade-1: rgba(0, 0, 0, .28);
  --shade-2: rgba(0, 0, 0, .40);
  --shade-3: rgba(0, 0, 0, .55);
  --lift:    rgba(190, 210, 175, .07);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--vellum-deep);
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(196, 208, 172, .30), transparent 62%),
    radial-gradient(90% 60% at 12% 108%, rgba(74, 96, 62, .22), transparent 66%),
    radial-gradient(70% 55% at 92% 6%, rgba(214, 186, 118, .20), transparent 60%),
    linear-gradient(178deg, var(--vellum-warm), var(--vellum-deep) 72%);
  background-attachment: fixed;
  transition: background-color .5s var(--ease), color .35s var(--ease);
  overflow-x: hidden;
}

[data-theme="night"] body {
  background-image:
    radial-gradient(120% 80% at 50% -12%, rgba(96, 132, 92, .28), transparent 60%),
    radial-gradient(90% 60% at 10% 110%, rgba(40, 62, 44, .55), transparent 64%),
    radial-gradient(60% 50% at 90% 4%, rgba(150, 120, 60, .16), transparent 58%),
    linear-gradient(178deg, #202721, #12170f 76%);
}

/* ── Grain: the tooth of old paper ───────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: -30%;
  pointer-events: none;
  z-index: 0;
  opacity: .38;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}
[data-theme="night"] body::before { mix-blend-mode: overlay; opacity: .30; }

/* ── Canopy: light falling through leaves ────────────────── */
.canopy {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    conic-gradient(from 205deg at 22% -18%, transparent 0deg, rgba(255, 246, 214, .30) 14deg, transparent 30deg),
    conic-gradient(from 168deg at 74% -12%, transparent 0deg, rgba(255, 248, 222, .22) 11deg, transparent 24deg),
    radial-gradient(140% 100% at 50% 50%, transparent 52%, var(--shade-2) 100%);
  mix-blend-mode: soft-light;
}
[data-theme="night"] .canopy { opacity: .55; }

/* ── Motes: spores adrift in a shaft of light ────────────── */
.motes { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.mote {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-bright), transparent 68%);
  opacity: 0;
  will-change: transform, opacity;
  animation: drift linear infinite;
}
@keyframes drift {
  0%   { transform: translate3d(0, 12vh, 0) scale(.6);   opacity: 0; }
  12%  { opacity: .5; }
  50%  { transform: translate3d(3.5vw, -42vh, 0) scale(1); }
  88%  { opacity: .35; }
  100% { transform: translate3d(-2.5vw, -96vh, 0) scale(.7); opacity: 0; }
}

/* ═══ Masthead ═══════════════════════════════════════════ */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--head-h);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0 clamp(.75rem, 2.5vw, 1.5rem);
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(to bottom, var(--vellum-warm) 55%, rgba(0, 0, 0, 0));
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}
.masthead::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--rule) 18%, var(--rule) 82%, transparent);
}
[data-theme="night"] .masthead {
  background: linear-gradient(to bottom, rgba(28, 35, 29, .92) 55%, rgba(0, 0, 0, 0));
}

.masthead-title {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: .85rem;
}
.masthead-title h1 {
  margin: 0;
  font-size: clamp(.95rem, 2.2vw, 1.15rem);
  font-weight: 400;
  letter-spacing: .24em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  text-shadow: 0 1px 0 var(--lift);
}
.masthead-rule {
  width: clamp(1.25rem, 6vw, 3.25rem);
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.masthead-tools { grid-column: 3; display: flex; justify-content: flex-end; gap: .15rem; }
.menu-btn { grid-column: 1; justify-self: start; }

/* ── Buttons ─────────────────────────────────────────────── */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .22s var(--ease), color .22s var(--ease),
              border-color .22s var(--ease), transform .22s var(--ease);
}
.icon-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover {
  color: var(--ink);
  border-color: var(--rule-soft);
  background: var(--lift);
  box-shadow: 0 1px 3px var(--shade-1);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { color: var(--gold); border-color: var(--rule); background: var(--lift); }

/* ── Translation ─────────────────────────────────────────── */
.version-btn {
  display: inline-flex;
  align-items: center;
  height: 2rem;
  margin-right: .3rem;
  padding: 0 .7rem;
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
  background: linear-gradient(to bottom, var(--lift), transparent);
  font-family: var(--sans);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--gold);
  cursor: pointer;
  box-shadow: 0 1px 2px var(--shade-1);
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.version-btn:hover { color: var(--ink); border-color: var(--gold); transform: translateY(-1px); }
.version-btn:active { transform: translateY(0); }

.version-panel { max-width: 30rem; }
.version-list { overflow-y: auto; padding: .7rem; }
.version-row {
  display: flex;
  align-items: center;
  gap: .9rem;
  width: 100%;
  padding: .8rem .85rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.version-row:hover { background: var(--lift); border-color: var(--rule-soft); }
.version-row[aria-current="true"] {
  background: linear-gradient(to right, var(--lift), transparent);
  border-color: var(--rule-soft);
  box-shadow: inset 2px 0 0 var(--gold);
}
.version-tag {
  flex: none;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 2.1rem;
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: linear-gradient(to bottom, var(--lift), transparent);
  font-family: var(--sans);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--gold);
}
.version-row[aria-current="true"] .version-tag {
  color: #fff;
  background: linear-gradient(to bottom, var(--moss), var(--moss-deep));
  border-color: var(--moss-deep);
}
[data-theme="night"] .version-row[aria-current="true"] .version-tag { color: #12170f; }
.version-meta { display: flex; flex-direction: column; gap: .16rem; min-width: 0; }
.version-name { font-size: 1rem; letter-spacing: .01em; }
.version-lang { font-size: .72rem; color: var(--ink-faint); font-style: italic; }

.ico-sun { display: none; }
[data-theme="night"] .ico-moon { display: none; }
[data-theme="night"] .ico-sun  { display: block; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ═══ Shell ══════════════════════════════════════════════ */
.shell {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: var(--lib-w) minmax(0, 1fr);
  align-items: start;
}

/* ═══ Library ════════════════════════════════════════════ */
.library {
  position: sticky;
  top: var(--head-h);
  height: calc(100dvh - var(--head-h));
  padding: 1.1rem .75rem 1.5rem 1.1rem;
}
.library-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: .8rem;
  padding-right: .35rem;
}
.library-search { position: relative; flex: none; }
.library-search input,
.search-field input {
  width: 100%;
  font: inherit;
  font-size: .88rem;
  color: var(--ink);
  padding: .5rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--field);
  box-shadow: inset 0 2px 4px var(--shade-1), 0 1px 0 var(--lift);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.library-search input::placeholder,
.search-field input::placeholder { color: var(--ink-faint); font-style: italic; }
.library-search input:focus,
.search-field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: inset 0 2px 4px var(--shade-1), 0 0 0 3px rgba(163, 130, 60, .16);
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.book-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
  mask-image: linear-gradient(to bottom, transparent, #000 1.25rem, #000 calc(100% - 1.5rem), transparent);
  padding: .25rem .1rem 1rem;
}
.book-list::-webkit-scrollbar { width: 6px; }
.book-list::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.testament {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 1.1rem .35rem .55rem;
  font-size: .66rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}
.testament:first-child { margin-top: .25rem; }
.testament::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--rule), transparent);
}

.book {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  width: 100%;
  padding: .34rem .6rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  font: inherit;
  font-size: .95rem;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.book:hover { color: var(--ink); background: var(--lift); border-color: var(--rule-soft); }
.book .n { flex: 1; }
.book .c { font-size: .72rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.book[aria-current="true"] {
  color: var(--ink);
  background: linear-gradient(to right, var(--lift), transparent);
  border-color: var(--rule-soft);
  box-shadow: inset 2px 0 0 var(--gold);
}
.book[aria-current="true"] .n { font-weight: 600; }
.book-empty { padding: 1rem .6rem; color: var(--ink-faint); font-style: italic; font-size: .88rem; }

/* ═══ The leaf (page) ════════════════════════════════════ */
.page {
  padding: clamp(1.25rem, 3vw, 2.75rem) clamp(.85rem, 3vw, 2rem) 5rem;
  display: flex;
  justify-content: center;
}

.leaf {
  position: relative;
  width: 100%;
  max-width: var(--leaf-w);
  padding: clamp(2.25rem, 5vw, 3.75rem) clamp(1.5rem, 5vw, 3.5rem) clamp(1.75rem, 4vw, 2.75rem);
  border-radius: 3px 3px 5px 5px;
  background:
    linear-gradient(to right, rgba(180, 158, 110, .13), transparent 3.5%, transparent 96.5%, rgba(180, 158, 110, .13)),
    radial-gradient(120% 90% at 50% 0%, var(--vellum), var(--vellum-warm) 78%);
  box-shadow:
    0 1px 1px var(--shade-1),
    0 3px 6px var(--shade-1),
    0 12px 26px var(--shade-2),
    0 34px 70px -22px var(--shade-3),
    inset 0 1px 0 var(--lift);
}
[data-theme="night"] .leaf {
  background:
    linear-gradient(to right, rgba(0, 0, 0, .22), transparent 3.5%, transparent 96.5%, rgba(0, 0, 0, .22)),
    radial-gradient(120% 90% at 50% 0%, #222a23, #1a201b 78%);
  border: 1px solid rgba(198, 164, 92, .1);
}

/* deckled stack of pages beneath */
.leaf-edge { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; }
.leaf-edge::before,
.leaf-edge::after {
  content: "";
  position: absolute;
  left: .4rem; right: .4rem;
  bottom: -4px;
  height: 8px;
  border-radius: 0 0 5px 5px;
  background: var(--vellum-deep);
  box-shadow: 0 2px 4px var(--shade-1);
  z-index: -1;
}
.leaf-edge::after { left: .85rem; right: .85rem; bottom: -8px; background: var(--vellum-edge); }

/* ── Chapter head ────────────────────────────────────────── */
.chapter-head { text-align: center; margin-bottom: clamp(1.5rem, 3.5vw, 2.25rem); }
.book-name {
  margin: 0;
  font-size: clamp(1.5rem, 4.2vw, 2.1rem);
  font-weight: 400;
  letter-spacing: .045em;
  color: var(--forest);
  text-shadow: 0 1px 0 var(--lift);
}
[data-theme="night"] .book-name { text-shadow: none; }
.chapter-no {
  margin: .55rem 0 0;
  font-size: .68rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.ornament { margin: .8rem auto 0; max-width: 15rem; color: var(--gold); }
.ornament svg { display: block; width: 100%; height: auto; fill: currentColor; stroke: none; opacity: .85; }
.ornament.small { max-width: 9rem; opacity: .55; }
.ornament .ln { fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; }
.leaf-foot { margin-top: clamp(1.5rem, 4vw, 2.5rem); }

/* ── Verses ──────────────────────────────────────────────── */
.verses {
  font-size: var(--read);
  line-height: 1.78;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.verses.poetry { text-align: left; hyphens: none; -webkit-hyphens: none; }

.v {
  cursor: pointer;
  border-radius: 3px;
  transition: background .3s var(--ease), box-shadow .3s var(--ease);
  padding: .05em .12em;
  margin: 0 -.06em;
}
.verses.poetry .v {
  display: block;
  padding: .3em .55em .3em 2.6em;
  margin: .1em -.55em;
  text-indent: -2.05em;
}
.v:hover { background: rgba(163, 130, 60, .1); }
.v.lit {
  background: linear-gradient(to bottom, rgba(198, 164, 92, .3), rgba(198, 164, 92, .17));
  box-shadow: inset 0 0 0 1px rgba(163, 130, 60, .3), 0 0 18px rgba(198, 164, 92, .28);
}
.v.kept { background: rgba(163, 130, 60, .1); box-shadow: inset 0 -2px 0 rgba(163, 130, 60, .4); }

.verses .n {
  font-family: var(--sans);
  font-size: .58em;
  font-weight: 600;
  letter-spacing: .02em;
  vertical-align: .55em;
  color: var(--gold);
  margin-right: .28em;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.verses.poetry .n { vertical-align: baseline; font-size: .68em; display: inline-block; width: 2em; text-align: right; margin-right: .6em; }

/* the illuminated opening letter */
.dropcap {
  float: left;
  font-size: 3.4em;
  line-height: .78;
  padding: .04em .09em 0 0;
  color: var(--moss-deep);
  font-weight: 500;
  text-shadow: 0 1px 0 var(--lift), 0 2px 4px var(--shade-1);
}
[data-theme="night"] .dropcap { color: var(--moss); text-shadow: 0 0 22px rgba(138, 164, 124, .3); }

.mark {
  background: linear-gradient(to bottom, transparent 58%, rgba(198, 164, 92, .45) 58%);
  border-radius: 2px;
  color: inherit;
  font-weight: 600;
}

/* ── Turn the page ───────────────────────────────────────── */
.turn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-top: clamp(1.25rem, 3vw, 2rem);
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule-soft);
}
.turn-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  max-width: 42%;
  padding: .48rem .95rem;
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
  background: linear-gradient(to bottom, var(--lift), transparent);
  font: inherit;
  font-size: .82rem;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px var(--shade-1);
  transition: color .2s var(--ease), border-color .2s var(--ease),
              transform .2s var(--ease), box-shadow .2s var(--ease);
}
.turn-btn svg { flex: none; width: .95rem; height: .95rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.turn-btn:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--rule);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px var(--shade-1);
}
.turn-btn:active:not(:disabled) { transform: translateY(0); }
.turn-btn:disabled { opacity: .3; cursor: default; }
.chapters-btn {
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ═══ Veils & panels ═════════════════════════════════════ */
.veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 7vh, 5rem) 1rem 2rem;
  background: rgba(38, 32, 20, .42);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: veil-in .3s var(--ease);
}
[data-theme="night"] .veil { background: rgba(6, 10, 7, .6); }
.veil[hidden] { display: none; }
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: 100%;
  max-width: 40rem;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: radial-gradient(110% 80% at 50% 0%, var(--vellum), var(--vellum-warm) 80%);
  box-shadow: 0 24px 60px -12px rgba(30, 24, 12, .5), inset 0 1px 0 var(--lift);
  overflow: hidden;
  animation: panel-in .34s var(--ease);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(-12px) scale(.985); } to { opacity: 1; transform: none; } }

.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .8rem .8rem .8rem 1.35rem;
  border-bottom: 1px solid var(--rule-soft);
}
.panel-head h2 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
}
.search-field { flex: 1; display: flex; align-items: center; gap: .55rem; }
.search-field > svg { flex: none; width: 1.05rem; height: 1.05rem; fill: none; stroke: var(--ink-faint); stroke-width: 1.5; stroke-linecap: round; }
.search-field input { border-radius: 8px; font-size: 1rem; }

.search-note { margin: 0; padding: .9rem 1.35rem; font-size: .85rem; font-style: italic; color: var(--ink-faint); }
.search-note em { color: var(--gold); font-style: normal; }

.results { overflow-y: auto; overscroll-behavior: contain; padding: 0 .6rem 1rem; }
.hit {
  display: block;
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.hit:hover { background: var(--lift); border-color: var(--rule-soft); }
.hit .ref {
  display: block;
  margin-bottom: .18rem;
  font-family: var(--sans);
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.hit .txt { display: block; font-size: .92rem; line-height: 1.6; color: var(--ink-soft); }
.hit + .hit { box-shadow: 0 -1px 0 var(--rule-soft); }

/* ── Chapter grid ────────────────────────────────────────── */
.chapters-panel { max-width: 32rem; }
.chapter-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr));
  gap: .4rem;
  padding: 1.1rem;
}
.chip {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-soft);
  border-radius: 7px;
  background: linear-gradient(to bottom, var(--lift), transparent);
  font: inherit;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 1px 2px var(--shade-1);
  transition: all .16s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--gold); transform: translateY(-1px); box-shadow: 0 3px 7px var(--shade-1); }
.chip[aria-current="true"] {
  color: #fff;
  background: linear-gradient(to bottom, var(--moss), var(--moss-deep));
  border-color: var(--moss-deep);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
[data-theme="night"] .chip[aria-current="true"] { color: #12170f; text-shadow: none; }

.empty { padding: 2.5rem 1.35rem; text-align: center; color: var(--ink-faint); font-style: italic; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.75rem;
  z-index: 90;
  padding: .6rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--vellum);
  color: var(--ink);
  font-size: .84rem;
  letter-spacing: .02em;
  box-shadow: 0 10px 28px -6px rgba(30, 24, 12, .45);
  transform: translate(-50%, 1.5rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Loading ─────────────────────────────────────────────── */
.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.5rem;
  background: var(--vellum-deep);
  transition: opacity .55s var(--ease), visibility .55s;
}
.loading.done { opacity: 0; visibility: hidden; }
.loading p { margin: 0; font-size: .72rem; letter-spacing: .28em; text-transform: uppercase; color: var(--ink-faint); }
.lamp {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, var(--gold-bright), var(--gold) 45%, transparent 70%);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(.86); opacity: .5;  box-shadow: 0 0 18px 2px rgba(198, 164, 92, .28); }
  50%      { transform: scale(1);   opacity: .95; box-shadow: 0 0 42px 8px rgba(198, 164, 92, .42); }
}

/* ── Page-turn ───────────────────────────────────────────── */
.leaf.turning .verses,
.leaf.turning .chapter-head { animation: settle .42s var(--ease); }
@keyframes settle { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* ═══ Responsive ═════════════════════════════════════════ */
.scrim { display: none; }

@media (max-width: 62rem) {
  .shell { grid-template-columns: 1fr; }
  .library {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 70;
    width: min(19rem, 84vw);
    height: 100dvh;
    padding-top: calc(1rem + env(safe-area-inset-top));
    background: radial-gradient(120% 70% at 0% 0%, var(--vellum), var(--vellum-warm) 75%);
    border-right: 1px solid var(--rule);
    box-shadow: 14px 0 40px -14px rgba(30, 24, 12, .5);
    transform: translateX(-102%);
    transition: transform .34s var(--ease);
  }
  .library.open { transform: none; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(38, 32, 20, .42);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: veil-in .3s var(--ease);
  }
  .scrim[hidden] { display: none; }
}

@media (min-width: 62.0625rem) { .menu-btn { display: none; } }

/* justification needs room to breathe; below this it opens rivers */
@media (max-width: 44rem) {
  .verses { text-align: left; hyphens: none; -webkit-hyphens: none; }
}

@media (max-width: 34rem) {
  :root { --head-h: 3.75rem; }
  .masthead-rule { display: none; }
  .masthead-title h1 { letter-spacing: .16em; }
  .leaf { border-radius: 2px; }
  .turn-btn { max-width: 38%; }
  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); }
}

/* ── Preferences ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .motes { display: none; }
}

@media print {
  .masthead, .library, .turn, .motes, .canopy, .loading, .veil, .toast, .leaf-edge { display: none !important; }
  body { background: #fff; }
  .leaf { box-shadow: none; max-width: none; background: #fff; }
}
