/* Vellum warm-parchment palette. Minimal viable styling per WI-035; full
 * polish lands in WI-047. Mirrors SCREEN-33-001/002/003 specs.
 */
:root {
  --vellum-parchment: #f5ecd7;
  --vellum-parchment-dark: #e8dcc0;
  --vellum-ink: #2b2118;
  /* WI-047 a11y: darkened from #5a4a36 to #4a3c28 for stronger AA contrast
   * (≥7:1 on parchment) when used for body-text-adjacent helper copy. */
  --vellum-ink-dim: #4a3c28;
  --vellum-rule: #c9b890;
  --vellum-accent: #8a4a2a;
  /* Secondary tokens consumed by studies.css (card surfaces, soft rules,
   * radii). Values from the studies mockups' _shared.css palette. */
  --vellum-parchment-soft: #fbf5e4;
  --vellum-rule-soft: #d8caa9;
  --vellum-accent-soft: #b87a4e;
  --vellum-danger: #a8321b;
  --vellum-card-bg: #fff8e8;
  --vellum-shadow: 0 1px 3px rgba(60, 40, 20, 0.10);
  --radius-sm: 4px;
  --radius-md: 8px;
  /* Width of the docked lexicon side panel (desktop). The appbar reserves
   * this much space on its right while the panel is open. */
  --vellum-lexicon-panel-width: 380px;
  /* iter-42 REQ-42-005 — readability scale token. The :root default is the
   * medium baseline; the html[data-bible-font-size="..."] rules below override
   * the variable when the user picks a non-default size. Body / scaling
   * surfaces consume this via `font-size: calc(<rem> * var(--bible-font-scale))`.
   * Pinned (icon) selectors deliberately omit the calc() so they remain
   * size-stable across user preference changes. */
  --bible-font-scale: 1;
}

/* iter-42 REQ-42-001 / REQ-42-005 — font-size preference application.
 * The html-level sentinel `data-bible-font-size` is the SOLE switch for the
 * scale variable. The bible-app-state subscriber is the only writer of the
 * sentinel (NFR-117 single-writer enforcement). Scalars are pinned by the
 * surface-coverage matrix: small=0.875, medium=1, large=1.25. */
html[data-bible-font-size="small"] {
  --bible-font-scale: 0.875;
}
html[data-bible-font-size="medium"] {
  --bible-font-scale: 1;
}
html[data-bible-font-size="large"] {
  --bible-font-scale: 1.25;
}

/* WI-047 a11y: visible focus ring on every interactive element.
 * Per WCAG 2.4.7. Outline + offset for both light and dark areas. */
*:focus-visible {
  outline: 2px solid var(--vellum-accent);
  outline-offset: 2px;
}

/* Shared button base + modifiers (iter-44). Vellum palette. Component-scoped
 * rules elsewhere in this file win on specificity where they need to. */
.btn {
  padding: 0.5rem 1.1rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  font-family: inherit;
  font-size: calc(0.92rem * var(--bible-font-scale));
  line-height: 1.2;
}
.btn:hover {
  background: var(--vellum-parchment-dark);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: calc(0.82rem * var(--bible-font-scale));
}
.btn-primary {
  background: var(--vellum-accent);
  color: #fff7e8;
  border-color: var(--vellum-accent);
  font-weight: 600;
}
.btn-primary:hover {
  filter: brightness(1.1);
  background: var(--vellum-accent);
}
.btn-secondary {
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  border-color: var(--vellum-rule);
}
.btn-destructive,
.btn-danger {
  background: #9a2a2a;
  color: #fff7e8;
  border-color: #9a2a2a;
  font-weight: 600;
}
.btn-destructive:hover,
.btn-danger:hover {
  filter: brightness(1.08);
  background: #9a2a2a;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--vellum-ink-dim);
}
.btn-ghost:hover {
  background: var(--vellum-parchment-dark);
  color: var(--vellum-ink);
}

/* Shared combobox suggestion listbox (iter-44). Used by the reader address
 * bar AND the vellum-study-editor passage range input — the same combobox-controller
 * builds both. Adjacent inline spans without styling render abutted
 * (`JohnBook`); these rules add the missing visual separation. */
.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(43, 33, 24, 0.12);
  max-height: 18rem;
  overflow-y: auto;
}
.suggestion-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: calc(0.9rem * var(--bible-font-scale));
}
.suggestion-item[aria-selected="true"] {
  background: var(--vellum-parchment-dark);
}
.suggestion-item:hover {
  background: var(--vellum-parchment-dark);
}
.suggestion-text {
  flex: 1 1 auto;
  color: var(--vellum-ink);
}
.kind-badge {
  flex: 0 0 auto;
  font-size: calc(0.72rem * var(--bible-font-scale));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--vellum-ink-dim);
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

html, body {
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  font-family: Georgia, "Iowan Old Style", serif;
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* App shell: a column at least one viewport tall. #main-app takes the spare
 * height, and inside it `.vellum-footer` (margin-top: auto) drops to the
 * bottom, so on a short page the footer sits at the viewport bottom; on a
 * long page it stays sticky at bottom: 0. The siblings of #main-app are
 * overlays (position: fixed or display: none). */
vellum-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#main-app {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

/* Appbar (tab strip). Wraps on a narrow viewport so that the sync pill drops
 * to its own row instead of widening the page. */
.appbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment-dark);
}

/* The docked lexicon panel (desktop) covers the right edge of the viewport,
 * from the top. Keep the appbar content (tabs + sync pill) clear of it. */
@media (min-width: 768px) {
  html[data-bible-lexicon-panel-open="true"] .appbar {
    padding-right: calc(var(--vellum-lexicon-panel-width) + 1rem);
  }
}

/* Vellum text wordmark in the appbar (WI-047). */
.appbar-brand {
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 700;
  /* iter-42 REQ-42-005 — wordmark scales with user preference. */
  font-size: calc(1.15rem * var(--bible-font-scale));
  color: var(--vellum-accent);
  letter-spacing: 0.02em;
  margin-right: 0.85rem;
  user-select: none;
}

.appbar-tab {
  display: inline-block;
  padding: 0.4rem 1rem;
  text-decoration: none;
  color: var(--vellum-ink);
  border: 1px solid transparent;
  border-radius: 4px;
  font-weight: 600;
}

.appbar-tab:hover {
  border-color: var(--vellum-rule);
  background: var(--vellum-parchment);
}

.appbar-tab:active {
  background: var(--vellum-parchment-dark);
}

.appbar-tab[data-bible-reader-tab-disabled="true"] {
  color: var(--vellum-ink-dim);
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
}

.sync-pill-slot {
  margin-left: auto;
  /* May shrink below its label width; the label truncates (see .sync-label). */
  min-width: 0;
  max-width: 100%;
}

/* Narrow viewport: tighter appbar so brand + tabs fit one row at 390px. Must
 * follow the base .appbar-* rules (same specificity). */
@media (max-width: 480px) {
  .appbar {
    padding: 0.5rem 0.75rem;
    gap: 0.35rem;
  }
  .appbar-brand {
    margin-right: 0.25rem;
  }
  .appbar-tab {
    padding: 0.4rem 0.6rem;
  }
}

/* ---------------------------------------------------------------------------
 * iter-38 WI-296 — vellum-sync-pill / shared sync-status contract.
 *
 * The structural rules below are copied from
 * offline-kitchen/static/css/sync-status.css (ADR-38-003). The palette tokens
 * are SHADOWED at the host element so the bible warm-parchment palette wins
 * for the duration of the pill's subtree without forking the structural CSS.
 *
 * Reconnect button is hidden via `display:none` when state=online to match
 * kitchen/notes (full visual parity per user direction; supersedes the
 * REQ-38-004 always-visible-disabled interpretation). The button remains in
 * DOM (contract test asserts presence + disabled) so accessibility/test
 * surface is unchanged.
 * ------------------------------------------------------------------------- */

/* Bible palette shadowing of the notes/kitchen tokens (ADR-38-003). */
vellum-sync-pill {
  --color-success: var(--vellum-accent);
  --color-error: #8a2a1a;
  --color-error-bg: rgba(138, 42, 26, 0.10);
  --accent-secondary: var(--vellum-accent);
  --border-subtle: var(--vellum-rule);
  --bg-active: var(--vellum-parchment-dark);
  --border-focus: var(--vellum-accent);
}

