/* Phone portrait first; wider screens get more room (responsive-layout skill).
   Theme: CSS custom properties. No data-theme => follow the OS; theme.js sets data-theme once the user picks.
   The top bar block is copied from J:\claude\web\home\recipe\public\styles.css. */
:root {
  color-scheme: light;

  --page:           #faf7f2;
  --surface-1:      #ffffff;
  --surface-2:      #f1ebe2;
  --text-primary:   #221d18;
  --text-secondary: #57504a;
  --muted:          #857b70;
  --border:         rgba(34, 29, 24, 0.12);
  --accent:         #8a2f2a;
  --accent-text:    #ffffff;

  --radius:    12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --reading-font: Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #15120f;
    --surface-1:      #1e1a16;
    --surface-2:      #2a2520;
    --text-primary:   #f3eee8;
    --text-secondary: #c8bdb1;
    --muted:          #958a7c;
    --border:         rgba(243, 238, 232, 0.12);
    --accent:         #e39a8c;
    --accent-text:    #1c0f0d;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #15120f;
  --surface-1:      #1e1a16;
  --surface-2:      #2a2520;
  --text-primary:   #f3eee8;
  --text-secondary: #c8bdb1;
  --muted:          #958a7c;
  --border:         rgba(243, 238, 232, 0.12);
  --accent:         #e39a8c;
  --accent-text:    #1c0f0d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.5;
}

a { color: var(--accent); }

/* --------------------------------- top bar --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  /* viewport-fit=cover: keep clear of a notch in landscape and the status bar. */
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { margin: 0; font-size: 1.15rem; }
.brand { text-decoration: none; color: var(--text-primary); }

.nav-links { display: flex; gap: 6px; }

.menu { position: relative; }

/* Inline SVG rather than emoji so all icons share one stroke weight and take their colour from the theme. */
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.menu-toggle:hover { background: var(--surface-2); color: var(--accent); }
.menu-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu-toggle[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--accent);
}

/* Each panel sets its own `display`, which would otherwise beat the browser's [hidden]{display:none} at equal
   specificity, hence the explicit override (css-display-override-traps). */
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}
.menu-panel[hidden] { display: none; }
.menu-panel a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text-secondary);
}
.menu-panel a:hover { background: var(--surface-2); color: var(--accent); }
.menu-panel a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Controls that can only work for the owner. Fails closed: an unknown role hides them. <html data-role> starts as
   "guest" in index.html, so nothing flashes up. The server refuses regardless; this only stops the page offering it. */
html:not([data-role='owner']) .needs-owner { display: none !important; }

/* Sign in / the account avatar, pushed to the far end of the top bar. */
.auth-control { margin-left: auto; display: flex; align-items: center; font-size: 0.9rem; }
.auth-control:empty { display: none; }

/* Light/dark switch (theme.js). It takes over pushing to the far end, so the avatar after it sits beside it. Looks
   like a .menu-toggle, but isn't one: app.js's menu listener must not see it. */
.theme-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle + .auth-control { margin-left: 0; }
.auth-btn {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}
.auth-btn:hover { border-color: var(--accent); color: var(--accent); }

.menu-toggle.avatar-btn { padding: 0; border: none; border-radius: 50%; }
.menu-toggle.avatar-btn:hover,
.menu-toggle.avatar-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--surface-2); }

.avatar-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  line-height: 1;
}
.avatar-circle.large { width: 42px; height: 42px; font-size: 1.15rem; }

/* Anchored to the right: the avatar sits at the top bar's far end. */
.menu-panel.user-menu { left: auto; right: 0; width: max-content; max-width: min(20rem, calc(100vw - 32px)); }
.user-menu-who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-menu-id { min-width: 0; }
.user-menu-email { font-weight: 600; overflow-wrap: anywhere; }
.user-menu-role { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.menu-panel .user-menu-item,
.user-menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--surface-2); color: var(--accent); }

