/*
  styles.css -- visual design for the Bible Study Assistant chat.
  Self-contained: no CDN, no build step. The title font is self-hosted (see
  the @font-face rule below) so nothing is ever fetched off this machine.
  Works at desktop and phone widths (see the media query near the bottom).
  Punctuation policy: plain ASCII only. Straight quotes throughout.
*/

/* Title font, self-hosted: Uncial Antiqua (an uncial-script revival, the
   majuscule hand used in New Testament manuscripts from roughly the 4th to
   8th centuries), by Brian J. Bonislawsky / Astigmatic, SIL Open Font
   License 1.1. Font file and full license text live alongside this file at
   fonts/UncialAntiqua-Regular.ttf and fonts/OFL.txt. No CDN, no external
   request; if this file ever fails to load, the fallback stack below (the
   system Papyrus font, then serif) keeps the title readable. */
@font-face {
  font-family: "Uncial Antiqua";
  src: url("fonts/UncialAntiqua-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3efe6;
  --panel: #ffffff;
  --ink: #2a241c;
  --muted: #746b5c;
  --accent: #8a5a2b;
  --accent-dark: #6e4720;
  --accent-soft: #f0e2c8;
  --scripture-bg: #fbf6ea;
  --scripture-border: #ddc99a;
  --warn: #8a5a00;
  --error: #a4302f;
  /* Red Letters indicator (T023): a restrained, slightly muted red used for the
     small words-of-Jesus badge and the citation accent edge. */
  --wj-accent: #b03a34;
  /* Words of Jesus, inline (T053): the red used for the recorded words of Jesus
     rendered bold inside verse text, in the reader AND the chat cited-verse
     blocks. A dedicated, theme-swappable custom property so the color is driven
     from one place: it reads clearly and boldly on the app's warm light surfaces,
     and a future dark theme sets --wj-text to a brighter red alongside its own
     palette so the red-letter styling follows automatically (works in light and
     dark). Deep enough for strong contrast, not a shouting fire-engine red. */
  --wj-text: #b3241c;
  /* Historical-context block (T014): a deliberately COOL slate/blue palette, so
     it reads as clearly different from the warm gold scripture quote blocks --
     background beyond the Bible, never mistaken for scripture. */
  --history-bg: #eef1f5;
  --history-border: #b9c4d4;
  --history-accent: #3f5a7a;
  --history-accent-dark: #2c435f;
  --history-ink: #26374b;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.06), 0 4px 14px rgba(40, 30, 10, 0.08);
  --radius: 14px;
  /* Persistent reader header bar height (T024). The body is padded down by this
     so both the reader and the chat clear the fixed bar. */
  --app-bar-height: 54px;
  /* Shared reading text size (T038): one multiplier drives the e-reader verse
     text AND the chat conversation (bubbles, cited verse quotes, the input
     row), set from static/textsize.js via the A-/A+ header control and
     restored from localStorage. 1 is the default (today's sizing, unchanged
     for anyone who never touches the control). Any future panel (the
     journal) that wants to match the reading size just multiplies its own
     font-size by this same variable. */
  --text-scale: 1;
  /* Chapter-picker read-status colors (T074): COMPLETE cells fill with the
     app's established "read" green (the same #4c6a2c the book-progress done
     state uses) under white numerals; PARTIALLY READ cells are that same green
     faded to a light tint under deep-green numerals. Both pairings hold WCAG
     AA contrast on this light palette (machine-checked in
     tests/test_chapterpicker.py). The app ships this single warm palette
     today; a future dark theme restyles the cells by overriding these
     variables alongside its own colors, the same convention every other
     themed control here follows. */
  --chapter-done-bg: #4c6a2c;
  --chapter-done-ink: #ffffff;
  --chapter-partial-bg: #dfe9cd;
  --chapter-partial-ink: #3c5522;
  --chapter-partial-border: #b9cc96;
  /* Responsive e-reader measure (T066): the reader column grows to fill
     whatever space is free between the journal and chat panels (and the full
     window when both are hidden), capped only by this readability ceiling.
     The ceiling scales with the A-/A+ text size so larger text always gets a
     proportionally longer line instead of squeezing fewer words onto the same
     fixed-width column: 60rem at 100% text size is roughly a 110-character
     measure, and every other step keeps that same character count. */
  --reader-max-width: calc(60rem * var(--text-scale));
}

* { box-sizing: border-box; }

/* Make the hidden attribute authoritative. Several reader containers set an
   explicit display (flex), which would otherwise beat the UA [hidden] rule and
   leave a hidden view (or the chat's fixed input bar) still on screen (T024). */
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  /* The reader and chat are co-resident and scroll internally (T025), so the
     window itself does not scroll: it is exactly the viewport, minus the fixed
     app bar (reserved by the padding-top). */
  height: 100vh;
  overflow: hidden;
  padding-top: var(--app-bar-height);
}

/* ---- workspace: reader + chat co-resident (T025) --------------------------
   Collapsed (default): a vertical stack, the reader filling the space with the
   chat as a slim bar beneath it. Desktop expanded: a horizontal split, the
   reader beside the chat. Mobile expanded: the reader stays, and the chat
   becomes a bottom sheet overlay (positioned in the phone media query). */
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

body.chat-expanded .workspace {
  flex-direction: row;
}

/* ---- header ----------------------------------------------------------------
   T037: the title area is a compact single strip so the conversation gets the
   vertical space back. The title stays one modest-size line; the subtitle and
   ESV attribution collapse behind a small "i" info affordance (a native
   <details>/<summary> disclosure, so it needs no extra JS and is keyboard and
   touch accessible by default). The full subtitle text stays in the DOM at all
   times (inside the <details>), it is just not rendered until opened. */

.topbar {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--accent-soft);
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
  text-align: center;
}

.topbar-compact {
  padding: 0.5rem 1rem 0.4rem;
}

.topbar-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
}

.topbar h1 {
  margin: 0;
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-weight: 400;
  font-size: 2.2rem;
  color: var(--accent-dark);
  letter-spacing: 0.04em;
}

.topbar-compact h1 {
  font-size: 1.3rem;
}

/* The info disclosure: collapsed, it is just the small round "i". Opened, the
   subtitle/ESV note drop in as a small floating card BELOW the row (absolutely
   positioned against .topbar's own position: relative), so opening it never
   reflows or squeezes the one-line title -- it overlays the conversation area
   briefly instead of pushing it down. */
.topbar-details {
  display: inline-flex;
  align-items: center;
  position: static;
}

.topbar-info-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1px solid var(--accent-soft);
  color: var(--muted);
  font-size: 0.68rem;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.topbar-info-toggle::-webkit-details-marker {
  display: none;
}

.topbar-info-toggle:hover,
.topbar-info-toggle:focus-visible {
  color: var(--accent-dark);
  border-color: var(--accent-dark);
}

.topbar-meta {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.4rem;
  width: max-content;
  max-width: min(320px, calc(100vw - 2rem));
  background: var(--panel);
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  box-shadow: var(--shadow);
  z-index: 5;
  text-align: center;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  max-width: 640px;
}

.topbar-compact .subtitle {
  max-width: 420px;
}

.source-note {
  margin: 0.25rem auto 0;
  color: var(--muted);
  font-size: 0.68rem;
  opacity: 0.85;
  max-width: 640px;
}

.status {
  margin: 0.35rem auto 0;
  font-size: 0.8rem;
  color: var(--accent-dark);
  min-height: 1.1em;
}

/* ---- conversation ----------------------------------------------------------
   Centered column that reads well on desktop and still fills a phone screen. */

.conversation {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  /* The conversation is the chat panel's internal scroll region (T025): it
     scrolls, the input row below it stays pinned. scroll-padding-bottom is kept
     in sync with the input row's ACTUAL rendered height (app.js's ResizeObserver
     on #ask-form writes --input-bar-height), so scrolling the newest message
     into view always clears the row even as it grows (the controls panel or the
     attached-reference pill expanding, a toggle wrapping on a narrow width). The
     fallback is used only before JS has measured the real height. */
  padding: 1.25rem 1.1rem 1rem;
  scroll-padding-bottom: var(--input-bar-height, 5rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.turn {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.1rem;
  max-width: 100%;
}

.turn.turn-user { align-items: flex-end; }
.turn.turn-assistant { align-items: flex-start; }

.bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  max-width: min(90%, 620px);
  box-shadow: var(--shadow);
  font-size: calc(1rem * var(--text-scale));
}

.bubble.user {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  background: var(--panel);
  border: 1px solid var(--accent-soft);
  border-bottom-left-radius: 4px;
}

/* Loading / "thinking" bubble shown while a question is in flight. */

.bubble.thinking {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
}

.thinking-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: thinking-bounce 1s ease-in-out infinite;
}

.thinking-dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-0.2rem); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-dot { animation: none; opacity: 0.7; }
}

.answer-text { font-size: calc(1rem * var(--text-scale)); }

.meta {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0.45rem 0 0.1rem;
}

.notice {
  font-size: 0.82rem;
  color: var(--warn);
  margin: 0 0 0.5rem;
}

.not-grounded {
  color: var(--error);
  font-weight: 700;
  margin-bottom: 0.3rem;
}

/* ---- citations: readable quote blocks with their references --------------- */

.citations { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }

.citation {
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}

/* Reference line: the "Book Chapter:Verse" plus an optional Old Testament tag,
   laid out on one row so the tag sits beside the reference (T016). */
