:root {
  --bg: #faf7f1;
  --bg-raised: #ffffff;
  --bg-sunken: #f1ece2;
  --fg: #22201c;
  --fg-soft: #55504a;
  --muted: #857e73;
  --line: #e3ddd2;
  --accent: #8a4b2a;
  --accent-soft: #f3e3d8;
  --mark: #ffe9a8;
  --shadow: 0 10px 30px rgba(40, 30, 15, 0.12);
  --rs: 1;
  --topbar-h: 54px;
  --read-width: 42rem;
  --font-read: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --hl-god: #d9a820;
  --hl-christ: #3b82d7;
  --hl-spirit: #2f9e63;
  --hl-sin: #c0392b;
  --hl-salvation: #8e5ac8;
  --hl-people: #d97b2f;
  --hl-love: #d65d8f;
  --hl-places: #46a6c9;
  --hl-prophecy: #9a6b3f;
  --hl-law: #7a7a7a;
}
html[data-theme="dark"] {
  --bg: #17161a;
  --bg-raised: #1f1e23;
  --bg-sunken: #121115;
  --fg: #e8e4dc;
  --fg-soft: #b7b1a6;
  --muted: #8b857a;
  --line: #302e35;
  --accent: #d99a72;
  --accent-soft: #3a2b22;
  --mark: #6b5a24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --hl-god: #e0b53a;
  --hl-christ: #6aa7e8;
  --hl-spirit: #4cb880;
  --hl-sin: #e06a5c;
  --hl-salvation: #b685e0;
  --hl-people: #eda062;
  --hl-love: #e58aae;
  --hl-places: #6cb8d8;
  --hl-prophecy: #be9460;
  --hl-law: #969696;
}
html[data-serif="sans"] {
  --font-read: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
html[data-width="wide"] {
  --read-width: 54rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--fg); color: var(--bg); padding: 0.6rem 1rem;
}
.skip-link:focus { left: 0; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-main { font-weight: 700; font-size: 1.02rem; letter-spacing: 0.01em; }
.brand-sub { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }

.text-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.42rem 0.7rem; border-radius: 8px;
  color: var(--fg-soft); font-size: 0.9rem; font-weight: 500;
}
.text-btn:hover { background: var(--bg-sunken); color: var(--fg); text-decoration: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1rem; height: 2.1rem; padding: 0 0.4rem;
  border-radius: 8px; color: var(--fg-soft);
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--fg); }
.icon-btn.sm { min-width: 1.9rem; height: 1.9rem; font-size: 0.85rem; }
.aa { font-weight: 600; letter-spacing: 0.03em; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }

.typo-wrap { position: relative; }
.typo-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  width: 15.5rem; padding: 0.6rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.typo-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.32rem 0.25rem; }
.typo-label { font-size: 0.8rem; color: var(--muted); }
.seg { display: flex; background: var(--bg-sunken); border-radius: 8px; padding: 2px; }
.seg-btn { padding: 0.24rem 0.55rem; font-size: 0.78rem; border-radius: 6px; color: var(--fg-soft); }
.seg-btn.on { background: var(--bg-raised); color: var(--fg); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }

