/* Berean reader — self-contained, no external fonts/CDNs (works offline / self-host).
   Parchment + ink + restrained scripture-gold. Reverent and legible. */
:root {
  --parchment: #faf6ee; --parchment-2: #f3ecdd; --ink: #23201a; --ink-soft: #5c554a;
  --muted: #8a8172; --rule: #e4dac4; --gold: #9a7b2e; --accent: #7a5c1c;
  --hl-y: #fff4c2; --hl-g: #d8f3dc; --hl-b: #d7e9ff; --hl-p: #ffe0ef; --sel: #f5e6b8;
  --card: #fff; --top-bg: rgba(250,246,238,0.94); --reader-size: 1.18rem;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --wrap: 820px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--sans); background: var(--parchment); color: var(--ink); line-height: 1.6; padding-bottom: 4.5rem; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; background: var(--top-bg); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule); padding: 0.6rem clamp(0.75rem,3vw,1.5rem);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.1rem; }
.brand { display: flex; align-items: baseline; gap: 0.5rem; }
.brand__name { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; letter-spacing: 0.01em; }
.brand__tag { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 0.5rem 0.7rem; margin-left: auto; }
.ctl { display: flex; flex-direction: column; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); gap: 0.15rem; }
.ctl select { font-family: var(--sans); font-size: 0.9rem; color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 0.35rem 0.5rem; min-width: 5.5rem; }
.search { display: flex; align-items: center; gap: 0.4rem; }
.search input { font-size: 0.9rem; padding: 0.4rem 0.6rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); min-width: 9rem; }
.chk { font-size: 0.72rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
.search button, .navbtn, .studybtn { font-family: var(--sans); font-size: 0.9rem; font-weight: 600; cursor: pointer; background: var(--ink); color: var(--parchment); border: 0; border-radius: 8px; padding: 0.45rem 0.9rem; }
.search button:hover, .studybtn:hover { background: var(--accent); }
.studybtn { background: transparent; color: var(--accent); border: 1px solid var(--rule); }
.studybtn:hover { background: var(--parchment-2); color: var(--accent); }

/* Layout */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 1.25rem clamp(0.75rem,3vw,1.5rem) 3rem; }
.chapter-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0.5rem 0 1.25rem; }
.ref { font-family: var(--serif); font-size: clamp(1.4rem,4vw,2rem); font-weight: 700; text-align: center; flex: 1; }
.navbtn { background: transparent; color: var(--accent); border: 1px solid var(--rule); }
.navbtn:hover { background: var(--parchment-2); }

/* Chapter action toolbar */
.chapter-tools { display: flex; justify-content: center; gap: 0.4rem; margin: -0.75rem 0 1.25rem; }
.chapter-tools .iconbtn { color: var(--accent); border: 1px solid var(--rule); background: transparent; }
.chapter-tools .iconbtn:hover { background: var(--parchment-2); }
.chapter-tools .iconbtn.active { background: var(--accent); color: var(--parchment); border-color: var(--accent); }

/* Reader */
.reader { font-family: var(--serif); font-size: var(--reader-size); }
.verse { padding: 0.18rem 0.3rem; border-radius: 5px; scroll-margin-top: 4rem; }
.verse .vnum { font-family: var(--sans); font-size: 0.7rem; font-weight: 700; color: var(--gold); vertical-align: super; margin-right: 0.35rem; cursor: pointer; user-select: none; }
.verse .vnum:hover { color: var(--accent); text-decoration: underline; }
.verse.hl-y { background: var(--hl-y); } .verse.hl-g { background: var(--hl-g); }
.verse.hl-b { background: var(--hl-b); } .verse.hl-p { background: var(--hl-p); }
.verse.sel { outline: 2px solid var(--gold); }
.verse.speaking { background: var(--sel); box-shadow: inset 3px 0 0 var(--gold); }
.verse .noteflag { font-family: var(--sans); font-size: 0.7rem; color: var(--accent); margin-left: 0.3rem; cursor: pointer; }
.verse .noteline { display: block; font-family: var(--sans); font-size: 0.82rem; color: var(--ink-soft); background: var(--card); border-left: 3px solid var(--gold); padding: 0.3rem 0.5rem; margin: 0.25rem 0 0.35rem 1rem; border-radius: 0 6px 6px 0; }

