/* Orthodox Library — parchment, Coptic red and gold. */
:root {
  --bg: #faf6ee;
  --bg-2: #f3ecdf;
  --surface: #ffffff;
  --ink: #1f1a15;
  --ink-2: #4a4139;
  --muted: #7a6f63;
  --line: #e7dece;
  --accent: #7a1f2b;
  --accent-ink: #ffffff;
  --accent-soft: #f4e4e2;
  --gold: #a87b22;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px -8px rgba(60, 40, 20, .18);
  --shadow-lg: 0 2px 4px rgba(60, 40, 20, .06), 0 18px 40px -16px rgba(60, 40, 20, .35);
  --radius: 14px;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --wrap: 1200px;
  --topic-l: 38%;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110e; --bg-2: #1b1713; --surface: #211c17; --ink: #f2ebe0; --ink-2: #d5cabb; --muted: #a39684;
    --line: #342c24; --topic-l: 72%; --accent: #e07d84; --accent-ink: #1a0d0f; --accent-soft: #3a2224; --gold: #d8b05e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.3), 0 18px 40px -16px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14110e; --bg-2: #1b1713; --surface: #211c17; --ink: #f2ebe0; --ink-2: #d5cabb; --muted: #a39684;
  --line: #342c24; --topic-l: 72%; --accent: #e07d84; --accent-ink: #1a0d0f; --accent-soft: #3a2224; --gold: #d8b05e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.3), 0 18px 40px -16px rgba(0,0,0,.8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
p a:not(.chip):not(.btn), .prose a:not(.btn), .muted a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
img { display: block; max-width: 100%; }
h1, h2, h3 { font-variant-numeric: lining-nums; font-family: var(--serif); font-weight: 600; line-height: 1.1; letter-spacing: -.01em; margin: 0; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2rem); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { width: 1.15em; height: 1.15em; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { display: inline-flex; align-items: center; gap: .45em; font: 600 .78rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 0 0 14px; }
section { margin: clamp(40px, 6vw, 72px) 0; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.4rem/1 var(--serif); letter-spacing: -.01em; white-space: nowrap; }
.logo-mark { width: 30px; height: 30px; color: var(--accent); }
.main-nav { display: flex; gap: 4px; }
.main-nav a { padding: 8px 12px; border-radius: 999px; font-weight: 500; font-size: .95rem; color: var(--ink-2); transition: background .15s, color .15s; }
.main-nav a:hover { background: var(--bg-2); color: var(--ink); }
.main-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.search { position: relative; margin-left: auto; display: flex; align-items: center; width: min(360px, 100%); }
.search > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 36px 0 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd { position: absolute; right: 12px; font: 500 .75rem var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.search input:focus ~ kbd { display: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.theme-toggle .only-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .only-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .only-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .only-dark { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .only-light { display: none; }
}
.menu-toggle { display: none; }

/* instant search dropdown */
.suggest { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; max-height: min(70vh, 520px); overflow: auto; text-align: left; }
.suggest h4 { margin: 8px 10px 4px; font: 600 .7rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.suggest a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 9px; }
.suggest a strong { font-weight: 500; line-height: 1.3; }
.suggest a span { font-size: .82rem; color: var(--muted); }
.suggest a.active, .suggest a:hover { background: var(--accent-soft); }
.suggest .all { flex-direction: row; align-items: center; gap: 6px; color: var(--accent); font-weight: 500; border-top: 1px solid var(--line); border-radius: 0 0 9px 9px; margin-top: 4px; }
.suggest .none { padding: 12px 10px; color: var(--muted); }

/* ---------- hero ---------- */
.hero { margin: 0; position: relative; overflow: hidden; border-bottom: 1px solid var(--line);
  background:
    radial-gradient(900px 400px at 85% -10%, color-mix(in srgb, var(--gold) 16%, transparent), transparent 70%),
    radial-gradient(700px 380px at 0% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg); }
.hero::after { content: ""; position: absolute; right: -60px; top: 50%; width: 420px; height: 420px; transform: translateY(-50%); opacity: .06; pointer-events: none;
  background: url("/static/favicon.svg") center/contain no-repeat; }
.hero-inner { padding-top: clamp(48px, 9vw, 110px); padding-bottom: clamp(40px, 7vw, 80px); max-width: 860px; position: relative; z-index: 1; margin-left: max(var(--gutter), calc((100vw - var(--wrap)) / 2 + var(--gutter))); padding-left: 0; }
.hero h1 { font-size: clamp(2.8rem, 8vw, 5.2rem); line-height: .98; letter-spacing: -.02em; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--ink-2); max-width: 600px; margin: 20px 0 30px; }
.hero-search { position: relative; display: flex; align-items: center; max-width: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); padding: 6px 6px 6px 18px; transition: box-shadow .15s, border-color .15s; }
.hero-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.hero-search > .icon { color: var(--muted); width: 1.3em; height: 1.3em; }
.hero-search input { flex: 1; min-width: 0; border: 0; background: none; height: 48px; padding: 0 12px; font-size: 1.05rem; outline: none; }
.hero-search button { height: 48px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.hero-search button:hover { filter: brightness(1.08); }
.hero-search.narrow { margin: 24px auto; }
.stats { display: flex; flex-wrap: wrap; gap: 12px 40px; margin: 36px 0 0; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-size: .8rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.stats dd { margin: 0; font: 600 2rem/1.1 var(--serif); font-variant-numeric: lining-nums; }

/* ---------- section heads ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.more { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 500; font-size: .95rem; white-space: nowrap; }
.more:hover .icon { transform: translateX(3px); }
.more .icon { transition: transform .15s; }

/* ---------- topics ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.topic-card { --tint: hsl(var(--h) 45% var(--topic-l, 38%)); display: grid; grid-template-areas: "icon count" "text text"; grid-template-columns: auto 1fr; gap: 14px 10px; align-content: start; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); transition: transform .18s, box-shadow .18s, border-color .18s; -webkit-tap-highlight-color: transparent; }
.topic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: transparent; }
.topic-card:active { transform: scale(.98); }
.topic-icon { grid-area: icon; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--tint); background: hsl(var(--h) 45% 50% / .12); }
.topic-icon svg { width: 24px; height: 24px; }
.topic-count { grid-area: count; justify-self: end; align-self: start; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--bg-2); border-radius: 999px; padding: 3px 10px; font-variant-numeric: tabular-nums; }
.topic-text { grid-area: text; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topic-name { font: 600 1.3rem/1.15 var(--serif); overflow-wrap: anywhere; }
.topic-blurb { color: var(--muted); font-size: .88rem; line-height: 1.4; }
.topic-grid.large .topic-card { padding: 22px; }

/* ---------- book cards ---------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 28px 20px; }
.book { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 6px 10px 10px 6px; overflow: hidden; background: var(--bg-2); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.cover::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 3px 0 0 rgba(0,0,0,.08), inset 0 0 0 1px rgba(0,0,0,.06); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.book:hover .cover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cover-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 16px 14px; color: #fbf3e4;
  background: linear-gradient(160deg, hsl(var(--h) 38% 30%), hsl(calc(var(--h) + 25) 42% 18%)); }
.cover-fallback::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(255, 230, 180, .35); border-radius: 4px; pointer-events: none; }
.cf-title { font: 600 1.05rem/1.15 var(--serif); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cf-author { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.book-meta h3 { font: 500 .95rem/1.3 var(--sans); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-meta p { margin: 3px 0 0; font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book:hover h3 { color: var(--accent); }

/* horizontal shelves */
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 20px; overflow-x: auto; padding: 6px 4px 16px; margin: 0 -4px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.shelf-row .book { scroll-snap-align: start; }

/* ---------- chips ---------- */
.chip-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .9rem; font-weight: 500; transition: border-color .15s, color .15s, background .15s; }
.chip span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.removable { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.removable .icon { width: .9em; height: .9em; }

/* ---------- callout ---------- */
.callout { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding: clamp(24px, 4vw, 40px); border-radius: calc(var(--radius) + 6px); background: var(--accent); color: var(--accent-ink); }
.callout p { margin: 8px 0 0; opacity: .88; max-width: 560px; }
.callout .btn { background: var(--accent-ink); color: var(--accent); border-color: transparent; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .95rem; cursor: pointer; white-space: nowrap; transition: transform .1s, filter .15s, border-color .15s; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: none; }
.btn.small { height: 36px; padding: 0 14px; font-size: .875rem; }

/* ---------- page heads & toolbar ---------- */
.page { padding-top: clamp(28px, 5vw, 48px); padding-bottom: 72px; }
.page-head { margin-bottom: 24px; }
.page-head p { margin: 10px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.field { position: relative; display: flex; align-items: center; }
.field.grow { flex: 1 1 260px; }
.field > .icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.field input, .field select { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; width: 100%; }
.field input { padding-left: 40px; }
.field select { padding-right: 36px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a6f63' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty h2, .empty h1 { color: var(--ink); margin-bottom: 10px; }
.empty.big { padding: 96px 16px; }

/* pagination */
.pager { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 48px; }
.pg { min-width: 42px; height: 42px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }

a.pg:hover { border-color: var(--accent); color: var(--accent); }
.pg.current { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pg.gap { border: 0; background: none; min-width: 20px; }

/* ---------- book detail ---------- */
.crumbs { display: flex; gap: 8px; font-size: .9rem; color: var(--muted); margin-bottom: 24px; }
.crumbs a:hover { color: var(--accent); }
.book-detail { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: clamp(24px, 5vw, 56px); align-items: start; }
.cover.large { border-radius: 8px 14px 14px 8px; box-shadow: var(--shadow-lg); }
.cover.large .cf-title { font-size: 1.6rem; -webkit-line-clamp: 8; }
.cover.large .cf-author { font-size: .85rem; }
.book-info h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
.by { font-size: 1.15rem; color: var(--ink-2); margin: 12px 0 0; }
.by a { color: var(--accent); }
.by a:hover { text-decoration: underline; text-underline-offset: 3px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0; }
.facts { display: grid; gap: 14px; margin: 0 0 24px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: baseline; }
.facts dt { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- reader ---------- */
/* The reader has its own complete colour sets, independent of the site's light/dark mode,
   so text, buttons and bubbles always contrast with the page colour the reader picked. */
.rd { --zoom: 1; --fs: 1; min-height: 100dvh; background: var(--rd-bg); color: var(--ink);
  --bg: #fffdf9; --bg-2: #f1ece3; --surface: #ffffff; --ink: #1f1a15; --ink-2: #463d35; --muted: #756a5e; --line: #e3dbcd;
  --accent: #7a1f2b; --accent-ink: #ffffff; --accent-soft: #f4e4e2; --gold: #a87b22;
  --rd-bg: #ece8e1; --rd-page: #ffffff; --rd-text-bg: #fffdf9; --rd-chrome: rgba(255, 253, 249, .95); }
.rd[data-mode="text"] { --rd-bg: var(--rd-text-bg); }
.rd[data-rtheme="sepia"] {
  --bg: #f4ead6; --bg-2: #e9dcc2; --surface: #f9f1e1; --ink: #33281d; --ink-2: #4d3f30; --muted: #7a6650; --line: #d9c8aa;
  --accent: #8a2a2f; --accent-ink: #ffffff; --accent-soft: #ecd3c8; --gold: #8d6418;
  --rd-bg: #e3d6bd; --rd-page: #f6ecd8; --rd-text-bg: #f4ead6; --rd-chrome: rgba(244, 234, 214, .95); }
.rd[data-rtheme="dark"] {
  --bg: #151311; --bg-2: #2a2520; --surface: #211d19; --ink: #ece4d8; --ink-2: #d2c7b7; --muted: #a09382; --line: #3a322a;
  --accent: #ec8f95; --accent-ink: #1a0d0f; --accent-soft: #3d2426; --gold: #d8b05e;
  --rd-bg: #0f0e0d; --rd-page: #1c1b19; --rd-text-bg: #151311; --rd-chrome: rgba(24, 22, 20, .95); }
.rd[data-rtheme="sepia"] canvas { filter: sepia(.38) saturate(1.15) brightness(.97); }
.rd[data-rtheme="dark"] canvas { filter: invert(.9) hue-rotate(180deg) brightness(1.05) contrast(.92); }
.rd .icon-btn:hover { background: var(--bg-2); }

.rd-bar, .rd-foot { position: fixed; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 8px; background: var(--rd-chrome); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); transition: transform .25s ease; color: var(--ink); }
.rd-bar { top: 0; padding: env(safe-area-inset-top) 10px 0; height: calc(58px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.rd-foot { bottom: 0; justify-content: space-around; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.rd.immersive .rd-bar { transform: translateY(-100%); }
.rd.immersive .rd-foot { transform: translateY(100%); }
.rd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.rd-title strong, .rd-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-title strong { font: 600 1.1rem/1.2 var(--serif); }
.rd-title span { font-size: .78rem; color: var(--muted); }
.rd-switch { display: flex; padding: 3px; border-radius: 999px; background: var(--bg-2); flex: none; }
.rd-switch button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.rd-switch button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.rd-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.rd-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.rd-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 6px 8px; border: 0; background: none; border-radius: 10px; color: var(--ink-2); font-size: .7rem; font-weight: 500; cursor: pointer; }
.rd-tool .icon { width: 22px; height: 22px; }
.rd-tool:hover { background: var(--bg-2); color: var(--ink); }
.rd-pageno { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rd-pageno input { width: 3.4em; height: 32px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 600; }
.rd-pageno input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* pages view */
.rd-pages { display: flex; flex-direction: column; align-items: flex-start; width: max-content; min-width: 100%; gap: 14px; padding: calc(74px + env(safe-area-inset-top)) 10px calc(84px + env(safe-area-inset-bottom)); }
.rd-page { position: relative; margin: 0 auto; width: calc(min(100vw - 20px, 860px) * var(--zoom)); background: var(--rd-page); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 8px 24px -12px rgba(0,0,0,.35); border-radius: 3px; overflow: hidden; }
.rd-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rd-page-num { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; opacity: .6; }
.rd-page.ready .rd-page-num { display: none; }

/* text view */
.rd-text { --tf: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Sans Coptic", serif; --lh: 1.65; max-width: 40em; margin: 0 auto; padding: calc(76px + env(safe-area-inset-top)) 22px calc(96px + env(safe-area-inset-bottom)); font-family: var(--tf); font-size: calc(19px * var(--fs)); line-height: var(--lh); color: var(--ink); overflow-wrap: break-word; }
.rd[data-font="sans"] .rd-text { --tf: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Coptic", sans-serif; }
.rd[data-spacing="tight"] .rd-text { --lh: 1.45; }
.rd[data-spacing="loose"] .rd-text { --lh: 1.95; }
.rd-flow p { margin: 0 0 .85em; }
.rd-flow h2, .rd-flow h3 { font-family: var(--serif); line-height: 1.2; margin: 1.6em 0 .6em; text-wrap: balance; }
.rd-flow h2 { font-size: 1.55em; }
.rd-flow h3 { font-size: 1.22em; }
.rd-flow b { font-weight: 700; }
.rd-flow sup { font-size: .65em; line-height: 0; }
.rd-flow figure { margin: 1.4em 0; text-align: center; }
.rd-flow figure img { display: inline-block; max-width: 100%; height: auto; border-radius: 4px; }
.rd[data-rtheme="dark"] .rd-flow figure img { filter: brightness(.88); }
.rd-flow aside.fn { font-size: .78em; line-height: 1.5; color: var(--muted); margin: 0 0 .6em; padding-left: .8em; border-left: 2px solid var(--line); }
.rd-flow .orn { text-align: center; letter-spacing: .5em; color: var(--muted); }
.rd-flow .lg { font: 500 .72em var(--sans); color: var(--muted); background: var(--bg-2); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.rd-flow mark.rd-hit, .rd-results mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
/* original page markers: quiet labels you can tap to open that page */
.rd-flow > .pm { display: block; height: 0; position: relative; }
.rd-flow > .pm::after { content: attr(data-page); position: absolute; right: -18px; top: -.2em; font: 500 11px/1 var(--sans); font-style: normal; color: var(--muted); opacity: .55; cursor: pointer; }
.rd-flow p .pm::after { content: ""; }
.rd-notice { margin: 0 0 2em; padding: 14px 16px; border-radius: 12px; background: var(--bg-2); color: var(--ink-2); font: .85rem/1.5 var(--sans); }
.rd-notice p { margin: 0; }
.rd-notice p + p { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.rd-notice .btn { height: 34px; }
.rd-flow > .rd-tapped { position: relative; }
.rd-tapline { position: absolute; height: 2px; margin-top: 1px; border-radius: 2px; background: var(--accent); pointer-events: none; animation: rd-pop .15s ease; }
.rd-jump { position: absolute; z-index: 5; transform: translateX(-50%); padding: 8px 14px; border: 0; border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 .8rem/1.2 var(--sans); box-shadow: 0 6px 18px -6px rgba(0,0,0,.45); cursor: pointer; white-space: nowrap; animation: rd-pop .15s ease; }
.rd-jump::before { content: ''; position: absolute; top: -5px; left: calc(50% + var(--arrow, 0px)); width: 10px; height: 10px; margin-left: -5px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
@keyframes rd-pop { from { opacity: 0; transform: translateX(-50%) translateY(-3px); } }
.rd-tapline { animation-name: none; }

/* bottom sheets */
.rd-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); }
.rd-sheet { position: fixed; z-index: 41; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100vw); max-height: min(78vh, 680px); display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px -10px rgba(0,0,0,.35); padding: 6px 18px calc(18px + env(safe-area-inset-bottom)); animation: sheet-up .2s ease; font-family: var(--sans); }
@keyframes sheet-up { from { transform: translate(-50%, 30px); opacity: 0; } }
.rd-sheet[hidden], .rd-scrim[hidden] { display: none; }
.rd-sheet > header { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.rd-sheet > header h2 { font-size: 1.35rem; }
.rd-sheet .field { flex: none; margin-bottom: 8px; }
.rd-sheet .field input { background: var(--bg-2); border-color: transparent; color: var(--ink); }
.rd-toc, .rd-results { overflow: auto; margin: 0 -18px; padding: 0 10px; }
.rd-toc ol, .rd-results { list-style: none; margin: 0; }
.rd-toc ol { padding: 0; }
.rd-toc button, .rd-results button { display: flex; width: 100%; gap: 12px; justify-content: space-between; align-items: baseline; padding: 11px 10px; border: 0; background: none; border-radius: 10px; text-align: left; color: var(--ink); cursor: pointer; font: inherit; }
.rd-toc button:hover, .rd-results button:hover { background: var(--bg-2); }
.rd-toc .l1 button { font-weight: 600; }
.rd-toc .l2 button { padding-left: 26px; }
.rd-toc .l3 button { padding-left: 42px; font-size: .92em; }
.rd-toc .current button { background: var(--accent-soft); color: var(--accent); }
.rd-toc .rpg, .rd-results .rpg { flex: none; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rd-results { padding: 0 10px; }
.rd-results button { flex-direction: column; gap: 4px; }
.rd-results .snip { font-size: .92rem; line-height: 1.45; color: var(--ink-2); }
.rd-search-status { margin: 0 0 6px; }
.rd-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.rd-opt > span { font-weight: 500; }
.rd[data-mode="text"] .rd-opt[data-only="pages"], .rd[data-mode="pages"] .rd-opt[data-only="text"] { display: none; }
.rd-stepper, .rd-choice { display: flex; align-items: center; padding: 3px; border-radius: 999px; background: var(--bg-2); }
.rd-stepper button, .rd-choice button { min-width: 44px; height: 36px; padding: 0 14px; border: 0; background: none; border-radius: 999px; color: var(--ink); font-weight: 600; cursor: pointer; }
.rd-stepper button:first-child { font-size: .8rem; }
.rd-stepper button:last-child { font-size: 1.15rem; }
.rd-stepper output { min-width: 52px; text-align: center; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.rd-choice button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.rd-choice.swatches button[data-value="light"] { background-color: #fff; color: #222; }
.rd-choice.swatches button[data-value="sepia"] { background-color: #f4ead6; color: #3b2f22; }
.rd-choice.swatches button[data-value="dark"] { background-color: #1c1a17; color: #eee; }
.rd-choice.swatches { gap: 6px; background: none; padding: 0; }
.rd-choice.swatches button { border: 1px solid var(--line); }
.rd-choice.swatches button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }

.rd-status { position: fixed; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; color: var(--ink-2); padding: 24px; }
.rd-status[hidden] { display: none; }
.rd-status.error .rd-spinner { display: none; }
.rd-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.rd-toast { width: max-content; position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: rgba(28, 24, 20, .94); color: #fbf6ee; font-size: .9rem; box-shadow: 0 8px 30px -8px rgba(0,0,0,.5); text-align: center; }
.rd-toast button { border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; margin-left: 4px; }
main.bare { min-height: 100dvh; }
@media (max-width: 640px) {
  .rd-bar { gap: 4px; padding-left: 4px; padding-right: 4px; }
  .rd-title strong { font-size: 1rem; }
  .rd-switch button { padding: 6px 11px; }
  .rd-pages { gap: 10px; padding-left: 6px; padding-right: 6px; }
  .rd-page { width: calc((100vw - 12px) * var(--zoom)); }
  .rd-text { padding-left: 20px; padding-right: 20px; }
  .rd-flow > .pm::after { right: -14px; }
  .rd-tool { min-width: 56px; }
}

/* ---------- authors index ---------- */
.letters { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 28px; position: sticky; top: 68px; z-index: 5; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); }
.letters a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.letters a:hover { background: var(--accent-soft); color: var(--accent); }
.author-index { columns: 3 280px; column-gap: 40px; }
.letter-group { break-inside: avoid; margin: 0 0 28px; }
.letter-group h2 { font-size: 2rem; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.letter-group ul { list-style: none; margin: 0; padding: 0; }
.letter-group a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 8px; margin: 0 -8px; border-radius: 8px; }
.letter-group a:hover { background: var(--surface); color: var(--accent); }
.count { font-size: .8rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- prose / about ---------- */
.prose { max-width: 720px; }
.prose h2 { margin: 40px 0 12px; }
.prose p { font-size: 1.08rem; color: var(--ink-2); }
.contact-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
blockquote { margin: 48px 0 24px; padding: 28px 32px; border-left: 3px solid var(--gold); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; font: italic 500 1.45rem/1.4 var(--serif); }
blockquote cite { display: block; margin-top: 12px; font: normal 500 .9rem var(--sans); color: var(--muted); }
.doxology { font: italic 600 1.15rem var(--serif); color: var(--gold); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 48px 0 40px; }
.footer-inner { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px 40px; }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 8px 24px; align-content: start; justify-content: flex-end; }
.footer-inner nav a { color: var(--ink-2); }
.footer-inner nav a:hover { color: var(--accent); }
.verse { font: italic 500 1.15rem/1.45 var(--serif); color: var(--ink-2); max-width: 460px; margin: 14px 0 0; }
.verse span { display: block; margin-top: 6px; font-style: normal; font-size: .95rem; color: var(--muted); }
.footer-inner .doxology { grid-column: 1 / -1; margin: 8px 0 0; font-size: 1rem; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .header-inner { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 12px; gap: 10px 12px; }
  .menu-toggle { display: inline-grid; }
  .theme-toggle { margin-left: auto; }
  .main-nav { order: 10; width: 100%; display: none; flex-direction: column; padding-top: 6px; }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 12px; border-radius: 10px; }
  .search { order: 5; width: 100%; margin: 0; }
  .search kbd { display: none; }
  .letters { top: 116px; }
  html { scroll-padding-top: 130px; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .book-detail { grid-template-columns: 1fr; }
  .book-detail .cover.large { width: min(240px, 70%); margin: 0 auto; }
  .book-info { text-align: center; }
  .actions { justify-content: center; }
  .actions .btn { flex: 1 1 100%; }
  .facts div { grid-template-columns: 1fr; gap: 6px; text-align: left; }
  .book-info .small { text-align: center; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 22px 14px; }
  .shelf-row { grid-auto-columns: 128px; gap: 14px; }
  .hero-search { padding-left: 14px; }
  .hero-search button { padding: 0 16px; }
  .stats { gap: 10px 28px; }
  .stats dd { font-size: 1.6rem; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-inner nav { justify-content: flex-start; }
  .hide-sm { display: none; }
  .hero::after { display: none; }
  .callout .btn { width: 100%; }
  .toolbar .field:not(.grow) { flex: 1 1 140px; }
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .topic-card { padding: 14px; gap: 12px 8px; }
  .topic-icon { width: 38px; height: 38px; border-radius: 10px; }
  .topic-icon svg { width: 21px; height: 21px; }
  .topic-name { font-size: 1.08rem; line-height: 1.2; }
  .topic-blurb { display: none; }
  .topic-count { font-size: .75rem; padding: 2px 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }

/* "you are here" highlight after jumping into the original pages */
.rd-hl { position: absolute; z-index: 2; border-radius: 3px; background: rgba(255, 200, 40, .45); mix-blend-mode: multiply; pointer-events: none; animation: rd-hl 3.6s ease forwards; }
.rd[data-rtheme="dark"] .rd-hl { background: rgba(255, 190, 60, .4); mix-blend-mode: screen; }
@keyframes rd-hl { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
.rd-page.flash { animation: rd-flash 1.6s ease; }
@keyframes rd-flash { 0%, 40% { box-shadow: 0 0 0 4px rgba(255, 190, 40, .8); } 100% { box-shadow: 0 1px 3px rgba(0,0,0,.12); } }
