/* v2 shell. Loaded after styles.css. */
html.v2 {
  --bg: #f7f2e9; --paper: #fffcf6; --paper-2: #f2ece1; --ink: #1d1b18; --muted: #6d675e;
  --line: #e6ded0; --accent: #8a4b2a; --accent-soft: #e9d3c3; --select: #f3e7da; --select-edge: #8a4b2a;
  --pop: #8a4b2a;
  --serif: "Iowan Old Style", "Charter", "Source Serif 4", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --v2-fs: 21px;
  --tabh: 64px;
  --barh: 56px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
}
html.v2.v2-sepia {
  --bg: #f1e6d0; --paper: #f8eedb; --paper-2: #ead9bc; --ink: #3b2f22; --muted: #7a6a55;
  --line: #dfcdae; --accent: #8a5a2b; --select: #e8d6b6;
}
html.v2[data-theme="dark"] {
  --bg: #121417; --paper: #1b1e22; --paper-2: #24282d; --ink: #ece7df; --muted: #a39d93;
  --line: #2e3238; --accent: #e0a77f; --accent-soft: #4a3326; --select: #2a2520; --select-edge: #e0a77f; --pop: #e0a77f;
}
html.v2 body { background: var(--bg); font-family: var(--sans); color: var(--ink); overscroll-behavior-y: none; }

/* ---------- top bar ---------- */
html.v2 .top {
  padding: var(--sat) 0 0; background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
body.v2-scrolled .top { border-bottom-color: var(--line); }
html.v2 .top-row, html.v2 #chapter-seg, html.v2 .section-nav, html.v2 .search-hint { display: none !important; }
.v2-bar { height: var(--barh); display: flex; align-items: center; gap: .4rem; padding: 0 .6rem; max-width: 60rem; margin: 0 auto; }
.v2-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; color: var(--ink); }
.v2-icon svg { width: 22px; height: 22px; }
.v2-icon:active { background: var(--paper-2); }
.v2-brand img { width: 30px; height: 30px; border-radius: 8px; }
.v2-aa { font-family: var(--serif); font-size: 1.15rem; }
.v2-ref {
  display: inline-flex; align-items: center; gap: .2rem; border: 0; background: var(--paper-2);
  padding: .45rem .7rem .45rem .95rem; border-radius: 999px; font-weight: 600; font-size: 1rem; min-height: 40px;
}
.v2-ref svg { width: 18px; height: 18px; opacity: .6; }
.v2-view-title { font-weight: 650; font-size: 1.05rem; display: none; }
.v2-bar-actions { margin-left: auto; display: flex; gap: .15rem; }
html.v2:not([data-v2view="read"]) .v2-ref { display: none; }
html.v2:not([data-v2view="read"]) .v2-view-title { display: block; }
html.v2 #search-form { display: none; max-width: 60rem; margin: 0 auto; padding: 0 .9rem .7rem; }
body.v2-search-on #search-form { display: block; }
html.v2 #q { border-radius: 12px; background: var(--paper-2); border: 0; min-height: 44px; padding: .6rem 1rem; font-size: 1rem; }
html.v2 #results { max-width: 60rem; margin: 0 auto .6rem; max-height: 60vh; overflow: auto; padding: 0 .9rem; }

/* ---------- tab bar ---------- */
.v2-tabs {
  position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px 4px calc(4px + var(--sab));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--line);
}
.v2-tabs button {
  border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; font-weight: 600; letter-spacing: .01em; padding: 6px 0 4px; min-height: 52px; border-radius: 12px;
}
.v2-tabs svg { width: 25px; height: 25px; }
.v2-tabs button[aria-current="page"] { color: var(--accent); }
.v2-tabs button:active { background: var(--paper-2); }
html.v2 main { padding-bottom: calc(var(--tabh) + var(--sab) + 1rem); }