.citation .ref-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.citation .ref {
  font-weight: 700;
  color: var(--accent-dark);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* A small, quiet pill marking an Old Testament verse in Whole Bible mode. */
.citation .ot-tag {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

/* Old Testament citation blocks get a subtly different accent edge so they are
   distinguishable at a glance from the New Testament ones. */
.citation.citation-ot {
  border-left-color: var(--muted);
}

/* A small, quiet pill marking a cited-verse block that contains the recorded
   words of Jesus (T023). It complements the inline red-and-bold verse text (T053)
   as a block-level label on the citation. Kept unobtrusive: the same pill shape as
   the Old Testament tag, with a restrained red accent so it reads as "words of
   Jesus" without shouting. */
.citation .wj-tag {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--wj-accent);
  background: var(--panel);
  border: 1px solid var(--wj-accent);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}

/* Verses with words of Jesus get a subtly red accent edge so they are
   distinguishable at a glance. Kept as an edge, not a fill or text color, so it
   stays quiet. */
.citation.citation-red {
  border-left-color: var(--wj-accent);
}

.citation .verse-text {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: calc(1.05rem * var(--text-scale));
  font-style: italic;
  color: var(--ink);
}

.citation .flag {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.74rem;
  font-style: normal;
  color: var(--warn);
}

/* A merged range block (T036): one quoted block whose ref-line title is the
   range reference (GALATIANS 4:21-26) and whose body lists each verse in the run
   in canonical order, with its verse number shown quietly beside the text. Single
   verses keep the plain .citation block above; only ranges use these rows. */
.citation.citation-range .range-verses {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.citation.citation-range .range-verse {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

/* The verse number is a small, unobtrusive superscript-like marker so the eye
   still reads the verse text as the main content. */
.citation.citation-range .verse-num {
  flex: 0 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
  min-width: 1.1em;
  text-align: right;
}

.warnings {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--warn);
}

/* ---- historical context (T014): visually distinct, clearly NOT scripture ---
   Cool slate/blue palette and a dashed top rule set it apart from the warm
   gold scripture quote blocks above, so background beyond the Bible is never
   read as scripture. */

.history-context {
  margin-top: 0.85rem;
  background: var(--history-bg);
  border: 1px solid var(--history-border);
  border-left: 4px solid var(--history-accent);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: var(--history-ink);
}

/* The "looking up" state while the gated web call runs. */
.history-context.looking-up {
  font-size: 0.86rem;
  color: var(--history-accent);
  font-style: italic;
}

.history-context.looking-up .history-spinner-text::after {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.4rem;
  border-radius: 50%;
  background: var(--history-accent);
  opacity: 0.4;
  animation: thinking-bounce 1s ease-in-out infinite;
  vertical-align: middle;
}

@media (prefers-reduced-motion: reduce) {
  .history-context.looking-up .history-spinner-text::after { animation: none; }
}

.history-label {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--history-accent-dark);
}

.history-caption-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.history-caption {
  font-size: 0.74rem;
  color: var(--history-accent);
  opacity: 0.9;
}

/* T045: the disclosure caret on the caption line. Collapsed (default) points
   right; expanded rotates to point down. A plain, borderless button keeps it
   visually small while staying a real, keyboard-focusable control. */
.history-caret {
  background: none;
  border: none;
  padding: 0 0.2rem;
  margin: 0;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  color: var(--history-accent-dark);
  transition: transform 0.15s ease;
}

.history-caret:hover { color: var(--history-accent); }

.history-caret:focus-visible {
  outline: 2px solid var(--history-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.history-caret-open {
  transform: rotate(90deg);
}

.history-text {
  font-size: 0.95rem;
  color: var(--history-ink);
}

.history-sources {
  margin-top: 0.5rem;
  font-size: 0.78rem;
}

.history-sources-collapsed {
  display: none;
}

.history-source-list {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.history-source {
  margin: 0.35rem 0;
}

.history-source-link { color: var(--history-accent-dark); }
.history-source-link:hover { color: var(--history-accent); }
.history-source-name { color: var(--history-ink); font-weight: 600; }
.history-source-detail { color: var(--history-ink); }

.history-source-url {
  margin-top: 0.1rem;
  word-break: break-all;
}

/* T045: the explicit trust-level note on a class-level source (kept without a
   verifiable URL by the server's no-fabrication guard), visually distinct from
   a linked source's clickable URL line above. */
.history-source-note {
  margin-top: 0.1rem;
  color: var(--muted);
  font-style: italic;
}

.history-context.history-empty {
  border-left-color: var(--muted);
  background: #f3f3f1;
}

.history-note {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

/* ---- ask form: fixed input bar at the bottom ------------------------------- */

.ask-form {
  /* In-flow within the chat panel (T025): the last child of the panel's flex
     column, so it sits pinned below the scrolling conversation with no
     viewport-fixed positioning. This is what lets the same chat work as a
     desktop side-by-side split and a mobile bottom sheet. */
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem;
  background: var(--panel);
  border-top: 1px solid var(--accent-soft);
  box-shadow: 0 -2px 12px rgba(40, 30, 10, 0.08);
  z-index: 3;
}

/* The textarea and send button share one row below the controls. */
.ask-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* ---- fine-print disclaimer (T032) -------------------------------------------
   Persistent, unobtrusive notice at the bottom of the chat panel, inside the
   input bar itself so it is always included in the ResizeObserver-measured
   --input-bar-height (see app.js) and the conversation's scroll padding stays
   correct without any extra wiring. Small and muted so it never competes with
   the input row for attention. */
.chat-disclaimer {
  width: 100%;
  max-width: 760px;
  margin: 0.1rem auto 0;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--muted);
  opacity: 0.8;
}

/* ---- collapsible controls panel (T019) -------------------------------------
   Scope, mode, and export used to sit directly on the input bar at all times,
   which made the bar tall and cluttered the default view. They now live in a
   panel collapsed by default; a small affordance opens it, and a summary chip
   on that affordance always shows the current scope and mode while closed. */

.controls {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.controls-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  width: auto;
  height: auto;
  padding: 0.35rem 0.7rem;
  margin: 0 0 0.5rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.controls-toggle:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.controls-toggle-icon {
  transition: transform 0.15s ease;
}

.controls-toggle.is-expanded .controls-toggle-icon {
  transform: rotate(180deg);
}

.controls-summary {
  color: var(--accent-dark);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.controls-panel[hidden] {
  display: none;
}

/* ---- "Export this study" (T013) --------------------------------------------
   A quiet secondary control inside the controls panel: turns the conversation
   into a written study PDF. Muted/outline styling keeps it clearly secondary
   to the primary send action. */

.export-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.export-bar button {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  height: 2.1rem;
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.export-bar button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.export-status {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---- "New chat" confirm (T039) ----------------------------------------------
   A quiet inline prompt that appears only when there is existing conversation
   history to lose; "Start new chat" is the one solid/filled action here (the
   deliberate, destructive choice), "Export first" and "Cancel" stay outline
   like the rest of the controls panel. */

.newchat-confirm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.65rem 0.8rem;
  background: var(--accent-soft);
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
}

.newchat-confirm[hidden] {
  display: none;
}

.newchat-confirm-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink);
}

.newchat-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.newchat-confirm-actions button {
  height: 2.1rem;
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
}

.newchat-export-first,
.newchat-cancel-btn {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
}

.newchat-export-first:hover,
.newchat-cancel-btn:hover {
  background: #fff;
}

.newchat-confirm-btn {
  background: var(--accent);
  color: #fff;
  border: none;
}

.newchat-confirm-btn:hover {
  background: var(--accent-dark);
}

/* ---- response mode toggle (Quick / Short Study / Deep dive) ----------------
   A three-way segmented control, centered above the input, so the user can
   choose how much detail to receive and switch it any time mid-conversation. */

.mode-toggle {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.mode-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* Hide the native radio dot; the whole card is the control. */
.mode-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.mode-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.mode-option:hover {
  border-color: var(--accent);
}

/* Selected card: warm accent fill. Driven by the checked radio via :has() on
   modern browsers, and by an is-selected class app.js sets on change, so the
   highlight still works where :has() is unsupported. */
.mode-option:has(input:checked),
.mode-option.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.mode-option:has(input:checked) .mode-name,
.mode-option.is-selected .mode-name {
  color: var(--accent-dark);
}

/* Keyboard focus ring for accessibility (the input is visually hidden). */
.mode-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- scripture scope toggle (New Testament / Whole Bible) (T016) -----------
   A two-way segmented control above the mode toggle, styled to match it, so the
   user can choose which scriptures to draw on and switch it any time
   mid-conversation. New Testament is the default. */

.scope-toggle {
  display: flex;
  gap: 0.4rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.scope-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.1rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.scope-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.scope-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.scope-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.scope-option:hover {
  border-color: var(--accent);
}

.scope-option:has(input:checked),
.scope-option.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.scope-option:has(input:checked) .scope-name,
.scope-option.is-selected .scope-name {
  color: var(--accent-dark);
}

.scope-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* When the Old Testament text is not loaded on the server, the Whole Bible
   option is disabled and dimmed rather than removed. */
.scope-option.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- contextual Red Letters switch (T058) ----------------------------------
   A small "include surrounding context" switch WITHIN the Red Letters scope,
   shown only while Red Letters is selected (app.js toggles the hidden
   attribute). Deliberately quieter than the scope buttons: it is a variant of
   one scope, not a fourth scope. */

.red-context-row {
  width: 100%;
  max-width: 760px;
  margin: 0.35rem auto 0;
}

.red-context-row[hidden] {
  display: none;
}

.red-context-switch {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border: 1px dashed var(--scripture-border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.8rem;
}

.red-context-switch input {
  accent-color: var(--accent);
  cursor: pointer;
}

.red-context-name {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.red-context-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.red-context-switch:hover {
  border-color: var(--accent);
}

.red-context-switch:has(input:checked) {
  background: var(--accent-soft);
  border-style: solid;
  border-color: var(--accent);
}

.question {
  flex: 1;
  resize: vertical;
  font-family: inherit;
  font-size: calc(1rem * var(--text-scale));
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

.question:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0 1.3rem;
  height: 2.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover:not(:disabled) { background: var(--accent-dark); }
button:disabled { opacity: 0.55; cursor: default; }

/* ---- icon-only send button (T019) -------------------------------------------
   Replaces the old text "Ask" button with a round, icon-only control (an
   inline SVG paper airplane; see index.html). aria-label carries the label
   for assistive tech since there is no visible text. */

.send-btn {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.send-btn svg {
  transform: translateX(1px);
}

/* ---- phone widths ----------------------------------------------------------
   Below ~600px: tighter padding, larger tap targets, toggle hints dropped to
   save height. The input and the icon send button stay side by side. */

@media (max-width: 600px) {
  .topbar { padding: 1.1rem 1rem 0.75rem; }
  .topbar h1 { font-size: 1.7rem; }
  .subtitle { font-size: 0.88rem; }
  .topbar-compact { padding: 0.4rem 0.75rem 0.35rem; }
  .topbar-compact h1 { font-size: 1.1rem; }
  .topbar-compact .subtitle { font-size: 0.74rem; max-width: 260px; }

  /* Same scroll-padding pattern as the base .conversation rule (T038 fix): the
     ask-form is in-flow (T025), so it already reserves its own real space in
     the flex column -- real padding-bottom here would double-count that space
     on top of the ask-form's own height. Before this fix a stale real
     padding-bottom equal to --input-bar-height survived from before T025 made
     the input row in-flow, which was harmless at normal sizes but overflowed
     the fixed-height mobile sheet at the max text-size step, pushing the send
     button below the viewport (caught by shoot-t038.js). scroll-padding-bottom
     still keeps a newly scrolled-to message clear of the input row; the
     fallback is larger here since the collapsed bar's input/button stack
     vertically at phone widths, before JS measures the real height. */
  .conversation {
    padding: 1rem 0.75rem;
    scroll-padding-bottom: var(--input-bar-height, 8rem);
  }
  .bubble { max-width: 100%; }

  .ask-form { padding: 0.7rem 0.75rem; }

  /* The icon-only send button stays beside the input at every width (it no
     longer needs the full-width stacking the old text "Ask" button did),
     which also keeps the collapsed bar's height low on phone. */
  .send-btn { width: 2.7rem; height: 2.7rem; }

  /* Keep the three modes side by side but drop the hint line to save height. */
  .mode-option { padding: 0.4rem 0.25rem; }
  .mode-name { font-size: 0.78rem; }
  .mode-hint { display: none; }

  /* Same treatment for the two-way scope toggle. */
  .scope-option { padding: 0.4rem 0.25rem; }
  .scope-name { font-size: 0.78rem; }
  .scope-hint { display: none; }

  /* The contextual Red Letters switch keeps its name, drops its hint line. */
  .red-context-hint { display: none; }
}

/* ========================================================================== */
/* ==== Bible reader (T024) ================================================= */
/* ========================================================================== */

/* Persistent header control: Books | location | Chat. Fixed at the top; the
   body's padding-top clears it for both the reader and the chat. */
.app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-bar-height);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--accent-soft);
  box-shadow: var(--shadow);
}

.app-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.1rem;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
  flex: 0 0 auto;
}

.app-bar-btn:hover:not(:disabled) {
  background: #e7d4ac;
}

.app-bar-chat {
  margin-left: auto;
}

/* The location reads as quiet centered text, but is a real button (tap it to
   jump to the current book's chapter grid). */
.reader-location {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.1rem;
  padding: 0 0.5rem;
  background: transparent;
  border: none;
  color: var(--accent-dark);
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.reader-location:hover:not(:disabled) { background: transparent; text-decoration: underline; }
.reader-location[hidden] { display: none; }

/* ---- shared text size control (T038): a small A-/A+ stepper in the header,
   sitting between the reader location and the Chat toggle so it never crowds
   either. Two buttons, not a slider: reachable and unambiguous at a glance,
   and disabled states plainly show the extremes. --text-scale (see :root) is
   what it actually drives; see static/textsize.js for the steps and
   persistence. */
.textsize-control {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 0 0 auto;
}

.textsize-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  font-family: inherit;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}

.textsize-dec { font-size: 0.7rem; }
.textsize-inc { font-size: 0.85rem; }

.textsize-btn:hover:not(:disabled) { background: #e7d4ac; }
.textsize-btn:disabled { opacity: 0.4; cursor: default; }
.textsize-btn:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* ---- account control and overlay (T044) -----------------------------------
   A small header control (Sign in, or the signed-in name plus Sign out) and a
   centered overlay card carrying the sign in / create account forms, in the
   app's warm panel-and-gold theme. Accounts gate only personal-data features;
   the reader and the chat never require one. */

.account-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.account-name {
  max-width: 9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 40; /* above the app bar and both panels */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 36, 28, 0.45);
}

.account-overlay[hidden] { display: none; }

.account-card {
  position: relative;
  width: 100%;
  max-width: 24rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--scripture-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.account-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.account-close:hover { background: var(--accent-soft); color: var(--accent-dark); }

.account-title {
  margin: 0 0 0.4rem;
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--accent-dark);
  text-align: center;
}

.account-sub {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.account-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.account-tab {
  flex: 1 1 0;
  height: 2.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}

.account-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-form[hidden] { display: none; }

.account-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.account-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.account-field input {
  height: 2.4rem;
  padding: 0 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
}

.account-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.account-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.account-error {
  margin: 0;
  min-height: 1em;
  font-size: 0.82rem;
  color: var(--error);
}

.account-submit {
  height: 2.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.account-submit:hover { background: var(--accent-dark); }

/* ---- account self-service and admin (T054) --------------------------------
   Roles, the admin panel, self password change, and recovery codes. All of it
   reuses the account overlay's look; these add only the new pieces. */

.account-submit-quiet {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
}
.account-submit-quiet:hover { background: var(--accent-soft); }

/* T067: the "Generate new recovery codes" button is a lone action that lives
   OUTSIDE a form, so unlike the "Change password" submit (a flex item stretched
   full width inside .account-form) it would otherwise render as a left-aligned,
   natural-width pill cramped against the recovery-codes description above it.
   Making it a full-width block gives it clear space above and centers it in the
   card, matching the centered "Change password" button in both light and dark
   theme (this is layout only; the theme colors come from .account-submit-quiet). */
.account-submit-block {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
}

.account-ok {
  margin: 0;
  min-height: 1em;
  font-size: 0.82rem;
  color: var(--accent-dark);
}

.account-alt {
  margin: 0.2rem 0 0;
  text-align: center;
}

.account-link {
  padding: 0;
  font-size: 0.82rem;
  color: var(--accent-dark);
  background: transparent;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}
.account-link:hover { color: var(--accent); }

.account-notice {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
}
.account-notice[hidden] { display: none; }

.account-subhead {
  margin: 1.2rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.recovery-codes {
  margin: 0 0 0.5rem;
  padding: 0.6rem 0.75rem;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.75rem;
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
}
.recovery-codes:empty { display: none; }

.recovery-code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  color: var(--ink);
  letter-spacing: 0.02em;
}

/* The admin panel overlay: a wider card, since it lists accounts. */
.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 41; /* above the account overlays */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 36, 28, 0.45);
}
.admin-overlay[hidden] { display: none; }

.admin-card {
  position: relative;
  width: 100%;
  max-width: 34rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--scripture-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-accounts {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.admin-account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
}

.admin-account-who {
  display: flex;
  flex-direction: column;
  min-width: 8rem;
  flex: 1 1 8rem;
}
.admin-account-name { font-weight: 700; color: var(--ink); }
.admin-account-handle { font-size: 0.78rem; color: var(--muted); }

.admin-account-meta {
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1 1 8rem;
}

.admin-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-action {
  height: 2rem;
  padding: 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: transparent;
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.admin-action:hover { background: var(--accent-soft); }

.admin-action-danger { color: var(--error); }
.admin-action-danger:hover { background: rgba(180, 60, 40, 0.12); }

.admin-account-result {
  flex: 1 1 100%;
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--accent-dark);
  word-break: break-word;
}
.admin-account-result:empty { display: none; }

/* The reader fills the viewport below the app bar; its sub-views scroll inside
   it, so the window itself does not scroll while reading. */
.reader-view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- the collapsible chat panel (T025) ------------------------------------
   chat-view holds two mutually exclusive faces: a slim collapsed bar and the
   full chat panel. Collapsed by default. */
.chat-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--accent-soft);
}

/* Collapsed: show only the slim bar. */
body.chat-collapsed .chat-view .chat-panel { display: none; }
body.chat-collapsed .chat-view { width: 100%; }

/* Expanded: show the panel, hide the slim bar. On desktop the panel is a fixed
   width column to the right of the reader (the split); the reader keeps flex:1
   and both are usable. */
body.chat-expanded .chat-view .chat-collapsed-bar { display: none; }
/* The chat is a fixed-width column beside the reader; its width is user
   adjustable and screen-aware (T034): --chat-width is written by resize.js
   (viewport-scaled default, or the persisted/dragged size), the min() fallback
   only shows for the pre-JS flash. position:relative anchors the drag divider. */
body.chat-expanded .chat-view {
  flex: 0 0 auto;
  width: var(--chat-width, min(440px, 42vw));
  height: 100%;
  border-top: none;
  border-left: 1px solid var(--accent-soft);
  box-shadow: -2px 0 12px rgba(40, 30, 10, 0.06);
  position: relative;
}

/* ---- the draggable split divider (T034, desktop only) --------------------
   A slim grabber straddling the chat's left border. Hidden when collapsed and
   on the phone (the bottom sheet resizes via its own handle). */
.chat-resizer { display: none; }
body.chat-expanded .chat-resizer {
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
  transform: translateX(-50%);
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}
/* A quiet visible seam, brightening on hover/focus so it is discoverable. */
.chat-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 2.4rem;
  border-radius: 999px;
  background: var(--scripture-border);
  transition: background 0.15s ease, height 0.15s ease;
}
.chat-resizer:hover::before,
.chat-resizer:focus-visible::before,
body.chat-resizing .chat-resizer::before {
  background: var(--accent);
  height: 3.4rem;
}
.chat-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* While dragging, suppress text selection and show the resize cursor globally. */
body.chat-resizing { cursor: col-resize; user-select: none; }

/* The slim collapsed bar: a quiet full-width strip that opens the chat. */
.chat-collapsed-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  height: auto;
  padding: 0.6rem 1rem;
  background: var(--panel);
  color: var(--accent-dark);
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
}
.chat-collapsed-bar:hover { background: var(--scripture-bg); }
.chat-collapsed-bar svg { flex: 0 0 auto; color: var(--accent); }
.chat-collapsed-label {
  font-weight: 700;
  font-size: 0.95rem;
}
.chat-collapsed-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The chat panel itself: a self-contained flex column (header, scrolling
   conversation, input row), so nothing depends on viewport-fixed positioning
   and it works the same in the desktop split and the mobile sheet. */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
  position: relative;
}

/* The drag handle (mobile bottom sheet only, revealed in the phone media
   query) and the collapse chevron. */
.chat-sheet-handle {
  display: none;
  flex: 0 0 auto;
  padding: 0.45rem 0;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
}
.chat-sheet-handle:active { cursor: grabbing; }
.chat-sheet-grip {
  display: block;
  width: 2.5rem;
  height: 0.3rem;
  border-radius: 999px;
  background: var(--scripture-border);
}

.chat-collapse-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  z-index: 4;
}
.chat-collapse-btn:hover:not(:disabled) { background: #e7d4ac; }

/* ---- book picker ---------------------------------------------------------- */

.reader-picker {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 3rem;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.reader-picker-title {
  margin: 0.25rem 0 0;
  text-align: center;
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-weight: 400;
  font-size: 1.9rem;
  color: var(--accent-dark);
}

.reader-picker-sub {
  margin: 0.35rem 0 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.picker-group { margin-bottom: 1.4rem; }

.picker-group-label {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 0.3rem;
}

.picker-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
}

.picker-book {
  height: auto;
  min-height: 2.6rem;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.picker-book:hover:not(:disabled) {
  background: var(--scripture-bg);
  border-color: var(--accent);
}

/* ---- chapter grid --------------------------------------------------------- */

.reader-chapters {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 3rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.reader-back {
  height: 2rem;
  padding: 0 0.85rem;
  font-size: 0.85rem;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.reader-back:hover:not(:disabled) { background: var(--accent-soft); }

/* T075: the book title sits centered between the previous/next book arrows.
   The bar owns the vertical margins the title used to carry, so the title's
   own margin drops to zero inside it. */
.reader-chapters-titlebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin: 0.9rem 0 1.2rem;
}

.reader-chapters-title {
  margin: 0;
  text-align: center;
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-weight: 400;
  font-size: 1.7rem;
  color: var(--accent-dark);
}

/* T075: the prev/next book arrows. Quiet round outline buttons in the same
   language as the "All books" pill; every color rides a theme variable so a
   future dark palette restyles them by overriding the variables (the T053
   precedent). The hover pins its own soft background so the global
   button:hover:not(:disabled) accent repaint never applies (the T047
   lesson), and a disabled arrow (Genesis's prev, Revelation's next) dims. */
.reader-book-arrow {
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.reader-book-arrow:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: var(--accent);
}
.reader-book-arrow:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}
.reader-book-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.reader-chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr));
  gap: 0.5rem;
}

.chapter-cell {
  height: 3.2rem;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--scripture-border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  /* T074: anchors the corner percent badge on partially read chapters. */
  position: relative;
}
.chapter-cell:hover:not(:disabled) {
  background: var(--scripture-bg);
  border-color: var(--accent);
}

/* T074: chapter-picker cells color-coded by the signed-in account's read
   status (progress.js sets data-read-state from the per-account store; a
   NOT-STARTED cell carries no attribute and keeps the default look above, and
   signed out nothing is set at all). The hover rules repeat the colored
   backgrounds explicitly so the generic .chapter-cell:hover:not(:disabled)
   rule never repaints a colored cell back to the default (the T047 lesson). */
.chapter-cell[data-read-state="complete"] {
  background: var(--chapter-done-bg);
  border-color: var(--chapter-done-bg);
  color: var(--chapter-done-ink);
}
.chapter-cell[data-read-state="complete"]:hover:not(:disabled) {
  background: var(--chapter-done-bg);
  border-color: var(--accent-dark);
  color: var(--chapter-done-ink);
  filter: brightness(1.12);
}
.chapter-cell[data-read-state="partial"] {
  background: var(--chapter-partial-bg);
  border-color: var(--chapter-partial-border);
  color: var(--chapter-partial-ink);
}
.chapter-cell[data-read-state="partial"]:hover:not(:disabled) {
  background: var(--chapter-partial-bg);
  border-color: var(--accent);
  color: var(--chapter-partial-ink);
}

/* T074: the small percentage-complete indicator in the top-right corner of a
   chapter cell. progress.js adds it ONLY on partially read chapters (complete
   and not-started cells stay clean); it is aria-hidden because the cell's
   aria-label already speaks the same percent. */
.chapter-cell-pct {
  position: absolute;
  top: 0.18rem;
  right: 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--chapter-partial-ink);
  pointer-events: none;
}

/* ---- T076: resume-or-restart prompt --------------------------------------
   Shown over the chapter picker when a signed-in reader opens a PARTIALLY
   read chapter whose verse 1 is already read. Every color rides a theme
   custom property, so a future dark palette restyles the dialog by
   overriding the variables (the T053 convention); the action buttons pin
   their own hover so the global button:hover rule never repaints them (the
   T047 lesson). */
.resume-overlay {
  position: fixed;
  inset: 0;
  z-index: 45; /* above the reader and app bar, below the badge celebration */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(42, 36, 28, 0.45);
}
.resume-overlay[hidden] { display: none; }
.resume-card {
  position: relative;
  box-sizing: border-box;
  width: min(92vw, 22rem);
  padding: 1.4rem 1.3rem 1.2rem;
  text-align: center;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--accent-soft);
  border-radius: 0.9rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.4);
}
.resume-title {
  margin: 0 1.4rem 0.3rem;
  font-size: calc(1.05rem * var(--text-scale));
  color: var(--accent-dark);
}
.resume-sub {
  margin: 0 0 1rem;
  font-size: calc(0.85rem * var(--text-scale));
  color: var(--muted);
}
.resume-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.resume-btn {
  width: 100%;
  padding: 0.6rem 0.8rem;
  font-size: calc(0.9rem * var(--text-scale));
  font-weight: 600;
  border: 1px solid var(--scripture-border);
  border-radius: 0.6rem;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
}
.resume-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.resume-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.resume-btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}
.resume-btn:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}
.resume-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.resume-close:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.resume-close:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* ---- windowed e-reader ---------------------------------------------------- */

