:root {
  --fs: 19px; --lh: 1.7;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --reading: var(--serif);
  --bar-h: 52px;
  --hl1: #f6d84a; --hl2: #7fd68a; --hl3: #74b9f5; --hl4: #f29bbd; --hl5: #f3a55c;
}
[data-theme="dark"] { --bg:#14171c; --panel:#1b1f26; --raise:#242a33; --ink:#e7e3da; --dim:#9aa1ad; --line:#2c333d; --accent:#d9a441; --jesus:#f08a80; --sel:#2b3646; --hla:.36; color-scheme: dark; }
[data-theme="black"] { --bg:#000; --panel:#0b0c0e; --raise:#16181c; --ink:#d6d2c9; --dim:#858b96; --line:#1f2329; --accent:#d9a441; --jesus:#e8847a; --sel:#1d2733; --hla:.34; color-scheme: dark; }
[data-theme="light"] { --bg:#fbfaf7; --panel:#fff; --raise:#f1eee8; --ink:#1d1c1a; --dim:#6b6a66; --line:#e2ded5; --accent:#8a5a12; --jesus:#b3261e; --sel:#e6edf7; --hla:.55; color-scheme: light; }
[data-theme="sepia"] { --bg:#f4ecd8; --panel:#faf4e4; --raise:#ebe0c6; --ink:#3b2f20; --dim:#7a6a53; --line:#dccfb0; --accent:#8a5a12; --jesus:#a83224; --sel:#e3d6b6; --hla:.6; color-scheme: light; }
[data-font="sans"] { --reading: var(--sans); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain; display: flex; flex-direction: column; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#bar { height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 12px; display: flex; align-items: center; gap: 4px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; z-index: 5; }
.ref { display: flex; align-items: center; gap: 4px; font-weight: 650; font-size: 17px; padding: 8px 8px 8px 4px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ref:hover, .chip:hover, .icon:hover { background: var(--raise); }
.chip { font-size: 13px; font-weight: 650; letter-spacing: .04em; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); flex: none; }
.grow { flex: 1; }
.icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--dim); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.small { width: 32px; height: 32px; } .icon.small svg { width: 18px; height: 18px; }
.icon.big { width: 48px; height: 48px; color: var(--ink); } .icon.big svg { width: 28px; height: 28px; fill: currentColor; stroke: none; }
.icon.on { color: var(--accent); }

#layout { flex: 1; min-height: 0; display: flex; position: relative; }
#reader { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; outline: none; scroll-padding-top: 16px; }
#text { max-width: 42em; margin: 0 auto; padding: 22px 22px 8px; font-family: var(--reading); font-size: var(--fs); line-height: var(--lh); min-height: 60vh; }
#text h1 { font-family: var(--sans); font-size: .8em; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 0 0 .2em; text-align: center; }
#text .chnum { font-size: 3em; line-height: 1; text-align: center; color: var(--accent); margin: 0 0 .5em; font-weight: 400; }
#text h2 { font-family: var(--sans); font-size: .82em; font-weight: 650; color: var(--dim); margin: 1.6em 0 .5em; line-height: 1.35; }
#text .sub { font-style: italic; color: var(--dim); font-size: .92em; margin: 0 0 .5em; }
#text p { margin: 0 0 .85em; }
#text .q1, #text .q2 { display: block; padding-left: 1.4em; text-indent: -1.4em; margin-left: .2em; }
#text .q2 { margin-left: 1.6em; }
#text .q3 { display: block; padding-left: 1.4em; text-indent: -1.4em; margin-left: 3em; }
#text .d { font-style: italic; color: var(--dim); }
.v { border-radius: 3px; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: .12em 0; }
.v sup.n { font-family: var(--sans); font-size: .6em; font-weight: 650; color: var(--dim); margin-right: .3em; user-select: none; vertical-align: .45em; line-height: 0; }
.nonum sup.n { display: none; }
.vline .v { display: block; margin-bottom: .45em; }
.red .j { color: var(--jesus); }
.v.sel { background: var(--sel); text-decoration: underline dotted var(--dim); text-underline-offset: .28em; }
.v.speaking { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.v.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 45%, transparent); } to { background: transparent; } }
.v[data-hl="1"] { background: color-mix(in srgb, var(--hl1) calc(var(--hla) * 100%), transparent); }
.v[data-hl="2"] { background: color-mix(in srgb, var(--hl2) calc(var(--hla) * 100%), transparent); }
.v[data-hl="3"] { background: color-mix(in srgb, var(--hl3) calc(var(--hla) * 100%), transparent); }
.v[data-hl="4"] { background: color-mix(in srgb, var(--hl4) calc(var(--hla) * 100%), transparent); }
.v[data-hl="5"] { background: color-mix(in srgb, var(--hl5) calc(var(--hla) * 100%), transparent); }
.v.sel[data-hl] { outline: 2px solid var(--dim); outline-offset: 1px; text-decoration: none; }
.mark { font-family: var(--sans); font-size: .62em; color: var(--accent); margin-left: .25em; user-select: none; vertical-align: .3em; }
.fn { font-family: var(--sans); font-size: .62em; color: var(--accent); vertical-align: .5em; cursor: help; padding: 0 .15em; line-height: 0; }
.empty { color: var(--dim); text-align: center; padding: 3em 1em; font-family: var(--sans); font-size: 15px; line-height: 1.5; }
.esvnote { font-family: var(--sans); font-size: 12px; color: var(--dim); margin-top: 2em; line-height: 1.5; }
.esvnote a { color: inherit; }

#pager { max-width: 42em; margin: 0 auto; padding: 8px 14px calc(40px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; gap: 10px; }
.pg { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); color: var(--dim); font-size: 15px; }
.pg:hover { background: var(--raise); color: var(--ink); }
.pg:disabled { visibility: hidden; }

/* commentary: side column on wide screens, bottom sheet on phones */
#cmt { width: min(44%, 560px); border-left: 1px solid var(--line); background: var(--panel); display: none; flex-direction: column; min-height: 0; }
body.cmt-open #cmt { display: flex; }
#cmtHead { display: flex; align-items: center; border-bottom: 1px solid var(--line); flex: none; }
#cmtTabs { flex: 1; display: flex; gap: 2px; overflow-x: auto; padding: 6px 6px 0; scrollbar-width: none; }
#cmtTabs::-webkit-scrollbar { display: none; }
#cmtTabs button { padding: 9px 12px; font-size: 14px; font-weight: 600; color: var(--dim); border-bottom: 2px solid transparent; white-space: nowrap; border-radius: 8px 8px 0 0; }
#cmtTabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }
#cmtTabs button.none { opacity: .45; }
#cmtBody { flex: 1; overflow-y: auto; padding: 14px 18px 60px; font-family: var(--reading); font-size: calc(var(--fs) * .9); line-height: 1.62; outline: none; }
#cmtBody .ce { padding: 10px 12px; margin: 0 -12px 4px; border-radius: 10px; border-left: 3px solid transparent; }
#cmtBody .ce.hit { background: var(--raise); border-left-color: var(--accent); }
#cmtBody .cv { font-family: var(--sans); font-size: 12.5px; font-weight: 700; color: var(--accent); letter-spacing: .03em; cursor: pointer; display: inline-block; margin-bottom: 2px; }
#cmtBody p { margin: 0 0 .7em; }
#cmtBody h3, #cmtBody h4 { font-family: var(--sans); font-size: .85em; margin: 1em 0 .4em; }
#cmtBody a[data-ref] { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: .18em; }
#cmtBody details.bookintro { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
#cmtBody details.bookintro summary { font-family: var(--sans); font-size: 13.5px; font-weight: 650; cursor: pointer; color: var(--dim); }
#cmtBody details.bookintro[open] summary { margin-bottom: 8px; }
#cmtBody .xr { display: block; width: 100%; text-align: left; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; font: inherit; }
#cmtBody .xr:hover { background: var(--raise); }
#cmtBody .xr b { font-family: var(--sans); font-size: 12.5px; color: var(--accent); display: block; }
#cmtBody .src { font-family: var(--sans); font-size: 12px; color: var(--dim); margin: 0 0 12px; }
@media (max-width: 899px) {
  #cmt { position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 58%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.35); z-index: 4; }
  body.cmt-open #reader { padding-bottom: 58vh; }
  #cmtBody { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  #bar .icon { width: 36px; }
}

#selBar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); background: var(--raise); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px 10px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 8; width: min(96vw, 520px); }
body.cmt-open #selBar { bottom: auto; top: calc(var(--bar-h) + env(safe-area-inset-top) + 8px); }
@media (min-width: 900px) { body.cmt-open #selBar { top: auto; bottom: 14px; left: 28%; } }
.selTop { display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding: 0 2px 6px 4px; }
.selRow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.selRow button { padding: 8px 11px; border-radius: 10px; font-size: 14px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); }
.selRow button.on { border-color: var(--accent); color: var(--accent); }
#colors { display: inline-flex; gap: 6px; margin-right: 4px; }
#colors button { width: 30px; height: 30px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
#colors button.on { border-color: var(--ink); }
#colors button.x { background: var(--panel); border: 1px dashed var(--dim); color: var(--dim); font-size: 13px; }

#player { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); background: var(--raise); border: 1px solid var(--line); border-radius: 16px; padding: 6px 8px; display: flex; align-items: center; gap: 4px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 7; max-width: 96vw; }
#player select { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; font-size: 13px; max-width: 110px; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 20; display: flex; justify-content: center; align-items: flex-start; padding: calc(env(safe-area-inset-top) + 4vh) 10px 10px; }
.sheetBox { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: min(100%, 640px); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#sheetBody { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.sheet h2 { margin: 0; font-size: 18px; display: flex; align-items: center; justify-content: space-between; }
.sheet h3 { margin: 10px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.sheet input[type=text], .sheet input[type=password], .sheet input[type=search], .sheet textarea { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 16px; }
.sheet textarea { min-height: 150px; resize: vertical; font-family: var(--reading); line-height: 1.5; }
.btn { padding: 10px 14px; border-radius: 10px; background: var(--raise); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #17130a; }
.btn.danger { color: #e06a5f; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.grid.nums { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.grid button { padding: 10px 6px; border-radius: 9px; background: var(--raise); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid button:hover, .list button:hover { background: var(--sel); }
.grid button.cur { outline: 2px solid var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 8px 12px; font-size: 14px; }
.seg button.on { background: var(--accent); color: #17130a; font-weight: 650; }
.list { display: flex; flex-direction: column; gap: 2px; }
.list button { text-align: left; padding: 10px; border-radius: 10px; font-size: 15px; line-height: 1.45; }
.list .r { display: block; font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; font-family: var(--sans); }
.list .t { font-family: var(--reading); }
.list mark { background: color-mix(in srgb, var(--accent) 40%, transparent); color: inherit; border-radius: 2px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.muted { color: var(--dim); font-size: 13.5px; line-height: 1.5; }
.err { color: #e06a5f; font-size: 14px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--dim); }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
code.inv { background: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 14px; user-select: all; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 999px; font-size: 14px; z-index: 30; max-width: 90vw; }
@media (prefers-reduced-motion: reduce) { .v.flash { animation: none; } }
@media print { #bar, #pager, #cmt, #selBar, #player { display: none !important; } #reader { overflow: visible; } }

.seg.wrap { flex-wrap: wrap; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plan p { margin: 0; }
.bar { height: 6px; border-radius: 3px; background: var(--raise); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.prayer { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.prayer .t { font-family: var(--reading); font-size: 16px; line-height: 1.5; white-space: pre-wrap; }
.prayer.ans { opacity: .65; }
.prayer .btn { padding: 6px 10px; font-size: 13px; }