/* ---------- reader ---------- */
html.v2[data-v2view="read"] .layout { display: block; max-width: none; padding: .5rem 1.25rem 2rem; }
html.v2[data-v2view="read"] .reading { max-width: 34rem; margin: 0 auto; width: auto; justify-self: auto; }
html.v2[data-v2view="read"] .reading > .section-search-wrap,
html.v2[data-v2view="read"] .reading > .blurb,
html.v2[data-v2view="read"] .reading > .themes-row,
html.v2[data-v2view="read"] .reading > .people-row,
html.v2[data-v2view="read"] .reading > .art-row,
html.v2[data-v2view="read"] .reading > .panel-actions,
html.v2[data-v2view="read"] .reading > .fine,
html.v2[data-v2view="read"] .reading > .marker { display: none; }
html.v2 .reading .chapter-kicker {
  margin: 1.6rem 0 0; text-align: center; color: var(--muted); font: 600 .78rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
}
html.v2 .reading h2, html.v2[data-theme] .reading h2 {
  text-align: center; font-family: var(--serif); font-weight: 500; color: var(--ink);
  font-size: clamp(1.7rem, 6.4vw, 2.4rem); line-height: 1.15; letter-spacing: -.01em; margin: .55rem auto 1.2rem; max-width: 26rem; text-wrap: balance;
}
.v2-study-btn {
  display: flex; align-items: center; justify-content: center; gap: .45rem; margin: 0 auto 1.6rem;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px;
  padding: .55rem 1.1rem; font-size: .9rem; font-weight: 600; min-height: 42px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.v2-study-ic { color: var(--accent); }
.v2-study-btn.v2-end { margin-top: 2rem; margin-bottom: .5rem; }
html.v2 .reading .verse {
  display: inline; padding: 0; margin: 0; border: 0; border-radius: 4px; background: none;
  font-family: var(--serif); font-size: var(--v2-fs); line-height: 1.78; color: var(--ink); transform: none !important;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; transition: background .15s;
}
html.v2 .reading .verse:hover { background: none; }
html.v2 .reading .verse .vn {
  font: 700 .6em/1 var(--sans); color: var(--muted); vertical-align: .55em; margin: 0 .22em 0 .35em; letter-spacing: 0;
}
html.v2 .reading .verse:first-of-type .vn { margin-left: 0; }
html.v2 .reading .verse.has-comment .vn::after { content: "•"; color: var(--accent); margin-left: .1em; }
html.v2 .reading .verse.v2-has-note .vn { color: var(--accent); }
html.v2 .reading .verse.v2-picked { text-decoration: underline dotted var(--accent); text-underline-offset: .28em; text-decoration-thickness: 2px; }
.verse[data-hl="yellow"] { background: color-mix(in srgb, #f6d878 60%, transparent) !important; }
.verse[data-hl="green"] { background: color-mix(in srgb, #a9dca0 60%, transparent) !important; }
.verse[data-hl="blue"] { background: color-mix(in srgb, #a7cdf2 60%, transparent) !important; }
.verse[data-hl="pink"] { background: color-mix(in srgb, #f3b2c6 60%, transparent) !important; }
.verse[data-hl="orange"] { background: color-mix(in srgb, #f5bf8a 60%, transparent) !important; }
html[data-theme="dark"] .verse[data-hl] { background: color-mix(in srgb, var(--hlc, #f6d878) 28%, transparent) !important; }
html.v2 .reading .verse .name { border-bottom-color: color-mix(in srgb, var(--accent) 35%, transparent); }
html.v2 .reading .pager { margin-top: 1.4rem; }
html.v2 .reading .nav-btn {
  flex: 1; border: 1px solid var(--line); background: var(--paper); border-radius: 14px; font-size: .85rem; padding: .7rem .9rem; color: var(--muted);
}
html.v2 .reading .pager .nav-btn:last-child { text-align: right; }
main.v2-in-r { animation: v2inR .28s cubic-bezier(.2,.8,.2,1); }
main.v2-in-l { animation: v2inL .28s cubic-bezier(.2,.8,.2,1); }
@keyframes v2inR { from { opacity: 0; transform: translateX(28px); } }
@keyframes v2inL { from { opacity: 0; transform: translateX(-28px); } }

/* ---------- generic sheet ---------- */
.v2-sheet-scrim, html.v2 #scrim {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 12, 8, .32); opacity: 0; transition: opacity .25s;
}
.v2-sheet-scrim.open { opacity: 1; }
html.v2 body.study-open #scrim { display: block !important; opacity: 1; z-index: 29; }
.v2-sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 40rem;
  max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--sab);
}
.v2-sheet.open { transform: none; }
.v2-sheet.v2-tall { height: 86dvh; }
.v2-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; flex: none; }
.v2-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: .3rem 1.1rem .5rem; flex: none; }
.v2-sheet-head h2 { font: 650 1.1rem/1.2 var(--sans); }
.v2-close { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 1.3rem; line-height: 1; color: var(--muted); }
.v2-sheet-body { overflow: auto; padding: .2rem 1.1rem 1.4rem; overscroll-behavior: contain; }
.v2-eyebrow { font: 700 .7rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.1rem 0 .55rem; }
.v2-sec { margin-top: .2rem; }
.v2-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.v2-chip { border: 1px solid var(--line); background: var(--paper-2); border-radius: 999px; padding: .45rem .8rem; font-size: .88rem; min-height: 38px; color: var(--ink); }
.v2-static { display: inline-flex; align-items: center; }
.v2-row-btn { display: block; width: 100%; text-align: left; border: 0; background: var(--paper-2); border-radius: 12px; padding: .8rem 1rem; margin-top: .8rem; font-weight: 600; color: var(--accent); min-height: 44px; }
.v2-fine { color: var(--muted); font-size: .78rem; margin-top: 1rem; }
.v2-input { width: 100%; border: 0; background: var(--paper-2); border-radius: 12px; min-height: 44px; padding: .6rem 1rem; font-size: 1rem; }

/* verse sheet */
.v2-verse-quote { margin: .2rem 0 .4rem; padding: .2rem 0 .2rem .9rem; border-left: 3px solid var(--accent); font: 1.08rem/1.6 var(--serif); }
.v2-hl-row { display: flex; gap: .65rem; margin: 1rem 0 .4rem; align-items: center; }
.v2-swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.v2-swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--paper); }
.v2-swatch-none { background: var(--paper-2); color: var(--muted); font-size: 1rem; }
.v2-actions { display: flex; gap: .5rem; align-items: center; margin-top: .7rem; flex-wrap: wrap; }
.v2-act { border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: .5rem 1rem; font-weight: 600; min-height: 42px; }
.v2-status { color: var(--muted); font-size: .8rem; }
.v2-note { width: 100%; min-height: 84px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: .7rem .8rem; font: 1rem/1.5 var(--sans); resize: vertical; margin-bottom: .3rem; }
.v2-mini-note { background: var(--paper-2); border-radius: 12px; padding: .7rem .85rem; margin-bottom: .5rem; }
.v2-mini-note strong { display: block; font-size: .9rem; margin-bottom: .2rem; }
.v2-mini-note p { font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* picker */
.v2-book-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem; }
.v2-book-grid button { text-align: left; border: 0; background: var(--paper-2); border-radius: 10px; padding: .6rem .8rem; font-size: .93rem; min-height: 42px; }
.v2-book-grid button.on, .v2-grid button.on { background: var(--accent); color: #fff; }
.v2-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: .4rem; margin-top: .6rem; }
.v2-grid button { border: 0; background: var(--paper-2); border-radius: 10px; min-height: 48px; font-weight: 600; font-variant-numeric: tabular-nums; }
.v2-back { border: 0; background: none; color: var(--accent); font-weight: 600; padding: .4rem 0; min-height: 40px; }
.v2-chapters h3 { font: 500 1.5rem var(--serif); margin: .2rem 0; }

/* settings */
.v2-size { display: flex; align-items: center; justify-content: space-between; background: var(--paper-2); border-radius: 14px; padding: .3rem; }
.v2-size-btn { border: 0; background: none; font-family: var(--serif); width: 64px; height: 46px; border-radius: 10px; }
.v2-size-btn.small { font-size: .95rem; } .v2-size-btn.big { font-size: 1.5rem; }
.v2-size-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.v2-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.v2-mode { border: 2px solid var(--line); border-radius: 14px; min-height: 56px; font-weight: 600; }
.v2-mode-light { background: #fffcf6; color: #1d1b18; } .v2-mode-sepia { background: #f1e6d0; color: #3b2f22; } .v2-mode-dark { background: #1b1e22; color: #ece7df; }
.v2-mode.on { border-color: var(--accent); }
.v2-sample { font: var(--v2-fs)/1.7 var(--serif); margin-top: 1.1rem; padding: .8rem 1rem; background: var(--bg); border-radius: 12px; }

/* hub */
.v2-tiles { display: grid; gap: .55rem; }
.v2-tile { display: flex; gap: .85rem; align-items: center; text-align: left; border: 0; background: var(--paper-2); border-radius: 16px; padding: .85rem 1rem; min-height: 64px; }
.v2-tile-ic { width: 40px; height: 40px; border-radius: 12px; background: var(--paper); color: var(--accent); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.v2-tile-t { display: flex; flex-direction: column; gap: .15rem; }
.v2-tile-t small { color: var(--muted); font-size: .8rem; }

/* ---------- study sheet: restyles app.js #study ---------- */
html.v2 .study {
  position: fixed !important; z-index: 30; left: 0; right: 0; bottom: 0; top: auto !important; margin: 0 auto; max-width: 40rem;
  height: 86dvh; max-height: none !important; overflow: auto; border: 0; border-radius: 22px 22px 0 0;
  background: var(--paper); box-shadow: 0 -12px 40px rgba(0,0,0,.18);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  padding: 0 1.1rem calc(1.4rem + var(--sab)); overscroll-behavior: contain;
}
html.v2 body.study-open .study { transform: none; }
html.v2 .study .sheet-head { position: sticky; top: 0; z-index: 2; background: var(--paper); display: flex; justify-content: space-between; align-items: center; padding: .7rem 0 .2rem; }
html.v2 .study .v2-grab { position: absolute; left: 50%; transform: translateX(-50%); top: 0; margin-top: 8px; }
html.v2 .study #close-study { display: inline-flex !important; border: 0; background: var(--paper-2); border-radius: 999px; padding: .35rem .85rem; min-height: 34px; font-weight: 600; font-size: .85rem; }
html.v2 .study h3 { font: 500 1.5rem/1.2 var(--serif); margin: .1rem 0 .7rem; }
html.v2 .study > .meta, html.v2 .study .link-shelf > #link-row { display: none; }
.v2-study-tabs {
  position: sticky; top: 2.9rem; z-index: 2; background: var(--paper); display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none;
  margin: 0 -1.1rem .8rem; padding: .3rem 1.1rem .65rem; border-bottom: 1px solid var(--line);
}
.v2-study-tabs::-webkit-scrollbar { display: none; }
.v2-study-tabs button { flex: none; border: 0; background: var(--paper-2); color: var(--ink); border-radius: 999px; padding: .45rem .9rem; font-size: .88rem; font-weight: 600; min-height: 38px; }
.v2-study-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
html.v2 .study[data-v2tab="notes"] #link-panel { display: none; }
html.v2 .study:not([data-v2tab="notes"]) > details,
html.v2 .study:not([data-v2tab="notes"]) > .note-box,
html.v2 .study:not([data-v2tab="notes"]) > .note-actions { display: none; }
html.v2 .study details.layer { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: .2rem 0; margin: 0; }
html.v2 .study details.layer > summary { font: 650 1.02rem var(--sans); padding: .8rem 0; }
html.v2 .study p { line-height: 1.6; }
html.v2 .study details details { background: var(--paper-2); border: 0; border-radius: 12px; padding: .1rem .85rem; margin: .45rem 0; }

html.v2 #card { border: 0; border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); max-width: min(34rem, 92vw); }
html.v2 #card::backdrop { background: rgba(15,12,8,.35); }

/* other views get the same container */
html.v2:not([data-v2view="read"]) main > * { max-width: 60rem; margin-left: auto; margin-right: auto; }
html.v2:not([data-v2view="read"]) main { padding-left: .9rem; padding-right: .9rem; }

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  html.v2 { --v2-fs: 22px; }
  .v2-tabs {
    top: 0; bottom: 0; right: auto; width: 88px; grid-template-columns: 1fr; grid-auto-rows: 72px; align-content: start;
    padding: calc(var(--barh) + 1rem) 8px 1rem; border-top: 0; border-right: 1px solid var(--line);
  }
  html.v2 body { padding-left: 88px; }
  html.v2 main { padding-bottom: 3rem; }
  .v2-tabs button { font-size: .72rem; }
  .v2-bar { max-width: none; padding: 0 1.4rem; }
  .v2-brand { margin-left: -88px; width: 88px; }
  html.v2 .study {
    left: auto; right: 0; top: 0 !important; bottom: 0; width: 30rem; max-width: 100vw; height: 100dvh; border-radius: 0;
    transform: translateX(105%); box-shadow: -12px 0 40px rgba(0,0,0,.14); padding-top: .4rem;
  }
  html.v2 .study .v2-grab { display: none; }
  .v2-sheet { left: auto; right: 1.5rem; bottom: 1.5rem; width: 26rem; max-height: calc(100vh - 3rem); border-radius: 22px; transform: translateY(calc(100% + 2rem)); }
  .v2-sheet.v2-tall { height: calc(100vh - 3rem); }
  .v2-sheet .v2-grab { display: none; }
  .v2-sheet-head { padding-top: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .v2-sheet, html.v2 .study, main.v2-in-r, main.v2-in-l { transition: none; animation: none; }
}
.v2-sheet[hidden], .v2-sheet-scrim[hidden] { display: none !important; }
html.v2 .reading .verse .name, html.v2 .reading .verse [data-word] { border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, transparent) !important; text-decoration: none; }
html.v2 select { font: inherit; border: 0; background: var(--paper-2); border-radius: 12px; min-height: 44px; padding: .5rem .8rem; color: var(--ink); max-width: 100%; }
html.v2 body { background-image: none; }
@media (min-width: 960px) { .v2-brand { position: fixed; left: 22px; top: calc(var(--sat) + 6px); margin: 0; width: 44px; z-index: 26; } }
@media (min-width: 960px) { .v2-brand { display: none !important; } }
html.v2 body:not(.study-open) .study { box-shadow: none; visibility: hidden; transition: transform .3s, visibility 0s .3s; }
.v2-tabs { z-index: 35; }
html.v2 .study { z-index: 37; }
html.v2 body.study-open #scrim { z-index: 36; }
html.v2 .top { z-index: 34; }
html.v2, html.v2 body { overflow-x: clip; }
html.v2 main { max-width: 100vw; overflow-x: clip; }
html.v2 main pre, html.v2 main table { max-width: 100%; overflow-x: auto; }
html.v2 #leader { bottom: calc(60px + var(--sab)); border-radius: 18px 18px 0 0; }
@media (min-width: 960px) { html.v2 #leader { bottom: 0; left: 88px; } }
html.v2 main input[type="search"], html.v2 main input[type="text"], html.v2 main input:not([type]), html.v2 main textarea {
  border: 1px solid var(--line); background: var(--paper); border-radius: 12px; min-height: 44px; padding: .55rem .9rem; font-size: 1rem; color: var(--ink); width: 100%; max-width: 32rem; outline-color: var(--accent);
}
html.v2 .reading .verse > p { display: inline; margin: 0; font: inherit; }