.reader-reading {
  flex: 1;
  display: flex;
  min-height: 0;
}

.reader-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  position: relative;
  scroll-behavior: auto;
  /* The reader compensates scrollTop by hand when it prepends or drops a block
     at the top. The browser's own scroll anchoring would ALSO adjust for that
     same content shift, double-counting it and drifting the reader down the
     chapter. Turn anchoring off so only the manual compensation applies. */
  overflow-anchor: none;
}

/* The reading column (T066): full available width up to the text-scaled
   readability ceiling declared on :root, centered when the ceiling bites.
   Because .reader-view is flex:1 in the workspace row, the column reflows
   automatically as the journal and chat panels open, close, and resize; no JS
   is involved. The side padding grows gently with the column (percentage
   against the container, clamped) so lines are never edge-to-edge but the
   margins stay modest, per Mark's too-much-whitespace complaint. */
.reader-blocks {
  width: 100%;
  max-width: var(--reader-max-width);
  margin: 0 auto;
  padding: 1rem clamp(1.25rem, 3%, 3rem) 40vh;
}

/* T030: while a shift-click or a touch drag handle is extending a verse range,
   suppress native text selection so only the app's own .verse-selected
   highlight is ever visible; removed the instant the gesture ends, so plain
   click-drag text selection for copying is unaffected the rest of the time. */
