/* Study Bible chapter page */
.reader-bar { position: sticky; top: 64px; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.pickwrap { position: relative; }
.reader-bar .wrap { display: flex; align-items: center; gap: 8px; height: 56px; }
.pick { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; position: relative; }
.pick:hover { border-color: color-mix(in srgb, var(--bronze) 50%, var(--line)); }
.pick .caret { opacity: .6; font-size: .7rem; }
.pick.ref { font: 700 1.05rem var(--serif); }
.bar-spacer { flex: 1; }
.bar-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid transparent; border-radius: 10px; padding: 7px 10px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: .92rem; }
.bar-btn:hover { background: var(--surface-2); color: var(--text); }
.bar-btn[aria-pressed="true"] { color: var(--bronze-2); background: var(--hl); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 300px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 50; text-align: left; }
.menu.open { display: block; }
.menu button { display: grid; grid-template-columns: 64px 1fr; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; gap: 8px; font-weight: 400; }
.menu button:hover { background: var(--surface-2); }
.menu button b { color: var(--bronze-2); font-weight: 700; }
.menu button small { display: block; color: var(--muted); font-size: .78rem; }
.menu .group { font: 700 .68rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; }
.badge { display: inline-block; font: 600 .66rem var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ember); border: 1px solid color-mix(in srgb, var(--ember) 45%, transparent); padding: 0 5px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }

.reader { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 48px; padding-top: 28px; align-items: start; }
.text-col { max-width: 700px; width: 100%; margin: 0 auto; }