/* ---------------------------------- pages ---------------------------------- */

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}
main h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.4rem 0 0.6rem; }
.muted, .loading { color: var(--muted); }
.lede { font-size: 1.05rem; color: var(--text-secondary); }
[aria-busy="true"] { opacity: 0.6; }

.placeholder {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-secondary);
}
.private-note { font-size: 0.9rem; color: var(--muted); }

/* The home page's section list: one column on a phone, two from tablet width. */
.sections { display: grid; gap: 10px; margin: 1rem 0; padding: 0; list-style: none; }
.sections a {
  display: block;
  height: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  text-decoration: none;
}
.sections a:hover { border-color: var(--accent); }
.sections strong { display: block; color: var(--accent); }
.sections span { font-size: 0.9rem; color: var(--text-secondary); }

.search-form { display: flex; gap: 8px; margin: 0.5rem 0 1rem; }
.search-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-size: 16px; /* iOS Safari zooms into any focused field under 16px */
}
.btn {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }

/* -------------------------------- Bible reader -------------------------------- */

main h2 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; color: var(--text-secondary); }
.crumbs { font-size: 0.9rem; color: var(--muted); }
.crumbs a { text-decoration: none; }

/* Book picker: wrapping columns of names; chapter picker: a grid of thumb-sized squares. */
.book-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; margin: 0; padding: 0; list-style: none; }
.book-list a { display: block; padding: 8px 4px; text-decoration: none; }
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr));
  gap: 8px;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}
.chapter-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.chapter-grid a:hover { border-color: var(--accent); }

/* Book summary: a "Summary" link beside the chapter count; the open summary sits above the chapter grid. */
.book-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.book-summary { margin: 0.5rem 0 1.5rem; }
.book-summary .paper-body h3 { font-size: 1rem; margin: 1.2rem 0 0.4rem; color: var(--text-secondary); }