.hl-glyph { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.hl-glyph i { width: 3px; border-radius: 1px; display: block; }
.hl-glyph i:nth-child(1) { height: 7px; background: var(--hl-god); }
.hl-glyph i:nth-child(2) { height: 11px; background: var(--hl-christ); }
.hl-glyph i:nth-child(3) { height: 9px; background: var(--hl-spirit); }
.hl-wrap { position: relative; }
.hl-panel { width: 21rem; max-width: calc(100vw - 1rem); max-height: min(80vh, 32rem); overflow-y: auto; }
.hl-panel .seg { margin-bottom: 0.55rem; }
.hl-hint { font-size: 0.74rem; color: var(--muted); margin: 0 0 0.55rem; line-height: 1.45; }
.hl-legend { display: flex; flex-direction: column; gap: 1px; }
.hl-row { display: flex; align-items: center; gap: 0.55rem; padding: 0.34rem 0.3rem; border-radius: 9px; }
.hl-row:hover { background: var(--bg-sunken); }
.swatch {
  width: 1.4rem; height: 1.4rem; border-radius: 7px;
  display: flex; align-items: center; justify-content: center; font-size: 0.8rem;
  background: color-mix(in srgb, var(--sw) 24%, transparent);
  border: 1px solid color-mix(in srgb, var(--sw) 65%, transparent);
}
.hl-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hl-name { font-weight: 650; font-size: 0.82rem; color: var(--fg); line-height: 1.2; }
.hl-desc { font-size: 0.72rem; color: var(--muted); line-height: 1.35; }

.m {
  border-radius: 3px;
  background: color-mix(in srgb, var(--m) 34%, transparent);
  box-shadow: inset 0 -1.5px 0 0 color-mix(in srgb, var(--m) 60%, transparent);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.m-god { --m: var(--hl-god); }
.m-christ { --m: var(--hl-christ); }
.m-spirit { --m: var(--hl-spirit); }
.m-sin { --m: var(--hl-sin); }
.m-salvation { --m: var(--hl-salvation); }
.m-people { --m: var(--hl-people); }
.m-love { --m: var(--hl-love); }
.m-places { --m: var(--hl-places); }
.m-prophecy { --m: var(--hl-prophecy); }
.m-law { --m: var(--hl-law); }

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  position: sticky; top: var(--topbar-h);
  width: 270px; flex: 0 0 270px;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-raised);
  padding: 0.9rem 0.7rem 2rem;
}
.testament-h {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); margin: 1rem 0.5rem 0.4rem;
}
.book-item { border-radius: 9px; }
.book-row {
  width: 100%; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.42rem 0.55rem; border-radius: 9px;
  color: var(--fg-soft); font-size: 0.92rem; text-align: left;
}
.book-row:hover { background: var(--bg-sunken); color: var(--fg); }
.book-row .chev { margin-left: auto; color: var(--muted); font-size: 0.7rem; transition: transform 0.15s; }
.book-item.active > .book-row { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.book-item.active > .book-row .chev { transform: rotate(90deg); color: var(--accent); }
.chap-grid { display: none; padding: 0.35rem 0.4rem 0.6rem; grid-template-columns: repeat(auto-fill, minmax(2.3rem, 1fr)); gap: 4px; }
.book-item.active .chap-grid { display: grid; }
.chap-grid a {
  display: flex; align-items: center; justify-content: center;
  height: 2.1rem; border-radius: 7px; font-size: 0.83rem;
  color: var(--fg-soft); background: var(--bg-sunken);
}
.chap-grid a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.chap-grid a.here { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: 1.2rem; padding: 0 0.55rem; }
.sidebar-foot a { font-size: 0.82rem; color: var(--muted); }
.sidebar-foot a:hover { color: var(--accent); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 44; }

.main { flex: 1; min-width: 0; padding: 1.4rem 1.2rem 4rem; }

.resume-banner {
  display: flex; align-items: center; gap: 0.9rem;
  max-width: var(--read-width); margin: 0 auto 1.2rem;
  padding: 0.7rem 0.9rem;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
}
.resume-copy { display: flex; flex-direction: column; min-width: 0; }
.resume-copy strong { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.resume-copy span { color: var(--fg); font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume-banner .icon-btn { margin-left: auto; }
.pill-btn {
  padding: 0.42rem 0.95rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.88rem;
}
.pill-btn:hover { filter: brightness(1.08); }

.search-panel {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: 1.2rem 1rem;
}
.search-bar {
  display: flex; align-items: center; gap: 0.6rem;
  max-width: 44rem; width: 100%; margin: 0 auto;
  background: var(--bg-raised); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 0.55rem 0.75rem;
  box-shadow: var(--shadow);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-glyph { color: var(--muted); flex: 0 0 auto; }
.search-bar input { flex: 1; min-width: 0; border: 0; background: none; font-size: 1.05rem; color: var(--fg); outline: none; }
.search-status { max-width: 44rem; width: 100%; margin: 0.7rem auto 0.3rem; font-size: 0.85rem; color: var(--muted); }
.search-results { max-width: 44rem; width: 100%; margin: 0 auto; padding: 0; list-style: none; overflow-y: auto; }
.search-results li { margin-bottom: 0.45rem; }
.result-btn {
  display: block; width: 100%; text-align: left;
  padding: 0.65rem 0.8rem; border-radius: 10px;
  background: var(--bg-raised); border: 1px solid var(--line);
}
.result-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.result-btn.ref-result {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.result-btn.ref-result .result-ref::before { content: "→ "; }
.ref-result .result-snippet { font-family: var(--font-ui); font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.result-ref { display: block; font-weight: 650; font-size: 0.85rem; color: var(--accent); margin-bottom: 0.15rem; }
.result-snippet { display: block; font-family: var(--font-read); font-size: 0.95rem; color: var(--fg-soft); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

.reading { max-width: var(--read-width); margin: 0 auto; outline: none; }
.crumb { font-size: 0.8rem; color: var(--muted); margin: 0 0 0.9rem; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }
.book-head { margin-bottom: 1.4rem; }
.book-name { font-size: 1.75rem; margin: 0; letter-spacing: -0.01em; }
.book-full { margin: 0.3rem 0 0; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.chapter-title {
  text-align: center; font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
  margin: 1.6rem 0 1.3rem; display: flex; align-items: center; gap: 0.9rem;
}
.chapter-title::before, .chapter-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.superscription {
  font-family: var(--font-read); font-style: italic;
  color: var(--fg-soft); font-size: calc(1.02rem * var(--rs));
  margin: 0 0 1.1rem; padding-left: 1.4rem;
}
.chapter-text {
  font-family: var(--font-read);
  font-size: calc(1.14rem * var(--rs));
  line-height: 1.78;
  color: var(--fg);
  margin: 0;
}
.verse { border-radius: 5px; padding: 0.06em 0.1em; margin: 0 -0.1em; cursor: pointer; }
.verse:hover { background: var(--accent-soft); }
.verse.copied { background: var(--accent-soft); }
.verse.flash { animation: flash 2s ease-out; }
@keyframes flash {
  0%, 55% { background: var(--mark); }
  100% { background: transparent; }
}
.vnum {
  font-size: 0.66em; font-weight: 700; color: var(--accent);
  vertical-align: 0.42em; margin-right: 0.32em;
  font-family: var(--font-ui); letter-spacing: 0.02em;
}
.pilcrow { color: var(--accent); font-weight: 600; }
.section-heading {
  display: block; text-align: center;
  font-family: var(--font-ui); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.22em; color: var(--muted);
  margin: 1.5rem 0 0.9rem;
}
.colophon {
  font-family: var(--font-read); font-style: italic;
  color: var(--muted); font-size: calc(0.95rem * var(--rs));
  border-top: 1px solid var(--line);
  margin-top: 2rem; padding-top: 1rem;
}
.colophon .pilcrow { font-style: normal; }

.chapter-nav { max-width: var(--read-width); margin: 2.6rem auto 0; display: flex; gap: 0.7rem; }
.nav-card {
  flex: 1; display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.75rem 0.95rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-raised);
  color: var(--fg);
}
.nav-card:hover { border-color: var(--accent); text-decoration: none; }
.nav-card.next { text-align: right; }
.nav-card.disabled { opacity: 0.4; pointer-events: none; }
.nav-dir { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.nav-where { font-weight: 600; font-size: 0.98rem; }

.home-hero { text-align: center; padding: 2.2rem 0 1.4rem; }
.home-hero h1 { font-family: var(--font-read); font-size: clamp(2rem, 5vw, 2.9rem); margin: 0 0 0.5rem; }
.home-hero p { color: var(--fg-soft); max-width: 34rem; margin: 0 auto; }
.home-stats { display: flex; justify-content: center; gap: 1.6rem; margin-top: 1.1rem; color: var(--muted); font-size: 0.85rem; }
.home-stats b { display: block; font-size: 1.25rem; color: var(--fg); font-family: var(--font-read); }
.home-grid { max-width: 56rem; margin: 1.6rem auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; }
.home-col h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 0.5rem; }
.book-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 1rem; }
.book-list li { break-inside: avoid; }
.book-list a { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.34rem 0.45rem; border-radius: 7px; color: var(--fg-soft); font-size: 0.92rem; }
.book-list a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.book-list .cnt { color: var(--muted); font-size: 0.78rem; }

.preface-body { font-family: var(--font-read); font-size: calc(1.08rem * var(--rs)); line-height: 1.8; }
.preface-body h2 { font-family: var(--font-ui); font-size: 0.95rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin: 2.2rem 0 0.8rem; }
.preface-body p { margin: 0 0 1.1rem; }
.preface-title { font-family: var(--font-read); font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0.5rem 0 1.6rem; text-align: center; }

.loading { text-align: center; color: var(--muted); padding: 3rem 0; font-size: 0.95rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%);
  z-index: 80; background: var(--fg); color: var(--bg);
  padding: 0.55rem 1.1rem; border-radius: 999px;
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 45;
    transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .home-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .text-btn span { display: none; }
  .text-btn .aa { display: inline; }
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .book-list { columns: 1; }
  .main { padding: 1rem 0.9rem 3.5rem; }
  .chapter-nav { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .verse.flash { animation: none; background: var(--mark); }
  * { transition: none !important; }
}