.reader-blocks.picking-active {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.reader-sentinel {
  height: 1px;
  width: 100%;
}

.chapter-block {
  padding: 1.5rem 0 0.5rem;
}

.chapter-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--accent-soft);
}

.chapter-heading-book {
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--accent-dark);
  letter-spacing: 0.02em;
}

.chapter-heading-num {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* Verses flow as continuous reading text (an e-reader, not a list). The verse
   number (.vnum) is sized in em against this, so it scales with it for free. */
.chapter-body {
  font-size: calc(1.12rem * var(--text-scale));
  line-height: 1.85;
  color: var(--ink);
  text-align: left;
}

.verse { }

/* Unobtrusive superscript verse number. */
.vnum {
  font-size: 0.62em;
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.15em;
  vertical-align: super;
  line-height: 0;
  user-select: none;
}

/* Recorded Words of Jesus, inline (T053): the direct words of Jesus render in red
   and bold within the verse text itself, replacing the old T023 dot marker. This
   one class is used EVERYWHERE verses render (reader verses and the chat
   cited-verse blocks, single and range), applied through the shared
   RedLetterSpans core, so the reader and the citations match. Presentation only:
   the surrounding text nodes carry the exact stored verse text unchanged. Color is
   driven by the --wj-text custom property so it stays legible in light and dark
   themes. */
.wj-text {
  color: var(--wj-text);
  font-weight: 700;
}

/* Journal reference bubbles (T051): a small, quiet marker shown in the reader on
   a verse (or chapter heading) that a signed-in account's journal entry
   references. It sits inline with the verse number; clicking it opens the entry
   (or a picker when several entries reference the same anchor). */
.journal-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.15em;
  margin: 0 0.28em 0 0.1em;
  padding: 0.02em 0.32em;
  vertical-align: middle;
  line-height: 1;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.journal-bubble:hover { background: var(--accent); color: #fff; }
.journal-bubble svg { display: block; flex: 0 0 auto; }
.journal-bubble-count {
  font-size: 0.7em;
  font-weight: 700;
  line-height: 1;
}
.journal-bubble:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}
/* The heading bubble sits after the chapter label, slightly larger to match the
   heading scale but still unobtrusive. */
.chapter-heading .journal-bubble { margin-left: 0.5em; }

/* The multi-entry picker: a small popover listing the entries that reference an
   anchor. Absolutely positioned in page coordinates by journalbubbles.js. */
.journal-bubble-picker {
  position: absolute;
  z-index: 60;
  min-width: 12rem;
  max-width: 20rem;
  max-height: 16rem;
  overflow-y: auto;
  padding: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--scripture-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.journal-bubble-picker-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}
.journal-bubble-picker-item:hover { background: var(--accent-soft); }
.journal-bubble-picker-item:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: -2px;
}
.journal-bubble-picker-title {
  font-weight: 600;
  color: var(--ink);
  font-size: calc(0.92rem * var(--text-scale));
}
.journal-bubble-picker-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.reader-error {
  margin: 2rem auto;
  max-width: 30rem;
  text-align: center;
  color: var(--error);
}