vellum-sync-pill {
  display: inline-flex;
  align-items: center;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border: 1px solid var(--border-subtle, #c9b890);
  border-radius: 3px;
  font-family: ui-monospace, 'SFMono-Regular', 'Menlo', 'Consolas',
               'Liberation Mono', monospace;
  /* iter-42 REQ-42-005 — sync pill wrapper text scales with user preference. */
  font-size: calc(0.875rem * var(--bible-font-scale));
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
  white-space: nowrap;
  /* Never wider than the appbar row; the label truncates instead. */
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* === State: Online === */
.sync-indicator[data-state="online"] {
  color: var(--color-success, #8a4a2a);
  border-color: var(--border-subtle, #c9b890);
  background: transparent;
}

/* Hide reconnect button when synced — parity with notes/kitchen. */
.sync-indicator[data-state="online"] .reconnect-btn {
  display: none;
}

/* === State: Syncing (task #13 WI-2) ===
 * Reachable only while the bootstrap-progress signal reports in-flight
 * hydration. Healthy-but-busy: the synced hue with a turning icon, so a long
 * chapter/lexicon download is visible in the appbar instead of reading
 * "Synced". */
.sync-indicator[data-state="syncing"] {
  color: var(--color-success, #8a4a2a);
  border-color: var(--border-subtle, #c9b890);
  background: transparent;
}

/* Hide reconnect while syncing — a cycle is already running. */
.sync-indicator[data-state="syncing"] .reconnect-btn {
  display: none;
}

.sync-indicator[data-state="syncing"] .sync-icon {
  animation: bible-sync-icon-spin 1.4s linear infinite;
}

@keyframes bible-sync-icon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sync-indicator[data-state="syncing"] .sync-icon {
    animation: none;
  }
}

/* === State: Offline === */
.sync-indicator[data-state="offline"] {
  color: var(--color-error, #8a2a1a);
  border-color: var(--color-error, #8a2a1a);
  background: var(--color-error-bg, rgba(138, 42, 26, 0.10));
}

/* === State: Unauthenticated === */
.sync-indicator[data-state="unauthenticated"] {
  color: var(--accent-secondary, #8a4a2a);
  border-color: var(--accent-secondary, #8a4a2a);
  background: rgba(138, 74, 42, 0.10);
}

/* While the sign-in form is the page, Reconnect has nothing to do: there is
 * no token to reconnect with, and the form is already the way in. */
body:has(vellum-auth-form) .sync-indicator .reconnect-btn {
  display: none;
}

/* === Icon === */
.sync-icon {
  display: inline-block;
  font-size: 0.875rem;
  line-height: 1;
}

/* === Label === */
.sync-label {
  /* iter-42 REQ-42-005 — sync-label is a body-text surface; scales with user preference. */
  font-size: calc(0.875rem * var(--bible-font-scale));
  /* A long progress label ("Syncing lexicon · N / M") ends in an ellipsis
   * on a narrow row. The full text stays in the wrapper's aria-label. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === Reconnect Button === */
.reconnect-btn {
  background: var(--color-error-bg, rgba(138, 42, 26, 0.10));
  border: 1px solid currentColor;
  color: inherit;
  font-family: inherit;
  /* iter-42 REQ-42-005 — sync pill action button scales with user preference. */
  font-size: calc(0.875rem * var(--bible-font-scale));
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: background-color 0.15s;
}

.reconnect-btn:hover {
  background: var(--bg-active, #e8dcc0);
}

.reconnect-btn:focus-visible {
  outline: 2px solid var(--border-focus, #8a4a2a);
  outline-offset: 2px;
}

.reconnect-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* REQ-38-004: bible KEEPS the reconnect button visible-but-disabled when
 * state=online. The kitchen `display: none` rule is INTENTIONALLY omitted
 * here. Do not re-introduce it without revising REQ-38-004. */

/* === Responsive: hide label on very narrow screens === */
@media (max-width: 360px) {
  .sync-label {
    display: none;
  }
}

/* Route containers. By default all are visible; vellum-app's hashchange
 * handler hides the inactive ones via inline display:none. */
.route-container {
  padding: 1rem 1.5rem;
}

/* ---------------------------------------------------------------------------
 * <vellum-welcome> — SCREEN-33-001 hero card (WI-036).
 * Warm-parchment palette mirrored from
 * docs/ux/mockups/offline-bible/welcome.html.
 * ------------------------------------------------------------------------- */
vellum-welcome {
  display: block;
}

vellum-welcome .welcome-hero {
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 8px;
  padding: 2rem 1.75rem 1.75rem;
  max-width: 580px;
  margin: 0.5rem auto 0;
  text-align: center;
}

vellum-welcome .welcome-hero h2 {
  font-family: Georgia, "Iowan Old Style", serif;
  color: var(--vellum-ink);
  /* iter-42 REQ-42-005 — welcome hero heading scales with user preference. */
  font-size: calc(1.55rem * var(--bible-font-scale));
  margin: 0 0 0.4rem;
}

vellum-welcome .welcome-hero p {
  color: var(--vellum-ink-dim);
  max-width: 48ch;
  margin: 0 auto 1.4rem;
  /* iter-42 REQ-42-005 — welcome hero body copy scales with user preference. */
  font-size: calc(0.93rem * var(--bible-font-scale));
  line-height: 1.55;
}

vellum-welcome .recommended-card {
  background: var(--vellum-parchment);
  border: 2px solid var(--vellum-accent);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin: 0 0 0.85rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

vellum-welcome .recommended-card .pick {
  flex: 1;
  min-width: 0;
}

vellum-welcome .recommended-card .name {
  font-weight: 600;
  color: var(--vellum-ink);
  /* iter-42 REQ-42-005 — recommended-card name scales with user preference. */
  font-size: calc(1rem * var(--bible-font-scale));
  margin: 0 0 0.15rem;
}

vellum-welcome .recommended-card .meta {
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — recommended-card meta scales with user preference. */
  font-size: calc(0.82rem * var(--bible-font-scale));
}

vellum-welcome .recommended-card .badge {
  display: inline-block;
  /* iter-42 REQ-42-005 — recommended-card badge label scales with user preference. */
  font-size: calc(0.68rem * var(--bible-font-scale));
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--vellum-accent);
  color: #fff7e8;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  font-weight: 600;
}

vellum-welcome .btn {
  padding: 0.5rem 1.1rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  /* iter-42 REQ-42-005 — welcome CTA button label scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
  font-family: inherit;
}

vellum-welcome .btn-primary {
  background: var(--vellum-accent);
  color: #fff7e8;
  border-color: var(--vellum-accent);
  font-weight: 600;
}

vellum-welcome .btn-primary:hover {
  filter: brightness(1.1);
}

vellum-welcome .welcome-fineprint {
  margin-top: 1.1rem;
  /* iter-42 REQ-42-005 — welcome fineprint scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  border-top: 1px solid var(--vellum-rule);
  padding-top: 0.85rem;
  text-align: left;
}

vellum-welcome .progress-status {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  /* iter-42 REQ-42-005 — welcome progress status scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

vellum-welcome .progress-bar {
  height: 6px;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

vellum-welcome .progress-fill {
  height: 100%;
  background: var(--vellum-accent);
  transition: width 200ms ease-out;
}

vellum-welcome .welcome-hero.error h2 {
  color: #9a2a2a;
}

vellum-welcome .err-glyph {
  /* Centring is done by the grid, not by a line-height matched to the box
   * height. A unit'd line-height is inherited as a fixed length, so it stops
   * tracking the reader's size preference. */
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #9a2a2a;
  color: #fff7e8;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* ---------------------------------------------------------------------------
 * <vellum-prefs> — SCREEN-33-003 (WI-037).
 * Mirrors docs/ux/mockups/offline-bible/preferences.html — minimal viable.
 * ------------------------------------------------------------------------- */
vellum-prefs {
  display: block;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 0;
}

vellum-prefs .pref-block {
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin: 0 0 1rem;
}

vellum-prefs .pref-block h2 {
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — prefs section heading scales with user preference. */
  font-size: calc(1.05rem * var(--bible-font-scale));
  margin: 0 0 0.2rem;
  color: var(--vellum-ink);
}

vellum-prefs .pref-block .help {
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — prefs help copy scales with user preference. */
  font-size: calc(0.83rem * var(--bible-font-scale));
  margin: 0 0 0.85rem;
}

/* Synced translations list */
vellum-prefs .synced-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

vellum-prefs .synced-list li,
vellum-prefs .synced-list vellum-prefs-translation-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--vellum-rule);
}

vellum-prefs .synced-list li:last-child,
vellum-prefs .synced-list vellum-prefs-translation-row:last-child {
  border-bottom: 0;
}

/* iter-40 WI-040-fixup: <vellum-prefs-lexicon-row> Strong's lexicon
 * download progress. Visual layout mirrors a synced-list row but
 * lives standalone (no checkbox; one row per app). */
vellum-prefs vellum-prefs-lexicon-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.4rem;
}

vellum-prefs vellum-prefs-lexicon-row .lexicon-row__label-text {
  font-weight: 600;
  color: var(--vellum-ink);
}

vellum-prefs vellum-prefs-lexicon-row .lexicon-row__status {
  flex: 1;
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — lexicon download status scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
}

vellum-prefs vellum-prefs-lexicon-row .lexicon-row__progress {
  width: 140px;
  height: 8px;
  accent-color: var(--vellum-accent);
}

vellum-prefs vellum-prefs-lexicon-row .lexicon-row__retry {
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  color: var(--vellum-ink);
  padding: 0.3rem 0.7rem;
  border-radius: 3px;
  font-family: inherit;
  cursor: pointer;
}

vellum-prefs vellum-prefs-lexicon-row .lexicon-row__retry:hover {
  background: var(--vellum-parchment);
  border-color: var(--vellum-accent);
}

vellum-prefs vellum-prefs-lexicon-row[data-lexicon-walker-state="ready"]
  .lexicon-row__status {
  color: var(--vellum-accent);
}

vellum-prefs .synced-list input[type=checkbox] {
  width: 17px;
  height: 17px;
  accent-color: var(--vellum-accent);
  flex: 0 0 auto;
}

vellum-prefs .tr-meta {
  flex: 1;
}

vellum-prefs .tr-name {
  font-weight: 600;
  color: var(--vellum-ink);
  /* iter-42 REQ-42-005 — translation row name scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
}

vellum-prefs .tr-sub {
  /* iter-42 REQ-42-005 — translation row sub-label scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

/* Translation download progress: "Downloading · N / M" + bar, the same
 * shape as the lexicon row, at the row's meta text size. */
vellum-prefs .tr-progress {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.3rem;
}

vellum-prefs .tr-progress__label {
  flex: 1;
  color: var(--vellum-ink-dim);
  font-size: calc(0.78rem * var(--bible-font-scale));
  font-variant-numeric: tabular-nums;
}

vellum-prefs .tr-progress__bar {
  width: 140px;
  height: 8px;
  accent-color: var(--vellum-accent);
}

vellum-prefs .synced-list input[type=checkbox]:disabled {
  cursor: progress;
}

vellum-prefs .tr-status {
  /* iter-42 REQ-42-005 — translation status pill text scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--vellum-rule);
  color: var(--vellum-ink-dim);
  background: var(--vellum-parchment);
}

vellum-prefs .tr-status.complete {
  color: #5b6f3a;
  border-color: rgba(91, 111, 58, 0.4);
  background: rgba(91, 111, 58, 0.10);
}

vellum-prefs .tr-status.downloading,
vellum-prefs .tr-status.cancelling {
  color: var(--vellum-accent);
  border-color: rgba(138, 74, 42, 0.4);
  background: rgba(138, 74, 42, 0.08);
}

vellum-prefs .tr-status.failed {
  color: #9a2a2a;
  border-color: rgba(154, 42, 42, 0.4);
  background: rgba(154, 42, 42, 0.10);
}

/* Inline progress row */
vellum-prefs .progress-row {
  width: 100%;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

vellum-prefs .progress-track {
  flex: 1;
  height: 6px;
  background: var(--vellum-rule);
  border-radius: 3px;
  overflow: hidden;
}

vellum-prefs .progress-fill {
  height: 100%;
  background: var(--vellum-accent);
  transition: width 200ms;
}

vellum-prefs .progress-pct {
  /* iter-42 REQ-42-005 — inline progress % numeric scales with user preference. */
  font-size: calc(0.75rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: right;
}

vellum-prefs .progress-cancel {
  background: transparent;
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  padding: 0.15rem 0.55rem;
  /* iter-42 REQ-42-005 — cancel button label scales with user preference. */
  font-size: calc(0.75rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  cursor: pointer;
}

/* Failed-row state */
vellum-prefs .synced-list li.row-failed {
  background: rgba(154, 42, 42, 0.05);
  border-left: 3px solid #9a2a2a;
}

vellum-prefs .download-error {
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  /* iter-42 REQ-42-005 — download-error inline message scales with user preference. */
  font-size: calc(0.8rem * var(--bible-font-scale));
  color: #9a2a2a;
}

vellum-prefs .download-error .err-glyph {
  font-weight: 700;
}

vellum-prefs .btn-retry {
  padding: 0.15rem 0.6rem;
  border: 1px solid #9a2a2a;
  background: transparent;
  color: #9a2a2a;
  border-radius: 4px;
  cursor: pointer;
  /* iter-42 REQ-42-005 — retry button label scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  font-family: inherit;
}

vellum-prefs .btn-retry:hover {
  background: rgba(154, 42, 42, 0.10);
}

vellum-prefs .link-dismiss {
  color: var(--vellum-ink-dim);
  text-decoration: underline;
  cursor: pointer;
  /* iter-42 REQ-42-005 — dismiss link scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
}

/* Default-translation select */
vellum-prefs select.pref-select {
  padding: 0.4rem 0.65rem;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — pref-select scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
  color: var(--vellum-ink);
  min-width: 200px;
}

vellum-prefs select.pref-select:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Font-size segmented control */
vellum-prefs .seg-group {
  display: inline-flex;
  border: 1px solid var(--vellum-rule);
  border-radius: 6px;
  overflow: hidden;
  background: var(--vellum-parchment);
}

vellum-prefs .seg-group button {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--vellum-rule);
  padding: 0.4rem 0.95rem;
  cursor: pointer;
  color: var(--vellum-ink);
  font-family: inherit;
  /* iter-42 REQ-42-005 — seg-group buttons (font-size labels themselves)
   * scale with user preference (ADR-42-005). */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-prefs .seg-group button:last-child {
  border-right: 0;
}

vellum-prefs .seg-group button.active {
  background: var(--vellum-accent);
  color: #fff7e8;
  font-weight: 600;
}

/* ---------------------------------------------------------------------------
 * <vellum-confirm-modal> — destructive-action confirmation dialog (WI-037).
 * <vellum-forget-device-modal> shares the same dialog chrome.
 * Project modal pattern: visibility via [open] attribute selector.
 * ------------------------------------------------------------------------- */
vellum-confirm-modal,
vellum-forget-device-modal {
  display: none;
}

vellum-confirm-modal[open],
vellum-forget-device-modal[open] {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

vellum-confirm-modal[open] .modal-backdrop,
vellum-forget-device-modal[open] .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(43, 33, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

vellum-confirm-modal .modal-dialog,
vellum-forget-device-modal .modal-dialog {
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 8px;
  padding: 1.4rem 1.5rem 1.25rem;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

vellum-confirm-modal .modal-title,
vellum-forget-device-modal .modal-title {
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — confirm-modal heading scales with user preference. */
  font-size: calc(1.15rem * var(--bible-font-scale));
  margin: 0 0 0.5rem;
  color: var(--vellum-ink);
}

vellum-confirm-modal .modal-body {
  margin: 0 0 1.1rem;
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — confirm-modal body text scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
  line-height: 1.5;
}

vellum-confirm-modal .modal-actions,
vellum-forget-device-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

vellum-confirm-modal .modal-actions .btn,
vellum-forget-device-modal .modal-actions .btn {
  padding: 0.45rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  font-family: inherit;
  /* iter-42 REQ-42-005 — modal action button labels scale with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-confirm-modal .modal-actions .btn-destructive,
vellum-forget-device-modal .modal-actions .btn-destructive {
  background: #9a2a2a;
  color: #fff7e8;
  border-color: #9a2a2a;
  font-weight: 600;
}

vellum-confirm-modal .modal-actions .btn-destructive:hover,
vellum-forget-device-modal .modal-actions .btn-destructive:hover {
  filter: brightness(1.08);
}

vellum-forget-device-modal .modal-actions .btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Forget-device body: lead-in, wipe-scope list, reassurance line. Same text
 * treatment as the confirm-modal body. */
vellum-forget-device-modal .modal-help,
vellum-forget-device-modal .wipe-scope,
vellum-forget-device-modal .modal-reassurance {
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — modal body text scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
  line-height: 1.5;
}

vellum-forget-device-modal .modal-help {
  margin: 0 0 0.35rem;
}

vellum-forget-device-modal .wipe-scope {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

vellum-forget-device-modal .modal-reassurance {
  margin: 0 0 1.1rem;
}

vellum-forget-device-modal .modal-unsynced-warning {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(154, 42, 42, 0.4);
  border-radius: 4px;
  background: rgba(154, 42, 42, 0.08);
  color: #9a2a2a;
  font-weight: 600;
  /* iter-42 REQ-42-005 — unsynced warning scales with user preference. */
  font-size: calc(0.92rem * var(--bible-font-scale));
}

/* ---------------------------------------------------------------------------
 * <vellum-cross-ref-preview-modal> — iter-47 / Task #9 cross-reference verse preview.
 * Centered modal overlay (NOT an inline section). Visibility is gated off the
 * `data-modal-status` sentinel (idle = closed) rather than an `[open]`
 * attribute. Mirrors the vellum-confirm-modal overlay pattern.
 * ------------------------------------------------------------------------- */
vellum-cross-ref-preview-modal {
  display: none;
}

vellum-cross-ref-preview-modal:not([data-modal-status="idle"]) {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

vellum-cross-ref-preview-modal .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(43, 33, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

vellum-cross-ref-preview-modal .modal-dialog {
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 8px;
  padding: 1.4rem 1.5rem 1.25rem;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

vellum-cross-ref-preview-modal .modal-title {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: calc(1.15rem * var(--bible-font-scale));
  margin: 0;
  color: var(--vellum-ink);
}

/* Task #9 (req 4) — Book Ch:Vs address sub-label beneath the title. */
vellum-cross-ref-preview-modal .cross-ref-address {
  margin: 0.15rem 0 0.9rem;
  color: var(--vellum-accent);
  font-weight: 600;
  font-size: calc(0.95rem * var(--bible-font-scale));
}

/* Verse text renders as plain prose — the vellum-passage-card chrome (translation
 * switcher, studies chip, per-card close ×) is suppressed inside the preview
 * so only the words show (req 2). data-strongs-disabled already renders the
 * tagged spans as non-clickable plain text. */
vellum-cross-ref-preview-modal vellum-passage-card .passage-card-header {
  display: none;
}

vellum-cross-ref-preview-modal vellum-passage-card .passage-card-body {
  font-size: calc(1rem * var(--bible-font-scale));
  line-height: 1.55;
  color: var(--vellum-ink);
}

vellum-cross-ref-preview-modal vellum-verse-line {
  display: block;
  margin: 0.1rem 0;
}

vellum-cross-ref-preview-modal vellum-verse-line .verse-number {
  font-weight: 600;
  color: var(--vellum-ink-dim);
  margin-right: 0.35rem;
}

/* Task #9 (req 2) — the cross-referenced target verse made visually distinct
 * from its surrounding context window. */
vellum-cross-ref-preview-modal vellum-verse-line.cross-ref-target-verse {
  background: var(--vellum-parchment-dark);
  border-left: 3px solid var(--vellum-accent);
  border-radius: 3px;
  padding: 0.15rem 0.4rem 0.15rem 0.5rem;
}

vellum-cross-ref-preview-modal .modal-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

vellum-cross-ref-preview-modal .modal-actions .btn {
  padding: 0.45rem 1rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  font-family: inherit;
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-cross-ref-preview-modal .modal-actions .btn-add-to-stack {
  background: var(--vellum-accent);
  color: var(--vellum-parchment);
  border-color: var(--vellum-accent);
  font-weight: 600;
}

vellum-cross-ref-preview-modal .modal-actions .btn-add-to-stack:hover {
  filter: brightness(1.08);
}

vellum-cross-ref-preview-modal .modal-actions .btn-add-to-stack[aria-disabled="true"] {
  background: var(--color-success, #5b6f3a);
  border-color: var(--color-success, #5b6f3a);
  cursor: default;
  filter: none;
}

vellum-cross-ref-preview-modal .modal-actions .btn-close {
  margin-left: auto;
}

/* The polite announce region carries no visual weight. */
vellum-cross-ref-preview-modal .cross-ref-promote-announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * <vellum-reader> + <vellum-address-bar> — WI-040 reader chrome.
 * Variant C: typed address bar + persistent "Books ▾" trigger.
 * Mirrors docs/ux/mockups/offline-bible/reader-variant-c-address-bar.html.
 * ------------------------------------------------------------------------- */
vellum-reader {
  display: block;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.5rem 0 1.5rem;
}

/* flex-start: an inline address-bar error grows the bar downward; the Books
 * button stays level with the input instead of re-centering. */
vellum-reader .reader-chrome {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 6px;
  margin-bottom: 1rem;
}

vellum-reader .btn-books-trigger {
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  font-family: inherit;
  /* iter-42 REQ-42-005 — Books trigger label scales with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
  font-weight: 600;
  white-space: nowrap;
}

vellum-reader .btn-books-trigger:hover {
  border-color: var(--vellum-accent);
}

vellum-address-bar {
  display: block;
  flex: 1;
  min-width: 0;
}

/* The suggestion listbox overlays the content below the input instead of
 * pushing it down. z-index 30 sits above the depth meter (5) and footer (10),
 * below the lexicon panel (40) and modals (1000). The combobox controller
 * flips it above the input (bottom: 100%; top: auto) when the on-screen
 * keyboard would cover it. */
vellum-address-bar .address-bar-field {
  position: relative;
}

vellum-address-bar .suggestion-list-anchor {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
}

vellum-address-bar .address-bar-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.7rem;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — address bar input scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

vellum-address-bar .address-bar-input[aria-invalid="true"] {
  border-color: #9a2a2a;
  background: rgba(154, 42, 42, 0.05);
}

vellum-address-bar .address-bar-error {
  margin-top: 0.4rem;
  /* iter-42 REQ-42-005 — address-bar inline error scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
  color: #9a2a2a;
}

vellum-address-bar .address-bar-error a.suggestion {
  color: var(--vellum-accent);
  text-decoration: underline;
  margin-left: 0.35rem;
}

vellum-reader .reader-cards {
  display: block;
}

/* Keeps a card revealed by an address-bar commit clear of the viewport edge. */
vellum-reader .reader-cards > * {
  scroll-margin-top: 1rem;
}

vellum-reader vellum-passage-card {
  display: block;
  padding: 1rem 1.1rem;
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 6px;
  margin-bottom: 0.85rem;
}

/* ---------------------------------------------------------------------------
 * <vellum-passage-card> — header chrome + state bodies (WI-041).
 * Mirrors docs/ux/mockups/offline-bible/reader-selected.html. Minimal viable;
 * full polish lands in WI-047.
 * ------------------------------------------------------------------------- */
vellum-passage-card {
  display: block;
}

vellum-passage-card .passage-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--vellum-rule);
}

vellum-passage-card .card-title-label {
  background: transparent;
  border: 0;
  padding: 0.15rem 0.25rem;
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — passage title button scales with user preference. */
  font-size: calc(1.05rem * var(--bible-font-scale));
  font-weight: 600;
  color: var(--vellum-ink);
  cursor: pointer;
  text-align: left;
}

vellum-passage-card .card-title-label:hover {
  color: var(--vellum-accent);
}

/* The title takes the spare width and is the one header item that may wrap;
 * the chip, the switcher and × keep their natural width. */
vellum-passage-card .passage-card-header > .card-title-label {
  flex: 1 1 auto;
  min-width: 0;
}

/*
 * "Studies · N" chip (studies-feature.md §Chip on passage-card). Pill shape
 * from the reader-studies-panel mockup. nowrap + flex-shrink: 0 keep the
 * label on one line on a narrow card ("Studies ·" / "0" otherwise).
 */
vellum-passage-card .studies-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--vellum-rule);
  border-radius: 999px;
  background: var(--vellum-parchment);
  color: var(--vellum-accent);
  font-family: inherit;
  font-size: calc(0.8rem * var(--bible-font-scale));
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

vellum-passage-card .studies-chip:focus-visible {
  outline: 2px solid var(--vellum-accent);
  outline-offset: 2px;
}

vellum-passage-card .studies-chip:hover {
  background: var(--vellum-parchment-dark);
}

vellum-passage-card .passage-card-header > select.card-translation-switcher,
vellum-passage-card .passage-card-header > .card-close {
  flex: 0 0 auto;
}

/*
 * Click-to-edit input slot (WI-044). Sized to occupy the same line-height
 * and padding box as `.card-title-label` so the button↔input swap induces
 * no layout shift. Inherits the warm-parchment palette.
 */
vellum-passage-card .card-title-input {
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 3px;
  padding: 0.15rem 0.35rem;
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — title input scales with user preference. */
  font-size: calc(1.05rem * var(--bible-font-scale));
  font-weight: 600;
  color: var(--vellum-ink);
  /* iter-42 REQ-42-008 — unitless multiplier ≥ 1.5 for a11y line-spacing.
   * Unitless so the line box scales with computed font-size (and therefore
   * with --bible-font-scale). */
  line-height: 1.5;
}

vellum-passage-card .card-title-input[aria-invalid="true"] {
  border-color: var(--vellum-error, #b94a48);
  outline-color: var(--vellum-error, #b94a48);
}

vellum-passage-card .card-title-error {
  margin-left: 0.5rem;
  color: var(--vellum-error, #b94a48);
  /* iter-42 REQ-42-005 — title validation error scales with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-passage-card .card-title-error + .suggestion,
vellum-passage-card .suggestion {
  margin-left: 0.5rem;
  color: var(--vellum-accent);
  /* iter-42 REQ-42-005 — suggestion link scales with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

/*
 * SR-only utility (WI-044 a11y). Matches the standard SR-only recipe so
 * #card-focus-live, #edit-mode-live, and #address-bar-help are visually
 * hidden but still announced by AT.
 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/*
 * Fallback notice (WI-044 AC 14, 15). Surfaced in the card body when the
 * requested translation is unavailable; layered over the rendered fallback
 * content (default branch) or the "unavailable" notice (hard-fail branch).
 */
vellum-passage-card .passage-fallback-notice {
  margin: 0.4rem 0;
  padding: 0.4rem 0.6rem;
  background: var(--vellum-warning-bg, #faf3e0);
  border-left: 3px solid var(--vellum-warning, #d6a45c);
  color: var(--vellum-ink);
  /* iter-42 REQ-42-005 — fallback notice banner scales with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
  font-style: italic;
}

vellum-passage-card select.card-translation-switcher {
  padding: 0.3rem 0.55rem;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — per-card translation switcher scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

vellum-passage-card select.card-translation-switcher:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

vellum-passage-card .passage-card-body {
  display: block;
}

/*
 * Range-card inline structural markers (REQ-43-004 / WI-013).
 *
 * Hierarchy invariant (C-43-004 lock, range-card-body-spec.md §"Visual
 * treatment"): book and chapter markers SHARE the same font-size; the
 * distinction is via weight (700 vs 500) and color (full ink vs dim ink),
 * never via size. Both stay subordinate to the card title at every
 * --bible-font-scale.
 */
vellum-passage-card .passage-book-marker {
  margin: 1.8rem 0 0.4rem;
  padding-top: 0.4rem;
  border-top: 2px solid var(--vellum-accent);
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 700;
  font-size: calc(0.95rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

vellum-passage-card .passage-chapter-marker {
  margin: 1.4rem 0 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--vellum-rule);
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 500;
  font-size: calc(0.95rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

vellum-passage-card .passage-chapter-section {
  display: block;
}

vellum-passage-card .passage-pending-hint {
  margin: 0.4rem 0 0.25rem;
  color: var(--vellum-ink-dim);
  font-style: italic;
  /* iter-42 REQ-42-005 — pending-load hint scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
}

vellum-passage-card .passage-pending-progress {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  /* iter-42 REQ-42-005 — pending progress numeric scales with user preference. */
  font-size: calc(0.82rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  font-variant-numeric: tabular-nums;
}

vellum-passage-card .passage-error-message {
  margin: 0.4rem 0 0.6rem;
  color: #9a2a2a;
  /* iter-42 REQ-42-005 — passage error text scales with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-passage-card .passage-retry {
  padding: 0.3rem 0.85rem;
  background: transparent;
  border: 1px solid var(--vellum-accent);
  color: var(--vellum-accent);
  border-radius: 4px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — retry button scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
  cursor: pointer;
}

vellum-passage-card .passage-retry:hover {
  background: var(--vellum-accent);
  color: #fff7e8;
}

/* ---------------------------------------------------------------------------
 * <vellum-verse-line> — verse number adjacent to verse text (WI-041).
 * Strong's-tagged spans (data-strongs) render with NO visual decoration per
 * REQ-33-007 AC 4 — they look identical to untagged spans.
 * ------------------------------------------------------------------------- */
vellum-verse-line {
  display: block;
  margin: 0.25rem 0;
  line-height: 1.65;
  /* iter-42 REQ-42-005 — primary readable surface scales with user preference. */
  font-size: calc(1rem * var(--bible-font-scale));
}

vellum-verse-line .verse-number {
  display: inline-block;
  min-width: 1.5em;
  margin-right: 0.35em;
  color: var(--vellum-accent);
  font-weight: 600;
  font-size: 0.78em;
  vertical-align: baseline;
  font-variant-numeric: tabular-nums;
}

vellum-verse-line .verse-text {
  color: var(--vellum-ink);
}

/* Passage picker modal ("Books ▾", "+ Add passage", "Choose a passage"). The
 * backdrop spans the viewport so "click outside the dialog" hits the backdrop
 * element (target===currentTarget) for the cancel path. */
vellum-books-drawer-modal {
  display: none;
}

vellum-books-drawer-modal[open] {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

vellum-books-drawer-modal[open] .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

vellum-books-drawer-modal .modal-dialog {
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 8px;
  padding: 1.4rem 1.5rem 1.25rem;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
}

vellum-books-drawer-modal .modal-title {
  margin: 0 0 0.85rem;
  /* iter-42 REQ-42-005 — picker title scales with user preference. */
  font-size: calc(1.1rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

vellum-books-drawer-modal .modal-body {
  color: var(--vellum-ink-dim);
  font-size: calc(0.95rem * var(--bible-font-scale));
  margin: 0 0 1rem;
}

vellum-books-drawer-modal .book-grid,
vellum-books-drawer-modal .chapter-grid {
  display: grid;
  gap: 0.4rem;
}

vellum-books-drawer-modal .book-grid {
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
}

vellum-books-drawer-modal .chapter-grid {
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr));
}

vellum-books-drawer-modal .book-btn,
vellum-books-drawer-modal .chapter-btn,
vellum-books-drawer-modal .modal-back,
vellum-books-drawer-modal .btn-cancel {
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--vellum-rule);
  background: var(--vellum-parchment);
  color: var(--vellum-ink);
  cursor: pointer;
  font-family: inherit;
  /* iter-42 REQ-42-005 — picker buttons scale with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-books-drawer-modal .book-btn {
  text-align: left;
}

vellum-books-drawer-modal .modal-back {
  margin-bottom: 0.75rem;
}

vellum-books-drawer-modal .book-btn:hover,
vellum-books-drawer-modal .chapter-btn:hover,
vellum-books-drawer-modal .book-btn:focus-visible,
vellum-books-drawer-modal .chapter-btn:focus-visible {
  border-color: var(--vellum-accent);
  color: var(--vellum-accent);
}

vellum-welcome .err-detail {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  /* iter-42 REQ-42-005 — welcome error detail scales with user preference. */
  font-size: calc(0.78rem * var(--bible-font-scale));
  background: rgba(154, 42, 42, 0.06);
  border: 1px solid rgba(154, 42, 42, 0.25);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  color: var(--vellum-ink);
  text-align: left;
  margin-top: 0.85rem;
}

/* ---------------------------------------------------------------------------
 * WI-043 — card stack management chrome.
 *   - Vertical stack layout (one card per row).
 *   - `+ Add passage` button below the stack.
 *   - Per-card "×" close button in the header.
 *   - iter-40 WI-016: cap removed (ADR-40-005); virtualization beyond
 *     CARD_VIRTUALIZATION_THRESHOLD=50 cards via IntersectionObserver.
 * ------------------------------------------------------------------------- */

vellum-reader .btn-add-passage {
  display: inline-block;
  margin: 0.5rem 0 1rem 0;
  padding: 0.45rem 0.85rem;
  background: var(--vellum-parchment);
  border: 1px dashed var(--vellum-rule);
  border-radius: 4px;
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — add-passage button label scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
  color: var(--vellum-ink);
  cursor: pointer;
}

vellum-reader .btn-add-passage:hover {
  background: var(--vellum-parchment-dark);
  border-style: solid;
  color: var(--vellum-accent);
}

/* Hidden while the stack is empty; the empty state's CTA takes its place. */
vellum-reader .btn-add-passage[hidden] {
  display: none;
}

vellum-passage-card .card-close {
  background: transparent;
  border: 0;
  padding: 0.1rem 0.4rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--vellum-ink);
  cursor: pointer;
  border-radius: 3px;
}

vellum-passage-card .card-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--vellum-accent);
}

vellum-passage-card[data-card-state="empty"] .passage-empty-hint {
  font-style: italic;
  color: var(--vellum-ink-soft, var(--vellum-ink));
  margin: 0;
  padding: 1rem 0;
  text-align: center;
}

/* ---------------------------------------------------------------------------
 * WI-003: <vellum-auth-form> styles (warm-parchment palette consistent with
 * SCREEN-34-001/002/003). Light-DOM, scoped via the host element selector.
 * ------------------------------------------------------------------------- */

vellum-auth-form {
  display: block;
  max-width: 28rem;
  margin: 4rem auto;
  padding: 2rem 2.5rem;
  background: var(--vellum-parchment-dark);
  border: 1px solid var(--vellum-rule);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

vellum-auth-form .vellum-wordmark {
  font-family: Georgia, "Iowan Old Style", serif;
  /* iter-42 REQ-42-005 — auth form wordmark scales with user preference. */
  font-size: calc(2rem * var(--bible-font-scale));
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--vellum-ink);
  text-align: center;
  margin-bottom: 0.5rem;
}

vellum-auth-form .vellum-auth-subhead {
  text-align: center;
  color: var(--vellum-ink-dim);
  margin: 0 0 1.5rem 0;
  /* iter-42 REQ-42-005 — auth subhead scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
}

vellum-auth-form .vellum-auth-banner {
  background: #e6d8a8;
  border: 1px solid var(--vellum-rule);
  color: var(--vellum-ink);
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border-radius: 3px;
  /* iter-42 REQ-42-005 — re-auth/status banner scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
}

vellum-auth-form .vellum-auth-alert {
  display: none;
  background: #f8d7d4;
  border: 1px solid #b06a55;
  color: #5a1f12;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border-radius: 3px;
  /* iter-42 REQ-42-005 — auth alert copy scales with user preference. */
  font-size: calc(0.95rem * var(--bible-font-scale));
}

vellum-auth-form .vellum-auth-alert.show {
  display: block;
}

vellum-auth-form .vellum-form-group {
  margin-bottom: 1rem;
}

vellum-auth-form .vellum-form-group label {
  display: block;
  font-weight: 600;
  color: var(--vellum-ink);
  margin-bottom: 0.25rem;
  /* iter-42 REQ-42-005 — form labels scale with user preference. */
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-auth-form .vellum-form-group input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  background: var(--vellum-parchment);
  border: 1px solid var(--vellum-rule);
  border-radius: 3px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — form input value text scales with user preference. */
  font-size: calc(1rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

vellum-auth-form .vellum-form-group input[readonly] {
  background: var(--vellum-parchment-dark);
  color: var(--vellum-ink-dim);
}

vellum-auth-form .vellum-form-group input[aria-invalid="true"] {
  border-color: #b06a55;
}

vellum-auth-form .vellum-auth-hint {
  margin: 0.25rem 0 0 0;
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — auth form hint scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
}

vellum-auth-form .vellum-auth-field-error {
  margin: 0.25rem 0 0 0;
  color: #5a1f12;
  /* iter-42 REQ-42-005 — field error scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
}

/* The slot stays mounted as a live region; take no space while empty. */
vellum-auth-form .vellum-auth-field-error:empty {
  margin: 0;
}

vellum-auth-form .vellum-auth-submit {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--vellum-accent);
  color: var(--vellum-parchment);
  border: none;
  border-radius: 3px;
  font-family: inherit;
  /* iter-42 REQ-42-005 — submit button label scales with user preference. */
  font-size: calc(1rem * var(--bible-font-scale));
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

vellum-auth-form .vellum-auth-submit:hover {
  filter: brightness(0.95);
}

vellum-auth-form .vellum-auth-help {
  margin: 1rem 0 0 0;
  text-align: center;
  color: var(--vellum-ink-dim);
  /* iter-42 REQ-42-005 — auth help link row scales with user preference. */
  font-size: calc(0.85rem * var(--bible-font-scale));
}

/*
 * iter-40 WI-019 — App-shell footer (ADR-40-008 §1, §2).
 *
 * Sticky to viewport bottom so the attribution + About link are always
 * reachable in <=1 click (NFR-40-005). Z-index ordering pin (advisory rec 1):
 *
 *   vellum-stack-depth-meter (z=5) < .vellum-footer (z=10) < vellum-lexicon-panel (z=40)
 *     < vellum-confirm-modal[open] (z=1000)
 *
 * Other overlays sit in the same bands: vellum-studies-panel (z=50, a
 * floating card that may sit over the docked lexicon panel) and
 * vellum-studies-delete-modal[open] (z=200), both in studies.css.
 *
 * The numeric magnitudes are chosen to leave room for future reader chrome
 * insertions; the strict ordering is what the test pins.
 */
.vellum-footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  /* #main-app is a flex column at least one viewport tall: on a short page
   * the auto margin takes the spare height, so the footer sits at the
   * viewport bottom instead of right under the content. */
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--vellum-parchment, var(--surface, #f6efe1));
  border-top: 1px solid var(--vellum-border, var(--divider, #d8caa9));
  /* iter-42 REQ-42-005 — app-shell footer attribution scales with user preference. */
  font-size: calc(0.8125rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim, var(--text-muted, #6b5b46));
}

.vellum-footer .vellum-footer-attribution {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vellum-footer .footer-link {
  color: var(--vellum-accent, var(--color-accent, #a04a2a));
  text-decoration: none;
  font-weight: 500;
  flex-shrink: 0;
}

.vellum-footer .footer-link:hover,
.vellum-footer .footer-link:focus-visible {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * iter-43 WI-021 — migration write-gate (REQ-43-010 / ADR-43-016).
 *
 * When `<vellum-migration-banner>` toggles
 * `html.bible-migration-in-progress`, cardstack-mutating affordances are
 * visually disabled (defense-in-depth on top of the reducer-level guard).
 * Affordance inventory is enumerated explicitly here per WI-021 risk note.
 * --------------------------------------------------------------------------- */
html.bible-migration-in-progress vellum-address-bar .address-bar-input,
html.bible-migration-in-progress vellum-passage-card .card-title-label,
html.bible-migration-in-progress vellum-passage-card .card-close,
html.bible-migration-in-progress vellum-passage-card select.card-translation-switcher {
  opacity: 0.5;
  pointer-events: none;
}

/* <vellum-reauth-banner>: a card fixed above the footer, so the expired
 * session prompt is in view on every route and does not move the page. It
 * opens only while a stale token is held; with no token the full sign-in
 * form is shown instead. */
vellum-reauth-banner:not([open]) {
  display: none;
}

vellum-reauth-banner[open] {
  display: block;
  position: fixed;
  left: 50%;
  bottom: 3.25rem;
  transform: translateX(-50%);
  width: min(26rem, calc(100vw - 2rem));
  box-sizing: border-box;
  z-index: 150;
  padding: 0.9rem 1rem 1rem;
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(40, 25, 10, 0.25);
  color: var(--vellum-ink);
}

vellum-reauth-banner .vellum-reauth-heading {
  margin: 0 0 0.6rem;
  font-size: calc(1.05rem * var(--bible-font-scale));
  font-weight: 700;
}

vellum-reauth-banner .vellum-reauth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

vellum-reauth-banner .vellum-reauth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-weight: 600;
  font-size: calc(0.9rem * var(--bible-font-scale));
}

vellum-reauth-banner .vellum-reauth-form input {
  font-family: inherit;
  font-size: calc(1rem * var(--bible-font-scale));
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  background: var(--vellum-parchment-soft);
  color: var(--vellum-ink);
}

vellum-reauth-banner .vellum-reauth-error {
  margin: 0;
  color: var(--vellum-danger);
  font-size: calc(0.85rem * var(--bible-font-scale));
}

vellum-reauth-banner .vellum-reauth-error:empty {
  display: none;
}

vellum-reauth-banner .vellum-reauth-submit {
  align-self: flex-end;
}

/* WI-009 (iter-40 phase-2) — <vellum-lexicon-panel> styles.
 *
 * Two form factors driven by a single 768px breakpoint:
 *   - Desktop (>=768px): docked right side panel, full viewport height,
 *     width --vellum-lexicon-panel-width. It overlays the right end of the
 *     appbar; app.css pads the appbar by the same width while the panel is
 *     open, so the tabs and the sync pill stay visible and usable.
 *   - Mobile  (<768px):  bottom sheet, ~62% viewport height, with grip.
 *
 * The rules below are written against the generic --color-* / --font-*
 * names. app.css does not define those names (the app palette is
 * --vellum-*), so the panel hosts map them to the app tokens here. Without
 * this map the hosts fell back to a system sans-serif and the cross-refs
 * disclosure buttons to browser defaults.
 */

vellum-lexicon-panel {
    display: none;
    box-sizing: border-box;
    background: var(--color-base);
    color: var(--color-text);
    font-family: var(--font-body);
    border: 1px solid var(--color-border);
    flex-direction: column;
    min-height: 0;
    z-index: 40;
}

vellum-lexicon-panel,
vellum-study-lexicon-block {
    --color-base: var(--vellum-card-bg);
    --color-surface: var(--vellum-parchment);
    --color-text: var(--vellum-ink);
    --color-text-muted: var(--vellum-ink-dim);
    --color-accent: var(--vellum-accent);
    --color-accent-soft: var(--vellum-accent-soft);
    --color-border: var(--vellum-rule-soft);
    --font-body: Georgia, "Iowan Old Style", serif;
    --font-heading: Georgia, "Iowan Old Style", serif;
    --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas,
                 'Liberation Mono', monospace;
}

/* Open: visible. The component sets data-bible-lexicon-panel-open on <html>;
 * panel chrome existence drives visibility — when closed, the panel renders
 * no children (an :empty match would also work but is more brittle). */
html[data-bible-lexicon-panel-open="true"] vellum-lexicon-panel {
    display: flex;
}

/* ---------------- Desktop docked-right (>=768px) ---------------- */
@media (min-width: 768px) {
    vellum-lexicon-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: var(--vellum-lexicon-panel-width);
        border-radius: 0;
        border-top: 0;
        border-bottom: 0;
        border-right: 0;
        box-shadow: -2px 0 6px rgba(0, 0, 0, 0.04);
    }
}

/* ---------------- Mobile bottom sheet (<768px) ---------------- */
@media (max-width: 767.98px) {
    vellum-lexicon-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 62vh;
        max-height: 72vh;
        border-radius: 14px 14px 0 0;
        border-top: 1px solid var(--color-border, #d8caa9);
        border-bottom: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.1);
    }
    /* Grip cue — produced by ::before since the component renders no
     * dedicated grip element. Larger transparent hit area extends below the
     * visible bar (mockup §NFR-40-004: 44x24px effective tap target). */
    vellum-lexicon-panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        margin: 0.45rem auto 0.2rem;
        background: var(--color-border, #d8caa9);
        border-radius: 2px;
        flex-shrink: 0;
    }
}

/* ---------------- Chrome ---------------- */
vellum-lexicon-panel .panel-chrome {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid var(--color-border, #d8caa9);
}
vellum-lexicon-panel .panel-title {
    flex: 1;
    font-family: var(--font-heading, Georgia, 'Times New Roman', serif);
    /* iter-42 REQ-42-005 — panel chrome title scales with user preference. */
    font-size: calc(0.95rem * var(--bible-font-scale));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
vellum-lexicon-panel .icon-btn,
vellum-lexicon-panel .panel-close {
    background: transparent;
    border: 0;
    color: var(--color-text-muted, #6b5b46);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 1rem;
}
vellum-lexicon-panel .icon-btn:hover,
vellum-lexicon-panel .panel-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ---------------- Tab strip ---------------- */
vellum-lexicon-panel .tab-strip {
    display: flex;
    gap: 0.15rem;
    padding: 0.3rem 0.5rem 0;
    border-bottom: 1px solid var(--color-border, #d8caa9);
    overflow-x: auto;
}
vellum-lexicon-panel .tab-strip .tab {
    font-family: var(--font-body);
    /* iter-42 REQ-42-005 — lexicon tab labels scale with user preference. */
    font-size: calc(0.82rem * var(--bible-font-scale));
    padding: 0.35rem 0.7rem;
    border: 1px solid transparent;
    border-bottom: 0;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    color: var(--color-text-muted, #6b5b46);
    white-space: nowrap;
    background: transparent;
}
vellum-lexicon-panel .tab-strip .tab[aria-selected="true"] {
    background: var(--color-base, #f6efe1);
    border-color: var(--color-border, #d8caa9);
    color: var(--color-text, #3a2e1f);
    position: relative;
    bottom: -1px;
}
vellum-lexicon-panel .tab-strip .tab .tab-label {
    font-family: var(--font-heading, Georgia, serif);
}

/* ---------------- Body ---------------- */
vellum-lexicon-panel .panel-body {
    padding: 0.7rem 0.85rem 1rem;
    overflow-y: auto;
    flex: 1;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lemma-row {
    margin-bottom: 0.2rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lemma {
    font-family: var(--font-heading, Georgia, serif);
    /* iter-42 REQ-42-005 — lemma hero scales with user preference. */
    font-size: calc(1.6rem * var(--bible-font-scale));
    color: var(--color-accent, #a04a2a);
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .translit {
    font-style: italic;
    margin-left: 0.35rem;
    color: var(--color-text, #3a2e1f);
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .id-tag {
    display: inline-block;
    font-family: var(--font-body);
    /* iter-42 REQ-42-005 — Strong's # pill (iter-41 primary identifier) scales with user preference. */
    font-size: calc(0.72rem * var(--bible-font-scale));
    color: var(--color-text-muted, #6b5b46);
    border: 1px solid var(--color-border, #d8caa9);
    border-radius: 999px;
    padding: 0.05rem 0.45rem;
    margin-left: 0.45rem;
    vertical-align: middle;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .pron {
    color: var(--color-text-muted, #6b5b46);
    /* iter-42 REQ-42-005 — pronunciation row scales with user preference. */
    font-size: calc(0.85rem * var(--bible-font-scale));
    margin: 0.1rem 0 0.4rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .gloss {
    font-style: italic;
    color: var(--color-text-muted, #6b5b46);
    margin: 0.3rem 0 0.6rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .field-row {
    /* iter-42 REQ-42-005 — field rows (POS, KJV usage, etc.) scale with user preference. */
    font-size: calc(0.84rem * var(--bible-font-scale));
    margin: 0.25rem 0;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .field-row b {
    color: var(--color-text-muted, #6b5b46);
    font-weight: 600;
    margin-right: 0.25rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .definition {
    /* iter-42 REQ-42-005 — definition body scales with user preference. */
    font-size: calc(0.92rem * var(--bible-font-scale));
    margin: 0.25rem 0 0;
    line-height: 1.55;
}

/* iter-40 WI-040-fixup polish: labeled section structure for the
 * lexicon entry body. Each field (pronunciation / gloss / POS / KJV
 * usage / definition / xrefs) gets a small caption-style label above
 * its body so readers can tell sections apart. */
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-section {
    margin: 0.7rem 0 0;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-section__label {
    /* iter-42 REQ-42-005 — section caption labels scale with user preference. */
    font-size: calc(0.72rem * var(--bible-font-scale));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted, var(--vellum-ink-dim, #6b5b46));
    margin: 0 0 0.15rem;
}

/* HTML elements that may appear inside any section body when the
 * STEPBible-Data source ships formatting markup. Defaults are mostly
 * fine; a couple of targeted rules improve readability. */
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-section :is(b, strong) { font-weight: 600; }
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-section :is(i, em) { font-style: italic; }
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-section ref {
    color: var(--vellum-accent, #a04a2a);
    font-style: italic;
    cursor: default;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .xrefs {
    margin: 0.5rem 0;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .xref-chip {
    display: inline-block;
    color: var(--color-accent, #a04a2a);
    border: 1px solid var(--color-border, #d8caa9);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    /* iter-42 REQ-42-005 — cross-reference chips scale with user preference. */
    font-size: calc(0.82rem * var(--bible-font-scale));
    margin: 0.1rem 0.2rem 0.1rem 0;
    text-decoration: none;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .xref-chip:hover {
    background: rgba(160, 74, 42, 0.08);
}

/* ---------------- iter-41 sense card chrome (REQ-41-001) ----------------
 *
 * Every sense — single or multi — renders inside a card with an accent
 * left "spine". Multi-sense cards add a muted ordinal numeral + "of N"
 * counter to the header line; single-sense cards omit those (they
 * carry no information at N=1). The variant-key chip is the uniform
 * primary chrome across both paths. See docs/ux/iteration-41/.
 */
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense--card {
    position: relative;
    margin: 0.9rem 0 0;
    padding: 0.55rem 0.65rem 0.65rem 0.9rem;
    background: var(--vellum-parchment, #f5ecd7);
    border: 1px solid var(--vellum-rule, #c9b890);
    border-left: 4px solid var(--vellum-accent, #8a4a2a);
    border-radius: 4px;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense--card:first-of-type {
    margin-top: 0.6rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0 0 0.35rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--vellum-rule, #c9b890);
    font-family: var(--font-heading, Georgia, 'Times New Roman', serif);
    /* iter-42 REQ-42-005 — sense card header scales with user preference. */
    font-size: calc(0.95rem * var(--bible-font-scale));
    font-weight: 600;
    color: var(--vellum-ink, #2b2118);
}
/* Sequential ordinal: muted secondary chrome — small monospace text on
 * the card surface, no pill background. The variant-key chip carries
 * primary identity uniformly across single and multi-sense cards. */
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__ordinal {
    display: inline-block;
    min-width: 1rem;
    padding: 0 0.15rem;
    color: var(--color-text-muted, #6b5b46);
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    /* iter-42 REQ-42-005/006 — preserve iter-41 hierarchy across scale settings. */
    font-size: calc(0.78rem * var(--bible-font-scale));
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.02em;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__variant-key {
    display: inline-block;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    /* iter-42 REQ-42-005/006 — primary identity chip scales with user preference. */
    font-size: calc(0.78rem * var(--bible-font-scale));
    font-weight: 600;
    color: var(--vellum-accent, #8a4a2a);
    background: var(--vellum-parchment-dark, #e8dcc0);
    border: 1px solid var(--vellum-rule, #c9b890);
    border-radius: 3px;
    padding: 0.1rem 0.4rem;
    line-height: 1.5;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__of-n {
    font-family: var(--font-body);
    /* iter-42 REQ-42-005 — "of N" caption scales with user preference. */
    font-size: calc(0.74rem * var(--bible-font-scale));
    font-weight: 400;
    color: var(--color-text-muted, #6b5b46);
    letter-spacing: 0.02em;
    /* iter-42 REQ-42-008 — explicit unitless line-height ≥ 1.5 for a11y. */
    line-height: 1.5;
}
/* Dense tier (4+ senses) tightens internal spacing. */
:is(vellum-lexicon-panel, vellum-study-lexicon-block)[data-density="dense"] .lexicon-sense--card {
    padding: 0.45rem 0.55rem 0.55rem 0.8rem;
    margin-top: 0.6rem;
}
:is(vellum-lexicon-panel, vellum-study-lexicon-block)[data-density="dense"] .lexicon-section {
    margin-top: 0.4rem;
}
/* Forced-colors fallback: spine becomes a solid border so the card is
 * still a clear unit when accent is overridden; ordinal + of-N fall
 * back to GrayText so they don't out-shout the variant-key chip. */
@media (forced-colors: active) {
    :is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense--card {
        border: 1px solid CanvasText;
        border-left-width: 4px;
    }
    :is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__ordinal,
    :is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__of-n {
        background: transparent;
        color: GrayText;
    }
    :is(vellum-lexicon-panel, vellum-study-lexicon-block) .lexicon-sense__variant-key {
        background: Canvas;
        color: CanvasText;
    }
}

/* ---------------- Skeleton (loading) ---------------- */
vellum-lexicon-panel .skeleton {
    padding: 0.4rem 0;
}
vellum-lexicon-panel .skeleton-line {
    height: 0.95rem;
    background: linear-gradient(
        90deg,
        var(--color-surface, #efe5d1) 0%,
        rgba(0, 0, 0, 0.04) 50%,
        var(--color-surface, #efe5d1) 100%
    );
    background-size: 200% 100%;
    border-radius: 3px;
    margin: 0.3rem 0;
    animation: lexicon-panel-shimmer 1.4s linear infinite;
}
vellum-lexicon-panel .skeleton-line-lemma { width: 45%; height: 1.5rem; }
vellum-lexicon-panel .skeleton-line-gloss { width: 70%; }
vellum-lexicon-panel .skeleton-line-def   { width: 95%; }
@keyframes lexicon-panel-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    vellum-lexicon-panel .skeleton-line {
        animation: none;
        background: var(--color-surface, #efe5d1);
    }
}

/* ---------------- Error / not-found ---------------- */
vellum-lexicon-panel .panel-error,
vellum-lexicon-panel .not-found {
    padding: 1rem 0.5rem;
}
vellum-lexicon-panel .panel-error-message {
    color: var(--color-text-muted, #6b5b46);
    /* iter-42 REQ-42-005 — panel error message scales with user preference. */
    font-size: calc(0.9rem * var(--bible-font-scale));
    margin: 0 0 0.7rem;
}
vellum-lexicon-panel .retry,
vellum-lexicon-panel .not-found-close {
    display: inline-block;
    border: 1px solid var(--color-border, #d8caa9);
    background: transparent;
    color: var(--color-accent, #a04a2a);
    padding: 0.3rem 0.8rem;
    border-radius: 3px;
    cursor: pointer;
    /* iter-42 REQ-42-005 — retry / not-found-close buttons scale with user preference. */
    font-size: calc(0.9rem * var(--bible-font-scale));
}
vellum-lexicon-panel .not-found-heading {
    font-family: var(--font-heading, Georgia, serif);
    /* iter-42 REQ-42-005 — not-found heading scales with user preference. */
    font-size: calc(1.1rem * var(--bible-font-scale));
    color: var(--color-text, #3a2e1f);
    margin-bottom: 0.4rem;
}
vellum-lexicon-panel .not-found-body {
    /* iter-42 REQ-42-005 — not-found body copy scales with user preference. */
    font-size: calc(0.88rem * var(--bible-font-scale));
    color: var(--color-text-muted, #6b5b46);
    margin-bottom: 0.9rem;
}

/* iter-47 cross-refs tab (Phase 7 / WI-018) */
/* Ported from docs/ux/mockups/offline-bible/iter-47/cross-ref-tab-default.html
 * lines 153-216. Mock hex literals mapped to design-system tokens
 * (docs/ux/design-system/offline-bible/tokens.css). The two disclosure
 * selectors (collapse + chevron rotation) ship here so WI-019's click
 * handler has selectors to bind to — they are no-ops until then. */

.cross-refs-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.25rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.6rem;
    font-family: var(--font-heading);
}

.cross-refs-total {
    font-family: var(--font-mono);
    font-size: calc(0.76rem * var(--bible-font-scale));
    background: var(--color-accent);
    color: var(--color-base);
    border: 1px solid var(--color-accent);
    padding: 0.02rem 0.4rem;
    border-radius: 999px;
}

.testament-group {
    margin: 0.35rem 0 0.35rem 0.25rem;
}

.testament-header {
    font-family: var(--font-heading);
    font-size: calc(0.92rem * var(--bible-font-scale));
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

/* The testament and book headers are <button> disclosure triggers. Strip the
 * browser button chrome (border, grey fill, centred text) so they read as
 * row headings, as .disc-btn does. */
.testament-header,
.book-header {
    display: block;
    width: 100%;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.25rem;
    text-align: left;
    cursor: pointer;
}

.testament-header {
    background: transparent;
    font-weight: 600;
}

.testament-header:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.testament-body {
    /* Scroll container for sticky .book-header children. */
    position: relative;
}

.book {
    margin: 0.15rem 0 0.25rem 1rem;
}

.book-header {
    position: sticky;
    top: 0;
    background: linear-gradient(
        to bottom,
        var(--color-base) 80%,
        transparent
    );
    z-index: 1;
    padding-top: 0.15rem;
    font-family: var(--font-heading);
    font-size: calc(0.88rem * var(--bible-font-scale));
    color: var(--color-text);
}

.book-header:hover {
    color: var(--color-accent);
}

.book-body {
    /* Container for chip-row children; sits beneath the sticky header. */
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.3rem;
    padding: 0.25rem 0 0.5rem 1.5rem;
}

.verse-chip {
    font-family: var(--font-mono);
    font-size: calc(0.78rem * var(--bible-font-scale));
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--color-border);
    background: var(--color-base);
    color: var(--color-accent);
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
}

.verse-chip:hover {
    background: var(--color-surface);
    border-color: var(--color-accent-soft);
}

.verse-chip:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Disclosure trigger button (testament + book rows) — WI-019 will wire the
 * click handler that flips aria-expanded; styling ships now. */
.disc-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 0;
    padding: 0.35rem 0.25rem;
    cursor: pointer;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    border-radius: var(--radius-sm);
}

.disc-btn:hover {
    background: var(--color-surface);
}

.disc-btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.disc-btn .chevron {
    color: var(--color-accent);
    display: inline-block;
    width: 0.8em;
    transition: transform 0.15s;
}

.disc-btn[aria-expanded="true"] .chevron {
    transform: rotate(90deg);
}

.disc-region {
    /* Container revealed/collapsed by the adjacent-sibling rule below. */
}

.disc-btn[aria-expanded="false"] + .disc-region {
    display: none;
}

/* Loading + empty advisory states reuse the panel chrome but get their own
 * hook for theme + spacing overrides. */
.loading {
    padding: 0.6rem 0.25rem;
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: calc(0.9rem * var(--bible-font-scale));
}

.empty {
    padding: 0.6rem 0.25rem;
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: calc(0.9rem * var(--bible-font-scale));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* WI-010 (iter-40 phase-2) — tagged-span affordance.
 *
 * Verse spans carrying `data-strongs` are clickable: they open the
 * `<vellum-lexicon-panel>` for the associated Strong's id(s). The dotted underline
 * in the design-system accent colour signals interactivity without the
 * visual weight of a full underline.
 */

[data-strongs] {
    text-decoration: underline dotted #a04a2a;
    text-decoration-thickness: 1.5px;
    cursor: pointer;
}

/* WI-006 (iter-47, ADR-47-003 / COMP-47-005) — suppression mode.
 *
 * When a <vellum-passage-card> carries the boolean attribute
 * `data-strongs-disabled`, descendant `[data-strongs]` spans MUST render
 * without the clickable affordance (no dotted underline, default cursor).
 * Inner spans themselves are not mutated — the host attribute alone gates
 * the visual treatment so the state is fully reversible. The click
 * delegate's runtime guard lives in vellum-passage-card.js.
 */
vellum-passage-card[data-strongs-disabled] [data-strongs] {
    text-decoration: none;
    cursor: default;
}

vellum-passage-card[data-strongs-disabled] [data-strongs]:hover {
    text-decoration: none;
    cursor: default;
}

/* vellum-search-results-card — WI-015 (iter-40 phase-3).
 *
 * Variant 4B locked: grouped-by-book, first 3 rows per group, "Show N more"
 * expansion. Mirrors the iter-40-search-results-card.html mockup. Senior
 * developer fills in concrete rules in the implementation step.
 *
 * Pinned styles (loading/empty/error state visual parity) live alongside
 * the component class names enumerated in vellum-search-results-card.js.
 */

/* Card chrome shell — stub placeholder. */
vellum-search-results-card {
    display: block;
}

/* Loading state — skeleton + spinner. */
vellum-search-results-card[data-card-state="loading"] .loading-body {
    /* placeholder */
}

/* Empty state — "no matches" body. */
vellum-search-results-card[data-card-state="empty"] .empty-body {
    /* placeholder */
}

/* Error state — retry affordance. */
vellum-search-results-card[data-card-state="error"] .error-body {
    /* placeholder */
}

/* Grouped-by-book ready body. */
vellum-search-results-card[data-card-state="ready"] .group {
    /* placeholder */
}

vellum-search-results-card .verse-ref-chip,
vellum-search-results-card [data-verse-ref-chip] {
    /* placeholder — verse-ref chip styling */
}

/*
 * vellum-stack-depth-meter — sticky depth indicator for the bible reader chrome.
 * Iter-40 WI-017 (REQ-40-009 UX support, NFR-40-006, ADR-40-005 §3,
 * SCREEN-40-004, COMP-40-009).
 *
 * Visibility is driven by the component itself (it renders empty children
 * below the 6-card threshold). The sticky positioning anchors the meter to
 * the top of the reader chrome so the "card N of M" indicator + bulk-compact
 * affordance remain visible while scrolling through a deep card stack.
 */

vellum-stack-depth-meter {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 0.5rem 0.75rem;
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--divider, #e5e5e5);
    /* iter-42 REQ-42-005 — sticky depth-meter wrapper text scales with user preference. */
    font-size: calc(0.875rem * var(--bible-font-scale));
    color: var(--text-muted, #555);
}

vellum-stack-depth-meter:empty {
    display: none;
}

vellum-stack-depth-meter .stack-depth-label {
    display: inline-block;
    margin-right: 0.75rem;
    font-weight: 500;
}

vellum-stack-depth-meter .stack-depth-bulk-compact {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    /* iter-42 REQ-42-005 — bulk-compact button scales with user preference. */
    font-size: calc(0.8125rem * var(--bible-font-scale));
    /* iter-42 REQ-42-008 — unitless multiplier ≥ 1.5 for a11y line-spacing. */
    line-height: 1.5;
    color: var(--text, #222);
    background: transparent;
    border: 1px solid var(--divider, #ccc);
    border-radius: 3px;
    cursor: pointer;
}

vellum-stack-depth-meter .stack-depth-bulk-compact:hover {
    background: var(--surface-hover, #f3f3f3);
}

vellum-stack-depth-meter .stack-depth-bulk-compact:focus-visible {
    outline: 2px solid var(--focus-ring, #4a90e2);
    outline-offset: 1px;
}

/* <vellum-about-page> — About / Licenses page (WI-020).
 *
 * Same page chrome as <vellum-prefs>: a centred 760px column, one
 * parchment-dark block per attribution source, accent-coloured links.
 * Tokens (--vellum-*, --bible-font-scale) are defined in app.css.
 */

vellum-about-page {
    display: block;
}

.vellum-about {
    max-width: 760px;
    margin: 0 auto;
    padding: 1rem 0;
    line-height: 1.55;
}

.vellum-about__heading {
    margin: 0 0 0.4rem;
    color: var(--vellum-ink);
    font-size: calc(1.6rem * var(--bible-font-scale));
    font-weight: 700;
}

.vellum-about__intro {
    margin: 0 0 1.25rem;
    color: var(--vellum-ink-dim);
    font-size: calc(1rem * var(--bible-font-scale));
}

.vellum-about__attribution-section {
    margin: 0 0 1rem;
    padding: 1rem 1.1rem;
    background: var(--vellum-parchment-dark);
    border: 1px solid var(--vellum-rule);
    border-radius: 6px;
}

.vellum-about__attribution-title {
    margin: 0 0 0.5rem;
    color: var(--vellum-ink);
    font-size: calc(1.05rem * var(--bible-font-scale));
}

.vellum-about__attribution-section p {
    margin: 0.2rem 0;
    color: var(--vellum-ink);
    font-size: calc(0.92rem * var(--bible-font-scale));
}

/* "Source:" / "License:" row labels. */
.vellum-about__source-row > span:first-child,
.vellum-about__license-row > span:first-child {
    color: var(--vellum-ink-dim);
}

.vellum-about a {
    color: var(--vellum-accent);
    text-decoration: none;
    /* Source URLs are long unbroken strings; let them wrap on a phone
     * instead of widening the page. */
    overflow-wrap: anywhere;
}

.vellum-about a:hover,
.vellum-about a:focus-visible {
    text-decoration: underline;
}

/* ============================================================================
 * studies.css — Studies feature styling.
 *
 * Mirrors the mockup tokens documented in
 * docs/architecture/offline-bible/studies/mockups/_shared.css and the
 * empty/list/editor states in empty-and-delete.html + vellum-studies-list.html +
 * vellum-study-editor.html.
 *
 * All variables (--vellum-*) are defined in app.css.
 * ============================================================================ */

/* ---------------- Page chrome (shared with index + editor) ---------------- */
.studies-page {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.studies-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--vellum-rule);
}

.studies-page-header .page-title {
  font-size: calc(1.6rem * var(--bible-font-scale));
  font-weight: 700;
  margin: 0;
  color: var(--vellum-ink);
}

.studies-page-header .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.studies-page-header .page-subtitle {
  color: var(--vellum-ink-dim);
  font-size: calc(0.9rem * var(--bible-font-scale));
  margin: 0.15rem 0 0;
}

/* ---------------- Empty state ---------------- */
.studies-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--vellum-ink-dim);
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--vellum-shadow);
}

.studies-empty-icon {
  font-size: calc(2.4rem * var(--bible-font-scale));
  color: var(--vellum-accent-soft);
  margin-bottom: 0.6rem;
  line-height: 1;
}

.studies-empty h2 {
  font-size: calc(1.25rem * var(--bible-font-scale));
  color: var(--vellum-ink);
  margin: 0 0 0.4rem;
  font-weight: 700;
}

.studies-empty p {
  margin: 0 auto 1.25rem;
  max-width: 42ch;
  line-height: 1.5;
}

/* ---------------- Index list ---------------- */
.vellum-studies-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--vellum-shadow);
  overflow: hidden;
}

.studies-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--vellum-rule-soft);
  cursor: pointer;
}

.studies-row:last-child { border-bottom: none; }

.studies-row:hover {
  background: var(--vellum-parchment-soft);
}

.studies-row:focus-visible {
  outline: 2px solid var(--vellum-accent);
  outline-offset: -2px;
}

.studies-row-titlewrap {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.studies-row-title {
  font-weight: 700;
  color: var(--vellum-ink);
}

.studies-row-title.muted {
  font-weight: 600;
  color: var(--vellum-ink-dim);
  font-style: italic;
}

/* Secondary line: "Updated <relative date>". */
.studies-row-meta {
  font-size: calc(0.8rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

/* ---------------- Index search ---------------- */
.studies-search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.85rem;
}

.studies-search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  background: var(--vellum-parchment-soft);
  color: var(--vellum-ink);
  font-family: inherit;
  font-size: calc(1rem * var(--bible-font-scale));
}

.studies-search-input::placeholder {
  color: var(--vellum-ink-dim);
  font-style: italic;
}

.studies-search-input:focus {
  border-color: var(--vellum-accent);
  background: var(--vellum-card-bg);
}

.studies-search-count {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--vellum-ink-dim);
  font-size: calc(0.85rem * var(--bible-font-scale));
}

.studies-row-actions {
  display: inline-flex;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* ---------------- Editor header ---------------- */
.vellum-study-editor {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.study-editor-header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--vellum-rule);
}

.editor-back {
  color: var(--vellum-ink-dim);
  text-decoration: none;
  font-size: calc(0.9rem * var(--bible-font-scale));
}

.editor-back:hover { color: var(--vellum-accent); }

.study-editor-title {
  flex: 1 1 auto;
  font-family: inherit;
  font-size: calc(1.55rem * var(--bible-font-scale));
  font-weight: 700;
  color: var(--vellum-ink);
  background: transparent;
  border: 1px dashed transparent;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  min-width: 0;
}

.study-editor-title:focus {
  border-color: var(--vellum-rule);
  background: var(--vellum-parchment-soft);
  outline: none;
}

.study-editor-title::placeholder {
  color: var(--vellum-ink-dim);
  font-style: italic;
  font-weight: 600;
}

.study-editor-delete { flex-shrink: 0; }

/* Narrow viewport: the back link and the buttons take the first row, and the
 * title takes a full second row, so a long title stays readable. */
@media (max-width: 600px) {
  .study-editor-header { flex-wrap: wrap; }
  .study-editor-save { margin-left: auto; }
  .study-editor-title {
    order: 1;
    flex-basis: 100%;
  }
}

/* ---------------- Display page (#/study/<id>) ---------------- */
.vellum-study-display {
  display: block;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.study-display-header {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--vellum-rule);
}

.study-display-back {
  flex-shrink: 0;
  color: var(--vellum-ink-dim);
  text-decoration: none;
  font-size: calc(0.9rem * var(--bible-font-scale));
}

.study-display-back:hover { color: var(--vellum-accent); }

.study-display-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: calc(1.55rem * var(--bible-font-scale));
  font-weight: 700;
  color: var(--vellum-ink);
  overflow-wrap: anywhere;
}

.study-display-edit { flex-shrink: 0; }

@media (max-width: 600px) {
  .study-display-header { flex-wrap: wrap; }
  .study-display-edit { margin-left: auto; }
  .study-display-title {
    order: 1;
    flex-basis: 100%;
  }
}

/* The route container already gives a side gutter at narrow widths; the
 * Studies pages do not add a second one. */
@media (max-width: 600px) {
  .studies-page,
  .vellum-study-editor,
  .vellum-study-display {
    padding-left: 0;
    padding-right: 0;
  }
}

/* ---------------- Block canvas ---------------- */
.study-block-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.study-block {
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule-soft);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  position: relative;
}

.study-block[data-bible-study-block-edit="true"] {
  outline: 2px solid var(--vellum-accent-soft);
  outline-offset: -2px;
}

/* WI-024 — Gutter visibility (REQ-44-007 / COMP-44-006).
 * Hover-capable viewports: gutter hidden by default; revealed by block hover
 * or gutter focus-within. Hover-incapable (touch/mobile): always visible. */
.study-block-gutter {
  opacity: 0;
  visibility: hidden;
}
.study-block-gutter .gutter-control {
  /* Keep gutter controls focusable even while the gutter container is
   * visually hidden — otherwise :focus-within can never trigger. */
  visibility: visible;
}
.study-block:hover .study-block-gutter {
  opacity: 1;
  visibility: visible;
}
.study-block-gutter:focus-within {
  opacity: 1;
  visibility: visible;
}
@media (hover: none) {
  .study-block-gutter {
    opacity: 1;
    visibility: visible;
  }
}

/* Gutter layout: a toolbar row at the top right of the block, tucked into
 * its padding, at every viewport width. Keep the controls inside the block:
 * a vertical column outside it is taller than a short block, so it would
 * overlap the next block's controls and a press could land on the wrong one. */
.study-block-gutter {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 0.15rem;
  margin: -0.45rem -0.6rem 0.3rem 0;
}

.study-block-gutter .gutter-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--vellum-ink-dim);
  font-family: inherit;
  font-size: calc(0.85rem * var(--bible-font-scale));
  line-height: 1;
  cursor: pointer;
}

.study-block-gutter .gutter-control:hover:not(:disabled) {
  background: var(--vellum-parchment-dark);
  border-color: var(--vellum-rule);
  color: var(--vellum-ink);
}

.study-block-gutter .gutter-control:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Keyboard pickup state of the drag handle (WAI-ARIA sortable). */
.study-block-gutter .gutter-control[aria-pressed="true"] {
  background: var(--vellum-accent);
  border-color: var(--vellum-accent);
  color: #fff7e8;
}

/* Block actions menu, inserted after the ⋮ trigger inside the gutter. */
.study-block-gutter-menu {
  position: absolute;
  top: calc(100% + 0.2rem);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.25rem 0;
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(43, 33, 24, 0.18);
}

.study-block-gutter-menu button {
  padding: 0.4rem 0.8rem;
  border: 0;
  background: transparent;
  color: var(--vellum-ink);
  font-family: inherit;
  font-size: calc(0.9rem * var(--bible-font-scale));
  text-align: left;
  cursor: pointer;
}

.study-block-gutter-menu button:hover,
.study-block-gutter-menu button:focus-visible {
  background: var(--vellum-parchment-dark);
}

/* iter-46 WI-012 (ADR-46-003, REQ-46-005) — pointer DnD visual states.
 * `html.dragging` is toggled by the drag controller for the lifetime of an
 * active pointer drag. CSS-only gating below is defense-in-depth; the
 * controller is the real enforcer (setPointerCapture + event delegation).
 */
html.dragging {
  cursor: grabbing;
}
html.dragging .study-block:not([data-source]) .study-block-gutter {
  pointer-events: none;
  opacity: 0.35;
}
html.dragging .study-block[data-source] {
  opacity: 0.5;
  outline: 1px dashed var(--vellum-accent-soft);
  outline-offset: -1px;
}
/* Touch parity: pointer events handle touch natively when touch-action
 * is none on the handle (prevents the browser scrolling instead of
 * delivering pointermove). */
.study-block-drag-handle {
  touch-action: none;
  cursor: grab;
}
html.dragging .study-block-drag-handle {
  cursor: grabbing;
}
[data-drag-preview] {
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm, 4px);
  padding: 0.25rem 0.5rem;
  opacity: 0.85;
  transform: translate(8px, 8px) rotate(1deg);
  font-size: calc(0.85rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
[data-drop-indicator] {
  background: var(--vellum-accent, #4a90e2);
  border-radius: 1px;
}

.study-block-edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-size: calc(0.8rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

.study-empty-canvas {
  padding: 2.5rem 1rem 1rem;
  text-align: center;
  color: var(--vellum-ink-dim);
  background: var(--vellum-card-bg);
  border: 1px dashed var(--vellum-rule);
  border-radius: var(--radius-md);
}

.study-empty-canvas p {
  margin: 0 0 0.5rem;
  max-width: 44ch;
  margin-inline: auto;
  line-height: 1.5;
}

.study-add-block-row {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.study-empty-canvas-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.add-block-btn { font-weight: 600; }

/* ---------------- Block: text/markdown ---------------- */
.study-block-text [data-bible-study-block-textarea] {
  width: 100%;
  font-family: inherit;
  font-size: calc(1rem * var(--bible-font-scale));
  line-height: 1.55;
  color: var(--vellum-ink);
  background: transparent;
  border: none;
  resize: vertical;
  min-height: 2.4em;
  padding: 0;
}

.study-block-text [data-bible-study-block-textarea]:focus { outline: none; }

/* iter-46 WI-009 (REQ-46-004 AC #1/#2) — text-block edit-mode textarea.
 * Width parity with passage/lexicon block content (the parent
 * `.study-block` enforces the canonical card width); ~7-line floor via
 * line-height-relative min-height; auto-grow is handled by JS on input.
 */
.study-block .study-block-edit[data-bible-study-text-textarea] {
  width: 100%;
  box-sizing: border-box;
  display: block;
  font-family: inherit;
  font-size: calc(1rem * var(--bible-font-scale));
  line-height: 1.55;
  color: var(--vellum-ink);
  background: var(--vellum-parchment-soft);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  resize: vertical;
  /* ~7 visible lines floor (1.55em line-height × 7) plus padding budget. */
  min-height: calc(1.55em * 7);
  padding: 0.5rem 0.6rem;
}

.study-block .study-block-edit[data-bible-study-text-textarea]:focus {
  outline: none;
  border-color: var(--vellum-accent);
}

/* View-mode rendered markdown container — matches the inner padding the
 * passage/lexicon block content uses so visual width is identical. */
.study-block .study-block-md {
  width: 100%;
  box-sizing: border-box;
}

/* ---------------- Block: passage ---------------- */
.passage-edit-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.passage-range-input,
.passage-translation-input {
  font-family: inherit;
  font-size: calc(0.95rem * var(--bible-font-scale));
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  background: var(--vellum-parchment-soft);
  color: var(--vellum-ink);
}

.passage-range-input { flex: 1 1 auto; min-width: 0; }
.passage-translation-input { width: 5.5rem; }

.passage-ref {
  font-weight: 700;
  color: var(--vellum-ink);
}

.translation-pin {
  margin-left: 0.4rem;
  font-size: calc(0.75rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  background: var(--vellum-parchment-soft);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.passage-parse-error {
  margin-left: 0.5rem;
  font-style: italic;
  font-size: calc(0.85rem * var(--bible-font-scale));
}

/* iter-46 WI-006 / ADR-46-001 §5 — parse-error / empty vellum-passage-card treatment.
   The vellum-passage-card in the vellum-study-display passage block renders empty when
   the rangeText is missing or unparseable. The .muted hint surfaces inline
   as a ::before pseudo-element so no extra markup is needed and the
   existing muted text token governs the color. */
.study-block-passage.study-block-display vellum-passage-card[data-parse-error="true"] {
  display: inline-block;
}

.study-block-passage.study-block-display vellum-passage-card[data-parse-error="true"]::before {
  content: "(passage unavailable)";
  color: var(--vellum-ink-dim, var(--text-muted, #6b5b46));
  font-style: italic;
  font-size: calc(0.85rem * var(--bible-font-scale));
}

/* ---------------- Block: lexicon ---------------- */
vellum-study-lexicon-block {
  display: block;
}

.study-lexicon-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.study-lexicon-lemma {
  font-weight: 700;
  font-size: calc(1.1rem * var(--bible-font-scale));
  color: var(--vellum-ink);
}

.study-lexicon-translit {
  font-style: italic;
  color: var(--vellum-ink-dim);
}

.study-lexicon-id {
  font-size: calc(0.75rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
  background: var(--vellum-parchment-soft);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.study-lexicon-gloss {
  margin-top: 0.35rem;
  color: var(--vellum-ink);
  line-height: 1.45;
}

.study-lexicon-muted {
  color: var(--vellum-ink-dim);
  font-style: italic;
}

.study-lexicon-error {
  color: var(--vellum-danger);
  font-size: calc(0.85rem * var(--bible-font-scale));
}

.study-lexicon-empty {
  color: var(--vellum-ink-dim);
  font-style: italic;
}

.lexicon-strongs-input {
  font-family: inherit;
  font-size: calc(1rem * var(--bible-font-scale));
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-sm);
  background: var(--vellum-parchment-soft);
  width: 6rem;
}

/* ---------------- Studies panel (overlap-driven side panel) ---------------- */
vellum-studies-panel { display: none; }

html[data-bible-studies-panel-open="true"] vellum-studies-panel {
  display: block;
  position: fixed;
  top: 4rem;
  right: 1rem;
  width: min(320px, 90vw);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(40, 25, 10, 0.25);
  z-index: 50;
}

.studies-panel-root { padding: 0.75rem 0.85rem; }

.studies-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.studies-panel-title {
  margin: 0;
  font-size: calc(1rem * var(--bible-font-scale));
  font-weight: 700;
  color: var(--vellum-ink);
}

.studies-panel-context {
  font-size: calc(0.8rem * var(--bible-font-scale));
  color: var(--vellum-ink-dim);
}

.studies-panel-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.panel-study-item {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--vellum-ink);
  text-decoration: none;
  border: 1px solid transparent;
}

.panel-study-item:hover {
  background: var(--vellum-parchment-soft);
  border-color: var(--vellum-rule-soft);
}

.panel-study-title { font-weight: 600; }

.studies-panel-status {
  padding: 0.6rem 0.2rem;
  color: var(--vellum-ink-dim);
  font-size: calc(0.9rem * var(--bible-font-scale));
  font-style: italic;
}

.studies-panel-error { color: var(--vellum-danger); font-style: normal; }

/* ---------------- Delete confirm modal ---------------- */
vellum-studies-delete-modal { display: none; }

vellum-studies-delete-modal[open] {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 200;
}

vellum-studies-delete-modal .modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

vellum-studies-delete-modal .modal {
  width: min(440px, 92%);
  background: var(--vellum-card-bg);
  border: 1px solid var(--vellum-rule);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px rgba(40, 25, 10, 0.35);
  padding: 1rem 1.1rem 0.9rem;
}

vellum-studies-delete-modal .modal h2 {
  margin: 0 0 0.5rem;
  font-size: calc(1.1rem * var(--bible-font-scale));
  font-weight: 700;
  color: var(--vellum-ink);
}

vellum-studies-delete-modal .modal p {
  margin: 0 0 1rem;
  color: var(--vellum-ink-dim);
  line-height: 1.5;
}

vellum-studies-delete-modal .modal strong { color: var(--vellum-ink); }

vellum-studies-delete-modal .modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