.plate { margin: 0 0 30px; }
.plate-img { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; }
.plate-img img { width: 100%; max-height: 430px; object-fit: cover; object-position: center 30%; }
.plate-count { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.plate-count button { width: 54px; height: 54px; padding: 0; border-radius: 8px; overflow: hidden; border: 2px solid rgba(255,255,255,.3); cursor: pointer; background: #000; }
.plate-count button[aria-pressed="true"] { border-color: var(--bronze); }
.plate-count img { width: 100%; height: 100%; object-fit: cover; }
.plate figcaption { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.plate figcaption b { color: var(--text-2); font-weight: 600; }

.chapter-head { margin-bottom: 8px; }
.chapter-head h1 { font: 700 2.6rem/1.1 var(--serif); margin: 6px 0 0; }
.chapter-head .sub { color: var(--muted); font-size: .95rem; margin-top: 6px; }

.scripture { font: 400 var(--read-size)/1.85 var(--serif); color: var(--text); }
.scripture p { margin: 0 0 1em; }
.scripture h2.sh { font: 700 1.05rem/1.3 var(--sans); color: var(--bronze-2); margin: 2em 0 .2em; letter-spacing: .01em; }
.scripture .parallels { font: .82rem var(--sans); color: var(--muted); margin: 0 0 .9em; }
.scripture .parallels a { color: var(--muted); text-decoration: underline dotted; }
.v { border-radius: 4px; transition: background .15s; cursor: pointer; }
.v:hover { background: color-mix(in srgb, var(--hl) 60%, transparent); }
.v.sel { background: var(--hl); box-shadow: 0 0 0 3px var(--hl); }
.v.marked { background: rgba(236,149,80,.22); }
.vn { font: 700 .62em var(--sans); color: var(--bronze); vertical-align: .55em; margin: 0 .25em 0 .1em; text-decoration: none !important; }
.wj { color: var(--wj); }
body.no-red .wj { color: inherit; }
.fn { all: unset; cursor: pointer; font: 700 .6em var(--sans); color: var(--ember); vertical-align: .6em; padding: 0 .12em; }
.name { all: unset; cursor: pointer; border-bottom: 1px dotted color-mix(in srgb, var(--bronze) 70%, transparent); }
.name:hover { color: var(--bronze-2); }

.chap-nav { display: flex; justify-content: space-between; gap: 12px; margin: 40px 0 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.chap-nav a { display: flex; flex-direction: column; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; min-width: 160px; color: var(--text); text-decoration: none !important; }
.chap-nav a small { color: var(--muted); font-size: .78rem; }
.chap-nav a b { font: 700 1.1rem var(--serif); }
.chap-nav a:last-child { text-align: right; }
.credits { font-size: .8rem; color: var(--muted); margin-top: 18px; }

/* side panel */
.panel { position: sticky; top: 136px; height: calc(100vh - 136px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; overflow: hidden; }
.panel-head { padding: 14px 16px 0; border-bottom: 1px solid var(--line); }
.panel-ctx { display: flex; align-items: center; justify-content: space-between; font-size: .85rem; color: var(--muted); }
.panel-ctx b { color: var(--text); font: 700 1rem var(--serif); }
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; margin-top: 8px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .86rem; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--bronze-2); border-color: var(--bronze); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 24px; font-size: .95rem; line-height: 1.65; color: var(--text-2); }
.pane[hidden] { display: none; }
.pane h4 { font: 700 .8rem var(--sans); color: var(--bronze); letter-spacing: .08em; text-transform: uppercase; margin: 18px 0 6px; }
.pane h4:first-child { margin-top: 0; }
.pane p { margin: 0 0 .8em; }
.pane section.active { background: var(--hl); margin: 0 -10px; padding: 8px 10px 2px; border-radius: 10px; }
.pane .sref { border-bottom: 1px dotted var(--bronze); text-decoration: none; }
.src-select { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: 600 .9rem var(--sans); margin-bottom: 8px; }
.cm-sec h5 { font-size: .9rem; margin: 12px 0 4px; }
.cm-sec blockquote { margin: 8px 0; padding-left: 12px; border-left: 2px solid var(--line); }
.note-ai { font-size: .78rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; padding: 7px 10px; margin-bottom: 14px; }
.xref { padding: 10px 0; border-bottom: 1px solid var(--line); }
.xref a { font-weight: 700; }
.xref p { margin: 3px 0 0; font: 400 .95rem/1.55 var(--serif); color: var(--text-2); }
.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; cursor: pointer; text-align: center; min-width: 64px; }
.word:hover, .word[aria-pressed="true"] { border-color: var(--bronze); }
.word .g { display: block; font: 500 1.15rem/1.3 "Gentium Plus", "SBL Greek", Georgia, serif; color: var(--text); }
.word .t { display: block; font-size: .72rem; color: var(--muted); font-style: italic; }
.word .e { display: block; font-size: .8rem; color: var(--bronze-2); font-weight: 600; }
.lex { margin-top: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.lex .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lex .head .g { font: 600 1.5rem var(--serif); color: var(--text); }
.lex .head .s { font-weight: 700; color: var(--bronze); font-size: .85rem; }
.lex .parse { font-size: .8rem; color: var(--muted); margin: 4px 0 8px; }
#map { height: 320px; border-radius: 12px; border: 1px solid var(--line); }
.map-list { margin-top: 10px; font-size: .88rem; }
.vid { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none !important; }
.vid img { border-radius: 8px; aspect-ratio: 16/9; object-fit: cover; }
.vid b { font: 700 .98rem/1.3 var(--serif); display: block; }
.vid small { color: var(--muted); }
.audio { display: none; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 22px; }
.audio.open { display: flex; }
.audio .bar { flex: 1; height: 4px; background: var(--line); border-radius: 2px; position: relative; }
.audio .bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 18%; background: var(--bronze); border-radius: 2px; }

/* popovers */
.pop { position: absolute; z-index: 70; width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; font: .92rem/1.6 var(--sans); color: var(--text-2); }
.pop h5 { margin: 0 0 6px; font: 700 1.05rem var(--serif); color: var(--text); }
.pop a { font-weight: 600; font-size: .85rem; }

/* verse action pill */
.vbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(140%); z-index: 45; display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px; box-shadow: var(--shadow); transition: transform .2s; max-width: calc(100vw - 24px); overflow-x: auto; }
.vbar.show { transform: translateX(-50%) translateY(0); }
.vbar b { font: 700 .95rem var(--serif); padding: 0 12px; white-space: nowrap; color: var(--bronze-2); }
.vbar button { background: none; border: 0; border-radius: 999px; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: .85rem; white-space: nowrap; color: var(--text-2); }
.vbar button:hover { background: var(--surface-2); color: var(--text); }

.study-fab { display: none; }
@media (max-width: 1080px) {
  .reader { grid-template-columns: 1fr; }
  .panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; max-height: 72vh; border-radius: 18px 18px 0 0; transform: translateY(105%); transition: transform .25s; z-index: 55; }
  .panel.open { transform: translateY(0); }
  .panel-head::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
  .study-fab { display: inline-flex; position: fixed; right: 16px; bottom: 18px; z-index: 44; }
  .vbar { bottom: 76px; }
  .reader-bar .hide-sm { display: none; }
}
@media (max-width: 600px) {
  .chapter-head h1 { font-size: 2.1rem; }
  .plate-img img { max-height: 260px; }
  .plate-count button { width: 42px; height: 42px; }
  .chap-nav a { min-width: 0; flex: 1; }
  .reader-bar .wrap { gap: 6px; position: relative; }
  .pickwrap { position: static; }
  .pick { padding: 7px 8px; gap: 4px; }
  .pick .caret { display: none; }         /* room for the book name beside the Listen button */
  .pick.ref { font-size: .98rem; }
  .bar-btn { padding: 7px 6px; }
  .pickwrap:first-child { min-width: 0; flex: 0 1 auto; }
  .pickwrap:first-child .pick { max-width: 100%; box-sizing: border-box; }
  .pick-name { max-width: none; min-width: 0; }
  .menu { left: 16px; right: 16px; width: auto; min-width: 0; }
  .bar-btn .lbl { display: none; }
}
:root:not([data-theme="light"]) #map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) sepia(.15); }
.vbar:not(.show) { visibility: hidden; opacity: 0; }
@media (max-width: 1080px) { .vbar.show ~ .study-fab, body:has(.vbar.show) .study-fab { display: none; } }

