/* Rogers app. Each screen is a sheet of ruled white paper: a red double margin line holds outline numerals
   and page numbers, blue rules separate entries, his words are set in serif ink. No AI text outside the Ask tab
   (JD, 2026-10-18). Approved look: docs/mockups/index.html (JD: white paper, not yellow). */
:root {
  --desk: #e4e6ec;
  --paper: #fbfaf6;
  --paper-hi: #f1efe8;      /* fields, notes */
  --ink: #1b2042;           /* ballpoint ink */
  --ink-2: #474c6b;
  --rule: #cdd8ec;          /* paper rules */
  --rule-strong: #7d92bf;
  --margin: #c2352b;        /* margin line, numerals */
  --card: #ffffff;          /* index card */
  --card-rule: #c9d6ec;
  --link: #3552b0;
  --mark: rgba(194, 53, 43, 0.16);
  --select: rgba(53, 82, 176, 0.2);
  --shadow: rgba(27, 32, 66, 0.2);
  --f-ui: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --f-his: "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif;
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  --mx: 44px;               /* margin line x */
  --cx: 62px;               /* content starts */
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #0a0c14; --paper: #121624; --paper-hi: #1c2133; --ink: #ece8dc; --ink-2: #b2b4c4;
    --rule: #262e48; --rule-strong: #5f6c9c; --margin: #e4685c;
    --card: #20263b; --card-rule: #323d5c; --link: #9cb0ee;
    --mark: rgba(228, 104, 92, 0.3); --select: rgba(156, 176, 238, 0.3); --shadow: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --desk: #0a0c14; --paper: #121624; --paper-hi: #1c2133; --ink: #ece8dc; --ink-2: #b2b4c4;
  --rule: #262e48; --rule-strong: #5f6c9c; --margin: #e4685c;
  --card: #20263b; --card-rule: #323d5c; --link: #9cb0ee;
  --mark: rgba(228, 104, 92, 0.3); --select: rgba(156, 176, 238, 0.3); --shadow: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--paper); scrollbar-color: var(--rule-strong) transparent; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--f-ui);
  -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
::selection { background: var(--select); }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea { caret-color: var(--margin); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 18px; height: 18px; stroke-width: 1.9; }
.ic.xs { width: 13px; height: 13px; stroke-width: 2; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- the sheet ---------- */
.app { position: relative; min-height: 100vh; outline: none;
  padding: calc(18px + env(safe-area-inset-top, 0px)) var(--gut-r) calc(var(--tabs-h) + 36px + env(safe-area-inset-bottom, 0px))
    calc(var(--cx) + env(safe-area-inset-left, 0px)); }
.app::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--mx) + env(safe-area-inset-left, 0px)); width: 4px;
  border-left: 1px solid var(--margin); border-right: 1px solid var(--margin); opacity: 0.7; pointer-events: none; }
.app > * + * { margin-top: 18px; }
.app.bare { padding-bottom: 40px; }
@media (min-width: 720px) {
  html, body { background: var(--desk); }
  .app { max-width: 640px; margin: 24px auto 0; background: var(--paper); border-radius: 14px 14px 0 0;
    box-shadow: 0 1px 2px var(--shadow), 0 30px 60px -30px var(--shadow); }
}

/* things that live in the margin */
.in-margin { position: absolute; left: calc(-1 * var(--cx) + 4px); width: 34px; text-align: right; color: var(--margin); }
.num { font: 600 19px/1.15 var(--f-his); top: 1px; }
.back { position: absolute; left: calc(-1 * var(--cx) + 1px); top: -8px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: none; color: var(--margin); border-radius: 10px; cursor: pointer; }
.back:hover { background: var(--paper-hi); }

/* full-width paper rule above an entry, crossing the margin like a real pad */
.ruled { position: relative; }
.ruled::before { content: ""; position: absolute; top: 0; height: 1px; background: var(--rule);
  left: calc(-1 * var(--cx) - env(safe-area-inset-left, 0px)); right: calc(-1 * var(--gut-r)); }