/* ---- reader at phone widths ---------------------------------------------- */

@media (max-width: 600px) {
  .app-bar { padding: 0 0.5rem; gap: 0.35rem; }
  .app-bar-btn { padding: 0 0.7rem; font-size: 0.85rem; }
  .reader-location { font-size: 0.95rem; }
  .textsize-control { gap: 0.1rem; }
  .textsize-btn { width: 1.7rem; height: 1.7rem; }
  .account-name { max-width: 5.5rem; font-size: 0.78rem; }
  .account-control { gap: 0.25rem; }
  .reader-picker,
  .reader-chapters { padding: 1rem 0.85rem 3rem; }
  .picker-books { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .reader-chapter-grid { grid-template-columns: repeat(auto-fill, minmax(2.9rem, 1fr)); }
  .reader-blocks { padding: 0.75rem 1rem 40vh; }
  .chapter-body { font-size: calc(1.08rem * var(--text-scale)); line-height: 1.8; }
}

/* ========================================================================== */
/* ==== Reader-chat integration: verse-ask + collapsible chat (T025) ======== */
/* ========================================================================== */

/* ---- citation links: a cited reference scrolls the reader to that verse ---- */
.citation .ref-link {
  height: auto;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.citation .ref-link:hover { color: var(--accent); }
.citation .ref-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---- attached verse-ask reference pill (above the chat input) ------------- */
.attached-ref {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.3rem 0.5rem 0.3rem 0.6rem;
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
}
.attached-ref-tag {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.attached-ref-label {
  font-weight: 700;
  color: var(--accent-dark);
  font-size: 0.9rem;
}
.attached-ref-clear {
  margin-left: auto;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  border: none;
}
.attached-ref-clear:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent-dark); }

/* ---- verse selection highlight + the citation-scroll flash ---------------- */
.verse.verse-selected {
  background: var(--accent-soft);
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--accent-soft);
}
@keyframes verse-flash-fade {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}
.verse.verse-flash {
  border-radius: 4px;
  animation: verse-flash-fade 1.6s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .verse.verse-flash { animation: none; }
}
/* A verse is focusable for keyboard verse-ask; give it a clear focus ring. */
.verse:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---- chapter-level ask (T031): a selected chapter heading ------------------
   Clicking a chapter heading selects the whole chapter; the heading carries the
   same app selection style (accent-soft fill + ring) that a selected verse does,
   so the two read as one selection system. Every heading in a chapter range is
   marked. */
.chapter-heading.chapter-heading-selected {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* Headings are focusable for keyboard chapter-ask; give them the same ring. */
.chapter-heading:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.chapter-heading[role="button"] { cursor: pointer; }

/* ---- the floating verse-ask chip ------------------------------------------ */
.verse-chip {
  position: fixed;
  z-index: 30;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.verse-chip[hidden] { display: none; }
.verse-chip-send {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: auto;
  padding: 0.4rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0;
  font-size: 0.85rem;
  font-weight: 700;
}
.verse-chip-send:hover:not(:disabled) { background: var(--accent-dark); }
.verse-chip-send svg { flex: 0 0 auto; }
.verse-chip-ref {
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.verse-chip-dismiss {
  width: 2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--muted);
  border: none;
  border-radius: 0;
}
.verse-chip-dismiss:hover:not(:disabled) { background: var(--scripture-bg); color: var(--accent-dark); }
/* Mark-as-read action on the chip (T042): a quiet second action between the
   send and dismiss buttons. Filled (checked) once the selection is fully read. */
.verse-chip-mark {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  background: var(--panel);
  color: var(--accent-dark);
  border: none;
  border-left: 1px solid var(--scripture-border);
  border-radius: 0;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.verse-chip-mark[hidden] { display: none; }
.verse-chip-mark:hover:not(:disabled) { background: var(--scripture-bg); }
.verse-chip-mark[data-state="complete"] {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
/* T077: "Mark chapter read through this verse" on the chip: a third quiet
   action beside the single-verse mark, so a running prefix (verses 1..N) can
   be marked in one press. Hidden when redundant (the selection starts at
   verse 1) or when the prefix is already fully read. */
.verse-chip-through {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.7rem;
  background: var(--panel);
  color: var(--accent-dark);
  border: none;
  border-left: 1px solid var(--scripture-border);
  border-radius: 0;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.verse-chip-through[hidden] { display: none; }
.verse-chip-through:hover:not(:disabled) { background: var(--scripture-bg); }
.verse-chip-send:focus-visible,
.verse-chip-mark:focus-visible,
.verse-chip-through:focus-visible,
.verse-chip-dismiss:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: -2px;
}

/* ---- touch drag handles for verse-by-verse range selection ---------------- */
.verse-handle {
  position: fixed;
  z-index: 29;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--panel);
  box-shadow: var(--shadow);
  touch-action: none;
}
.verse-handle[hidden] { display: none; }

/* ---- mobile bottom sheet: the expanded chat slides over the reader -------- */
@media (max-width: 600px) {
  /* Keep the reader as the full-height base layer; the sheet overlays it. */
  body.chat-expanded .workspace { flex-direction: column; }
  body.chat-expanded .chat-view {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    /* Screen-aware, user-adjustable sheet height (T034): --chat-sheet-height is
       written by resize.js (viewport-scaled default, or the persisted/dragged
       size); the 85vh fallback only shows for the pre-JS flash. The drag handle
       (reader.js, delegating the math to resize.js) sets it between a slim peek
       and near-full height. The desktop --chat-width on the same element is
       ignored here because width is 100%. */
    height: var(--chat-sheet-height, 85vh);
    max-height: calc(100vh - var(--app-bar-height));
    border-left: none;
    border-top: 1px solid var(--accent-soft);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(40, 30, 10, 0.18);
    z-index: 15;
    transition: transform 0.2s ease;
  }
  body.chat-expanded .chat-view.chat-dragging { transition: none; }
  /* The drag handle is the sheet's grab affordance; the collapse chevron sits
     out of the way top-right as a secondary control. */
  body.chat-expanded .chat-sheet-handle { display: flex; }
  .chat-collapsed-hint { display: none; }
  /* The desktop split divider never applies on the phone; the sheet resizes via
     its drag handle instead (T034). */
  body.chat-expanded .chat-resizer { display: none; }
}

/* ==========================================================================
   Journal (T040): a collapsible LEFT panel mirroring the chat's right panel.
   Desktop: journal | reader | chat, all usable at once (three panes). The
   journal has no persistent collapsed rail (it is opened from the header
   Journal button, closed from its own chevron), so when it is collapsed it
   simply takes no space and the reader/chat behave exactly as before it
   existed. Narrow screens: the journal is a full-screen tab over the reader.
   ========================================================================== */

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

.app-bar-journal { flex: 0 0 auto; }

/* Collapsed (default): the journal takes no space at all. */
.journal-view { display: none; }

/* Either side panel expanding lays the workspace out as a row so the reader
   stays centered between them. (The chat already does this for its own state;
   this adds the journal trigger.) */
body.journal-expanded .workspace { flex-direction: row; }

/* Expanded: a fixed-width column on the LEFT of the reader, mirroring the
   chat's right column. Its width is user adjustable and screen-aware (T052,
   mirroring the chat's T034 resize): --journal-width is written by
   journalresize.js (viewport-scaled default, or the persisted/dragged size),
   the min() fallback only shows for the pre-JS flash. position:relative anchors
   the drag divider on the panel's right edge. */
body.journal-expanded .journal-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 0 0 auto;
  width: var(--journal-width, min(400px, 40vw));
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--accent-soft);
  box-shadow: 2px 0 12px rgba(40, 30, 10, 0.06);
  position: relative;
}

/* ---- the draggable split divider (T052, desktop only) --------------------
   A slim grabber straddling the journal's right border, the mirror of the
   chat's T034 divider. Hidden when collapsed and on the phone (there the
   journal is a full-screen tab, not a resizable panel). */
.journal-resizer { display: none; }
body.journal-expanded .journal-resizer {
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 10px;
  transform: translateX(50%);
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}
/* A quiet visible seam, brightening on hover/focus so it is discoverable. */
.journal-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 2.4rem;
  border-radius: 999px;
  background: var(--scripture-border);
  transition: background 0.15s ease, height 0.15s ease;
}
.journal-resizer:hover::before,
.journal-resizer:focus-visible::before,
body.journal-resizing .journal-resizer::before {
  background: var(--accent);
  height: 3.4rem;
}
.journal-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* While dragging, suppress text selection and show the resize cursor globally. */
body.journal-resizing { cursor: col-resize; user-select: none; }