/* ---------- v2 additions ---------- */
.scripture p.q1, .scripture p.q2, .scripture p.qr, .scripture p.qc { margin: 0; }
.scripture p.q1 { padding-left: 1.4em; text-indent: -1em; }
.scripture p.q2 { padding-left: 2.6em; text-indent: -1em; }
.scripture p.qr { text-align: right; }
.scripture p.qc, .scripture p.pc { text-align: center; }
.scripture p.pi { padding-left: 1.4em; }
.scripture p.li1 { padding-left: 1.6em; text-indent: -1em; margin: 0 0 .3em; }
.scripture p.li2 { padding-left: 2.8em; text-indent: -1em; margin: 0 0 .3em; }
.scripture p.d { font-style: italic; color: var(--text-2); font-size: .94em; }
.scripture .bk { height: .9em; }
.scripture .q1 + .p, .scripture .q2 + .p, .scripture .q1 + .m, .scripture .q2 + .m { margin-top: 1em; }
.scripture h3.sh { font: 600 .98rem/1.3 var(--sans); color: var(--bronze-2); margin: 1.4em 0 .2em; }
.scripture p.sh { font: italic .95rem var(--sans); color: var(--muted); margin: .4em 0; }
.nd { font-variant: small-caps; letter-spacing: .04em; }
.qs { font-style: italic; color: var(--muted); }
.pil { color: var(--muted); font-size: .8em; margin-right: .2em; }
.bab-orig { color: var(--bronze-2); font-size: .88em; }
.bab-alt { color: var(--muted); font-size: .9em; }
.bab-lit { color: var(--muted); font-style: italic; font-size: .9em; }
.bab-xref { color: var(--muted); font-size: .8em; }
.bab-pl { color: var(--ember); }
[data-s] { cursor: help; }
[data-s]:hover { color: var(--bronze-2); }
.tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--hl); color: var(--bronze-2); font-size: .72rem; }
.loading { color: var(--muted); }
.wj-sample { color: var(--wj); font-weight: 700; }
.close-panel { width: 32px; height: 32px; }
@media (min-width: 1081px) { .close-panel { display: none; } }
.book-menu { width: min(640px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; }
.chap-menu { width: min(340px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; }
.pick-name { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px; padding: 4px; }
.book-menu-grid a { padding: 6px 8px; border-radius: 6px; color: var(--text-2); font-size: .88rem; }
.book-menu-grid a:hover, .book-menu-grid a.on { background: var(--surface-2); color: var(--bronze-2); text-decoration: none; }
.menu .chap-grid { padding: 4px 6px 8px; }
.menu .chap-grid a { min-width: 36px; padding: 5px 0; font-size: .85rem; }
.menu[data-menu-id="trans"] { max-height: 70vh; overflow-y: auto; }
/* interlinear (BIB) view */
.il-verse { margin: 0 0 1.4em; }
.il-verse .vn { vertical-align: top; }
.il-words { display: inline-flex; flex-wrap: wrap; gap: 6px 10px; vertical-align: top; }
.il-verse.heb .il-words { direction: rtl; }
.il-w { display: inline-flex; flex-direction: column; align-items: center; font-family: var(--sans); }
.il-w .o { font: 500 1.15rem/1.3 "SBL Hebrew", "Ezra SIL", "Gentium Plus", Georgia, serif; color: var(--text); }
.il-w .tr { font-size: .7rem; color: var(--muted); font-style: italic; direction: ltr; }
.il-w .gl { font-size: .78rem; color: var(--bronze-2); font-weight: 600; direction: ltr; }
.il-w .sn { font-size: .62rem; color: var(--muted); direction: ltr; }
.word .g.heb { font-family: "SBL Hebrew", "Ezra SIL", Georgia, serif; }
.words.heb { direction: rtl; }
.words.heb .word { direction: ltr; }
.panel-body .cm-sec { padding: 6px 0 4px; border-bottom: 1px solid var(--line); }
.panel-body .cm-sec:last-child { border-bottom: 0; }
.panel-body .cm-sec.active { background: var(--hl); margin: 0 -10px; padding: 8px 10px 4px; border-radius: 10px; border-bottom-color: transparent; }
.src-note { font-size: .78rem; color: var(--muted); margin: 10px 0 0; }

/* Bible Themes */
[data-filter-group]:first-of-type { margin-top: 12px; }
.theme-area { border-bottom: 1px solid var(--line); }
.theme-area summary { display: flex; justify-content: space-between; gap: 12px; padding: 14px 2px; cursor: pointer; font: 700 1.2rem var(--serif); }
.theme-list { list-style: none; margin: 0 0 16px; padding: 0; columns: 3 240px; column-gap: 28px; }
.theme-list li { break-inside: avoid; padding: 4px 0; }
.theme-list li[hidden] { display: none; }
.theme-body blockquote.key-text { margin: 8px 0 18px; padding-left: 14px; border-left: 2px solid var(--gold, #c99a5b); }
.theme-related { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.theme-row { display: block; padding: 7px 0; border-bottom: 1px solid var(--line); }

/* Listen: player and verse-by-verse highlight */
.v.reading { background: color-mix(in srgb, var(--bronze) 26%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bronze) 26%, transparent); }
.player { position: sticky; bottom: 12px; z-index: 45; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 18px 0; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.player[hidden] { display: none; }
.pl-play { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--bronze); color: #15110b; font-size: .9rem; cursor: pointer; }
.pl-seek { flex: 1 1 120px; min-width: 0; accent-color: var(--bronze); }
.pl-time { font: 500 .85rem var(--sans); color: var(--muted); min-width: 36px; }
.pl-btn { padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text); font: 600 .82rem var(--sans); cursor: pointer; white-space: nowrap; }
.pl-btn.on { background: var(--hl); border-color: var(--bronze); color: var(--bronze-2); }
.pl-note { flex-basis: 100%; margin: 0; font: 400 .75rem var(--sans); color: var(--muted); }
@media (max-width: 1080px) {
  .player { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 16px 16px 0 0; border-bottom: 0; }
  body.listening .vbar { bottom: 112px; }
  body.listening .study-fab { bottom: 112px; }
  body.listening .reader { padding-bottom: 110px; }
}
@media (min-width: 1081px) { body.listening .vbar { bottom: 112px; } }

/* Verse links land clear of the sticky header and reader bar */
#scripture [id^="v"] { scroll-margin-top: 150px; }

/* Audio Bible */
.ab-player { position: sticky; top: 76px; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.ab-player[hidden] { display: none; }
.ab-now { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; font-family: var(--serif); font-size: 1.15rem; }
.ab-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.ab-seek { width: 100%; margin-top: 10px; }
.ab-times { display: flex; justify-content: space-between; font: 500 .82rem var(--sans); color: var(--muted); }
.ab-player .chap-grid { padding: 10px 0 4px; max-height: 118px; overflow-y: auto; }
.ab-list { display: grid; gap: 8px; margin-bottom: 18px; }
.ab-book { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; width: 100%; text-align: left; padding: 13px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); cursor: pointer; font: 500 .9rem var(--sans); }
.ab-book b { font: 700 1.1rem var(--serif); }
.ab-book:hover, .ab-book.on { border-color: var(--bronze); }