/* Compare */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.75rem; }
.cmp__head { font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-bottom: 0.4rem; border-bottom: 1px solid var(--rule); }
.cmp .row { display: contents; }
.cmp .cell { padding: 0.3rem 0; border-bottom: 1px solid #efe7d6; }
.cmp .vnum { font-family: var(--sans); font-size: 0.7rem; font-weight: 700; color: var(--gold); vertical-align: super; margin-right: 0.3rem; }

/* Panels (results / related / study) */
.panel { margin-bottom: 1.5rem; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 0.9rem; margin-left: 0.5rem; }
.results__list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.results__list li { padding: 0.5rem 0.7rem; background: var(--card); border: 1px solid var(--rule); border-radius: 8px; cursor: pointer; }
.results__list li:hover { border-color: var(--gold); }
.r-ref { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; color: var(--accent); }
.r-ver { font-family: var(--sans); font-size: 0.66rem; color: var(--muted); }
.r-text { font-family: var(--serif); color: var(--ink-soft); }
.results__list mark { background: var(--hl-y); }
.tiny { font-size: 0.72rem; color: var(--muted); margin-top: 0.6rem; }

/* Study panel */
.study { display: flex; flex-direction: column; gap: 1.25rem; }
.study h3 { font-family: var(--serif); font-size: 1.1rem; margin-bottom: 0.4rem; }
.study .empty { color: var(--muted); font-size: 0.9rem; }
.study ul { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.study li { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 0.4rem 0.6rem; display: flex; align-items: center; gap: 0.5rem; }
.study .s-ref { font-family: var(--sans); font-size: 0.8rem; font-weight: 700; color: var(--accent); cursor: pointer; }
.study .s-text { flex: 1; font-family: var(--serif); color: var(--ink-soft); font-size: 0.95rem; }
.study .s-del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.study .s-del:hover { color: #b23; }
.study .newcoll { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.study .newcoll input { flex: 1; padding: 0.35rem 0.5rem; border: 1px solid var(--rule); border-radius: 8px; }
.dot { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); }

/* Commentary */
.commentary { display: flex; flex-direction: column; gap: 1rem; }
.commentary .intro { font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
.commentary .block { border-left: 3px solid var(--rule); padding-left: 0.8rem; }
.commentary .block__ref { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; color: var(--accent); cursor: pointer; }
.commentary .block p { font-family: var(--serif); margin: 0.35rem 0; line-height: 1.7; }
.commentary .empty { color: var(--muted); }

/* Prayer builder */
.prayer { display: flex; flex-direction: column; gap: 0.9rem; }
.prayer__controls { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; }
.prayer__controls select, .prayer__controls input, .prayer__situation input {
  font-family: var(--sans); font-size: 0.9rem; color: var(--ink); background: var(--card);
  border: 1px solid var(--rule); border-radius: 8px; padding: 0.35rem 0.5rem; }
.prayer__situation { display: flex; flex-direction: column; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); gap: 0.2rem; }
.prayer__situation input { text-transform: none; letter-spacing: normal; font-size: 0.95rem; }
.prayer__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.prayer__actions .vbbtn { background: var(--parchment-2); color: var(--accent); border: 1px solid var(--rule); }
.prayer__actions .vbbtn:hover { background: var(--card); }
.prayer__text { font-family: var(--serif); font-size: 1.1rem; line-height: 1.7; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 10px; padding: 0.9rem 1rem; width: 100%; resize: vertical; }
.prayer__savedhead { font-family: var(--serif); font-size: 1.05rem; margin-top: 0.5rem; }
.prayer__saved-ref { font-family: var(--sans); font-size: 0.75rem; font-weight: 700; color: var(--accent); }

/* Verse action bar */
.versebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0.75rem; z-index: 30;
  background: var(--ink); color: var(--parchment); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  padding: 0.5rem 0.7rem; display: flex; align-items: center; gap: 0.6rem; max-width: 96vw; flex-wrap: wrap; }
.versebar__ref { font-family: var(--serif); font-weight: 700; font-size: 0.95rem; }
.versebar__acts { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.swatches { display: inline-flex; gap: 0.2rem; }
.sw { width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 1px solid rgba(255,255,255,0.4); cursor: pointer; padding: 0; }
.sw--x { background: transparent; color: var(--parchment); font-size: 0.7rem; }
.vbbtn { font-family: var(--sans); font-size: 0.82rem; background: rgba(255,255,255,0.12); color: var(--parchment); border: 0; border-radius: 7px; padding: 0.3rem 0.6rem; cursor: pointer; }
.vbbtn:hover { background: rgba(255,255,255,0.25); }
.vbbtn--x { background: transparent; }
.vbsel { font-size: 0.82rem; background: rgba(255,255,255,0.12); color: var(--parchment); border: 0; border-radius: 7px; padding: 0.3rem 0.4rem; }
.vbsel option { color: #000; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 8px; cursor: pointer; padding: 0; border: 0; background: transparent; color: inherit; }
.iconbtn svg { display: block; }
.versebar .iconbtn { background: rgba(255,255,255,0.12); color: var(--parchment); }
.versebar .iconbtn:hover { background: rgba(255,255,255,0.28); }
.versebar .iconbtn--x { background: transparent; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 4.5rem; z-index: 40; background: var(--accent); color: #fff; padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 0.85rem; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* Footer */
.foot { border-top: 1px solid var(--rule); padding: 1.5rem clamp(0.75rem,3vw,1.5rem); text-align: center; color: var(--muted); font-size: 0.8rem; max-width: var(--wrap); margin: 0 auto; }
.attribution { margin-bottom: 0.4rem; }
.foot__verse { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin-bottom: 0.5rem; }
.foot a { color: var(--accent); }

/* Reading comfort: text size + dark mode + voice picker */
.comfort { display: inline-flex; gap: 0.25rem; align-items: center; }
.comfort .iconbtn { color: var(--accent); border: 1px solid var(--rule); background: transparent; }
.comfort .iconbtn:hover { background: var(--parchment-2); }
.comfort .iconbtn.txt { font-family: var(--serif); font-weight: 700; font-size: 0.9rem; }
.chapter-tools .voicesel { font-family: var(--sans); font-size: 0.8rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); color: var(--ink); padding: 0.2rem 0.4rem; max-width: 12rem; }

body.dark {
  --parchment: #17150f; --parchment-2: #201d15; --card: #24211a; --top-bg: rgba(23,21,15,0.94);
  --ink: #ece4d3; --ink-soft: #c4bca9; --muted: #948b78; --rule: #38332a;
  --gold: #d9b563; --accent: #e7ca7d; --sel: #4a3d1f;
  --hl-y: #574d22; --hl-g: #26432f; --hl-b: #243851; --hl-p: #4a2a3b;
}
body.dark .results__list mark { color: var(--ink); }

@media (max-width: 640px) {
  .controls { width: 100%; }
  .search input { min-width: 0; flex: 1; }
  .cmp { grid-template-columns: 1fr; }
  .cmp__head + .cmp__head { display: none; }
}