/* When the journal forces the row layout but the chat is still collapsed, the
   collapsed chat must not keep its column-layout full width (that 100% is only
   for the bottom-bar layout); shrink it to a slim right rail so all three
   regions coexist. */
body.journal-expanded.chat-collapsed .chat-view {
  width: auto;
  flex: 0 0 auto;
}
body.journal-expanded.chat-collapsed .chat-collapsed-bar {
  width: 3.1rem;
  height: 100%;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.6rem;
  padding: 0.8rem 0.4rem;
  border-left: 1px solid var(--accent-soft);
}
body.journal-expanded.chat-collapsed .chat-collapsed-label {
  writing-mode: vertical-rl;
  margin-left: 0;
}
body.journal-expanded.chat-collapsed .chat-collapsed-hint { display: none; }

/* ---- the journal panel body ---------------------------------------------- */
.journal-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.journal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--accent-soft);
  background: var(--panel);
  flex: 0 0 auto;
}
.journal-heading {
  margin: 0;
  font-family: "Uncial Antiqua", Papyrus, Georgia, serif;
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--accent-dark);
  letter-spacing: 0.03em;
}
.journal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.journal-close:hover { background: var(--scripture-bg); color: var(--accent-dark); }

/* Signed-out invitation. */
.journal-signedout {
  padding: 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: flex-start;
}
.journal-signedout-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}
.journal-signin-btn {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.journal-signin-btn:hover { background: var(--accent-dark); }

.journal-signedin {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

/* ---- journal tabs: Entries vs Progress (T042) ----------------------------- */
.journal-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.9rem 0;
  flex: 0 0 auto;
}
.journal-tab {
  padding: 0.35rem 0.85rem;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  font-size: calc(0.9rem * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
}
/* The hover rule must pin the background explicitly AND outrank the generic
   button:hover:not(:disabled) rule (specificity (0,2,1)), which otherwise
   wins the background property and paints a hovered tab --accent-dark under
   --accent-dark text, leaving the active tab's label unreadable while the
   pointer rests on it (the T043 harness had to park the mouse to screenshot
   around this; fixed in T047). :not(:disabled) lifts this to (0,3,0). */
.journal-tab:hover:not(:disabled) {
  color: var(--accent-dark);
  background: transparent;
}
.journal-tab.is-active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}
.journal-tab:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* The two panes fill the signed-in area; only one shows at a time. */
.journal-entries-pane,
.journal-progress-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.journal-entries-pane[hidden],
.journal-progress-pane[hidden] { display: none; }

/* The progress pane holds two blocks now (the T042 rollups, then the T043
   badge shelf beneath them); the PANE itself scrolls as one unit so a tall
   badge shelf cannot squeeze the rollups down to a sliver (T042's own
   .journal-progress used to scroll internally, which left the badge shelf
   sitting outside that scroll box with no way to reach it once the shelf
   grew taller than the leftover flex space, most visibly on narrow screens
   where .journal-view is position: fixed and overflow cannot bleed into the
   document to compensate). */
.journal-progress-pane {
  overflow-y: auto;
}

/* ---- the Progress view (T042) --------------------------------------------- */
.journal-progress {
  flex: 0 0 auto;
  padding: 0.8rem 0.9rem 1.2rem;
}
.progress-signedout,
.progress-loading {
  color: var(--muted);
  font-size: calc(0.95rem * var(--text-scale));
  padding: 0.6rem 0.2rem;
}
.progress-headline {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--accent-soft);
}
.progress-row { display: block; }
.progress-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.progress-row-label {
  font-size: calc(0.95rem * var(--text-scale));
  font-weight: 600;
  color: var(--ink);
}
.progress-row-pct {
  font-size: calc(0.9rem * var(--text-scale));
  font-weight: 700;
  color: var(--accent-dark);
  flex: 0 0 auto;
}
.progress-bar-track {
  height: 0.55rem;
  margin: 0.28rem 0 0.2rem;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0;
  /* T056: each prestige cycle paints its bars in its own color; progress.js
     sets --cycle-color per fill from ProgressCore's 10-color cycle palette.
     Without it (signed out, old markup) the app accent still applies. */
  background: var(--cycle-color, var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}
.progress-bar-fill.is-complete { background: var(--cycle-color, #5b7a3a); }

/* T056: the cycle caption and the prestige control above the bars. */
.progress-cycle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0 0 0.5rem;
}
.progress-cycle-note {
  font-size: calc(0.82rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cycle-color, var(--accent-dark));
}
.progress-prestige-btn {
  font: inherit;
  font-size: calc(0.82rem * var(--text-scale));
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--accent-dark);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.progress-prestige-btn:hover,
.progress-prestige-btn:focus-visible { background: var(--accent-dark); }
.progress-row-count {
  font-size: calc(0.78rem * var(--text-scale));
  color: var(--muted);
}
.progress-whole .progress-row-label { font-size: calc(1.05rem * var(--text-scale)); }
.progress-whole .progress-bar-track { height: 0.7rem; }

.progress-section { margin: 0.6rem 0; }
.progress-section-details > summary {
  list-style: none;
  cursor: pointer;
}
.progress-section-details > summary::-webkit-details-marker { display: none; }
/* The caret is the SOLE expand affordance (T065 removed T055's redundant
   "Show N books" button). It sits in a header row beside the section bar,
   rotates when the section is open, and brightens on hover/focus so the
   disclosure is still an obvious click target. */
.progress-section-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.progress-section-caret {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
  transition: transform 0.15s ease;
}
.progress-section-details[open] > summary .progress-section-caret {
  transform: rotate(90deg);
}
.progress-section-head .progress-section-bar { flex: 1 1 auto; }
.progress-section-details > summary:hover .progress-section-caret,
.progress-section-details > summary:focus-visible .progress-section-caret {
  color: var(--accent);
}
.progress-section-bar .progress-row-label {
  font-size: calc(0.82rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.progress-book-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.5rem 0 0.4rem 0.6rem;
  border-left: 2px solid var(--accent-soft);
  margin: 0.2rem 0 0.4rem 0.3rem;
}
.progress-book-row .progress-row-label {
  font-size: calc(0.9rem * var(--text-scale));
  font-weight: 500;
}
.progress-book-row .progress-bar-track { height: 0.4rem; }

/* T074: a Progress-tab book NAME is a real <button> that opens that book's
   chapter picker in the reader. It dresses as the plain label it replaced
   (the row's bar and counts are unchanged) with link affordances: the accent
   ink, an underline on hover, and a visible focus ring. The hover pins a
   transparent background so the generic button:hover:not(:disabled) rule
   never paints it as a solid pill (the T047 lesson). */
.progress-book-link {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0;
  height: auto;
  color: var(--accent-dark);
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  transition: none;
}
.progress-book-link:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}
.progress-book-link:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* ---- milestone badge shelf (T043) ------------------------------------------
   Earned/locked always reflects live server state (accounts/badges.py); this
   is presentation only. Locked tiles reuse the exact same SVG as an earned
   tile of the same tier (badges.py generates one drawing per tier) with a
   grayscale filter and reduced opacity, plus a small lock glyph, so nothing
   here has to keep two drawings in sync. */
.badge-shelf-section {
  margin-top: 0.6rem;
  /* T065: the same 0.9rem horizontal inset as the rest of the journal panel
     (.journal-progress, .journal-header, .journal-tabs); the shelf used to sit
     flush against the pane's left edge. */
  padding: 0.9rem 0.9rem 1.2rem;
  border-top: 1px solid var(--accent-soft);
}
.badge-shelf-heading {
  margin: 0 0 0.6rem;
  font-size: calc(0.82rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge-shelf-empty {
  color: var(--muted);
  font-size: calc(0.88rem * var(--text-scale));
}
.badge-tier-group { margin: 0 0 0.9rem; }
.badge-tier-heading {
  margin: 0 0 0.4rem;
  font-size: calc(0.78rem * var(--text-scale));
  font-weight: 700;
  color: var(--accent-dark);
}
.badge-tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
  gap: 0.6rem;
}
.badge-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem;
  border-radius: 0.5rem;
}
.badge-tile-art {
  position: relative;
  width: 2.6rem;
  height: 2.6rem;
}
.badge-tile-art svg { width: 100%; height: 100%; display: block; }
.badge-tile.is-locked .badge-tile-art svg {
  filter: grayscale(1) opacity(0.5);
}
.badge-tile-lock {
  position: absolute;
  right: -0.15rem;
  bottom: -0.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  background: var(--panel);
  border: 1px solid var(--scripture-border);
  border-radius: 50%;
  color: var(--muted);
}
.badge-tile-label {
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 600;
  color: var(--ink);
  line-height: 1.15;
}
.badge-tile.is-locked .badge-tile-label { color: var(--muted); }
.badge-tile-status {
  font-size: calc(0.66rem * var(--text-scale));
  color: var(--muted);
}
.badge-tile.is-earned .badge-tile-status { color: var(--accent-dark); }
/* T056: the re-earn multiplier chip ("x2".."x10") worn on the medallion when
   a badge has been earned in more than one prestige cycle. */
.badge-tile-mult {
  position: absolute;
  right: -0.3rem;
  top: -0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.2rem;
  background: var(--accent-dark);
  border: 1px solid var(--panel);
  border-radius: 999px;
  color: #fff;
  font-size: calc(0.6rem * var(--text-scale));
  font-weight: 700;
  line-height: 1;
}

/* ---- the celebration modal (T055) ------------------------------------------
   A real, accessible modal WITH a close button: a dimmed backdrop, a centered
   dialog, focus moved in and Escape/backdrop to dismiss. Several unlocks from
   one mark play in sequence (smallest to largest). The first whole-Bible
   completion is a distinct, bigger celebration that also shows the editable
   word from the creator. No external assets. */
.badge-celebration {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(20, 12, 4, 0.55);
}
.badge-celebration[hidden] { display: none; }
.badge-modal {
  position: relative;
  box-sizing: border-box;
  width: min(92vw, 26rem);
  max-height: 88vh;
  overflow-y: auto;
  text-align: center;
  padding: 1.4rem 1.3rem 1.2rem;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--accent-soft);
  border-radius: 0.9rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.4);
}
.badge-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
}
.badge-modal-close:hover,
.badge-modal-close:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.badge-modal-art {
  width: 4.2rem;
  height: 4.2rem;
  margin: 0.2rem auto 0.7rem;
}
.badge-modal-art svg { width: 100%; height: 100%; display: block; }
.badge-modal-kicker {
  margin: 0 0 0.2rem;
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.badge-modal-title {
  margin: 0 0 0.6rem;
  font-size: calc(1.15rem * var(--text-scale));
  color: var(--accent-dark);
}
.badge-modal-done {
  margin-top: 0.8rem;
  padding: 0.45rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: calc(0.9rem * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
}
.badge-modal-done:hover,
.badge-modal-done:focus-visible { background: var(--accent-dark); }
/* The whole-Bible celebration is bigger and warmer; the first one especially. */
.badge-celebration.is-whole .badge-modal { width: min(94vw, 30rem); }
.badge-celebration.is-whole .badge-modal-art { width: 5.2rem; height: 5.2rem; }
.badge-celebration.is-first-whole .badge-modal {
  width: min(96vw, 34rem);
  border-color: var(--accent);
  box-shadow: 0 1.2rem 3.5rem rgba(0, 0, 0, 0.45);
}
.badge-celebration.is-first-whole .badge-modal-art { width: 6.4rem; height: 6.4rem; }
.badge-modal-creator {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--accent-soft);
  text-align: left;
}
.badge-modal-creator-head {
  margin: 0 0 0.5rem;
  font-size: calc(0.72rem * var(--text-scale));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge-modal-creator-para {
  margin: 0 0 0.6rem;
  font-size: calc(0.95rem * var(--text-scale));
  line-height: 1.55;
}
.badge-modal-creator-para:last-child { margin-bottom: 0; }
/* T056: the per-cycle celebration ladder message inside the whole-Bible
   celebration modal (rung selected server-side, capping at cycle 10). */
.badge-modal-ladder {
  margin: 0.7rem 0 0;
  padding: 0.7rem 0.85rem;
  background: var(--scripture-bg);
  border: 1px solid var(--scripture-border);
  border-radius: 0.55rem;
  text-align: left;
}
.badge-modal-ladder-para {
  margin: 0 0 0.6rem;
  font-size: calc(0.95rem * var(--text-scale));
  line-height: 1.55;
}
.badge-modal-ladder-para:last-child { margin-bottom: 0; }

/* ---- reader: the per-chapter mark-read control (T042) --------------------- */
/* T070: the per-chapter control sits inside the centered heading, directly
   under the "CHAPTER N" label, centered to match it (was left-aligned below
   the heading rule). */
.chapter-progress {
  display: flex;
  justify-content: center;
  margin: 0.15rem 0 0.1rem;
}
.chapter-progress[hidden] { display: none; }
/* T072: the SECOND "Mark chapter read" control, at the END of each chapter on
   its OWN line right-aligned after the last verse, so a reader can mark a
   chapter read without scrolling back to the heading. It reuses the pill button
   styling (.chapter-progress-btn) and the mark state of the centered top
   control; only its placement differs. Placed after .chapter-progress so its
   flex-end override wins (equal specificity, later in source), and after the
   [hidden] rule so hiding it (display:none) still wins. */
.chapter-progress-end {
  justify-content: flex-end;
  margin: 0.4rem 0 0.15rem;
}
.chapter-progress-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  background: var(--panel);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-size: calc(0.82rem * var(--text-scale));
  font-weight: 600;
  cursor: pointer;
}
.chapter-progress-btn:hover { background: var(--scripture-bg); }
.chapter-progress-btn svg { opacity: 0.35; flex: 0 0 auto; }
.chapter-progress-btn[data-state="complete"] {
  background: #eef3e4;
  border-color: #b9cc96;
  color: #4c6a2c;
}
.chapter-progress-btn[data-state="complete"] svg { opacity: 1; }
.chapter-progress-btn[data-state="partial"] { border-style: dashed; }
.chapter-progress-btn:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

/* T069/T070: the whole-book "Mark book read" control at the start of each book
   (its first chapter), centered directly under the book NAME inside the heading
   (the per-chapter control is centered under the "CHAPTER N" label). Styled a
   touch more prominent than the per-chapter control since it marks the entire
   book in one action. Its hover and complete backgrounds are pinned with
   :hover:not(:disabled) (specificity (0,3,0)/(0,4,0)) so they outrank the
   generic button:hover:not(:disabled) rule (specificity (0,2,1)) that would
   otherwise repaint the background and can leave the label hard to read (the
   same fix the journal tabs needed). */
.book-progress {
  display: flex;
  justify-content: center;
  margin: 0.15rem 0 0.1rem;
}
.book-progress[hidden] { display: none; }
.book-progress-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.85rem;
  background: var(--accent-dark);
  color: var(--panel);
  border: 1px solid var(--accent-dark);
  border-radius: 999px;
  font-size: calc(0.84rem * var(--text-scale));
  font-weight: 700;
  cursor: pointer;
}
.book-progress-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  filter: brightness(1.12);
}
.book-progress-btn svg { opacity: 0.9; flex: 0 0 auto; }
.book-progress-btn[data-state="complete"] {
  background: #4c6a2c;
  border-color: #4c6a2c;
  color: #ffffff;
}
.book-progress-btn[data-state="complete"]:hover:not(:disabled) {
  background: #4c6a2c;
  filter: brightness(1.12);
}
.book-progress-btn[data-state="complete"] svg { opacity: 1; }
.book-progress-btn:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.journal-toolbar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--accent-soft);
  flex: 0 0 auto;
}
.journal-new {
  flex: 0 0 auto;
  padding: 0.4rem 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.journal-new:hover { background: #e7d4ac; }
.journal-search-field { flex: 1 1 auto; min-width: 0; }
.journal-search {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  background: var(--scripture-bg);
  color: var(--ink);
  font-size: 0.9rem;
}

/* ---- bulk export (T041): a chosen month or an arbitrary date range -------
   Collapsed behind a compact toggle by default (T073), mirroring the chat
   controls-panel pattern (T019), so the range-export controls no longer
   clutter the top of the Entries tab. */
.journal-export-collapsible {
  flex: 0 0 auto;
  padding: 0.4rem 0.9rem;
  border-bottom: 1px solid var(--accent-soft);
}
.journal-export-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.journal-export-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.journal-export-toggle-icon {
  transition: transform 0.15s ease;
}
.journal-export-toggle.is-expanded .journal-export-toggle-icon {
  transform: rotate(180deg);
}
.journal-export-panel {
  margin-top: 0.5rem;
}
.journal-export-panel[hidden] {
  display: none;
}
.journal-export-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 0 0 auto;
}
.journal-export-scope,
.journal-export-date {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--scripture-border);
  border-radius: 6px;
  background: var(--scripture-bg);
  color: var(--ink);
  font-size: 0.82rem;
}
.journal-export-to {
  color: var(--muted);
  font-size: 0.8rem;
}
.journal-export-btn {
  padding: 0.3rem 0.75rem;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.journal-export-btn:hover:not(:disabled) { background: var(--accent-soft); }
.journal-export-status {
  font-size: 0.78rem;
  color: var(--muted);
  flex-basis: 100%;
}

.journal-body-split {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  position: relative;
}

/* The entry list, grouped by month. When no entry is open it fills the pane and
   scrolls internally; when an entry IS open the list is bound to its own
   scrollable region so a long list can never push the editor (and its bottom
   buttons) off the panel -- see body.journal-entry-open below (T068). */
.journal-list {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.4rem 0.6rem 0.8rem;
}

/* ---- the internal vertical split (T068) ----------------------------------
   With an entry open, split the entries pane into a bounded list on top and the
   editor below, so the editor's buttons (New entry Save, or Delete/Export/Edit)
   stay reachable regardless of entry count. The list takes a fixed height from
   --journal-list-height (written by journalsplit.js, with a sane pre-JS
   fallback) and keeps scrolling internally; the editor takes the rest. This is
   the height-axis mirror of the T034/T052 width resize and composes with it. */
body.journal-entry-open .journal-list {
  flex: 0 0 auto;
  height: var(--journal-list-height, 42%);
}
body.journal-entry-open .journal-editor {
  flex: 1 1 auto;
}
/* The scrollable-text min-height override for the bounded split lives further
   down, AFTER the base .journal-body-editor / .journal-read-body rules, so it
   wins by source order (see "bounded split: let the text region shrink"). */

/* The draggable divider between the list and the editor: a horizontal grabber,
   the mirror of the chat/journal width dividers (T034/T052) in the height axis.
   Hidden unless an entry is open (nothing to split otherwise). Unlike the width
   divider it is NOT desktop-only: the vertical squeeze happens on the phone tab
   too, so the list is bounded and the divider is draggable there as well. */
.journal-split-resizer { display: none; }
body.journal-entry-open .journal-split-resizer {
  display: block;
  position: relative;
  flex: 0 0 auto;
  height: 12px;
  margin: 0.1rem 0;
  cursor: row-resize;
  touch-action: none;
}
/* A quiet visible seam, brightening on hover/focus so it is discoverable (the
   horizontal counterpart of the width divider's vertical pill). */
.journal-split-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.4rem;
  height: 3px;
  border-radius: 999px;
  background: var(--scripture-border);
  transition: background 0.15s ease, width 0.15s ease;
}
.journal-split-resizer:hover::before,
.journal-split-resizer:focus-visible::before,
body.journal-split-resizing .journal-split-resizer::before {
  background: var(--accent);
  width: 3.4rem;
}
.journal-split-resizer:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* While dragging, suppress text selection and show the resize cursor globally. */
body.journal-split-resizing { cursor: row-resize; user-select: none; }
.journal-month {
  margin: 0.7rem 0.3rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
/* A compact, flat list item (T064): one open control per row, no expand arrow
   and no snippet preview (the T048 collapse was removed). */
.journal-item {
  display: block;
  width: 100%;
  margin-bottom: 0.2rem;
  background: var(--scripture-bg);
  border: 1px solid transparent;
  border-radius: 8px;
  overflow: hidden;
}
/* A SUBTLE hover highlight that keeps the title readable in light and dark
   (it uses theme variables, never a flat dark fill). The inner open button is
   forced transparent on hover just below, so this row tint is what shows --
   replacing the old global dark-brown button:hover that made the title
   unreadable and gave it no padding (T064). */
.journal-item:hover {
  background: var(--accent-soft);
  border-color: var(--scripture-border);
}
.journal-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.journal-item-open {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  height: auto;
  /* Compact vertical rhythm tied to the shared reading text size (T064): the
     row grows and shrinks with the A-/A+ control, and the horizontal padding
     keeps the title and date off the row edges. */
  padding: calc(0.34rem * var(--text-scale)) 0.6rem;
  margin: 0;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
/* Keep the button itself transparent even on hover, so the row's subtle tint
   shows through and the title never sits on a dark fill (overrides the global
   dark-brown button:hover). */
.journal-item-open:hover:not(:disabled),
.journal-item-open:focus-visible { background: transparent; }
.journal-item-title {
  font-weight: 600;
  color: var(--ink);
  font-size: calc(0.95rem * var(--text-scale));
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.journal-item-date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: calc(0.72rem * var(--text-scale));
  white-space: nowrap;
}
.journal-empty {
  padding: 0.8rem 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The editor. */
.journal-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 2 1 auto;
  border-top: 1px solid var(--accent-soft);
  padding: 0.7rem 0.8rem 0.8rem;
  gap: 0.5rem;
}
.journal-title-input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
  font-size: calc(1.05rem * var(--text-scale));
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
}
.journal-date {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.journal-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.journal-tool {
  padding: 0.28rem 0.55rem;
  min-width: 2rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}
.journal-tool:hover { background: #e7d4ac; }
.journal-tool-ref { font-weight: 600; }

.journal-body-editor {
  flex: 1 1 auto;
  min-height: 6rem;
  overflow-y: auto;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: calc(1rem * var(--text-scale));
  line-height: 1.6;
}
.journal-body-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.journal-body-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}
.journal-body-editor ul,
.journal-body-editor ol { margin: 0.3rem 0; padding-left: 1.4rem; }
.journal-body-editor p { margin: 0.3rem 0; }

/* Verse-reference chips inside a journal entry: a small linked pill that jumps
   the reader to the passage. */
.journal-ref {
  display: inline;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid var(--scripture-border);
  border-radius: 6px;
  padding: 0 0.35rem;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.journal-ref:hover { background: #e7d4ac; }

.journal-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 0 0 auto;
}
.journal-save-status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1em;
}
.journal-editor-actions { display: flex; gap: 0.4rem; }
.journal-delete {
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--error);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.journal-delete:hover { background: #f6e7e6; border-color: var(--error); }
.journal-export-entry {
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.journal-export-entry:hover:not(:disabled) { background: var(--accent-soft); }
.journal-save {
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.journal-save:hover { background: var(--accent-dark); }

/* ---- read / edit modes (T050) --------------------------------------------- */
/* Both panes fill the editor container; only the active one is shown (the other
   carries the [hidden] attribute, which the global rule turns off). */
.journal-read-pane,
.journal-edit-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  gap: 0.5rem;
}

/* READ mode: a rendered, non-editable view of the entry. */
.journal-read-head { display: flex; flex-direction: column; gap: 0.15rem; }
/* The title row carries the close (X) control at its right edge (T064): the
   open entry can always be dismissed back to the list. */
.journal-read-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.journal-read-title {
  margin: 0;
  font-size: calc(1.15rem * var(--text-scale));
  font-weight: 600;
  color: var(--ink);
}
/* The close (X) control on the open entry's header (T064). A real keyboard
   button; its hover overrides the global dark-brown button:hover with a subtle
   readable tint. */
.journal-read-close {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.journal-read-close:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: var(--scripture-border);
}
.journal-read-date {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.journal-read-body {
  flex: 1 1 auto;
  min-height: 6rem;
  overflow-y: auto;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--scripture-border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: calc(1rem * var(--text-scale));
  line-height: 1.6;
}
.journal-read-body ul,
.journal-read-body ol { margin: 0.3rem 0; padding-left: 1.4rem; }
.journal-read-body p { margin: 0.3rem 0; }
.journal-read-empty { color: var(--muted); font-style: italic; }

/* Bounded split (T068): let the text region shrink. In the internal split the
   editor can be squeezed to its min height; the read body and the edit body both
   scroll internally, so drop their 6rem floor to a small min when an entry is
   open. This keeps the editor's foot -- its Save/Done or Delete/Export/Edit
   buttons -- pinned at the bottom of the pane and on screen no matter how tall
   the list is dragged; a long entry simply scrolls within the body. Placed after
   the base rules above so it wins by source order (the base rules keep their
   --text-scale sizing; only the min-height is overridden here). */
body.journal-entry-open .journal-body-editor,
body.journal-entry-open .journal-read-body {
  min-height: 2.5rem;
}

/* The Edit control opens the editable experience; Done returns to read mode. */
.journal-edit-btn {
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.journal-edit-btn:hover { background: var(--accent-dark); }
.journal-done {
  padding: 0.4rem 0.8rem;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--scripture-border);
  border-radius: 999px;
  cursor: pointer;
}
.journal-done:hover { background: var(--accent-soft); }

/* Edit-mode chip: an atomic pill carrying a navigable label and a remove "x".
   contenteditable="false" keeps it one indivisible token in the editor. */
.journal-ref-editable {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0 0.15rem 0 0.35rem;
  vertical-align: baseline;
}
.journal-ref-editable .journal-ref-link {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}
.journal-ref-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-dark);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.journal-ref-remove:hover { background: #e0c48f; color: var(--error); }
.journal-ref-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---- narrow screens: the journal is a full-screen tab over the reader ----- */
@media (max-width: 600px) {
  /* Keep the workspace a column; the journal overlays it (tab-style). */
  body.journal-expanded .workspace { flex-direction: column; }
  body.journal-expanded .journal-view {
    display: flex;
    position: fixed;
    top: var(--app-bar-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    border-right: none;
    box-shadow: none;
    z-index: 16;
  }
  /* The journal is a full-screen tab on the phone, not a resizable panel, so
     the drag divider is hidden here (mirroring the chat divider, which is also
     hidden on the phone in favor of the bottom-sheet handle). */
  body.journal-expanded .journal-resizer { display: none; }
  /* On the phone the journal and chat are mutually exclusive tabs, so the
     journal never has to share the row with a collapsed chat rail. */
  body.journal-expanded.chat-collapsed .chat-collapsed-bar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0.6rem 1rem;
    border-left: none;
  }
  body.journal-expanded.chat-collapsed .chat-collapsed-label {
    writing-mode: horizontal-tb;
  }
}