h1.t { font: 800 30px/1.1 var(--f-ui); letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
.sec { position: relative; padding-top: 26px; }
.sec > h2 { font: 700 20px/1.2 var(--f-ui); margin: 0; letter-spacing: -0.01em; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; text-wrap: balance; }
.sec > h2 small { font: 500 14.5px var(--f-ui); color: var(--ink-2); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.sec-note { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }
.fine { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.empty { margin: 12px 0 0; font-size: 15px; color: var(--ink-2); }
.empty.flush { margin: 0; }
.empty + .btn { margin-top: 12px; }
.sec-note.divider { margin: 0; padding-top: 14px; }
.cite.head { font-size: 14px; margin-top: 8px; }
.meta.head { font-size: 14.5px; }
.num.at-entry { top: 15px; }
/* a search hit that is not a byte-exact slice: said plainly, in ink */
.approx { display: inline-block; margin: 0 0 6px; padding: 1px 8px; border: 1px solid var(--rule-strong); border-radius: 4px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

.list { margin-top: 8px; }
.entry { padding-block: 14px; }
.his { font-family: var(--f-his); font-size: 17px; line-height: 1.5; margin: 0; hanging-punctuation: first; overflow-wrap: break-word; }
.his.q { font-size: 19px; line-height: 1.42; }
.his.pre { white-space: pre-line; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.cite { margin: 6px 0 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cite b { font-weight: 600; color: var(--ink); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; margin-top: 2px; font-size: 13.5px; color: var(--ink-2); }
.meta a, .linkish { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.meta a, .meta .ref { display: inline-flex; align-items: center; min-height: 44px; }
.meta a:hover, .linkish:hover { text-decoration-color: var(--ink); }
/* inline links in a citation keep the line height; an invisible pad makes the tap area 44px tall */
.cite a.linkish { position: relative; white-space: nowrap; }
.cite a.linkish::after { content: ""; position: absolute; inset: -12px -8px; }
.match { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.match::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--margin); flex: none; }
.match.on::before { background: var(--margin); }
.kind { font-weight: 500; }
.save { margin-left: auto; width: 44px; height: 44px; margin-block: -6px; margin-right: -10px; display: grid; place-items: center;
  border: 0; background: none; color: var(--ink-2); border-radius: 10px; cursor: pointer; }
.save:hover { background: var(--paper-hi); color: var(--ink); }
.save[aria-pressed="true"] { color: var(--margin); }
.save[aria-pressed="true"] .ic { fill: currentColor; }
.save:disabled { opacity: 0.5; cursor: progress; }

.sermon-row { display: block; text-decoration: none; padding-block: 12px; min-height: 44px; }
.sermon-row b { display: block; font: 600 17px/1.3 var(--f-ui); }
.sermon-row span { display: block; margin-top: 3px; font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sermon-row:hover b { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.more { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 2px; padding: 0; border: 0; background: none;
  font-weight: 600; font-size: 14.5px; color: var(--ink); cursor: pointer; text-align: left;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.more:hover { text-decoration-color: var(--ink); }
.more:disabled { color: var(--ink-2); cursor: progress; }

details > summary .ic.turn { transition: transform 160ms ease-out; }
details[open] > summary .ic.turn { transform: rotate(180deg); }

/* scripture refs inside his words */
.ref { color: inherit; cursor: pointer; text-decoration: underline dotted var(--link); text-decoration-thickness: 2px; text-underline-offset: 4px; }
button.ref { font: inherit; background: none; border: 0; padding: 0; }
.ref:hover, .ref[aria-expanded="true"] { text-decoration-style: solid; }
::highlight(jump), ::highlight(hit) { background-color: var(--mark); }
.passage > p { display: inline; margin: 0; }
mark.jump { background: var(--mark); color: inherit; }
.pop-host { position: relative; }

/* verse card: a 3x5 index card */
.vcard { position: absolute; left: -6px; right: -6px; z-index: 5; background: var(--card); color: var(--ink); border-radius: 6px;
  box-shadow: 0 1px 2px var(--shadow), 0 14px 30px -10px var(--shadow); font-family: var(--f-ui);
  animation: card-in 170ms cubic-bezier(.2, .8, .2, 1); }
.vcard::before { content: ""; position: absolute; top: -7px; left: calc(var(--nx, 40px) - 7px); width: 14px; height: 14px; background: var(--card);
  transform: rotate(45deg); border-radius: 2px 0 0 0; }
.vcard header { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; padding: 12px 50px 8px 14px; border-bottom: 2px solid var(--margin); }
.vcard header b { font: 700 16px var(--f-ui); }
.vcard header .tr { font: 600 13px var(--f-ui); color: var(--ink-2); }
.vcard .x { position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 8px; color: var(--ink-2); cursor: pointer; }
.vcard .x:hover { color: var(--ink); background: var(--paper-hi); }
.vcard .vt { margin: 0; padding: 2px 14px 0; font: 400 17px/28px var(--f-his); white-space: pre-line;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, var(--card-rule) 27px 28px); }
.vcard .vt.msg { font: 400 15px/28px var(--f-ui); color: var(--ink-2); }
.vcard footer { padding: 10px 14px 10px; display: grid; gap: 2px; }
.vcard .copy { font-size: 11.5px; line-height: 1.4; color: var(--ink-2); margin-bottom: 4px; }
.vcard .links { display: flex; flex-wrap: wrap; gap: 0 18px; }
.vcard .full { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; font-size: 14.5px; color: var(--link); text-decoration: none; }
.vcard .full:hover { text-decoration: underline; text-underline-offset: 3px; }
@keyframes card-in { from { opacity: 0; transform: translateY(-6px); } }

/* fields and controls */
.searchrow { display: flex; gap: 8px; }
.field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 12px; background: var(--paper-hi);
  border: 1px solid var(--rule-strong); border-radius: 10px; color: var(--ink-2); }
.field:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 16px; color: var(--ink); }
.field input::placeholder { color: var(--ink-2); opacity: 1; }
.field input::-webkit-search-cancel-button { display: none; }
.btn { height: 46px; padding: 0 14px; border-radius: 10px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; border: 1px solid var(--rule-strong); background: var(--paper-hi); color: var(--ink); text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.small { height: 44px; font-size: 14px; }
.seg { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--paper-hi); }
.seg a, .seg button { flex: 1 1 auto; min-width: 0; min-height: 44px; display: grid; place-items: center; white-space: nowrap; border: 0; background: none;
  padding: 0 6px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); text-decoration: none; cursor: pointer; }
.seg [aria-current="true"] { background: var(--ink); color: var(--paper); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { position: relative; display: inline-flex; align-items: center; gap: 5px; height: 44px; padding: 0 10px 0 12px; border-radius: 999px;
  border: 1px solid var(--rule-strong); font-size: 14px; font-weight: 500; color: var(--ink); max-width: 100%; }
.filter:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
.filter select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.filter span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter.set { border-color: var(--ink); background: var(--paper-hi); font-weight: 600; }
.filter:hover { background: var(--paper-hi); }

/* verse title: the hymn-board moment */
.vtitle { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; margin: 0; }
.vtitle .bk { font: 700 26px/1 var(--f-ui); letter-spacing: -0.01em; }
.vtitle .cv { font: 800 88px/0.92 var(--f-ui); letter-spacing: -0.04em; font-variant-numeric: lining-nums; overflow-wrap: anywhere; }
.vtitle .cv.long { font-size: 56px; }
.under-title { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: 14px; }
.under-title > * { min-height: 44px; display: inline-flex; align-items: center; }

/* book and chapter pickers */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; margin-top: 12px; }
.grid a { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--rule); border-radius: 8px; text-decoration: none;
  font-weight: 600; font-variant-numeric: tabular-nums; }
.grid a:hover { border-color: var(--rule-strong); background: var(--paper-hi); }
.grid a small { display: block; font-size: 10.5px; font-weight: 500; color: var(--ink-2); line-height: 1; margin-top: -8px; }
.books { list-style: none; margin: 8px 0 0; padding: 0; columns: 2; column-gap: 18px; }
.books li { break-inside: avoid; }
.books a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-height: 44px; padding: 10px 0; text-decoration: none; font-weight: 600; }
.books a span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.books a.none { color: var(--ink-2); font-weight: 500; }
.books a:hover { text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
.books-h { font: 700 13px/1 var(--f-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); margin: 18px 0 0; }

/* groups of the same line across sermons */
.group { margin-top: 6px; }
.group > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; font-size: 13.5px; color: var(--ink); }
.group > summary::-webkit-details-marker { display: none; }
.group ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 1px solid var(--rule-strong); display: grid; gap: 14px; }
.group li .his { font-size: 16px; }
.group li .cite { margin-top: 3px; }
.kindsec > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 48px; font: 700 18px/1.2 var(--f-ui); }
.kindsec > summary::-webkit-details-marker { display: none; }
.kindsec > summary small { font: 500 14px var(--f-ui); color: var(--ink-2); }

/* notes: JD's own words, on a slightly darker slip */
.note { margin-top: 12px; padding: 10px 12px 12px; background: var(--paper-hi); border-radius: 8px; }
.note-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.note p { margin: 4px 0 0; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: break-word; }
.note textarea { display: block; width: 100%; margin-top: 6px; min-height: 88px; resize: vertical; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.4; }
.note textarea:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.note .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.note .edit { border: 0; background: none; padding: 0 6px; min-height: 44px; margin: -12px -6px -12px auto; font-size: 13px; font-weight: 600; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; cursor: pointer; }
.err { color: var(--margin); font-size: 14px; font-weight: 500; margin: 8px 0 0; }

/* transcript */
/* Every <p> in rendered_html is a PDF page break, not a paragraph: the text runs on, and each page's hidden
   marker span shows its number in the margin at the line where the page starts. textContent is untouched. */
.transcript { margin-top: 12px; font: 400 18px/1.62 var(--f-his); overflow-wrap: break-word; }
.transcript > p { display: inline; margin: 0; }
.transcript .page[hidden] { display: inline !important; font-size: 0; -webkit-user-select: none; user-select: none; } /* aria-hidden too: never read aloud or copied */
.transcript .page::before { content: "p. " attr(data-page); position: absolute; left: calc(-1 * var(--cx) + 1px); width: 40px; margin-top: 0.45em;
  text-align: right; font: 600 12px/1.2 var(--f-ui); color: var(--margin); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* login */
.login { max-width: 420px; padding-top: 12vh; }
.login h1 { font: 800 44px/1 var(--f-ui); letter-spacing: -0.03em; margin: 0; }
.login .lede { font: 400 19px/1.45 var(--f-his); margin: 10px 0 0; color: var(--ink-2); }
.login form { margin-top: 28px; display: grid; gap: 12px; }
.login label.lbl { font-weight: 600; font-size: 14px; }

/* loading: ruled skeleton lines */
.skel { display: grid; gap: 14px; margin-top: 18px; }
.skel i { display: block; height: 14px; border-radius: 4px; background: var(--paper-hi); animation: pulse 1.2s ease-in-out infinite alternate; }
.skel i:nth-child(2n) { width: 78%; }
.skel i:nth-child(3n) { width: 56%; }
@keyframes pulse { to { opacity: 0.45; } }

/* bottom tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper);
  border-top: 1px solid var(--rule-strong);
  padding: 4px max(6px, env(safe-area-inset-right, 0px), calc((100vw - 640px) / 2)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px), calc((100vw - 640px) / 2)); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; text-decoration: none;
  color: var(--ink-2); font-size: 11.5px; font-weight: 600; border-radius: 8px; }
.tabs a span { padding-bottom: 2px; border-bottom: 2px solid transparent; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] span { border-bottom-color: var(--margin); }
.tabs a:hover { color: var(--ink); }

/* "A new version is ready": a slip above the tab bar, never over the text for long; Reload or close it */
.update { position: fixed; z-index: 11; left: max(12px, env(safe-area-inset-left, 0px), calc((100vw - 616px) / 2)); right: max(12px, env(safe-area-inset-right, 0px), calc((100vw - 616px) / 2));
  bottom: calc(var(--tabs-h) + 10px + env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 4px;
  padding: 0 0 0 14px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 14.5px; font-weight: 500;
  box-shadow: 0 1px 2px var(--shadow), 0 10px 24px -8px var(--shadow); animation: card-in 170ms cubic-bezier(.2, .8, .2, 1); }
.update span { flex: 1; min-width: 0; }
.update button { min-height: 44px; border: 0; background: none; color: inherit; cursor: pointer; border-radius: 8px; }
.update .go { padding: 0 10px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.update .x { width: 44px; display: grid; place-items: center; }
.update :focus-visible { outline-color: var(--paper); outline-offset: -4px; }

.theme-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.theme-row .seg { flex: 1; max-width: 260px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
