/* Follow-Along Bible — a quiet reading page with a listening dock. */
:root {
  --bg: #f6f1e7;
  --paper: #fbf8f1;
  --ink: #221d17;
  --ink-2: #5e554a;
  --ink-3: #8b8174;
  --line: #e3dacb;
  --chip: #ece4d5;
  --accent: #8a5a12;
  --accent-ink: #fffaf0;
  --mark: #f6e2a6;
  --mark-edge: #c8922a;
  --listen: #2f6b4f;
  --listen-ring: rgba(47, 107, 79, .28);
  --danger: #a33a2c;
  --shadow: 0 10px 30px rgba(52, 38, 18, .14), 0 2px 6px rgba(52, 38, 18, .08);
  --scale: 1;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --dock-h: 128px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --paper: #1b1814; --ink: #ece5d8; --ink-2: #b9ae9d; --ink-3: #877d70; --line: #2e2922;
    --chip: #2a251f; --accent: #e0aa52; --accent-ink: #1a140b; --mark: #3d321d; --mark-edge: #d9a441;
    --listen: #5fb48a; --listen-ring: rgba(95, 180, 138, .28); --danger: #e0806f;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120f; --paper: #1b1814; --ink: #ece5d8; --ink-2: #b9ae9d; --ink-3: #877d70; --line: #2e2922;
  --chip: #2a251f; --accent: #e0aa52; --accent-ink: #1a140b; --mark: #3d321d; --mark-edge: #d9a441;
  --listen: #5fb48a; --listen-ring: rgba(95, 180, 138, .28); --danger: #e0806f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  -webkit-tap-highlight-color: transparent; min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--ink-3); }
.center { text-align: center; }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.where {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 8px 10px 8px 12px; border: 0;
  border-radius: 12px; background: transparent; font-family: var(--serif); font-size: 1.2rem; font-weight: 600;
}
.where:hover, .where:focus-visible { background: var(--chip); }
#whereText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 0;
  background: var(--chip); color: var(--ink-2); font-size: .82rem; font-weight: 600; text-decoration: none;
  letter-spacing: .01em; white-space: nowrap;
}
.chip:hover { color: var(--ink); }
.chip.toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip.toggle[aria-pressed="true"] { color: var(--accent); }
.chip.toggle[aria-pressed="true"] .dot { background: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: transparent; color: var(--ink-2); position: relative;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--chip); color: var(--ink); }
.icon-btn.big { width: 52px; height: 52px; }
.icon-btn.big svg { width: 24px; height: 24px; }
#menu svg { fill: currentColor; stroke: none; }

/* ---------- banner */
.banner {
  margin: 10px max(12px, env(safe-area-inset-left)); padding: 12px 14px; border-radius: 12px; background: var(--paper);
  border: 1px solid var(--line); color: var(--ink-2); font-size: .92rem; line-height: 1.45;
}
.banner strong { color: var(--ink); }
.banner.warn { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

/* ---------- reader */
.reader {
  max-width: 40rem; margin: 0 auto; padding: 20px 20px calc(var(--dock-h) + 110px + env(safe-area-inset-bottom));
  outline: none;
}
.intro {
  margin: 4px 0 26px; padding: 18px 18px 12px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
}
.intro h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.25rem; }
.intro p { margin: 0 0 10px; line-height: 1.55; color: var(--ink-2); font-size: .95rem; }
.chap-title {
  margin: 8px 0 18px; font-family: var(--serif); font-weight: 600; font-size: calc(1.55rem * var(--scale));
  letter-spacing: .005em; color: var(--ink);
}
.chap-title .num { color: var(--accent); margin-left: .25em; }
.verses { font-family: var(--serif); font-size: calc(1.18rem * var(--scale)); line-height: 1.72; }
.v {
  margin: 0 -10px; padding: 3px 10px; border-radius: 8px; border-left: 3px solid transparent;
  transition: background-color .5s ease, border-color .5s ease; scroll-margin: 120px 0 calc(var(--dock-h) + 90px);
}
.v + .v { margin-top: 2px; }
.v sup {
  font-family: var(--sans); font-size: .62em; font-weight: 700; color: var(--accent); margin-right: .35em;
  vertical-align: .45em; line-height: 0; user-select: none;
}
.v.on { background: var(--mark); border-left-color: var(--mark-edge); }
.v.flash { animation: flash 1.2s ease-out 1; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mark-edge) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.v.empty { color: var(--ink-3); font-style: italic; font-size: .92em; }
.vhead {
  margin: 18px 0 6px; font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.loading { color: var(--ink-3); font-family: var(--sans); font-size: 1rem; padding: 40px 0; text-align: center; }
.chap-nav { display: flex; justify-content: space-between; gap: 12px; margin: 34px 0 12px; }
.nav-btn {
  flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink-2); font-size: .92rem; text-align: center;
}
.nav-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.nav-btn:disabled { visibility: hidden; }
.credit { margin: 22px 0 0; font-size: .78rem; line-height: 1.5; color: var(--ink-3); text-align: center; }

/* ---------- jump card */
.jump {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--dock-h) + 12px + env(safe-area-inset-bottom));
  width: min(34rem, calc(100% - 24px)); display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line);
  box-shadow: var(--shadow); animation: rise .28s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.jump-main { display: flex; flex-direction: column; min-width: 0; }
