:root {
  --bg:           #f7f3e9;
  --bg-elev:      #fffdf7;
  --bg-card:      #fdfaf0;
  --border:       #e4dac1;
  --border-soft:  #efe7d3;
  --text:         #2a1f0e;
  --text-muted:   #6b5a3d;
  --text-dim:     #957f59;
  --accent:       #b8870a;
  --accent-soft:  #d4af37;
  --accent-bg:    #fff3cd;
  --sacred:       #8b4513;
  --highlight:    #fff3cd;
  --highlight-strong: #ffe089;
  --player-bg:    #2a1f0e;
  --player-text:  #f7f3e9;
  --radius:       8px;
  --radius-lg:    14px;
  --serif:        'Merriweather', Georgia, serif;
  --sans:         'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg:           #0d1019;
  --bg-elev:      #131826;
  --bg-card:      #161c2c;
  --border:       #222a40;
  --border-soft:  #1a2030;
  --text:         #e8e4d8;
  --text-muted:   #a8a294;
  --text-dim:     #6c6859;
  --accent:       #d4af37;
  --accent-soft:  #e9c97a;
  --accent-bg:    #2a2206;
  --sacred:       #f5d35a;
  --highlight:    #5a4400;
  --highlight-strong: #8a6800;
  --player-bg:    #050608;
  --player-text:  #f5f2e8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ===== Header ===== */
.header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg-elev) 95%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand .accent { color: var(--accent); }
.nav {
  display: flex; gap: 4px; margin-left: auto;
}
.nav a {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--bg-card); color: var(--text); }
.nav a.active { color: var(--accent); background: var(--accent-bg); }
.icon-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-card); border-color: var(--accent); }

/* ===== Hero ===== */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin: 0 0 18px;
  max-width: 18ch;
  letter-spacing: -0.01em;
}
.hero .lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0 0 24px;
}
.eyebrow {
  font-family: var(--sans);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0 0 14px;
  font-weight: 600;
}
.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px;
  margin-top: 36px;
  padding-top: 28px; border-top: 1px solid var(--border);
}
.hero-stats .num {
  font-family: var(--sans);
  font-size: 1.8rem; font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.hero-stats .lbl {
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 6px;
}
@media (max-width: 720px) {
  .hero-stats { grid-template-columns: 1fr 1fr; }
}

/* ===== Controls bar ===== */
.controls {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  align-items: end;
}
.ctrl label {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.ctrl select, .ctrl input {
  font-family: var(--sans);
  font-size: 0.95rem;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
}
.ctrl select:focus, .ctrl input:focus {
  outline: none; border-color: var(--accent);
}
@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
}

/* ===== Book grid ===== */
.testament-section { padding: 40px 0; border-top: 1px solid var(--border); }
.testament-section:first-of-type { border-top: 0; }
.testament-section h2 {
  font-family: var(--sans);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin: 0 0 18px;
  font-weight: 600;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.book-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1rem;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer;
}
.book-tile:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.book-tile .ch {
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* ===== Player page ===== */
.player-page { padding: 32px 0 140px; }
.crumb {
  font-family: var(--sans); font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.18em;
  margin: 0 0 10px;
}
.crumb a { color: var(--text-muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.player-title {
  font-family: var(--serif);
  font-size: 2.2rem;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.player-meta {
  font-family: var(--sans);
  color: var(--text-muted);
  margin: 0 0 32px;
  font-size: 0.95rem;
}

/* ===== Chapter selector ===== */
.chap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 6px;
  margin: 24px 0;
}
.chap-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 10px 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
}
.chap-btn:hover { border-color: var(--accent); }
.chap-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* ===== Reading view (paragraph layout, Bible-style) ===== */
.verses {
  font-family: var(--serif);
  font-size: 1.18rem;
  line-height: 1.85;
  color: var(--text);
  max-width: 68ch;
  margin: 0 auto;
}
.verses p {
  margin: 0 0 1.3em;
  text-indent: 0;
}
.verses .vnum {
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 700;
  color: var(--accent);
  vertical-align: super;
  margin-right: 0.25em;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.verses .vnum:hover { color: var(--accent-soft); }
.verses .vnum.active {
  color: var(--bg);
  background: var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 0.3em;
}
.verses .word {
  cursor: pointer;
  transition: background 0.08s;
  border-radius: 3px;
}
.verses .word:hover { background: color-mix(in oklab, var(--accent-bg) 70%, transparent); }
.verses .word.active {
  background: var(--highlight-strong);
  padding: 0 2px;
  margin: 0 -2px;
}
.sacred {
  color: var(--sacred);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Section/poetic indent for paragraphs that begin with whitespace in the source */
.verses p.indent { padding-left: 2em; }

/* Chapter title row */
.chapter-head {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  text-align: center;
  margin: 8px 0 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* ===== Audio bar (sticky bottom) ===== */
.audio-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--player-bg);
  color: var(--player-text);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
  z-index: 60;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.18);
}
.audio-bar audio { flex: 1; height: 36px; }
.ab-info {
  font-family: var(--sans);
  font-size: 0.86rem;
  min-width: 240px;
}
.ab-info .b { font-weight: 600; }
.ab-info .v { color: rgba(255,255,255,0.65); font-size: 0.76rem; }
.ab-nav { display: flex; gap: 6px; }
.ab-nav button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--player-text);
  width: 36px; height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  display: grid; place-items: center;
}
.ab-nav button:hover { background: rgba(255,255,255,0.16); }
.ab-nav button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Search ===== */
.search-row {
  margin: 24px 0;
  position: relative;
}
.search-row input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
}
.search-row input:focus { outline: none; border-color: var(--accent); }
.search-row svg {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-dim);
}

/* ===== Footer ===== */
footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  margin-top: 64px;
  margin-bottom: 80px;
  text-align: center;
  font-family: var(--sans);
  color: var(--text-dim);
  font-size: 0.86rem;
}
footer a { color: var(--text-muted); text-decoration: none; }
footer a:hover { color: var(--accent); }