/* Reading text: serif, a size that needs no zoom on a phone, generous leading, one verse per line. */
.chapter-text {
  font-family: var(--reading-font);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-primary);
  hyphens: auto;
  overflow-wrap: break-word;
}
.verse {
  margin: 0;
  padding: 0.15rem 0.35rem;
  margin-inline: -0.35rem;
  border-radius: 4px;
  scroll-margin-top: calc(var(--stuck-h, 4.5rem) + 1rem); /* clear the top bar and page head (app.js measures them) on #v16 */
}
.verse + .verse { margin-top: 0.35rem; }
.verse.is-target { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.vnum {
  font-family: var(--font);
  font-size: 0.68em;
  font-weight: 600;
  vertical-align: 0.45em;
  line-height: 0;
  color: var(--muted);
  text-decoration: none;
  /* a bigger tap target than the digits themselves */
  padding: 0.6em 0.15em;
}
.vnum:hover { color: var(--accent); }
.pilcrow { color: var(--muted); }
.psalm-title, .subscription { font-style: italic; color: var(--text-secondary); font-size: 0.95em; }
.psalm-title i, .subscription i { font-style: normal; }
.subscription { margin-top: 1.2rem; }

/* The reader pages' head (crumbs, Listen, title, prev/next; on /bible, title and search) stays put under the top bar while the text scrolls, so
   there is no second prev/next at the bottom. app.js measures --topbar-h. flow-root holds the floated Listen button. */
.page-head {
  position: sticky;
  top: var(--topbar-h, 0px);
  z-index: 4;
  display: flow-root;
  margin: 0 -16px 0.75rem;
  padding: 0 16px 0.5rem;
  background: var(--page);
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin: 0.2rem 0 0.3rem; }
.page-head > p.muted { margin: 0 0 0.4rem; }
.page-head .search-form { margin: 0; }
.page-head .filters { margin: 0.5rem 0 0; } /* reference: category chips */
.page-head .search-form ~ p { margin: 0.5rem 0 0; } /* search: "Go to" and the verse count under the box */
.page-head .book-meta { margin: 0 0 0.3rem; }
.page-head .paper-meta { margin: 0 0 0.3rem; } /* paper / reference entry: badges and dates */
.chapter-nav { display: flex; justify-content: space-between; gap: 12px; margin: 0.4rem 0 0; }
.chapter-nav a {
  padding: 4px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  text-decoration: none;
  white-space: nowrap;
}
.chapter-nav a:hover { border-color: var(--accent); }

/* Search hits */
.go-to { font-weight: 600; }
.hits { margin: 0.5rem 0 1rem; padding: 0; list-style: none; }
.hit { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.hit > a { font-weight: 600; text-decoration: none; }
.hit p { margin: 0.2rem 0 0; font-family: var(--reading-font); font-size: 1.05rem; line-height: 1.6; }
mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.more { display: block; margin: 0 auto 1rem; }

@media (min-width: 640px) {
  .book-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chapter-text { font-size: 1.2rem; line-height: 1.75; }
}

@media print {
  .chapter-nav, .crumbs { display: none; }
}

@media (min-width: 640px) {
  .topbar { gap: 12px 20px; padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 14px; }
  .topbar h1 { font-size: 1.25rem; }
  main { padding-top: 24px; }
  main h1 { font-size: 1.75rem; }
  .sections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Landscape phone: wide but short, so keep the bar compact (responsive-layout trap 1). */
@media (orientation: landscape) and (max-height: 500px) {
  .topbar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .topbar h1 { font-size: 1.1rem; }
  .page-head { position: static; } /* too little height to give the head a permanent slice of it */
}

@media print {
  .topbar { display: none; }
  .page-head { position: static; border: 0; }
}

/* ------------------------------ research papers ------------------------------ */

.filters { display: grid; gap: 6px; margin: 0.75rem 0 1rem; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.filter-row > .muted { min-width: 3.2rem; font-size: 0.85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.4rem 0; }
.chip {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge.status-active { color: var(--accent); }
.badge.public { color: var(--accent); }

.paper-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.paper-card { padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.paper-card h2 { margin: 0 0 0.3rem; font-size: 1.1rem; color: inherit; }
.paper-card h2 a { text-decoration: none; }
.paper-card p { margin: 0.3rem 0; }
.paper-meta { font-size: 0.85rem; }

.paper .lede { margin: 0.6rem 0; }
.key-passages { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.key-passages .muted { font-size: 0.85rem; }
.paper-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0.8rem 0 0.4rem; }
a.btn { display: inline-block; text-decoration: none; }

/* Paper prose: the same serif as the reader, slightly smaller since it is study text, not scripture. */
.paper-body, .note-body, .source-note { overflow-wrap: break-word; }
.paper-body { font-family: var(--reading-font); font-size: 1.08rem; line-height: 1.65; }
.paper-body h2, .paper-body h3 { font-family: var(--font); }
/* Sections (h2) must outrank their subsections (h3): a ruled, full-colour heading over a smaller one. */
.paper-body section > h2 {
  font-size: 1.5rem; font-weight: 700; line-height: 1.25; color: var(--accent);
  margin: 2.4rem 0 0.8rem; padding-bottom: 0.35rem; border-bottom: 2px solid var(--accent);
}
.paper-body section:first-child > h2 { margin-top: 1.2rem; }
.paper .paper-body h3 {
  font-size: 1.15rem; font-weight: 700; line-height: 1.3; color: var(--text-primary);
  margin: 1.8rem 0 0.5rem; padding-left: 0.6rem; border-left: 4px solid var(--accent);
}
.paper-body ul, .paper-body ol, .note-body ul, .note-body ol { padding-left: 1.3rem; }
.paper-body li + li { margin-top: 0.3rem; }
.paper-body blockquote, .note-body blockquote { margin: 0.6rem 0; padding: 0.1rem 0 0.1rem 0.9rem; border-left: 3px solid var(--border); color: var(--text-secondary); }
.paper section, .paper-body h3[id], .sources li { scroll-margin-top: calc(var(--stuck-h, 4.5rem) + 1rem); }

/* Paper contents: numbered sections, subsections indented under them. */
.toc { margin: 1rem 0; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.toc h2 { margin: 0 0 0.3rem; font-size: 1rem; }
.toc ol { margin: 0; padding-left: 1.3rem; }
.toc ol ol { list-style: none; padding-left: 0.9rem; font-size: 0.92rem; }
.toc li { margin: 0.15rem 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }
code { font-size: 0.9em; padding: 0 3px; border-radius: 3px; background: var(--surface-2); }

.claim-tag {
  display: inline-block;
  margin-right: 2px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: 0.12em;
}
.claim-scriptural { color: var(--accent); }
.claim-disputed, .claim-speculative { font-style: italic; }

a.ref { text-decoration: underline dotted; text-underline-offset: 2px; white-space: nowrap; }
a.ref[aria-expanded="true"] { text-decoration-style: solid; }
a.cite { font-family: var(--font); font-size: 0.8em; text-decoration: none; vertical-align: 0.1em; }

.sources { margin: 0; padding: 0; list-style: none; }
.sources li { display: flex; gap: 10px; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border); border-radius: 4px; }
.sources li.is-target { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.sid { flex: none; min-width: 2rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.source-kind { font-size: 0.8rem; color: var(--muted); }
.source-note { font-size: 0.92rem; color: var(--text-secondary); }

.session-note { margin: 0.5rem 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); }
.session-note > summary { padding: 0.6rem 0.8rem; cursor: pointer; font-weight: 600; }
.session-note > summary time { margin-right: 6px; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.note-body { padding: 0 0.9rem 0.6rem; }
.kjv-note { margin-top: 2rem; font-size: 0.85rem; }

/* Verse popover (public/ref-popover.js). It sets its own display, so [hidden] needs restating
   (css-display-override-traps). Positioned by script through el.style, which the CSP allows. */
.ref-pop {
  position: absolute;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: min(24rem, calc(100vw - 16px));
  max-height: min(22rem, 60svh);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.ref-pop[hidden] { display: none; }
.ref-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 12px; border-bottom: 1px solid var(--border); }
.ref-pop-close { min-width: 36px; min-height: 36px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; }
.ref-pop-close:hover { background: var(--surface-2); color: var(--accent); }
.ref-pop-body { overflow-y: auto; padding: 6px 12px; font-family: var(--reading-font); font-size: 1.02rem; line-height: 1.55; overscroll-behavior: contain; }
.ref-pop-verse { margin: 0.25rem 0; }
.ref-pop-sub { margin: 0.5rem 0 0.1rem; font-family: var(--font); font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.ref-pop-go { padding: 8px 12px; border-top: 1px solid var(--border); text-decoration: none; font-size: 0.9rem; }

/* Print / Save as PDF: the paper only, black on white, with source URLs spelled out. */
@media print {
  .crumbs, .filters, .paper-actions, .ref-pop, .session-note > summary::marker { display: none; }
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --page: #fff; --surface-1: #fff; --surface-2: #eee; --text-primary: #000; --text-secondary: #222; --muted: #444;
    --border: #bbb; --accent: #000; --accent-text: #fff;
  }
  body { font-size: 11pt; }
  main { max-width: none; padding: 0; }
  a, a.ref { text-decoration: none; }
  .sources a::after { content: " (" attr(href) ")"; font-size: 0.85em; word-break: break-all; }
  .paper-body li, .sources li { break-inside: avoid-page; }
  .session-note { border: 0; }
  .session-note > summary { padding-left: 0; list-style: none; }
  .note-body { padding: 0; }
}

/* --------------------------- highlights and notes (owner) --------------------------- */

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Translucent, so the same four read on the light and the dark page. */
.hl-yellow { --hl: rgba(245, 197, 24, 0.34); --hl-solid: #e8b80c; }
.hl-green  { --hl: rgba(74, 200, 110, 0.28); --hl-solid: #3fae62; }
.hl-blue   { --hl: rgba(80, 150, 240, 0.28); --hl-solid: #4a8de0; }
.hl-pink   { --hl: rgba(236, 100, 170, 0.28); --hl-solid: #d9579b; }
.verse[class*="hl-"], .annot-text[class*="hl-"] { background: var(--hl); }
.verse.is-target[class*="hl-"] { box-shadow: inset 3px 0 0 var(--accent); }

.chapter-text[data-annotate] .verse { cursor: pointer; }
.chapter-text[data-annotate] .verse:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.verse.selected { outline: 2px dashed var(--accent); outline-offset: -1px; }

.note-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; min-height: 28px; padding: 0 4px; margin-left: 2px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--accent);
  vertical-align: middle; cursor: pointer;
}
.note-mark .icon { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.note-mark:hover { background: var(--surface-2); }

/* The selection bar: pinned to the bottom of the screen, clear of the home indicator. */
.select-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px;
  padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.12);
}
.select-bar[hidden] { display: none; } /* it sets display, which beats [hidden] (css-display-override-traps) */
body:has(.select-bar:not([hidden])) main { padding-bottom: 8rem; }
.select-label { flex-basis: 100%; text-align: center; font-weight: 600; font-size: 0.95rem; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 36px; height: 36px; border: 2px solid var(--border); border-radius: 50%; cursor: pointer;
  background: var(--surface-2);
}
.swatch[data-hl="yellow"] { background: #f5c518; }
.swatch[data-hl="green"]  { background: #4ac86e; }
.swatch[data-hl="blue"]   { background: #5096f0; }
.swatch[data-hl="pink"]   { background: #ec64aa; }
.swatch-none { background: linear-gradient(135deg, transparent 45%, var(--muted) 45%, var(--muted) 55%, transparent 55%), var(--surface-1); }
.swatch:hover, .swatch:focus-visible { border-color: var(--text-primary); }
.select-bar[aria-busy] .swatch { opacity: 0.5; cursor: progress; }
.select-clear {
  min-width: 40px; min-height: 40px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-secondary); font-size: 1.4rem; cursor: pointer;
}
.select-clear:hover { background: var(--surface-2); color: var(--accent); }
@media (min-width: 640px) {
  .select-label { flex-basis: auto; }
}

/* The note editor (a modal <dialog>). */
.note-dialog {
  width: min(32rem, calc(100vw - 24px));
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
}
.note-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.note-dialog h2 { margin: 0 0 10px; font-size: 1.1rem; }
.note-dialog textarea {
  width: 100%; min-height: 9rem; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--page); color: var(--text-primary);
  font: 16px/1.5 var(--reading-font); resize: vertical;
}
.note-error { min-height: 1.2em; margin: 6px 0; color: var(--accent); font-size: 0.9rem; }
.note-actions { display: flex; gap: 8px; justify-content: flex-end; }
.note-actions .danger { margin-right: auto; color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* /notes */
.annot-list { margin: 0; padding: 0; list-style: none; }
.annot-item { padding: 0.8rem 0; border-bottom: 1px solid var(--border); }
.annot-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 0.35rem; }
.annot-head a { font-weight: 600; }
.annot-head time { margin-left: auto; font-size: 0.85rem; }
.hl-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--hl-solid); }
.annot-text {
  margin: 0; padding: 0.35rem 0.6rem; border-radius: 4px;
  font-family: var(--reading-font); font-size: 1.05rem; line-height: 1.6;
}
.annot-text sup { font-family: var(--font); font-size: 0.65em; color: var(--muted); margin-right: 2px; }
.annot-note { margin-top: 0.5rem; padding-left: 0.75rem; border-left: 3px solid var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; }

@media print {
  .select-bar, .note-mark { display: none; }
}

/* -------------------------------- Reading plans -------------------------------- */
.plan-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0.8rem 0; }
.plan-bar progress { flex: 1 1 10rem; height: 10px; accent-color: var(--accent); }
.plan-progress-line { font-size: 0.9rem; color: var(--text-secondary); }
.plan-progress-line.behind { color: var(--accent); font-weight: 600; }
.plan-today, .plan-catchup {
  margin: 1rem 0; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1);
}
.plan-today h2, .plan-catchup h2 { margin: 0 0 0.4rem; color: var(--text-primary); }
.plan-today h2:focus { outline: none; }
.plan-today p { margin: 0.35rem 0; }
.plan-readings.big { font-family: var(--reading-font); font-size: 1.25rem; margin: 0.5rem 0 0.8rem; }
.plan-readings .sep { color: var(--muted); }
.plan-done { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 600; }
.plan-ahead { margin-top: 0.9rem; padding-top: 0.7rem; border-top: 1px solid var(--border); }
.plan-start { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0.5rem 0; }
.plan-start input {
  margin-left: 6px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); color: var(--text-primary); font: inherit;
}
.plan-error { flex-basis: 100%; min-height: 1.2em; margin: 0; color: var(--accent); font-size: 0.9rem; }
.plan-error:empty { min-height: 0; }
.plan-manage, .plan-all { margin: 1rem 0; }
.plan-manage summary, .plan-all summary { cursor: pointer; font-weight: 600; color: var(--text-secondary); padding: 6px 0; }
/* "All N days" sticks just under the page head while its list scrolls (--stuck-h = top bar + head, from app.js). */
.plan-all > summary {
  position: sticky; top: var(--stuck-h, 0px); z-index: 3;
  margin: 0 -16px; padding: 6px 16px; background: var(--page); border-bottom: 1px solid var(--border);
}
.page-head .lede { margin: 0 0 0.3rem; }
.page-head > p:last-child, .page-head > .plan-today:last-child { margin-bottom: 0; }
@media print { .plan-all > summary { position: static; border: 0; } }
.btn.danger { color: var(--accent); }
.plan-days { margin: 0.4rem 0 0; padding: 0; list-style: none; }
.plan-day { display: flex; align-items: flex-start; gap: 10px; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.plan-day input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.plan-day-n { font-weight: 600; }
.plan-day time { font-size: 0.85rem; }
.plan-day.is-read .plan-readings a { color: var(--muted); }
.plan-day.is-today { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ------------------------------ theology and church-history reference ------------------------------ */
/* Index by category (cards like the paper list) and a vertical timeline: a single column on a phone, with the
   date beside the entry from 640px. Dates are short ("c. 341", "680–681"), so a fixed column fits them. */

.ref-tabs { display: flex; gap: 14px; margin: 0.6rem 0 0.4rem; font-size: 0.95rem; }
.ref-tabs [aria-current] { font-weight: 600; border-bottom: 2px solid var(--accent); }
.ref-tabs a { text-decoration: none; }
.ref-list { display: grid; gap: 10px; margin: 0 0 1.2rem; padding: 0; list-style: none; }
.ref-card { padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-1); }
.ref-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.ref-card h3 a { text-decoration: none; }
.ref-card p { margin: 0.25rem 0 0; }
.when { color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crumbs .sep { margin: 0 4px; }

.tl-century h2 { margin: 1.2rem 0 0.5rem; font-size: 1rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.timeline { margin: 0; padding: 0 0 0 14px; list-style: none; border-left: 2px solid var(--border); }
.tl-item { position: relative; display: grid; gap: 2px; padding: 0 0 0.9rem 0.6rem; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 0.45em;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--page);
}
.tl-item h3 { margin: 0; font-size: 1.02rem; }
.tl-item h3 a { text-decoration: none; }
.tl-item p { margin: 0.2rem 0 0; }
@media (min-width: 640px) {
  .tl-item { grid-template-columns: 7.5rem 1fr; gap: 12px; }
  .tl-item .when { padding-top: 0.15em; }
}
@media print {
  .ref-tabs { display: none; }
}

/* -------------------------------- experiences journal -------------------------------- */
.journal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.journal-head h1 { margin-right: auto; }
.journal-card .paper-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.journal-card p { overflow-wrap: break-word; }
.journal-entry .paper-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.journal-refs { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.journal-refs .muted { font-size: 0.85rem; margin-right: 4px; }
.journal-text { font-family: var(--reading-font); font-size: 1.06rem; line-height: 1.65; overflow-wrap: break-word; }
.journal-text p { margin: 0 0 0.8rem; }
.badge.kind-vision, .badge.kind-dream { color: var(--accent); }

.journal-form { display: grid; gap: 14px; margin: 0.75rem 0 1rem; max-width: 46rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 14px; }
.field-row .field { flex: 1 1 10rem; }
.field { display: grid; gap: 4px; font-weight: 600; font-size: 0.95rem; }
.field .muted, .hint { font-weight: 400; font-size: 0.85rem; }
.hint { margin: 0; }
.field input, .field select, .field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-weight: 400;
  font-size: 16px; /* iOS Safari zooms into any focused field under 16px */
}
.field textarea { resize: vertical; min-height: 6rem; line-height: 1.5; font-family: var(--reading-font); font-size: 1.02rem; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.journal-error { margin: 0; color: var(--accent); font-weight: 600; }
.journal-form .btn:disabled { opacity: 0.6; cursor: progress; }
.leave-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 0.7rem 0.9rem; border: 1px solid var(--accent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-1));
}
.leave-bar[hidden] { display: none; } /* display:flex would otherwise beat [hidden] (css-display-override-traps) */
.leave-bar p { flex: 1 1 100%; margin: 0; font-weight: 600; }

/* --------------------------------- read aloud (speech.js) --------------------------------- */

.no-tts [data-listen] { display: none; } /* no speech engine in this browser: no button that does nothing */
/* Top right of the page: first in the page's html and floated, so the crumbs and title flow beside it. */
.btn.listen { float: right; display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px 12px; }
.btn.listen .icon { width: 18px; height: 18px; }
.icon.solid { fill: currentColor; stroke: none; }
.speaking { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 4px;
  box-shadow: inset 3px 0 0 var(--accent); scroll-margin: calc(var(--stuck-h, 4rem) + 1rem) 0 6rem; }

/* The player: pinned to the bottom like the verse selection bar, clear of the home indicator. */
.tts-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px;
  padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.12);
}
.tts-bar[hidden] { display: none; } /* display:flex beats [hidden] (css-display-override-traps) */
body:has(.tts-bar:not([hidden])) main { padding-bottom: 7rem; }
/* Selecting verses while listening: the selection bar takes the bottom, the player waits (speech carries on). */
body:has(.select-bar:not([hidden])) .tts-bar { display: none; }
.tts-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface-2); color: var(--text-primary); cursor: pointer;
}
.tts-btn:hover, .tts-btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.tts-main { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tts-main:hover, .tts-main:focus-visible { color: var(--accent-text); }
.tts-pick select {
  min-height: 40px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); color: var(--text-primary); font: inherit; font-size: 16px;
}
.tts-voice select { max-width: 11rem; text-overflow: ellipsis; }
.tts-rate { display: inline-flex; align-items: center; gap: 8px; }
.tts-rate input { width: 9rem; min-height: 40px; accent-color: var(--accent); }
.tts-rate-value { min-width: 3.2em; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
@media print { .tts-bar, [data-listen] { display: none !important; } .speaking { background: none; box-shadow: none; } }