.jump-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.jump-ref { font-family: var(--serif); font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jump-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.verdict.done-good { color: var(--listen); background: color-mix(in srgb, var(--listen) 14%, transparent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 600; text-decoration: none;
}
.btn.small { height: 36px; padding: 0 12px; border-radius: 10px; font-size: .86rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.text-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 8px 0; }

/* ---------- dock */
.dock {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  padding: 8px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.heard {
  max-width: 34rem; margin: 0 auto 6px; height: 1.5em; overflow: hidden; text-align: center; font-size: .86rem;
  color: var(--ink-3); white-space: nowrap; direction: rtl; text-overflow: ellipsis;
}
.heard-text { direction: ltr; unicode-bidi: plaintext; }
.heard .hit { color: var(--accent); font-weight: 700; }
.heard .interim { opacity: .65; }
.dock-row { display: flex; align-items: center; justify-content: center; gap: 28px; }
.badge {
  position: absolute; top: 6px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.listen {
  position: relative; display: inline-flex; align-items: center; gap: 10px; height: 60px; padding: 0 26px 0 22px;
  border-radius: 30px; border: 0; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 1.02rem;
  letter-spacing: .01em; box-shadow: var(--shadow);
}
.listen svg { width: 24px; height: 24px; }
.listen .ring { position: absolute; inset: -6px; border-radius: 36px; border: 2px solid transparent; pointer-events: none; }
.listen[aria-pressed="true"] { background: var(--listen); color: #fff; }
.listen[aria-pressed="true"] .ring { border-color: var(--listen-ring); animation: breathe 2.4s ease-in-out infinite; }
.listen.hearing .ring { border-color: var(--listen); animation-duration: 1.1s; }
.listen.starting { opacity: .8; }
.listen:disabled { opacity: .45; cursor: not-allowed; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.06); opacity: .35; } }

/* ---------- sheets */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 16, 10, .38); animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 41; left: 50%; bottom: 0; transform: translateX(-50%); width: min(40rem, 100%);
  max-height: min(86vh, 760px); overflow: auto; overscroll-behavior: contain;
  padding: 6px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  border-radius: 22px 22px 0 0; background: var(--paper); box-shadow: var(--shadow); animation: up .26s ease-out;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }
@media (min-width: 720px) {
  .sheet { bottom: auto; top: 8vh; border-radius: 22px; max-height: 84vh; }
}
.sheet-head {
  position: sticky; top: -6px; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0 10px; background: var(--paper);
}
.sheet-head h2 { margin: 0; font-family: var(--serif); font-size: 1.25rem; }
.sheet-foot { display: flex; justify-content: center; padding-top: 8px; }
.type-form { display: flex; gap: 8px; }
.type-form input {
  flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); font-size: 1.05rem;
}
.type-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.type-hint { min-height: 1.3em; margin: 6px 2px 2px; font-size: .86rem; color: var(--ink-3); }
.type-hint.err { color: var(--danger); }
.picker { margin-top: 8px; }
.picker h3 {
  margin: 14px 0 8px; font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.picker .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.picker.chapters .grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.picker .grid button {
  min-height: 42px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font-size: .88rem; text-align: center; line-height: 1.2;
}
.picker .grid button:hover { border-color: var(--ink-3); }
.picker .grid button.cur { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.picker .back { margin-top: 10px; }

.history { list-style: none; margin: 4px 0 0; padding: 0; }
.history li { border-bottom: 1px solid var(--line); }
.history button {
  display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 4px;
  border: 0; background: none; text-align: left;
}
.history .ref { font-family: var(--serif); font-size: 1.05rem; }
.history .meta { flex: none; font-size: .78rem; color: var(--ink-3); }
.history li.cur .ref { color: var(--accent); font-weight: 700; }
.history .src { display: inline-block; margin-left: 6px; font-family: var(--sans); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.setting { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting label, .setting-label { display: block; font-weight: 600; margin-bottom: 8px; }
.setting-note { display: block; margin: 6px 0 0; font-size: .82rem; line-height: 1.4; color: var(--ink-3); font-weight: 400; }
.setting.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.setting.switch .setting-label { margin: 0; }
.setting.switch input {
  -webkit-appearance: none; appearance: none; position: relative; width: 50px; height: 30px; flex: none; margin: 0;
  border-radius: 15px; background: var(--chip); border: 1px solid var(--line); transition: background-color .2s ease;
}
.setting.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s ease;
}
.setting.switch input:checked { background: var(--accent); border-color: transparent; }
.setting.switch input:checked::after { transform: translateX(20px); }
.setting.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.size-row { display: flex; align-items: center; gap: 12px; }
.size-row input { flex: 1; accent-color: var(--accent); }
.size-a { font-family: var(--serif); color: var(--ink-2); }
.size-a.small { font-size: .9rem; } .size-a.large { font-size: 1.5rem; }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--chip); }
.seg button { flex: 1; height: 38px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font-size: .9rem; font-weight: 600; }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.about { margin: 16px 0 0; font-size: .8rem; line-height: 1.5; color: var(--ink-3); }

.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: .9rem; box-shadow: var(--shadow); animation: fade .2s ease-out;
}

@media (max-width: 400px) {
  .where { font-size: 1.08rem; padding-left: 6px; }
  .chip { padding: 0 10px; }
  .top-actions { gap: 4px; }
  .dock-row { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
