/* Lectio interface styles, built on Bootstrap 5.3.
 *
 * Brand source of truth: brand/brand-book.md and brand/palette.json.
 * - Colours come only from the palette (tests/test_brand.py enforces this).
 * - Serif for content, sans for interface, mono for identifiers; no fourth family.
 * - Gold marks where you are (the navigation ribbon), Saturday in the weekly chart and the
 *   Finished status badge. The logo's ribbon is part of the identity, not an interface mark.
 * - No shadows (elevation is a sage border), 4px radius for controls, 8px for panels.
 */

/* --- fonts (self-hosted upstream releases, glyphs unmodified; see app/static/fonts/README.md) --- */
@font-face {
  font-family: "Alegreya";
  src: url("../fonts/Alegreya-wght.woff2") format("woff2-variations"),
       url("../fonts/Alegreya-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("../fonts/Alegreya-Italic-wght.woff2") format("woff2-variations"),
       url("../fonts/Alegreya-Italic-wght.woff2") format("woff2");
  font-weight: 400 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("../fonts/SourceSans3VF-Upright.ttf.woff2") format("woff2-variations"),
       url("../fonts/SourceSans3VF-Upright.ttf.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Code Pro";
  src: url("../fonts/SourceCodeVF-Upright.ttf.woff2") format("woff2-variations"),
       url("../fonts/SourceCodeVF-Upright.ttf.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

/* --- palette primitives (brand/palette.json → colors) --------------------------- */
:root {
  --lectio-color-forest: #174B3E;
  --lectio-color-paper: #F7F2E6;
  --lectio-color-gilt: #C5A15B;
  --lectio-color-ink: #242923;
  --lectio-color-sage: #DCE5DE;
  --lectio-color-white: #FFFFFF;
  --lectio-color-gilt-deep: #7A5D22;
  --lectio-color-graphite: #555C56;
  --lectio-color-rubric: #9A3426;
  --lectio-color-charcoal: #1B1A18;
  --lectio-color-charcoal-raised: #252321;
  --lectio-color-charcoal-rule: #3A3733;
  --lectio-color-ash: #BDB6A8;
  --lectio-color-fern: #9CCBB4;

  --lectio-font-serif: "Alegreya", Georgia, "Times New Roman", serif;
  --lectio-font-sans: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --lectio-font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --lectio-radius-control: 0.25rem;
  --lectio-radius-panel: 0.5rem;
  --lectio-ribbon: 3px;
}

/* --- light theme (palette.json → themes.light) ------------------------------------ */
:root,
[data-bs-theme="light"] {
  --lectio-background: var(--lectio-color-paper);
  --lectio-surface: var(--lectio-color-white);
  --lectio-surface-secondary: var(--lectio-color-sage);
  --lectio-text: var(--lectio-color-ink);
  --lectio-text-muted: var(--lectio-color-graphite);
  --lectio-primary: var(--lectio-color-forest);
  --lectio-on-primary: var(--lectio-color-paper);
  --lectio-accent: var(--lectio-color-gilt);
  --lectio-accent-text: var(--lectio-color-gilt-deep);
  --lectio-on-accent: var(--lectio-color-ink);
  --lectio-danger: var(--lectio-color-rubric);
  --lectio-danger-text: var(--lectio-color-rubric);
  --lectio-border: var(--lectio-color-sage);
  --lectio-rule: var(--lectio-color-forest);
  --lectio-control-border: var(--lectio-color-graphite);
  --lectio-focus: var(--lectio-color-forest);
  --lectio-scrim: color-mix(in srgb, var(--lectio-color-ink) 45%, transparent); /* behind dialogs */
  /* Forest is kept for page titles, links, buttons and progress; section headings and
     figures use Ink so green does not dominate (palette proportion: forest 12%). */
  --lectio-title: var(--lectio-color-forest);
  --lectio-heading: var(--lectio-color-ink);
  /* Activity chart: a month that missed its time goal, lighter than the primary bars and still
     at least 3:1 on the surface (test_brand). */
  --lectio-chart-missed: color-mix(in srgb, var(--lectio-color-forest) 60%, var(--lectio-color-white));
  /* Weekly chart: one palette colour per weekday, Monday → Sunday. Sunday is Rubric, after
     the red-letter days of manuscript calendars. Values are printed, so colour is not needed
     to read the chart. */
  --lectio-day-0: var(--lectio-color-forest);
  --lectio-day-1: var(--lectio-color-fern);
  --lectio-day-2: var(--lectio-color-graphite);
  --lectio-day-3: var(--lectio-color-gilt-deep);
  --lectio-day-4: var(--lectio-color-ink);
  --lectio-day-5: var(--lectio-color-gilt);
  --lectio-day-6: var(--lectio-color-rubric);

  --bs-body-color-rgb: 36, 41, 35;
  --bs-body-bg-rgb: 247, 242, 230;
  --bs-emphasis-color-rgb: 36, 41, 35;
  --bs-secondary-color-rgb: 85, 92, 86;
  --bs-primary-rgb: 23, 75, 62;
  --bs-link-color-rgb: 23, 75, 62;
  --bs-link-hover-color-rgb: 36, 41, 35;
  --bs-danger-rgb: 154, 52, 38;
}
/* A forced light theme keeps native controls and scrollbars light on dark devices. */
[data-bs-theme="light"] { color-scheme: light; }

/* --- dark theme (palette.json → themes.dark) ---------------------------------------
 * Grounds are warm neutral charcoals; Fern (green) is kept for links, buttons, progress and
 * the success mark, as Forest is in light mode.
 * The palette defines no dark error text colour (Rubric on Charcoal is below 4.5:1), so
 * destructive text uses Paper and relies on its label; danger surfaces stay Rubric. */
[data-bs-theme="dark"] {
  --lectio-background: var(--lectio-color-charcoal);
  --lectio-surface: var(--lectio-color-charcoal-raised);
  --lectio-surface-secondary: var(--lectio-color-charcoal-rule);
  --lectio-text: var(--lectio-color-paper);
  --lectio-text-muted: var(--lectio-color-ash);
  --lectio-primary: var(--lectio-color-fern);
  --lectio-on-primary: var(--lectio-color-charcoal);
  --lectio-accent: var(--lectio-color-gilt);
  --lectio-accent-text: var(--lectio-color-gilt);
  --lectio-on-accent: var(--lectio-color-charcoal);
  --lectio-danger: var(--lectio-color-rubric);
  --lectio-danger-text: var(--lectio-color-paper);
  --lectio-border: var(--lectio-color-charcoal-rule);
  --lectio-rule: var(--lectio-color-fern);
  --lectio-control-border: var(--lectio-color-ash);
  --lectio-focus: var(--lectio-color-fern);
  --lectio-scrim: color-mix(in srgb, var(--lectio-color-charcoal) 75%, transparent);
  --lectio-title: var(--lectio-color-paper);
  --lectio-heading: var(--lectio-color-paper);
  --lectio-chart-missed: color-mix(in srgb, var(--lectio-color-fern) 55%, var(--lectio-color-charcoal-raised));
  /* Ink and Forest disappear on Charcoal; Paper and Sage take their places. */
  --lectio-day-0: var(--lectio-color-sage);
  --lectio-day-1: var(--lectio-color-fern);
  --lectio-day-2: var(--lectio-color-graphite);
  --lectio-day-3: var(--lectio-color-gilt-deep);
  --lectio-day-4: var(--lectio-color-paper);
  --lectio-day-5: var(--lectio-color-gilt);
  --lectio-day-6: var(--lectio-color-rubric);

  --bs-body-color-rgb: 247, 242, 230;
  --bs-body-bg-rgb: 27, 26, 24;
  --bs-emphasis-color-rgb: 247, 242, 230;
  --bs-secondary-color-rgb: 189, 182, 168;
  --bs-primary-rgb: 156, 203, 180;
  --bs-link-color-rgb: 156, 203, 180;
  --bs-link-hover-color-rgb: 247, 242, 230;
  --bs-danger-rgb: 247, 242, 230;
  color-scheme: dark;
}

/* --- Bootstrap mapped onto the brand tokens (both themes) ------------------------------ */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-font-sans-serif: var(--lectio-font-sans);
  --bs-font-monospace: var(--lectio-font-mono);
  --bs-body-font-family: var(--lectio-font-sans);
  --bs-body-font-size: 1rem;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--lectio-text);
  --bs-body-bg: var(--lectio-background);
  --bs-emphasis-color: var(--lectio-text);
  --bs-secondary-color: var(--lectio-text-muted);
  --bs-secondary-bg: var(--lectio-surface-secondary);
  --bs-tertiary-color: var(--lectio-text-muted);
  --bs-tertiary-bg: var(--lectio-surface);
  --bs-heading-color: var(--lectio-heading);
  --bs-primary: var(--lectio-primary);
  --bs-danger: var(--lectio-danger);
  --bs-danger-border-subtle: var(--lectio-danger);
  --bs-link-color: var(--lectio-primary);
  --bs-link-hover-color: var(--lectio-text);
  --bs-border-color: var(--lectio-border);
  --bs-border-color-translucent: var(--lectio-border);
  --bs-border-radius: var(--lectio-radius-control);
  --bs-border-radius-sm: var(--lectio-radius-control);
  --bs-border-radius-lg: var(--lectio-radius-panel);
  --bs-border-radius-xl: var(--lectio-radius-panel);
  --bs-border-radius-xxl: var(--lectio-radius-panel);
  --bs-box-shadow: none;
  --bs-box-shadow-sm: none;
  --bs-box-shadow-lg: none;
  --bs-box-shadow-inset: none;
  --bs-highlight-bg: var(--lectio-surface-secondary);
  --bs-highlight-color: var(--lectio-text);
  --bs-code-color: var(--lectio-text);
  --bs-form-invalid-color: var(--lectio-danger-text);
  --bs-form-invalid-border-color: var(--lectio-danger);
  --bs-form-valid-color: var(--lectio-primary);
  --bs-form-valid-border-color: var(--lectio-primary);
}

/* --- base typography (brand/brand-book.md § D) ---------------------------------------- */
body {
  background: var(--lectio-background);
  color: var(--lectio-text);
  font-family: var(--lectio-font-sans);
  text-rendering: optimizeLegibility;
}
h1, h2, h3, .h1, .h2, .h3,
.display-5, .display-6, .font-serif {
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-weight: 600;
  color: var(--lectio-heading);
}
/* Page titles keep the brand Forest (Paper in dark mode); h1.h2 covers titles set smaller. */
h1, .h1, h1.h2, h1.h3, .display-5, .display-6 { color: var(--lectio-title); }
h1, .h1 { font-size: 2.25rem; line-height: 2.75rem; letter-spacing: -0.005em; }
h2, .h2 { font-size: 1.75rem; line-height: 2.25rem; letter-spacing: 0; }
h3, .h3 { font-size: 1.375rem; line-height: 1.875rem; letter-spacing: 0; }
h4, .h4, h5, .h5, h6, .h6 { font-family: var(--lectio-font-sans); font-weight: 600; color: var(--lectio-text); letter-spacing: 0; }
h4, .h4 { font-size: 1.125rem; line-height: 1.625rem; }
h5, .h5 { font-size: 1rem; line-height: 1.5rem; }
h6, .h6 { font-size: 0.875rem; line-height: 1.25rem; letter-spacing: 0.01em; }
.display-5 { font-size: 3rem; line-height: 3.5rem; letter-spacing: -0.01em; }
.display-6 { font-size: 2.25rem; line-height: 2.75rem; letter-spacing: -0.005em; font-variant-numeric: tabular-nums; }
@media (max-width: 575.98px) {
  h1, .h1 { font-size: 1.875rem; line-height: 2.375rem; }
  .display-5 { font-size: 2.25rem; line-height: 2.75rem; }
}
.font-serif { font-weight: inherit; color: inherit; }
.font-monospace, code, kbd, samp { font-family: var(--lectio-font-mono); font-size: 0.875rem; }
small, .small { font-size: 0.8125rem; line-height: 1.125rem; letter-spacing: 0.01em; }
.form-label, .ui-label { font-size: 0.875rem; line-height: 1.25rem; font-weight: 500; letter-spacing: 0.01em; }
.form-text { font-size: 0.8125rem; line-height: 1.125rem; letter-spacing: 0.01em; color: var(--lectio-text-muted); }
.text-body-secondary { color: var(--lectio-text-muted) !important; }
.lead { font-size: 1.125rem; line-height: 1.75rem; }

/* Reading text: books, notes and quotations carry the serif (18/30, 60–75 characters). */
.reading {
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-size: 1.125rem;
  line-height: 1.875rem;
  font-variant-numeric: oldstyle-nums proportional-nums;
  max-width: 70ch;
}
/* Marginal note: serif italic 14/21. */
.marginal {
  font-family: var(--lectio-font-serif);
  font-style: italic;
  font-size: 0.875rem;
  line-height: 1.3125rem;
  color: var(--lectio-text-muted);
}
/* Sentence-case caption (formerly an all-caps "eyebrow"). */
.eyebrow { font-size: 0.8125rem; line-height: 1.125rem; letter-spacing: 0.01em; color: var(--lectio-text-muted); }
.tabular, table, .stat-value, .progress-label, .chart-summary { font-variant-numeric: tabular-nums; }
.min-w-0 { min-width: 0; }

/* --- focus: 2px outline, 2px offset (Fern in dark mode) ------------------------------- */
:focus-visible { outline: 2px solid var(--lectio-focus); outline-offset: 2px; }
.btn:focus-visible, .btn-check:focus-visible + .btn,
.form-control:focus, .form-select:focus, .form-check-input:focus,
.page-link:focus, .nav-link:focus-visible, .btn-close:focus {
  outline: 2px solid var(--lectio-focus);
  outline-offset: 2px;
  box-shadow: none;
}
.skip-link {
  position: absolute; left: 1rem; top: 0.5rem; z-index: 1100;
  background: var(--lectio-surface); color: var(--lectio-primary);
  border: 1px solid var(--lectio-border); border-radius: var(--lectio-radius-control);
  padding: 0.5rem 1rem;
}

/* --- navigation: the ribbon marks where you are ----------------------------------------- */
.app-nav {
  --bs-navbar-padding-y: 0;
  background: var(--lectio-background);
  border-bottom: 1px solid var(--lectio-border);
}
/* Lockup on the 64-unit symbol tile (brand-book § B): gap 17, wordmark cap height = text block (40),
   centred on the tile (top at y 12). The wordmark file is 169.74 units high for a cap height of 117.54;
   its descender hangs below the symbol. */
.app-nav .navbar-brand { --brand-tile: 1.75rem; display: flex; align-items: flex-start; gap: calc(var(--brand-tile) * 17 / 64); padding: 0.75rem 0; margin-right: 1.5rem; }
.brand-wordmark {
  display: block; width: auto;
  height: calc(var(--brand-tile) * 40 / 64 * 169.74 / 117.54);
  margin-top: calc(var(--brand-tile) * 12 / 64);
  margin-bottom: calc(var(--brand-tile) * (52 / 64 - 40 / 64 * 169.74 / 117.54)); /* negative: keeps the bar's height */
}
.brand-logo { display: block; height: 1.75rem; width: auto; } /* ≥ 24 px minimum size */
/* Primary symbol on light grounds, reversed symbol on dark ones — follows the applied theme. */
.brand-logo-dark { display: none; }
[data-bs-theme="dark"] .brand-logo-light { display: none; }
[data-bs-theme="dark"] .brand-logo-dark { display: block; }
.app-nav .nav-link {
  color: var(--lectio-text);
  font-weight: 500;
  padding: calc(1.125rem - var(--lectio-ribbon)) 0.75rem 1.125rem;
  border-top: var(--lectio-ribbon) solid transparent;
}
.app-nav .nav-link:hover { color: var(--lectio-primary); }
.app-nav .nav-link.active {
  color: var(--lectio-text);
  font-weight: 600;
  border-top-color: var(--lectio-accent);
}
.app-nav .btn-link.nav-link { border-top: 0; padding: 0.375rem 0; }
.app-nav .navbar-toggler { border-color: var(--lectio-control-border); }
/* Toggler icon drawn in palette Ink (light) and Paper (dark) instead of Bootstrap's greys. */
.app-nav {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23242923' stroke-linecap='square' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
[data-bs-theme="dark"] .app-nav {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23F7F2E6' stroke-linecap='square' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
/* Language switch (signed out): "EN · PT", the current one in full text colour, the other muted. */
.language-switch {
  display: flex; align-items: center; list-style: none; margin: 0 0.5rem 0 0; padding: 0;
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.06em;
}
.language-switch li + li::before { content: "·"; color: var(--lectio-text-muted); padding: 0 0.1rem; }
.language-switch a, .language-switch-current { display: inline-block; padding: 0.375rem 0.3rem; border-radius: var(--lectio-radius-control); }
.language-switch a { color: var(--lectio-text-muted); text-decoration: none; }
.language-switch a:hover, .language-switch a:focus-visible { color: var(--lectio-primary); }
.language-switch-current { color: var(--lectio-heading); }
/* Phones: tighter, so English still fits on one row; longer labels (Portuguese) wrap under the logo. */
@media (max-width: 575.98px) {
  .app-nav .container:has(.language-switch) { flex-wrap: wrap; row-gap: 0; }
  .app-nav .container:has(.language-switch) .navbar-brand { margin-right: 0.75rem; }
  /* Shorter than the logo's row, so it only shows once the buttons wrap to a row of their own. */
  .app-nav .container:has(.language-switch) > :last-child { margin-block: 0.5rem; }
  .language-switch { margin-right: 0; }
  .language-switch a, .language-switch-current { padding-inline: 0.2rem; }
}
@media (max-width: 991.98px) {
  .app-nav .nav-link { border-top: 0; border-left: var(--lectio-ribbon) solid transparent; padding: 0.5rem 0.75rem; }
  .app-nav .nav-link.active { border-left-color: var(--lectio-accent); }
}
.app-footer {
  border-top: 1px solid var(--lectio-border);
  color: var(--lectio-text-muted);
  font-size: 0.8125rem;
}

/* --- buttons ------------------------------------------------------------------------ */
.btn {
  --bs-btn-font-family: var(--lectio-font-sans);
  --bs-btn-font-weight: 600;
  --bs-btn-border-radius: var(--lectio-radius-control);
  --bs-btn-box-shadow: none;
  --bs-btn-focus-box-shadow: none;
  letter-spacing: 0.01em;
}
.btn-primary {
  --bs-btn-color: var(--lectio-on-primary);
  --bs-btn-bg: var(--lectio-primary);
  --bs-btn-border-color: var(--lectio-primary);
  --bs-btn-hover-color: var(--lectio-background);
  --bs-btn-hover-bg: var(--lectio-text);
  --bs-btn-hover-border-color: var(--lectio-text);
  --bs-btn-active-color: var(--lectio-background);
  --bs-btn-active-bg: var(--lectio-text);
  --bs-btn-active-border-color: var(--lectio-text);
  --bs-btn-disabled-color: var(--lectio-on-primary);
  --bs-btn-disabled-bg: var(--lectio-primary);
  --bs-btn-disabled-border-color: var(--lectio-primary);
}
.btn-outline-primary {
  --bs-btn-color: var(--lectio-primary);
  --bs-btn-border-color: var(--lectio-primary);
  --bs-btn-hover-color: var(--lectio-on-primary);
  --bs-btn-hover-bg: var(--lectio-primary);
  --bs-btn-hover-border-color: var(--lectio-primary);
  --bs-btn-active-color: var(--lectio-on-primary);
  --bs-btn-active-bg: var(--lectio-primary);
  --bs-btn-active-border-color: var(--lectio-primary);
  --bs-btn-disabled-color: var(--lectio-primary);
  --bs-btn-disabled-border-color: var(--lectio-primary);
}
.btn-outline-secondary {
  --bs-btn-color: var(--lectio-text);
  --bs-btn-border-color: var(--lectio-control-border);
  --bs-btn-hover-color: var(--lectio-text);
  --bs-btn-hover-bg: var(--lectio-surface-secondary);
  --bs-btn-hover-border-color: var(--lectio-control-border);
  --bs-btn-active-color: var(--lectio-primary);
  --bs-btn-active-bg: var(--lectio-surface-secondary);
  --bs-btn-active-border-color: var(--lectio-primary);
  --bs-btn-disabled-color: var(--lectio-text-muted);
  --bs-btn-disabled-border-color: var(--lectio-border);
}
.btn-danger {
  --bs-btn-color: var(--lectio-color-paper);
  --bs-btn-bg: var(--lectio-danger);
  --bs-btn-border-color: var(--lectio-danger);
  --bs-btn-hover-color: var(--lectio-background);
  --bs-btn-hover-bg: var(--lectio-text);
  --bs-btn-hover-border-color: var(--lectio-text);
  --bs-btn-active-color: var(--lectio-background);
  --bs-btn-active-bg: var(--lectio-text);
  --bs-btn-active-border-color: var(--lectio-text);
}
.btn-outline-danger {
  --bs-btn-color: var(--lectio-danger-text);
  --bs-btn-border-color: var(--lectio-danger);
  --bs-btn-hover-color: var(--lectio-color-paper);
  --bs-btn-hover-bg: var(--lectio-danger);
  --bs-btn-hover-border-color: var(--lectio-danger);
  --bs-btn-active-color: var(--lectio-color-paper);
  --bs-btn-active-bg: var(--lectio-danger);
  --bs-btn-active-border-color: var(--lectio-danger);
}
.btn-link { --bs-btn-color: var(--lectio-primary); --bs-btn-hover-color: var(--lectio-text); --bs-btn-font-weight: 500; }
.btn-link.text-danger { color: var(--lectio-danger-text) !important; }

/* --- forms --------------------------------------------------------------------------- */
.form-control, .form-select {
  background-color: var(--lectio-surface);
  color: var(--lectio-text);
  border-color: var(--lectio-control-border);
  border-radius: var(--lectio-radius-control);
}
.form-control::placeholder { color: var(--lectio-text-muted); opacity: 1; }
.form-control:focus, .form-select:focus { background-color: var(--lectio-surface); color: var(--lectio-text); border-color: var(--lectio-primary); }
.form-check-input { border-color: var(--lectio-control-border); }
.form-check-input:checked { background-color: var(--lectio-primary); border-color: var(--lectio-primary); }
.input-group > .form-control, .input-group > .form-select, .input-group > .btn { border-radius: var(--lectio-radius-control); }
.input-group > :not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > :not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.invalid-feedback { font-size: 0.8125rem; }
/* Invalid fields: a Rubric border and the message under the field. Bootstrap's warning icon is
   dropped (its red is not in the palette, and the message already says what is wrong). */
.form-control.is-invalid { background-image: none; padding-right: 0.75rem; }
.form-select.is-invalid:not([multiple]):not([size]) { --bs-form-select-bg-icon: none; padding-right: 2.25rem; }
/* Format choice when adding a book (macros.format_choice): a segmented Print / E-book / Audiobook. */
.format-choice-block .btn-group { display: flex; }
.format-choice-block .btn { flex: 1 1 0; }
.format-choice.is-invalid .btn { border-color: var(--lectio-danger); }
.format-choice-error { flex-basis: 100%; order: 1; margin-top: 0; }
/* A time of day (time_field.SegmentedTimeInput): hour : minute boxes, then AM/PM on a 12-hour
   clock, which wraps under the boxes when the column is narrow. */
.time-input { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem; }
.time-input .time-segment { flex: none; width: 3.25rem; text-align: center; font-variant-numeric: tabular-nums; }
.time-input .time-segment.form-control-sm { width: 2.75rem; }
.time-input .time-segment.is-invalid { padding-right: 0.5rem; }
.time-colon { font-weight: 600; }
.time-period { flex: none; margin-left: 0.25rem; }
.time-period .btn { font-variant-numeric: tabular-nums; }

/* --- panels: white (Charcoal Raised) with a sage border, no shadows ------------------------------ */
.card {
  --bs-card-bg: var(--lectio-surface);
  --bs-card-border-color: var(--lectio-border);
  --bs-card-border-radius: var(--lectio-radius-panel);
  --bs-card-inner-border-radius: calc(var(--lectio-radius-panel) - 1px);
  --bs-card-color: var(--lectio-text);
  --bs-card-title-color: var(--lectio-text);
}
.auth-card { margin-top: 2rem; }
.alert {
  --bs-alert-bg: var(--lectio-surface);
  --bs-alert-color: var(--lectio-text);
  --bs-alert-border-color: var(--lectio-border);
  --bs-alert-link-color: var(--lectio-primary);
  --bs-alert-border-radius: var(--lectio-radius-panel);
  border-left-width: var(--lectio-ribbon);
}
.alert-success { border-left-color: var(--lectio-primary); }
.alert-info { border-left-color: var(--lectio-text-muted); }
.alert-warning { border-left-color: var(--lectio-accent-text); }
.alert-danger { border-left-color: var(--lectio-danger); }

/* --- flash messages: one quiet line, no box; the mark carries the colour -------------------
 * Success is Forest (Fern in dark mode), errors Rubric, notices Graphite (Ash). Rubric is too
 * dark to read on Charcoal, so the error mark is a filled disc with a Paper glyph (6.5:1) and the
 * error text uses --lectio-danger-text (Paper in dark mode). Leaving messages collapse their
 * row (grid 1fr → 0fr) so the page below slides up instead of jumping. */
.flash {
  --flash-mark: var(--lectio-text-muted);
  --flash-on-mark: var(--lectio-background);
  display: grid;
  grid-template-rows: 1fr;
  color: var(--lectio-text);
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}
.flash-success { --flash-mark: var(--lectio-primary); --flash-on-mark: var(--lectio-on-primary); }
.flash-danger { --flash-mark: var(--lectio-danger); --flash-on-mark: var(--lectio-color-paper); color: var(--lectio-danger-text); }
.flash.is-leaving { grid-template-rows: 0fr; opacity: 0; }
.flash-body { display: flex; align-items: flex-start; gap: 0.625rem; min-height: 0; overflow: hidden; padding-bottom: 1rem; line-height: 1.5rem; }
.flash-body > .icon { margin-top: 0.125rem; color: var(--flash-mark); }
.flash-body > .icon path { stroke: var(--flash-on-mark); }
.icon-disc { fill: currentColor; stroke: none; }
.flash-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: var(--lectio-radius-control);
  background: transparent;
  color: var(--lectio-text-muted);
}
.flash-close:hover { color: var(--lectio-text); }
.list-group {
  --bs-list-group-bg: var(--lectio-surface);
  --bs-list-group-color: var(--lectio-text);
  --bs-list-group-border-color: var(--lectio-border);
  --bs-list-group-border-radius: var(--lectio-radius-panel);
}
.list-group-flush { --bs-list-group-bg: transparent; }
.breadcrumb { --bs-breadcrumb-divider-color: var(--lectio-text-muted); --bs-breadcrumb-item-active-color: var(--lectio-text-muted); font-size: 0.875rem; }

/* --- tables: 1px forest rule under headers, sage rules between rows ------------------------------ */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--lectio-text);
  --bs-table-border-color: var(--lectio-border);
}
.table > thead > tr > * {
  border-bottom: 1px solid var(--lectio-rule);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.pagination {
  --bs-pagination-color: var(--lectio-primary);
  --bs-pagination-bg: var(--lectio-surface);
  --bs-pagination-border-color: var(--lectio-border);
  --bs-pagination-hover-color: var(--lectio-text);
  --bs-pagination-hover-bg: var(--lectio-surface-secondary);
  --bs-pagination-hover-border-color: var(--lectio-border);
  --bs-pagination-focus-color: var(--lectio-text);
  --bs-pagination-focus-bg: var(--lectio-surface-secondary);
  --bs-pagination-focus-box-shadow: none;
  --bs-pagination-active-color: var(--lectio-on-primary);
  --bs-pagination-active-bg: var(--lectio-primary);
  --bs-pagination-active-border-color: var(--lectio-primary);
  --bs-pagination-disabled-color: var(--lectio-text-muted);
  --bs-pagination-disabled-bg: var(--lectio-surface);
  --bs-pagination-disabled-border-color: var(--lectio-border);
  --bs-pagination-border-radius: var(--lectio-radius-control);
}
.page-link { font-variant-numeric: tabular-nums; }
/* Phones: up to nine items must fit, so Previous/Next shrink to arrows and the buttons tighten. */
.pagination .pager-arrow { display: none; }
@media (max-width: 575.98px) {
  .pagination { --bs-pagination-padding-x: 0.6rem; }
  .pagination .pager-arrow { display: inline; }
  .pagination .pager-word { display: none; }
}

/* --- tabs (library shelves): forest underline marks the selection; gold stays in the nav --- */
.shelf-tabs {
  --bs-nav-pills-link-active-bg: transparent;
  --bs-nav-pills-link-active-color: var(--lectio-text);
  --bs-nav-pills-border-radius: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none; /* swiped, not scrolled: no browser scrollbar */
  border-bottom: 1px solid var(--lectio-border);
}
.shelf-tabs::-webkit-scrollbar { display: none; }
/* On phones the right edge fades out, hinting at the shelves beyond it; the padding lets the last
   shelf scroll clear of the fade. */
@media (max-width: 575.98px) {
  .shelf-tabs {
    padding-right: 2rem;
    mask-image: linear-gradient(to right, black calc(100% - 2rem), transparent);
  }
}
.shelf-tabs .nav-link {
  white-space: nowrap;
  color: var(--lectio-text);
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.75rem;
}
.shelf-tabs .nav-link.active { font-weight: 600; border-bottom-color: var(--lectio-text); }
.shelf-tabs .count { font-size: 0.8125rem; color: var(--lectio-text-muted); margin-left: 0.15rem; }

/* --- lists pairing a name with its figures: kept narrow enough to read across on wide screens --- */
.list-measure { max-width: 42rem; }

/* --- authors list (library): names are content (serif), counts line up as figures -------------- */
.author-table .author-name { font-family: var(--lectio-font-serif); }
.author-table .author-count { color: var(--lectio-heading); width: 6rem; }

/* --- library filters: sort and order apply on change; order is two outline triangles ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; }
.filter-bar .filter-query { flex: 1 1 14rem; max-width: 24rem; }
/* The tag menu's width doesn't follow its options, so choosing tags never moves the row. */
.tag-filter-menu .form-select { width: 11rem; max-width: 100%; }
/* The link to the Tags page shares the label's line, so it adds nothing to the row. */
.tag-filter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
/* Without the menu it sits in the row itself: same height as .form-select-sm, so its text centres on the row's controls. */
.tag-manage-alone { line-height: calc(0.875rem * 1.5 + 0.5rem + 2px); }
.order-arrows { display: flex; gap: 0.25rem; }
.order-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: calc(0.875rem * 1.5 + 0.5rem + 2px); /* same height as .form-select-sm */
  color: var(--lectio-text-muted);
  border-bottom: 2px solid transparent; /* the selected order is underlined, like the shelf tabs */
  cursor: pointer;
}
.order-arrow:hover { color: var(--lectio-text); }
.btn-check:checked + .order-arrow { color: var(--lectio-text); border-bottom-color: var(--lectio-text); }
.btn-check:checked + .order-arrow .icon { fill: currentColor; } /* Ink (Paper in dark mode) */
.btn-check:focus-visible + .order-arrow { outline: 2px solid var(--lectio-focus); outline-offset: 2px; }
/* Only favorites: the heart works like an order arrow; on, it is filled in Gilt Deep (as the stars). */
.favorite-filter { text-align: center; } /* the heart under the middle of its label */
.favorite-filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: calc(0.875rem * 1.5 + 0.5rem + 2px); /* same height as .form-select-sm */
  color: var(--lectio-text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.favorite-filter-toggle:hover { color: var(--lectio-text); }
.btn-check:checked + .favorite-filter-toggle { color: var(--lectio-accent-text); border-bottom-color: var(--lectio-text); }
.btn-check:checked + .favorite-filter-toggle .icon { fill: currentColor; }
.btn-check:focus-visible + .favorite-filter-toggle { outline: 2px solid var(--lectio-focus); outline-offset: 2px; }

/* Favorites: a filled heart in lists, and the toggle on a book's page (outline until pressed). */
.favorite-mark { display: inline-flex; vertical-align: -0.125em; color: var(--lectio-accent-text); }
.favorite-mark .icon { fill: currentColor; }
.favorite-toggle { display: inline-flex; align-items: center; height: calc(0.875rem * 1.5 + 0.5rem + 2px); } /* as .btn-sm with text */
.favorite-toggle.is-favorite .icon { fill: currentColor; }

/* --- statistics ---------------------------------------------------------------------- */
/* Two tiles per row on phones, three beside the goal card, six in one row without it. Equal rows,
   stretched to the goal card's height. */
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 1rem; height: 100%; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .stat-grid-wide { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stat-tile {
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
  padding: 1rem 1.125rem;
  transition: background-color 0.15s ease;
}
/* Hover tints the panel a little towards Sage (Charcoal Rule in dark mode); no shadows. */
@media (hover: hover) {
  .stat-tile:hover { background: color-mix(in srgb, var(--lectio-surface) 55%, var(--lectio-surface-secondary)); }
}
.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.75rem;
  border-radius: var(--lectio-radius-control);
  background: var(--lectio-surface-secondary);
  color: var(--lectio-primary);
}
.stat-value { font-family: var(--lectio-font-serif); font-weight: 600; font-size: 1.75rem; line-height: 2.25rem; color: var(--lectio-heading); }
.stat-unit { font-family: var(--lectio-font-sans); font-size: 0.875rem; font-weight: 500; color: var(--lectio-text-muted); }
.stat-label { font-size: 0.875rem; font-weight: 500; color: var(--lectio-text); }
.stat-hint { font-size: 0.8125rem; color: var(--lectio-text-muted); margin-top: 0.125rem; }

/* This year's goal: the rings centred in the card, the legend centred below them. */
.goal-card .card-body { display: flex; flex-direction: column; }
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 1rem; }
.goal-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.goal-rings { display: grid; place-items: center; flex: none; width: 8.5rem; }
.goal-rings > * { grid-area: 1 / 1; }
.goal-rings svg { display: block; width: 100%; height: auto; }
.goal-ring-track, .goal-ring { fill: none; stroke-width: 10; }
.goal-ring-track { stroke: var(--lectio-surface-secondary); }
.goal-ring-books { stroke: var(--lectio-primary); }
.goal-ring-pages { stroke: var(--lectio-accent-text); }
.goal-pace { stroke: var(--lectio-heading); stroke-width: 1.5; stroke-linecap: square; }
/* Hover: the arc thickens, the other ring fades, its legend line darkens (mouse only). */
@media (hover: hover) {
  .goal-ring { transition: stroke-width 150ms ease, opacity 150ms ease; }
  .goal-ring:hover { stroke-width: 14; }
  .goal-rings:has(.goal-ring:hover) .goal-ring:not(:hover) { opacity: 0.35; }
  .goal-body:has(.goal-ring-books:hover) .goal-legend-books,
  .goal-body:has(.goal-ring-pages:hover) .goal-legend-pages { font-weight: 600; color: var(--lectio-heading); }
}
@media (prefers-reduced-motion: reduce) { .goal-ring { transition: none; } }
.goal-rings-center { display: flex; flex-direction: column; align-items: center; margin: 0; line-height: 1.1; }
.goal-rings-figure { font-family: var(--lectio-font-serif); font-weight: 600; font-size: 1.5rem; color: var(--lectio-heading); font-variant-numeric: tabular-nums; }
.goal-rings-figure-long { font-size: 1.125rem; }  /* "100/100" fits inside the inner ring */
.goal-rings-caption { font-size: 0.75rem; color: var(--lectio-text-muted); }
.goal-legend { max-width: 100%; font-size: 0.875rem; }
.goal-legend li { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }
.goal-legend .legend-key { flex: none; }
.goal-figure { margin-inline-start: auto; padding-inline-start: 1.5rem; font-variant-numeric: tabular-nums; }
.goal-edit { align-self: center; }

/* Stats page: the period switcher, and the year mode's finished books and highlights. */
/* Period tabs (All time, then each year) as pills: outlined, the current one filled. */
.year-switch { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.year-switch a {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.375rem 1.125rem;
  border: 1px solid var(--lectio-control-border); border-radius: 999px;
  font-size: 1.0625rem; font-weight: 500; line-height: 1.25; color: var(--lectio-text); text-decoration: none;
}
.year-switch a:hover { background: var(--lectio-surface-secondary); color: var(--lectio-text); }
.year-switch a[aria-current="page"] {
  border-color: var(--lectio-primary); background: var(--lectio-primary); color: var(--lectio-on-primary); font-weight: 600;
}
td a[aria-current="page"] { font-weight: 600; color: var(--lectio-heading); }
.year-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 1.25rem 1rem; }
.year-book { display: block; text-decoration: none; }
.year-book-title { display: block; margin-top: 0.5rem; font-family: var(--lectio-font-serif); font-size: 0.875rem; line-height: 1.25rem; color: var(--lectio-heading); }
.year-book:hover .year-book-title { text-decoration: underline; }
.year-book-meta { display: block; font-size: 0.8125rem; color: var(--lectio-text-muted); }
.year-highlights dt { font-size: 0.8125rem; font-weight: 500; color: var(--lectio-text-muted); }
.year-highlights dt:not(:first-child) { margin-top: 0.75rem; }
.year-highlights dd { margin-bottom: 0.125rem; }
.goal-legend .legend-key-pace { width: 2px; margin-inline: 0.3125rem; border: 0; border-radius: 0; background: var(--lectio-heading); }
/* This month against the monthly time target: full width under the rings (or alone). */
.goal-month { align-self: stretch; display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.875rem; }
.goal-month .h6 { color: var(--lectio-heading); }
.goal-month-figure { font-variant-numeric: tabular-nums; }
/* A year's months on the Goals page; the cells take the goal badges' colours (goal-complete…). */
.goal-months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0.25rem; }
.goal-months-cell {
  display: grid;
  place-items: center;
  height: 1.75rem;
  border: 1px solid transparent;
  border-radius: var(--lectio-radius-control);
  font-size: 0.75rem;
  font-weight: 600;
}
.goal-months-current { outline: 2px solid var(--lectio-primary); outline-offset: 1px; }

/* --- covers: an image frame, or a flat tinted block with the title in serif ------------------ */
.cover {
  aspect-ratio: 2 / 3;
  border: 1px solid var(--lectio-border);
  border-radius: 2px;
  overflow: hidden;
  background: var(--lectio-surface-secondary);
  flex-shrink: 0;
  position: relative;
}
/* The image covers the placeholder beneath it, which shows until it loads (or if it fails to). */
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-xs { width: 2.5rem; }
.cover-sm { width: 3.75rem; }
.cover-md { width: 100%; }
.cover-lg { width: 100%; max-width: 16rem; }
.cover-placeholder {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0.625rem;
  text-align: left;
  color: var(--lectio-color-paper);
  border-color: transparent;
}
/* Sits at the foot of the cover and grows upward. Ten lines fit on the smallest cover that shows a
   title (.reading-cover), so only a very long title is cut, and always at its end. */
.cover-placeholder .cover-title {
  font-family: var(--lectio-font-serif);
  font-size: 0.8125rem;
  line-height: 1.1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 10;
  -webkit-box-orient: vertical;
}
/* At xs/sm the title already sits beside the cover, so a placeholder is just its tint (and a book
   of the Bible's icon, centred): the title would only break mid-word at that width. */
.cover-xs .cover-title, .cover-sm .cover-title { display: none; }
.cover-tone-0 { background: var(--lectio-color-forest); }
.cover-tone-1 { background: var(--lectio-color-gilt-deep); }
.cover-tone-2 { background: var(--lectio-color-ink); }
.cover-tone-3 { background: var(--lectio-color-graphite); }
[data-bs-theme="dark"] .cover-placeholder, .cover-placeholder.cover-has-image { border-color: var(--lectio-border); }
/* A book of the Bible: its category's icon (BibleCategory.icon) in the top-left corner, in the
   title's Paper. */
.cover-icon { position: absolute; top: 0.625rem; left: 0.625rem; line-height: 0; }
.cover-icon .icon { width: 1.5rem; height: 1.5rem; }
.cover-lg .cover-icon .icon { width: 2rem; height: 2rem; }
.cover-xs .cover-icon, .cover-sm .cover-icon { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.cover-sm .cover-icon .icon { width: 1rem; height: 1rem; }
.cover-xs .cover-icon .icon { width: 0.75rem; height: 0.75rem; }

/* --- library grid ---------------------------------------------------------------------- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 1.5rem 1rem; }
.book-card-title {
  display: -webkit-box;
  margin-top: 0.5rem;
  font-family: var(--lectio-font-serif);
  font-weight: 600;
  line-height: 1.3;
  color: var(--lectio-text);
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-card-author { display: block; font-size: 0.875rem; color: var(--lectio-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-card-meta { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; margin-top: 0.375rem; }
.book-card-meta .progress-wrap { width: 100%; }
.book-title { font-family: var(--lectio-font-serif); font-weight: 600; }
.progress-cell { min-width: 9rem; }

/* --- progress: forest on a sage track ----------------------------------------------------- */
.progress-wrap { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.375rem; }
.progress-line {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 0.375rem;
  border: 0;
  border-radius: 999px;
  background: var(--lectio-surface-secondary);
  overflow: hidden;
}
.progress-line::-webkit-progress-bar { background: var(--lectio-surface-secondary); border-radius: 999px; }
.progress-line::-webkit-progress-value { background: var(--lectio-primary); border-radius: 999px; }
.progress-line::-moz-progress-bar { background: var(--lectio-primary); border-radius: 999px; }
.progress-lg { height: 0.5rem; }
.progress-label { font-size: 0.8125rem; color: var(--lectio-text-muted); white-space: nowrap; }

/* --- badges: labels carry the meaning; colour is secondary -------------------------------- */
.badge {
  --bs-badge-font-weight: 600;
  --bs-badge-border-radius: var(--lectio-radius-control);
  font-family: var(--lectio-font-sans);
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.status-want_to_read, .goal-ahead, .goal-on_track { background: var(--lectio-surface-secondary); color: var(--lectio-text); }
.status-reading, .goal-complete { background: var(--lectio-primary); color: var(--lectio-on-primary); }
/* A finished book is a milestone: Gilt ground, dark text (6:1+), the label carries the meaning. */
.status-finished { background: var(--lectio-accent); color: var(--lectio-on-accent); }
/* Feedback: open in the quiet ground, under way and done in Forest, declined in outline. */
.feedback-new, .feedback-planned { background: var(--lectio-surface-secondary); color: var(--lectio-text); }
.feedback-in_progress, .feedback-done { background: var(--lectio-primary); color: var(--lectio-on-primary); }
.feedback-wont_do,
.status-paused, .status-abandoned, .goal-behind, .goal-missed, .goal-upcoming {
  background: transparent;
  color: var(--lectio-text-muted);
  border-color: var(--lectio-control-border);
}
.stars { color: var(--lectio-accent-text); letter-spacing: 0.05em; white-space: nowrap; }
.stars-off { color: var(--lectio-border); }

/* --- tags: the reader's own labels, as quiet outlined links; tags have no colours of their own.
 * A tag a list is filtered by sits on sage, with a cross to take it out of the filter.
 * A tag never breaks inside its pill; one wider than its column ends in an ellipsis. ------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.25rem 0.375rem; padding-left: 0; margin-bottom: 0; }
.tag-list > li { min-width: 0; max-width: 100%; }
.tag-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* A book's tags with the pencil that edits them in place (books/detail.html); "Add tags" without any. */
.book-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.375rem; }
.book-tags:not(:has(.tag-list, .book-tags-edit:not([hidden]))) { display: none; }
.book-tags-edit { padding: 0.125rem 0.25rem; line-height: 1; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--lectio-font-sans);
  font-size: 0.8125rem;
  line-height: 1.25rem;
  padding: 0 0.5rem;
  color: var(--lectio-primary);
  /* A tint of the link colour: the border token vanishes on dark cards. */
  border: 1px solid color-mix(in srgb, var(--lectio-primary) 35%, transparent);
  border-radius: var(--lectio-radius-control);
  text-decoration: none;
  white-space: nowrap;
  max-width: 100%;
}
.tag:hover { border-color: var(--lectio-primary); text-decoration: underline; }
.tag-active { color: var(--lectio-text); background: var(--lectio-surface-secondary); border-color: var(--lectio-surface-secondary); }
.tag-active:hover { border-color: var(--lectio-text); }
/* "Clear all tags" is an action, not a tag: filled like a primary button, at a tag's size. */
.tag-clear { color: var(--lectio-on-primary); background: var(--lectio-primary); border-color: var(--lectio-primary); }
.tag-clear:hover { color: var(--lectio-background); background: var(--lectio-text); border-color: var(--lectio-text); text-decoration: none; }
/* Short name-and-count pairs: a long list flows into columns on wide screens so a count stays
   beside its tag; a short one stays a single narrow list (columns would scatter a few tags). */
.tag-index { max-width: 42rem; }
.tag-index:has(> li:nth-child(10)) { max-width: none; columns: 15rem; column-gap: 2.5rem; }
.tag-index li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--lectio-border); break-inside: avoid; }
.tag-index-name { min-width: 0; overflow-wrap: anywhere; }

/* --- dashboard: margin column (streak, week, note) beside the reading list ------------------- */
.onboarding { max-width: 30rem; margin: 1.5rem auto 0; color: var(--lectio-text-muted); }
.dash-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.5rem; }
.dash-summary { color: var(--lectio-text-muted); }
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "streak" "week" "reading" "note";
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
  overflow: hidden;
}
.dash-streak, .dash-week, .dash-note, .dash-reading { padding: 1.5rem; }
.dash-streak { grid-area: streak; padding-bottom: 0.5rem; }
.dash-week { grid-area: week; }
.dash-note { grid-area: note; }
.dash-note:empty { display: none; }
.dash-reading { grid-area: reading; border-top: 1px solid var(--lectio-border); }
@media (min-width: 992px) {
  .dash-grid {
    grid-template-columns: minmax(17rem, 1fr) minmax(0, 2fr);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "streak reading" "week reading" "note reading";
  }
  .dash-streak, .dash-week, .dash-note { background: var(--lectio-background); border-right: 1px solid var(--lectio-border); }
  .dash-note:empty { display: block; }
  .dash-reading { border-top: 0; padding: 1.5rem 2rem; }
}
/* A section's heading with its "All …" link at the far end. */
.dash-section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }

/* Streak: a large figure, no box. */
.streak { display: flex; align-items: baseline; gap: 0.5rem; }
.streak-number {
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 3.5rem;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--lectio-heading);
}
.streak-unit { font-family: var(--lectio-font-serif); font-size: 1.375rem; color: var(--lectio-heading); }
.streak-caption { font-size: 0.875rem; color: var(--lectio-text-muted); }

/* Week chart. */
.week-chart-svg { width: 100%; height: 6rem; display: block; }
.week-baseline { fill: var(--lectio-border); }
.week-bar.day-0 { fill: var(--lectio-day-0); }
.week-bar.day-1 { fill: var(--lectio-day-1); }
.week-bar.day-2 { fill: var(--lectio-day-2); }
.week-bar.day-3 { fill: var(--lectio-day-3); }
.week-bar.day-4 { fill: var(--lectio-day-4); }
.week-bar.day-5 { fill: var(--lectio-day-5); }
.week-bar.day-6 { fill: var(--lectio-day-6); }
.week-labels { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 0.375rem; text-align: center; }
.week-labels li { display: flex; flex-direction: column; font-size: 0.8125rem; line-height: 1.125rem; color: var(--lectio-text-muted); }
.week-labels abbr { text-decoration: none; }
.week-labels .is-today { color: var(--lectio-text); font-weight: 700; }
.week-labels .is-future { opacity: 0.6; }
.week-value { font-size: 0.75rem; min-height: 1.125rem; font-variant-numeric: tabular-nums; }
/* A picked day (app.js): its bar and label stay, the others fade; its figures fill the hint. */
.week-plot { position: relative; }
.week-hint { min-height: 1.25rem; margin-bottom: 0.25rem; font-size: 0.8125rem; line-height: 1.25rem; color: var(--lectio-heading); font-variant-numeric: tabular-nums; }
.week-bar, .week-labels li { transition: opacity 0.15s ease; }
.week-chart.has-pick .week-bar:not(.is-picked), .week-chart.has-pick .week-labels li:not(.is-picked) { opacity: 0.35; }
.week-labels li.is-picked { color: var(--lectio-heading); font-weight: 700; }
.week-hits { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.week-hits[hidden] { display: none; }
.week-hit { appearance: none; padding: 0; border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.week-hit:focus-visible { outline: 2px solid var(--lectio-primary); outline-offset: -2px; border-radius: 2px; }

/* Recent notes: quotations in the reading serif with a Gilt Deep rule; every second one sits
 * against the far margin with its rule there (logical sides, so right-to-left text mirrors).
 * Highlights are italic, the reader's own notes upright. Four lines at most. */
.dash-quote-item { margin: 0 0 1.25rem; }
.dash-quote-item:last-child { margin-bottom: 0; }
.dash-quote {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
  font-family: var(--lectio-font-serif);
  font-style: italic;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--lectio-text);
  border-inline-start: 3px solid var(--lectio-accent-text);
  padding-inline-start: 0.875rem;
  margin: 0 0 0.375rem;
  white-space: pre-line;
}
.dash-quote.is-note { font-style: normal; }
.dash-source { font-size: 0.8125rem; color: var(--lectio-text-muted); padding-inline-start: calc(0.875rem + 3px); }
.dash-quote-item.is-end { text-align: end; }
.dash-quote-item.is-end .dash-quote { border-inline-start: 0; padding-inline-start: 0; border-inline-end: 3px solid var(--lectio-accent-text); padding-inline-end: 0.875rem; }
.dash-quote-item.is-end .dash-source { padding-inline-start: 0; padding-inline-end: calc(0.875rem + 3px); }

/* Currently reading list. */
.reading-row {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--lectio-border);
}
.reading-row:last-child { border-bottom: 0; }
.reading-cover { display: block; }
.reading-cover .cover-title { font-size: 0.6875rem; }
.cover-placeholder .cover-title { overflow-wrap: anywhere; }
.reading-title {
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.125rem;
  line-height: 1.4;
  color: var(--lectio-text);
  text-decoration: none;
}
.reading-title:hover { text-decoration: underline; }
.reading-author { font-size: 0.875rem; color: var(--lectio-text-muted); }
.reading-finish { font-size: 0.8125rem; color: var(--lectio-text-muted); }
.reading-progress { display: block; margin-top: 0.625rem; max-width: 22rem; }
.reading-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.125rem; }
.reading-percent { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--lectio-text); }
.reading-action { font-size: 0.875rem; color: var(--lectio-text-muted); }
.reading-action:hover { color: var(--lectio-text); }
@media (max-width: 575.98px) {
  .reading-row { grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: 0.875rem; }
  .reading-cover .cover-title { font-size: 0.625rem; }
  .reading-cover .cover-placeholder { padding: 0.5rem; }
  .reading-cover .cover-icon { top: 0.5rem; left: 0.5rem; }
}

/* --- reading sessions: a ledger, one section per day; dotted leaders join a session to its progress --- */
.session-day { margin-bottom: 2rem; }
.session-day-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: 1rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--lectio-rule);
}
.session-day-title { font-size: 1.375rem; line-height: 1.875rem; margin: 0; }
.session-day-date { font-family: var(--lectio-font-sans); font-size: 0.875rem; font-weight: 400; letter-spacing: 0.01em; color: var(--lectio-text-muted); margin-inline-start: 0.25rem; }
.session-day-totals { margin: 0; font-size: 0.875rem; color: var(--lectio-text-muted); font-variant-numeric: tabular-nums; }
.session-lines { list-style: none; margin: 0; padding: 0; }
.session-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--lectio-border);
}
.session-line:last-child { border-bottom: 0; }
.session-time { flex: none; width: 2.75rem; font-size: 0.875rem; color: var(--lectio-text-muted); font-variant-numeric: tabular-nums; }
.session-book {
  flex: 0 1 auto;
  min-width: 0;
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  text-decoration: none;
}
.session-book:hover { text-decoration: underline; }
/* An empty flex item sits on the baseline, so its dotted border is a leader under the text line. */
.session-leader { flex: 1 0 1.5rem; border-bottom: 1px dotted var(--lectio-text-muted); }
.session-figures { flex: none; display: flex; column-gap: 0.75rem; font-variant-numeric: tabular-nums; }
.session-duration { min-width: 4.5rem; text-align: end; color: var(--lectio-text-muted); }
.session-edit { flex: none; font-size: 0.875rem; }
.session-note { flex-basis: 100%; margin: 0.125rem 0 0; padding-inline-start: 3.5rem; white-space: pre-line; }
/* Phones: the title takes the line beside the time; progress and duration go under it. */
@media (max-width: 575.98px) {
  .session-line { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) auto; }
  .session-leader { display: none; }
  .session-book { grid-column: 2; }
  .session-edit { grid-column: 3; grid-row: 1; }
  .session-book ~ .session-figures { grid-column: 2 / -1; grid-row: 2; }
  .session-duration { min-width: 0; }
  .session-note { grid-column: 2 / -1; padding-inline-start: 0; }
}

/* --- charts: time in forest (Fern), pages in the gold text colour (Gilt Deep, Gilt in dark mode,
   as for stars), sage for empty periods ------------------------------------------------------- */
.activity-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1rem; }
.chart-legend { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.125rem 0.5rem; border: 1px solid transparent; border-radius: var(--lectio-radius-control); }
.legend-key { width: 0.75rem; height: 0.75rem; border-radius: 2px; border: 2px solid var(--lectio-primary); background: var(--lectio-primary); }
.legend-key-pages { border-color: var(--lectio-accent-text); background: var(--lectio-accent-text); }
.legend-toggle { border-color: var(--lectio-border); cursor: pointer; margin: 0; }
.legend-toggle:hover { border-color: var(--lectio-control-border); }
.legend-toggle .icon { color: var(--lectio-text-muted); }
.btn-check:focus-visible + .legend-toggle { outline: 2px solid var(--lectio-focus); outline-offset: 2px; }
.btn-check:checked + .legend-toggle .icon-eye-off,
.btn-check:not(:checked) + .legend-toggle .icon-eye { display: none; }
/* Hidden pages: a hollow key, the eye crossed out, and the time bars take the whole pair. */
.btn-check:not(:checked) + .legend-toggle { color: var(--lectio-text-muted); }
.btn-check:not(:checked) + .legend-toggle .legend-key-pages { background: transparent; }
.activity:has(#show-pages:not(:checked)) .series-pages { display: none; }
.activity:has(#show-pages:not(:checked)) .bar-time { transform: scaleX(2.1538); } /* 7 / 3.25 */

.chart + .chart { margin-top: 1.5rem; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 1rem; margin-bottom: 0.5rem; }
.chart-title { margin: 0; }
.chart-summary { font-size: 0.8125rem; color: var(--lectio-text-muted); }
.chart-svg { width: 100%; height: 7.5rem; display: block; }
.chart-hit { fill: transparent; }
.chart-slot:hover .chart-hit { fill: var(--lectio-background); }
.chart-svg .bar-time { fill: var(--lectio-primary); transform-box: fill-box; transform-origin: left; transition: transform 0.2s ease; }
.chart-svg .bar-pages { fill: var(--lectio-accent-text); }
.chart-svg .bar-goal-missed { fill: var(--lectio-chart-missed); }
.chart-svg .bar-empty { fill: var(--lectio-surface-secondary); }
/* The busiest period's time: dots measured on screen, as the SVG stretches, and hover still
   reaches the bars underneath. */
.chart-peak { stroke: var(--lectio-text-muted); stroke-width: 1.5px; stroke-dasharray: 0 4px; stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.chart-peak-label { margin: 0 0 0.25rem; text-align: end; font-size: 0.75rem; color: var(--lectio-text-muted); }
/* Monthly time goal met: a dot over the time bar, in a row above the chart (a circle inside the
   stretched SVG would turn oval). It follows the bar's centre: 3.125 of 10 units, or 5 once the
   pages are hidden and the bar widens. */
.chart-goal-dot { display: inline-block; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; background: var(--lectio-primary); }
.chart-goals { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: 0.4375rem; margin-bottom: 0.25rem; }
.chart-goals li { position: relative; }
.chart-goals .chart-goal-dot { position: absolute; top: 0; left: 31.25%; transform: translateX(-50%); transition: left 0.2s ease; }
.activity:has(#show-pages:not(:checked)) .chart-goals .chart-goal-dot { left: 50%; }
/* One column per period; a name may overflow into its unnamed neighbours. */
.chart-ticks { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-top: 0.375rem; font-size: 0.75rem; line-height: 1rem; color: var(--lectio-text-muted); }
.chart-ticks li { display: flex; justify-content: center; white-space: nowrap; }

/* --- search ------------------------------------------------------------------------------- */
.search-field { max-width: 11rem; }
.result-item { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 0; border-bottom: 1px solid var(--lectio-border); }
/* No width of its own (flex-basis 0), so a long title or author line breaks beside the cover
   instead of pushing the whole text below it on phones. */
.result-text { flex: 1 1 0; }
.result-actions { flex-shrink: 0; }
/* Search results: "Add" opens a small menu of formats under it; picking one adds the book. */
.add-to-library { position: relative; display: flex; align-items: center; gap: 0.25rem; }
.add-to-library .form-select { width: auto; } /* as wide as its longest shelf, not the row */
.add-menu > summary { list-style: none; }
.add-menu > summary::-webkit-details-marker { display: none; }
.add-menu-options {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 5;
  display: flex;
  gap: 0.25rem;
  width: max-content; /* not squeezed to the width of the form it hangs from */
  padding: 0.375rem;
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
}
@media (max-width: 575.98px) {
  .result-item { flex-wrap: wrap; }
  /* Own line, right-aligned, so the format menu still opens under "Add". */
  .result-actions { width: 100%; display: flex; justify-content: flex-end; }
}
/* When the bar is narrower than its one-line layout needs (phones, small tablets and the
   two-column layout on laptops): the search box and its button on the first line, so
   "Title, author or ISBN" fits, and "Search in" and "Source" side by side below. It follows
   the bar's own width, not the window's. Ids beat Bootstrap's input-group corner rules. */
.search-bar { container: search-bar / inline-size; }
@container search-bar (max-width: 41rem) {
  .search-bar .input-group { flex-wrap: wrap; row-gap: 0.5rem; }
  .search-bar #q { flex: 1 1 60%; padding-inline: 0.75rem; } /* fits the placeholder down to 320px */
  .search-bar .input-group > .btn { order: 1; }
  .search-bar .search-field { order: 2; flex: 1 1 40%; max-width: none; font-size: 1rem; padding-left: 0.75rem; padding-right: 2.25rem; }
  .search-bar #field { margin-left: 0; border-top-left-radius: var(--lectio-radius-control); border-bottom-left-radius: var(--lectio-radius-control); }
  .search-bar .search-field:last-of-type { border-top-right-radius: var(--lectio-radius-control); border-bottom-right-radius: var(--lectio-radius-control); }
}
.section-label { font-size: 0.875rem; font-weight: 600; letter-spacing: 0.01em; color: var(--lectio-text-muted); }

.page-count-step { max-width: 34rem; }

/* --- book details and notes ----------------------------------------------------------------- */
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin-bottom: 1rem; }
.meta-list dt { font-size: 0.875rem; font-weight: 500; color: var(--lectio-text-muted); }
.meta-list dd { margin: 0; }
.description { white-space: pre-line; }
/* Long words and URLs (pasted links, provider descriptions) wrap instead of widening the page. */
.description, .highlight, .note-body, .note-excerpt { overflow-wrap: anywhere; }
.note-card {
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
  padding: 1rem 1.125rem;
  margin-bottom: 0.75rem;
  break-inside: avoid;
  position: relative;
}
/* The way to the note's page (macros.note_card): in the top corner, shown while the card is
 * hovered or holds focus, and always on touch screens, which have no hover. */
.note-open {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--lectio-radius-control);
  color: var(--lectio-primary);
  opacity: 0;
  transition: opacity 0.15s;
}
.note-card:hover .note-open, .note-card:focus-within .note-open { opacity: 1; }
.note-open:hover { background: var(--lectio-background); }
.note-open + * { margin-inline-end: 1.5rem; } /* the first line keeps clear of the chevron */
@media (hover: none) { .note-open { opacity: 1; } }
.highlight {
  font-family: var(--lectio-font-serif);
  font-optical-sizing: auto;
  font-size: 1.125rem;
  line-height: 1.875rem;
  font-variant-numeric: oldstyle-nums proportional-nums;
  border-left: 2px solid var(--lectio-border);
  padding: 0 0 0 0.875rem;
  margin: 0 0 0.5rem;
  white-space: pre-line;
}
.notes-masonry { columns: 1; column-gap: 1rem; }

/* A book's notes in its order (macros.note_card with margin): the place ("p. 42", "3:16") in a
 * column to the left, once per place, in the muted UI sans; on phones it heads its notes. */
.note-row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); column-gap: 1rem; }
.note-place {
  margin: 0;
  padding-top: 1.125rem;
  text-align: end;
  font-size: 0.8125rem;
  line-height: 1.125rem;
  letter-spacing: 0.01em;
  color: var(--lectio-text-muted);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
@media (max-width: 575.98px) {
  .note-row { grid-template-columns: minmax(0, 1fr); }
  .note-place { padding-top: 0.5rem; margin-bottom: 0.375rem; text-align: start; }
  .note-place-repeat { padding: 0; margin: 0; }
}

/* The order of a book's notes: the current one as plain text, the other a link. */
.notes-tools { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.notes-order { display: inline-flex; gap: 0.75rem; }
.notes-order-current { color: var(--lectio-text); font-weight: 600; }

/* The book page's own sections (books/detail.html). */
.section-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.875rem; }
.section-count { color: var(--lectio-text-muted); font-variant-numeric: tabular-nums; }

/* The note box on a book's page (app.js): folded, it is one field-like line that opens the form;
 * the card around it goes until then. The quote is typed in the reading serif, the reader's
 * thoughts in the serif italic of a marginal note. */
.note-composer.is-folded { padding: 0; border: 0; background: none; }
.note-composer-prompt {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  text-align: start;
  font-family: var(--lectio-font-serif);
  font-style: italic;
  color: var(--lectio-text-muted);
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-control-border);
  border-radius: var(--lectio-radius-control);
}
.note-composer-prompt:hover { border-color: var(--lectio-primary); }
.note-quote-input, .note-thoughts-input { font-family: var(--lectio-font-serif); font-optical-sizing: auto; }
.note-quote-input { font-size: 1.0625rem; }
.note-thoughts-input { font-style: italic; }

/* A note's Markdown (note_markdown.render), set in the surrounding serif (.reading or
 * .marginal). Its headings start at h3, below the page title and the section heading, and stay
 * serif since they are content. A quote inside a note is the reader's citation, quieter than a
 * highlight (the book's words). Wide tables and code scroll sideways instead of the page. */
.note-body > :last-child { margin-bottom: 0; }
.note-body :is(p, ul, ol, pre, blockquote, table) { margin: 0 0 0.75em; }
.note-body :is(ul, ol) { padding-inline-start: 1.5em; }
.note-body li > p { margin-bottom: 0.25em; }
.note-body :is(h3, h4, h5, h6) {
  font-family: var(--lectio-font-serif);
  font-style: normal;
  font-weight: 600;
  color: var(--lectio-heading);
  margin: 1.25em 0 0.5em;
}
.note-body > :is(h3, h4, h5, h6):first-child { margin-top: 0; }
.note-body h3 { font-size: 1.25em; line-height: 1.4; }
.note-body h4 { font-size: 1.1em; line-height: 1.4; }
.note-body :is(h5, h6) { font-size: 1em; line-height: inherit; }
.note-body blockquote {
  border-inline-start: 2px solid var(--lectio-border);
  padding-inline-start: 0.875em;
  color: var(--lectio-text-muted);
}
.note-body code { font-size: 0.875em; }
.note-body pre {
  padding: 0.75rem 1rem;
  background: var(--lectio-background);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-control);
  overflow-x: auto;
  line-height: 1.5;
}
.note-body pre code { font-size: 0.875rem; }
.note-body hr { border: 0; border-top: 1px solid var(--lectio-border); opacity: 1; margin: 1.25em 0; }
.note-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.9em; }
.note-body :is(th, td) { padding: 0.25em 0.75em; border-bottom: 1px solid var(--lectio-border); }
.note-body th { font-weight: 600; color: var(--lectio-heading); }

/* --- confirmation dialog (base.html, app.js) ------------------------------------------------
 * Replaces the browser's confirm box. A panel like the cards: sage border, no shadow; the page
 * behind is dimmed. The confirm button is Rubric for destructive actions, Forest otherwise. */
.confirm-dialog {
  width: min(28rem, calc(100% - 2rem));
  padding: 0; /* clicks on the dialog itself are on the backdrop: app.js closes it */
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
  background: var(--lectio-surface);
  color: var(--lectio-text);
}
.confirm-dialog::backdrop { background: var(--lectio-scrim); }
.confirm-body { padding: 1.25rem 1.5rem; }
.confirm-title { font-family: var(--lectio-font-sans); font-size: 1.125rem; line-height: 1.625rem; font-weight: 600; color: var(--lectio-heading); margin: 0; }
.confirm-quote { font-size: 1rem; line-height: 1.625rem; margin: 0.75rem 0 0; }
.confirm-detail { color: var(--lectio-text-muted); margin: 0.5rem 0 0; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* --- reading timer (base.html, app.js) -------------------------------------------------------
 * A strip under the navigation while a timer runs, outside the collapsible menu so phones see
 * it too. The clock is a figure (Ink/Paper, tabular so it doesn't jitter); Stop opens a dialog
 * styled like the confirmation dialog. */
.timer-bar { background: var(--lectio-surface); border-bottom: 1px solid var(--lectio-border); }
.timer-bar-body { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; padding-block: 0.5rem; }
.timer-bar .icon { color: var(--lectio-primary); }
.timer-book { flex: 1 1 8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--lectio-font-serif); color: inherit; text-decoration: none; }
/* The title links to the book's page: hovering anywhere on the bar underlines it to say so. */
.timer-bar:hover .timer-book[href], .timer-book[href]:focus-visible { text-decoration: underline; }
.timer-clock { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--lectio-heading); }
.timer-state { font-size: 0.875rem; color: var(--lectio-text-muted); }
.timer-actions { display: flex; gap: 0.5rem; margin-inline-start: auto; }
.timer-open { display: inline-flex; color: var(--lectio-primary); }

/* The reading view (reading/timer.html): a window over a table with an open book and a mug, in
 * line art (1.5 px strokes, square terminals, as the icons). The sun (Forest: it marks progress
 * through the hour) turns about the middle of the sill, rising at the left and setting at the
 * right of the window once an hour; app.js sets --reading-elapsed so it stands where the timer
 * is. Two wisps of steam rise from the mug in turn. The view's is-paused class stops both. */
.reading-view { display: flex; flex-direction: column; align-items: center; text-align: center; padding-block: 2rem 3rem; }
.reading-scene { width: min(100%, 26rem); height: auto; margin-bottom: 1.5rem; }
.reading-scene path { fill: none; stroke: var(--lectio-heading); stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.reading-scene .reading-scene-fill { fill: var(--lectio-surface); }
.reading-scene .reading-scene-steam {
  stroke: var(--lectio-text-muted);
  stroke-linecap: round;
  stroke-dasharray: 12 36;
  animation: reading-steam 4s ease-in-out infinite;
}
.reading-scene .reading-scene-steam + .reading-scene-steam { animation-delay: -2s; }
.reading-view.is-paused .reading-scene-steam { animation-play-state: paused; }
@keyframes reading-steam {
  0% { stroke-dashoffset: 12; opacity: 0; }
  30% { opacity: 1; }
  100% { stroke-dashoffset: -24; opacity: 0; }
}
.reading-sun {
  fill: var(--lectio-primary);
  transform-box: view-box;
  transform-origin: 120px 108px;
  animation: reading-sun 3600s linear infinite;
  animation-delay: var(--reading-elapsed, 0s);
}
.reading-view.is-paused .reading-sun { animation-play-state: paused; }
@keyframes reading-sun {
  from { transform: rotate(-90deg); }
  to { transform: rotate(90deg); }
}
.reading-view-book { font-family: var(--lectio-font-serif); font-size: 1.5rem; line-height: 2rem; font-weight: 600; color: var(--lectio-heading); margin: 0; max-width: 36rem; overflow-wrap: anywhere; }
.reading-view-clock { font-size: 3rem; line-height: 1.2; margin: 0.5rem 0 0; }
.reading-view-state { color: var(--lectio-text-muted); margin: 0.25rem 0 0; }
.reading-view-none { padding-block: 2rem 0.5rem; text-align: center; }

/* The dictionary under the reading view (reading/timer.html, filled in by app.js too). A
 * reading column: definitions in serif, as text from a book; labels and credits in sans. */
.dictionary { max-width: 40rem; margin: 2rem auto 3rem; padding-top: 1.5rem; border-top: 1px solid var(--lectio-border); }
.dictionary-result:not(:empty) { margin-top: 1.25rem; }
.dictionary-word { font-family: var(--lectio-font-serif); font-size: 1.5rem; font-weight: 600; color: var(--lectio-heading); margin: 0; overflow-wrap: anywhere; }
.dictionary-phonetic { font-family: var(--lectio-font-sans); font-size: 1rem; font-weight: 400; color: var(--lectio-text-muted); }
.dictionary-meaning { margin-top: 1rem; }
.dictionary-pos { font-size: 0.875rem; font-style: italic; color: var(--lectio-text-muted); margin: 0 0 0.25rem; }
.dictionary-definitions { font-family: var(--lectio-font-serif); padding-inline-start: 1.25rem; margin: 0; }
.dictionary-definitions li + li { margin-top: 0.375rem; }
.dictionary-example { display: block; font-style: italic; color: var(--lectio-text-muted); }
.dictionary-synonyms { font-size: 0.875rem; color: var(--lectio-text-muted); margin: 0.5rem 0 0; }
.dictionary-credit { font-size: 0.8125rem; color: var(--lectio-text-muted); margin: 1.25rem 0 0; }
.dictionary-message { margin: 0; }
.dictionary-recent { font-size: 0.875rem; color: var(--lectio-text-muted); margin: 1rem 0 0; }
.dictionary-recent a + a::before { content: "·"; display: inline-block; margin-inline: 0.4rem; color: var(--lectio-text-muted); }
.dictionary.is-loading .dictionary-result { opacity: 0.6; }
@media (prefers-reduced-motion: reduce) {
  .reading-sun { animation: none; } /* the sun stays at noon */
  .reading-scene .reading-scene-steam { animation: none; stroke-dasharray: none; } /* still wisps */
}
.timer-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 1rem; }
@media (min-width: 768px) { .notes-masonry { columns: 2; } }
@media (min-width: 1200px) { .notes-masonry { columns: 3; } }

/* --- empty states and landing ---------------------------------------------------------------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state .icon { color: var(--lectio-primary); }
.icon { display: inline-block; flex-shrink: 0; }

/* --- landing (always dark: main.index passes appearance="dark") -----------------------------
 * Direction D, "Evening with margins". No JavaScript and no inline styles. The four spines with
 * notes link to #notes-<book>, empty targets just above the margins diagram: following one
 * scrolls to the diagram, and :target with sibling selectors lights that book's path. A fresh
 * visit (no target) shows The Republic. The book being read (White Nights) has the shelf's ribbon.
 * Nothing scrolls sideways: below 768px the shelf shares the width out; below 992px the diagram
 * stacks as a tree (the note at the top, the four books under it).
 * Gold, allowed here: the card's ribbon, the ribbon in White Nights and the note in the diagram.
 * Every animation is inside prefers-reduced-motion: no-preference; without it, the final state. */
.landing { padding-bottom: 2rem; }
.landing em { font-style: italic; }
.landing-kicker { margin: 0 0 1.25rem; font-size: 0.875rem; font-weight: 600; letter-spacing: 0.01em; color: var(--lectio-accent-text); }
.landing-muted { margin: 0; color: var(--lectio-text-muted); line-height: 1.6; }
.landing .landing-center { text-align: center; margin-inline: auto; }
.landing-measure { max-width: 34em; }
.landing-h2 { margin: 0; font-size: 2.25rem; line-height: 1.2; }
.landing-h2--display { font-weight: 400; font-size: clamp(2rem, 4vw, 3rem); max-width: 18em; }
/* "Where one book / meets another.": a note in the margin, a curved line joining the two lines' ends.
 * Both lines are set flush right, so they end at the same place whatever the language or font. */
.landing-meet { position: relative; display: inline-block; white-space: nowrap; text-align: right; }
.landing-meet em, .landing-meet-stop { color: var(--lectio-primary); }
/* It starts at a dot after "book" and ends in the sentence's own full stop (a short arm runs left to meet it). */
.landing-meet-arc { position: absolute; top: 0.62em; bottom: 0.305em; right: -0.72em; width: 0.6em; border: 0.045em solid var(--lectio-primary); border-left: 0; border-radius: 0 100% 100% 0 / 0 50% 50% 0; }
.landing-meet-arc::before { content: ""; position: absolute; top: -0.095em; left: -0.07em; width: 0.14em; height: 0.14em; border-radius: 50%; background: var(--lectio-primary); }
.landing-meet-arc::after { content: ""; position: absolute; bottom: -0.045em; right: 100%; width: 0.12em; height: 0.045em; background: var(--lectio-primary); }
.landing-h3 { margin: 0 0 0.625rem; font-size: 1.375rem; }
.landing-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 2.5rem; }

/* Hero: the headline beside an example reading session. */
.landing-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 4rem; padding-top: 6.5rem; padding-bottom: 6rem; }
.landing-hero-text { flex: 999 1 30rem; min-width: 0; }
.landing-title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(2.5rem, 5vw, 4.25rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.landing-lead { margin: 1.75rem 0 0; max-width: 32em; font-family: var(--lectio-font-serif); font-size: 1.25rem; line-height: 1.7; color: var(--lectio-text-muted); }
.landing-card {
  position: relative;
  flex: 1 1 22rem;
  min-width: 0;
  margin: 0;
  padding: 2rem;
  overflow: hidden;
  background: var(--lectio-surface);
  border: 1px solid var(--lectio-border);
  border-radius: var(--lectio-radius-panel);
}
.landing-ribbon {
  position: absolute; top: 0; right: 2rem;
  width: 0.875rem; height: 4.5rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
}
.landing-card p { margin: 0; }
.landing-card-status { display: flex; align-items: center; gap: 0.625rem; font-size: 0.875rem; color: var(--lectio-text-muted); }
/* An open book drawn in outline; with motion allowed, its right-hand page turns over now and then. */
.landing-turn { position: relative; flex: none; width: 1.25rem; height: 0.875rem; perspective: 4rem; }
.landing-turn::before, .landing-turn::after, .landing-turn-leaf { position: absolute; top: 0; width: 50%; height: 100%; border: 1.5px solid var(--lectio-primary); background: var(--lectio-surface); }
.landing-turn::before { content: ""; left: 0; border-radius: 3px 0 0 3px; }
.landing-turn::after { content: ""; right: 0; border-radius: 0 3px 3px 0; }
.landing-turn-leaf { left: 50%; z-index: 1; border-radius: 0 3px 3px 0; transform-origin: left center; }
.landing-card .landing-card-title { margin-top: 1.5rem; font-family: var(--lectio-font-serif); font-size: 1.75rem; font-weight: 600; line-height: 1.2; color: var(--lectio-text); }
.landing-card-author { font-family: var(--lectio-font-serif); font-style: italic; color: var(--lectio-text-muted); }
.landing-card-figures { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.8125rem; color: var(--lectio-text-muted); font-variant-numeric: tabular-nums; }
.landing-card .landing-card-figures { margin-top: 1.75rem; }
.landing-bar { display: block; height: 0.25rem; margin-top: 0.5rem; border-radius: 0.125rem; background: var(--lectio-border); overflow: hidden; }
.landing-bar-fill { display: block; height: 100%; background: var(--lectio-primary); transform-origin: left center; }
.landing-bar-fill--session { width: 48%; }
.landing-card-quote {
  margin: 1.75rem 0 0; padding-top: 1.25rem;
  border-top: 1px solid var(--lectio-border);
  font-family: var(--lectio-font-serif); font-style: italic; line-height: 1.6; color: var(--lectio-text);
}
.landing-week { display: flex; align-items: center; gap: 0.375rem; margin-top: 1.5rem; }
.landing-week-label { margin-right: 0.5rem; font-size: 0.8125rem; color: var(--lectio-text-muted); }
.landing-day { width: 0.875rem; height: 0.875rem; border-radius: 2px; background: var(--lectio-border); }
.landing-day.is-read { background: var(--lectio-primary); }
.landing-day.is-today { background: transparent; border: 2px solid var(--lectio-primary); }

/* Shelf: eight spines on a board. The four with notes are links to the margins and carry the
   small square the hint explains. Each spine's size is in units (rem on wide screens; on phones
   the widths become shares of the row). */
.landing-shelf { padding-top: 3rem; padding-bottom: 7rem; }
.landing-section-head { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2.5rem; }
.landing-shelf-row {
  display: flex; align-items: flex-end; gap: 0.375rem;
  height: 17.5rem;
  padding: 0 0.5rem;
  border-bottom: 6px solid var(--lectio-border);
}
.landing-spine {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  width: calc(var(--spine-width) * 1rem);
  height: calc(var(--spine-height) * 1rem);
  border-radius: 3px 3px 0 0;
  writing-mode: vertical-rl;
  font-family: var(--lectio-font-serif);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
a.landing-spine:hover { transform: translateY(-0.5rem); }
a.landing-spine::after {
  content: "";
  position: absolute; bottom: 0.625rem; left: 50%;
  width: 0.5rem; height: 0.5rem; margin-left: -0.25rem;
  border-radius: 2px;
  background: var(--lectio-color-fern);
}
.landing-spine--walden { --spine-width: 3.5; --spine-height: 13.75; background: var(--lectio-color-forest); color: var(--lectio-color-paper); }
.landing-spine--odyssey { --spine-width: 4.5; --spine-height: 15.625; background: var(--lectio-color-sage); color: var(--lectio-color-ink); }
.landing-spine--meditations { --spine-width: 3; --spine-height: 12.5; background: var(--lectio-color-graphite); color: var(--lectio-color-paper); }
.landing-spine--whitenights { --spine-width: 5.5; --spine-height: 16.375; background: var(--lectio-color-paper); color: var(--lectio-color-forest); font-size: 1.0625rem; font-weight: 600; }
.landing-spine--republic { --spine-width: 3.75; --spine-height: 14.25; background: var(--lectio-color-gilt-deep); color: var(--lectio-color-paper); }
.landing-spine--leaves { --spine-width: 4; --spine-height: 15; background: var(--lectio-color-ash); color: var(--lectio-color-ink); }
.landing-spine--discourse { --spine-width: 3.75; --spine-height: 13.75; background: var(--lectio-color-rubric); color: var(--lectio-color-paper); }
.landing-spine--confessions { --spine-width: 4.375; --spine-height: 15.375; background: var(--lectio-color-sage); color: var(--lectio-color-forest); }
.landing-spine-ribbon {
  position: absolute; top: 0; right: 0.625rem;
  width: 0.625rem; height: 4rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
  transform-origin: top center;
}
.landing-hint { display: flex; align-items: center; gap: 0.625rem; margin: 1.25rem 0 0; font-size: 0.9375rem; color: var(--lectio-text-muted); }
.landing-hint-mark { width: 0.625rem; height: 0.625rem; border-radius: 2px; background: var(--lectio-primary); flex: none; }
@media (max-width: 767.98px) {
  .landing-shelf { padding-bottom: 5rem; }
  .landing-shelf-row { gap: 0.25rem; height: 15rem; padding: 0; }
  .landing-spine { flex: var(--spine-width) 1 0; width: auto; min-width: 0; height: calc(var(--spine-height) * 0.85rem); font-size: 0.8125rem; }
  .landing-spine--whitenights { font-size: 0.875rem; }
  .landing-spine-ribbon { right: 0.375rem; width: 0.5rem; height: 3.25rem; }
  a.landing-spine::after { bottom: 0.5rem; width: 0.4375rem; height: 0.4375rem; margin-left: -0.21875rem; }
}
/* From 768px the shelf no longer fills the width: centre the whole section on the page, with
   the board just a little wider than its books. */
@media (min-width: 768px) {
  .landing-shelf .landing-section-head { align-items: center; text-align: center; }
  .landing-shelf-row { width: fit-content; margin-inline: auto; padding: 0 1.5rem; }
  .landing-hint { justify-content: center; }
}

/* The margins: one note joined to four books by orthogonal lines (brand-book § E, Connections).
   Narrow screens (the default here): a tree, the note at the top left, a trunk down its left
   edge and one branch per book. From 992px: the note in the middle, two books on each side. */
.landing-margins {
  padding: 6.5rem 0 7rem;
  background: var(--lectio-surface);
  border-block: 1px solid var(--lectio-border);
}
.landing-margins .landing-h2 { margin-bottom: 1.25rem; }
/* The spines' targets sit just above the section's title (not at their place in the flow), so following one
   lands with the title, the diagram and the caption in view. Kept as siblings for the :target ~ rules. */
.landing-margins { position: relative; }
.landing-target { position: absolute; top: 5rem; left: 0; display: block; }
.landing-diagram { position: relative; max-width: 26rem; height: 21rem; margin: 4rem auto 0; }
.landing-line { position: absolute; display: block; background: var(--lectio-primary); opacity: 0.25; transition: opacity 0.6s ease; }
.landing-line--left { left: 0.875rem; top: 1.75rem; width: 1px; height: 16.8125rem; transform-origin: top center; }
.landing-diagram .landing-line--left { opacity: 1; } /* the note's stem */
.landing-line--right { display: none; }
.landing-line--walden, .landing-line--meditations, .landing-line--republic, .landing-line--discourse { left: 0.875rem; width: 1.375rem; height: 1px; transform-origin: left center; }
.landing-line--walden { top: 5.0625rem; }
.landing-line--meditations { top: 9.5625rem; }
.landing-line--republic { top: 14.0625rem; }
.landing-line--discourse { top: 18.5625rem; }
.landing-node {
  position: absolute; display: block;
  width: 1.125rem; height: 1.125rem; box-sizing: border-box;
  border: 1.5px solid var(--lectio-color-paper); border-radius: 2px;
  outline: 2px solid transparent; outline-offset: 4px;
  transition: outline-color 0.5s ease;
}
.landing-node--walden, .landing-node--meditations, .landing-node--republic, .landing-node--discourse { left: 2.25rem; }
.landing-node--walden { top: 4.5rem; background: var(--lectio-color-forest); }
.landing-node--meditations { top: 9rem; background: var(--lectio-color-graphite); }
.landing-node--republic { top: 13.5rem; background: var(--lectio-color-gilt-deep); }
.landing-node--discourse { top: 18rem; background: var(--lectio-color-rubric); }
/* A book's square is a link too (to the same target as its label). It is skipped by Tab and
   screen readers, which reach the label; the invisible ::before makes a 42px touch target. */
a.landing-node:hover { border-color: var(--lectio-primary); } /* the ring (outline) stays the selection's */
a.landing-node::before { content: ""; position: absolute; inset: -0.75rem; }
.landing-node--note { left: 0; top: 0; width: 1.75rem; height: 1.75rem; border: 0; }
/* The landing's only gold (test_brand.test_gold_usage_is_limited names this line). */
.landing-ribbon, .landing-spine-ribbon, .landing-node--note { background: var(--lectio-accent); }
.landing-node-label { position: absolute; right: 0; display: flex; flex-direction: column; margin: 0; text-decoration: none; }
.landing-node-title { font-family: var(--lectio-font-serif); font-size: 1.0625rem; line-height: 1.4; color: var(--lectio-text); }
.landing-node-meta { font-size: 0.8125rem; color: var(--lectio-text-muted); transition: color 0.5s ease; }
a.landing-node-label:hover .landing-node-title { text-decoration: underline; text-underline-offset: 3px; }
.landing-node-label--note { left: 2.75rem; top: 0; }
.landing-node-label--note .landing-node-title { font-style: italic; font-size: 1.1875rem; }
.landing-node-label--walden, .landing-node-label--meditations, .landing-node-label--republic, .landing-node-label--discourse { left: 4rem; }
.landing-node-label--walden { top: 4.25rem; }
.landing-node-label--meditations { top: 8.75rem; }
.landing-node-label--republic { top: 13.25rem; }
.landing-node-label--discourse { top: 17.75rem; }
@media (min-width: 992px) {
  .landing-diagram { max-width: none; width: 47.5rem; height: 21.25rem; }
  .landing-line--left, .landing-line--right { display: block; top: 10.625rem; width: 18.25rem; height: 1px; }
  .landing-line--left { left: 5.5625rem; transform-origin: right center; }
  .landing-diagram .landing-line--left { opacity: 0.25; }
  .landing-line--right { left: 23.75rem; transform-origin: left center; }
  .landing-line--walden, .landing-line--meditations, .landing-line--republic, .landing-line--discourse { width: 1px; height: 7.5625rem; }
  .landing-line--walden { left: 5.5625rem; top: 3.0625rem; transform-origin: bottom center; }
  .landing-line--meditations { left: 5.5625rem; top: 10.625rem; transform-origin: top center; }
  .landing-line--republic { left: 42rem; top: 3.0625rem; transform-origin: bottom center; }
  .landing-line--discourse { left: 42rem; top: 10.625rem; transform-origin: top center; }
  .landing-node--walden { left: 5rem; top: 2.5rem; }
  .landing-node--meditations { left: 5rem; top: 17.625rem; }
  .landing-node--republic { left: 41.4375rem; top: 2.5rem; }
  .landing-node--discourse { left: 41.4375rem; top: 17.625rem; }
  .landing-node--note { left: 22.875rem; top: 9.75rem; }
  .landing-node-label { right: auto; }
  .landing-node-label--walden, .landing-node-label--meditations { left: 7rem; }
  .landing-node-label--walden { top: 2rem; }
  .landing-node-label--meditations { top: 17.125rem; }
  .landing-node-label--republic, .landing-node-label--discourse { left: 25.5625rem; width: 15rem; text-align: right; }
  .landing-node-label--republic { top: 2rem; }
  .landing-node-label--discourse { top: 17.125rem; }
  .landing-node-label--note { left: 15.625rem; top: 12.375rem; width: 16.25rem; text-align: center; }
}
.landing-captions { margin-top: 2.5rem; }
/* The note's title, set upright inside the italic caption so its quotes read clearly. */
.landing-caption-note { font-style: normal; color: var(--lectio-text); white-space: nowrap; }
.landing-caption { display: none; margin: 0 auto; max-width: 34em; text-align: center; font-family: var(--lectio-font-serif); font-style: italic; font-size: 1.0625rem; color: var(--lectio-text-muted); }

/* Which book is shown. A fresh visit: The Republic. Following a spine (or a book in the diagram)
   targets #notes-<book>: The Republic steps back and that book lights, with the trunk on its side. */
.landing-line--republic, .landing-line--right { opacity: 1; }
.landing-node--republic { outline-color: var(--lectio-primary); }
.landing-node-label--republic .landing-node-meta { color: var(--lectio-primary); }
.landing-caption--republic { display: block; }
.landing-target:target ~ .landing-diagram .landing-line--republic,
.landing-target:target ~ .landing-diagram .landing-line--right { opacity: 0.25; }
.landing-target:target ~ .landing-diagram .landing-node--republic { outline-color: transparent; }
.landing-target:target ~ .landing-diagram .landing-node-label--republic .landing-node-meta { color: var(--lectio-text-muted); }
.landing-target:target ~ .landing-captions .landing-caption--republic { display: none; }
#notes-walden:target ~ .landing-diagram .landing-line--walden,
#notes-walden:target ~ .landing-diagram .landing-line--left,
#notes-meditations:target ~ .landing-diagram .landing-line--meditations,
#notes-meditations:target ~ .landing-diagram .landing-line--left,
#notes-republic:target ~ .landing-diagram .landing-line--republic,
#notes-republic:target ~ .landing-diagram .landing-line--right,
#notes-discourse:target ~ .landing-diagram .landing-line--discourse,
#notes-discourse:target ~ .landing-diagram .landing-line--right { opacity: 1; }
#notes-walden:target ~ .landing-diagram .landing-node--walden,
#notes-meditations:target ~ .landing-diagram .landing-node--meditations,
#notes-republic:target ~ .landing-diagram .landing-node--republic,
#notes-discourse:target ~ .landing-diagram .landing-node--discourse { outline-color: var(--lectio-primary); }
#notes-walden:target ~ .landing-diagram .landing-node-label--walden .landing-node-meta,
#notes-meditations:target ~ .landing-diagram .landing-node-label--meditations .landing-node-meta,
#notes-republic:target ~ .landing-diagram .landing-node-label--republic .landing-node-meta,
#notes-discourse:target ~ .landing-diagram .landing-node-label--discourse .landing-node-meta { color: var(--lectio-primary); }
#notes-walden:target ~ .landing-captions .landing-caption--walden,
#notes-meditations:target ~ .landing-captions .landing-caption--meditations,
#notes-republic:target ~ .landing-captions .landing-caption--republic,
#notes-discourse:target ~ .landing-captions .landing-caption--discourse { display: block; }

/* Habits and the closing line. */
.landing-habits { padding-top: 6.5rem; }
.landing-habits .landing-h2 { margin-bottom: 3rem; max-width: 20em; }
.landing-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr)); gap: 1.5rem; }
.landing-panel { padding: 1.75rem; background: var(--lectio-surface); border: 1px solid var(--lectio-border); border-radius: var(--lectio-radius-panel); }
.landing-panel .landing-muted { margin-bottom: 1.25rem; }
.landing-panel .landing-muted:last-child { margin-bottom: 0; }
/* The habit panels' inset cards: a label, one large figure, a small picture, a quiet line. */
/* Side by side, both insets fill their (equal-height) panels; the goal shelf sits at the inset's foot. */
.landing-panel { display: flex; flex-direction: column; }
.landing-inset { flex: 1 1 auto; display: flex; flex-direction: column; padding: 1.25rem 1.25rem 1rem; background: var(--lectio-background); border: 1px solid var(--lectio-border); border-radius: var(--lectio-radius-panel); }
.landing-inset-label { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--lectio-text-muted); }
.landing-inset-figures { display: flex; align-items: baseline; gap: 0.5rem; margin: 0.25rem 0 1rem; font-variant-numeric: tabular-nums; }
.landing-inset-figure { font-family: var(--lectio-font-serif); font-size: 2.5rem; font-weight: 600; line-height: 1; color: var(--lectio-heading); }
.landing-inset-total { font-family: var(--lectio-font-serif); font-size: 1.125rem; color: var(--lectio-text-muted); }
/* The log: a week as a ledger, one colour for every day's bar, sized by minutes (75 = full). */
.landing-log { display: grid; gap: 0.375rem; margin: 0; padding: 0; list-style: none; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.landing-log-day { display: grid; grid-template-columns: 2.25rem 1fr 7.5rem; align-items: center; gap: 0.75rem; }
.landing-log-name { color: var(--lectio-text-muted); }
.landing-log-track { display: block; height: 0.625rem; }
.landing-log-bar { display: block; height: 100%; border-radius: 0 2px 2px 0; transform-origin: left center; background: var(--lectio-primary); }
.landing-log-value { text-align: end; color: var(--lectio-text-muted); }
.landing-log-day.is-rest .landing-log-track { border-bottom: 1px dashed var(--lectio-border); height: 0.3125rem; align-self: start; margin-top: 0.15rem; }
.landing-log-day.is-rest .landing-log-value { font-family: var(--lectio-font-serif); font-style: italic; }
.landing-log-day.is-rest .landing-log-bar { display: none; }
.landing-log-day:nth-child(1) .landing-log-bar { width: 60%; }
.landing-log-day:nth-child(2) .landing-log-bar { width: 40%; }
.landing-log-day:nth-child(4) .landing-log-bar { width: 80%; }
.landing-log-day:nth-child(5) .landing-log-bar { width: 27%; }
.landing-log-day:nth-child(6) .landing-log-bar { width: 100%; }
.landing-log-day:nth-child(7) .landing-log-bar { width: 40%; }
.landing-goal-percent { margin-inline-start: auto; font-weight: 600; color: var(--lectio-primary); }
/* The goal as a shelf of 24 spines, not a chart: one height band (books differ a little, no more),
 * a band near the head of each read spine, the shelf sitting at the foot of the inset. */
.landing-goal-shelf { display: flex; align-items: flex-end; gap: 3px; height: 4.5rem; margin-top: auto; padding-bottom: 2px; border-bottom: 2px solid var(--lectio-border); }
.landing-goal-book { position: relative; flex: 1 1 0; height: 88%; border-radius: 2px 2px 0 0; border: 1px solid var(--lectio-border); border-bottom: 0; }
.landing-goal-book:nth-child(3n) { height: 100%; }
.landing-goal-book:nth-child(4n+1) { height: 82%; }
.landing-goal-book:nth-child(5n+2) { height: 94%; }
.landing-goal-book.is-read { background: var(--lectio-primary); border-color: var(--lectio-primary); }
.landing-goal-book.is-read::before { content: ""; position: absolute; inset: 0.4rem 22% auto; height: 2px; background: var(--lectio-background); opacity: 0.45; }
.landing-goal-book.is-current { border-color: var(--lectio-primary); }
.landing-goal-book.is-current::after { content: ""; position: absolute; inset: auto 0 0; height: 50%; background: var(--lectio-primary); opacity: 0.55; }
.landing-closing { padding-top: 8rem; padding-bottom: 6rem; text-align: center; }
.landing-closing .landing-h2 { margin: 0 auto; }
.landing-closing .landing-muted { margin: 1.5rem auto 0; }
.landing-closing .landing-actions { justify-content: center; }

@media (max-width: 575.98px) {
  .landing-hero { padding-top: 3.5rem; padding-bottom: 4rem; gap: 2.5rem; }
  .landing-card { padding: 1.5rem; }
  .landing-margins { padding: 4.5rem 0 5rem; }
  .landing-target { top: 3rem; }
  .landing-closing { padding-top: 5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes landing-fade { from { opacity: 0; } }
  @keyframes landing-drop { from { transform: translateY(-101%); } }
  @keyframes landing-grow-x { from { transform: scaleX(0); } }
  @keyframes landing-grow-y { from { transform: scaleY(0); } }
  @keyframes landing-shelve { from { opacity: 0; transform: translateY(2.5rem); } }
  @keyframes landing-turn { 0%, 55% { transform: rotateY(0); } 85%, 100% { transform: rotateY(-180deg); } }
  @keyframes landing-sway { 0%, 100% { transform: rotate(-1.2deg); } 50% { transform: rotate(1.2deg); } }

  /* Following a spine glides down to the diagram instead of jumping. */
  html:has(.landing-target) { scroll-behavior: smooth; }

  /* Entrance animations fill backwards only, so hover still applies after them. The hero's text and
   * card are there from the first frame; only small details in the card move. */
  .landing-ribbon { animation: landing-drop 1.6s cubic-bezier(0.3, 0.8, 0.2, 1) 0.4s backwards; }
  .landing-turn-leaf { animation: landing-turn 4s cubic-bezier(0.45, 0, 0.25, 1) infinite; }
  .landing-bar-fill { animation: landing-grow-x 2.4s cubic-bezier(0.3, 0.7, 0.2, 1) 0.3s backwards; }
  .landing-spine-ribbon { animation: landing-sway 6s ease-in-out infinite; }
  .landing-goal-book { transform-origin: bottom center; animation: landing-grow-y 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .landing-goal-book:nth-child(4n+2) { animation-delay: 0.08s; }
  .landing-goal-book:nth-child(4n+3) { animation-delay: 0.16s; }
  .landing-goal-book:nth-child(4n) { animation-delay: 0.24s; }
  .landing-log-bar { animation: landing-grow-x 1.2s cubic-bezier(0.3, 0.7, 0.2, 1) backwards; }
  .landing-log-day:nth-child(2) .landing-log-bar { animation-delay: 0.08s; }
  .landing-log-day:nth-child(4) .landing-log-bar { animation-delay: 0.24s; }
  .landing-log-day:nth-child(5) .landing-log-bar { animation-delay: 0.32s; }
  .landing-log-day:nth-child(6) .landing-log-bar { animation-delay: 0.4s; }
  .landing-log-day:nth-child(7) .landing-log-bar { animation-delay: 0.48s; }
  /* Where scroll-driven animation is supported, the bars and spines grow as their card comes up the
     screen instead of on load (they sit far below the fold, so on load they'd be over before seen).
     Elsewhere the load-time animation above stays. */
  @supports (animation-timeline: view()) {
    .landing-inset { view-timeline: --landing-inset block; }
    .landing-log-bar, .landing-goal-book { animation-timeline: --landing-inset; animation-duration: auto; animation-delay: 0s; animation-fill-mode: both; animation-range: cover 8% cover 30%; }
    .landing-log-day:nth-child(2) .landing-log-bar { animation-delay: 0s; animation-range: cover 10% cover 32%; }
    .landing-log-day:nth-child(4) .landing-log-bar { animation-delay: 0s; animation-range: cover 14% cover 36%; }
    .landing-log-day:nth-child(5) .landing-log-bar { animation-delay: 0s; animation-range: cover 16% cover 38%; }
    .landing-log-day:nth-child(6) .landing-log-bar { animation-delay: 0s; animation-range: cover 18% cover 40%; }
    .landing-log-day:nth-child(7) .landing-log-bar { animation-delay: 0s; animation-range: cover 20% cover 42%; }
    /* The shelf fills from left to right, six spines at a time. */
    .landing-goal-book:nth-child(n) { animation-delay: 0s; }
    .landing-goal-book:nth-child(n+7) { animation-range: cover 12% cover 34%; }
    .landing-goal-book:nth-child(n+13) { animation-range: cover 16% cover 38%; }
    .landing-goal-book:nth-child(n+19) { animation-range: cover 20% cover 42%; }
  }
  .landing-spine { animation: landing-shelve 1s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .landing-shelf-row > :nth-child(2) { animation-delay: 0.1s; }
  .landing-shelf-row > :nth-child(3) { animation-delay: 0.2s; }
  .landing-shelf-row > :nth-child(4) { animation-delay: 0.3s; }
  .landing-shelf-row > :nth-child(5) { animation-delay: 0.4s; }
  .landing-shelf-row > :nth-child(6) { animation-delay: 0.5s; }
  .landing-shelf-row > :nth-child(7) { animation-delay: 0.6s; }
  .landing-shelf-row > :nth-child(8) { animation-delay: 0.7s; }
  /* The tree: the stem grows down, then the branches out. */
  .landing-line--left, .landing-line--right { animation: landing-grow-y 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.3s backwards; }
  .landing-line--walden, .landing-line--meditations, .landing-line--republic, .landing-line--discourse { animation: landing-grow-x 0.8s cubic-bezier(0.4, 0, 0.2, 1) 1.3s backwards; }
  /* Wide: the trunks grow out from the note, then the branches up and down. */
  @media (min-width: 992px) {
    .landing-line--left, .landing-line--right { animation-name: landing-grow-x; }
    .landing-line--walden, .landing-line--meditations, .landing-line--republic, .landing-line--discourse { animation-name: landing-grow-y; }
  }
  .landing-node, .landing-node-label { animation: landing-fade 1.2s ease 2s backwards; }
  .landing-node--note, .landing-node-label--note { animation-delay: 0.1s; }

  /* Where the browser can, the shelf and the diagram draw in as they scroll into view. Every
     part follows its whole shelf or diagram (named timelines), so a part never waits for its
     own position: the diagram is complete by the time it sits in the lower half of the screen. */
  @supports (animation-timeline: view()) {
    .landing-shelf-row { view-timeline: --landing-shelf block; }
    .landing-diagram { view-timeline: --landing-diagram block; }
    .landing-shelf-row > .landing-spine { animation-timeline: --landing-shelf; animation-delay: 0s; animation-range: entry 0% entry 90%; }
    .landing-line, .landing-node, .landing-node-label { animation-timeline: --landing-diagram; animation-delay: 0s; }
    .landing-node--note, .landing-node-label--note { animation-range: entry 0% entry 50%; }
    .landing-line--left, .landing-line--right { animation-range: entry 20% entry 80%; }
    .landing-line--walden, .landing-line--meditations, .landing-line--republic, .landing-line--discourse { animation-range: entry 70% cover 25%; }
    .landing-node:not(.landing-node--note), .landing-node-label:not(.landing-node-label--note) { animation-range: entry 90% cover 30%; }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* --- book page: cover beside the title; the reading card under it on a phone, so progress and
   logging start within the first screen ----------------------------------------------------- */
.book-head {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  grid-template-areas: "cover title" "reading reading";
  gap: 1rem;
}
.book-head-cover { grid-area: cover; }
.book-head-title { grid-area: title; min-width: 0; }
.book-head-reading { grid-area: reading; min-width: 0; }
/* The narrow cover sets its title like the dashboard's phone cover (.reading-cover). */
@media (max-width: 767.98px) {
  .book-head-cover .cover-title { font-size: 0.625rem; }
  .book-head-cover .cover-placeholder { padding: 0.5rem; }
  .book-head-cover .cover-icon { top: 0.5rem; left: 0.5rem; }
}
@media (min-width: 768px) {
  .book-head {
    grid-template-columns: 13rem minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "cover title" "cover reading";
    column-gap: 1.5rem;
  }
}
.book-menu { position: relative; flex: none; }
.book-menu-options { flex-direction: column; align-items: stretch; }
.book-menu-options .btn, .book-menu-options form { width: 100%; }
/* The status as a pill in its badge colours: the select is see-through, the pill paints it. */
.status-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: var(--lectio-radius-control);
  font-size: 0.875rem;
  font-weight: 500;
}
.status-pill select {
  appearance: none;
  padding: 0.125rem 1.625rem 0.125rem 0.625rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
}
.status-pill select option { background: var(--lectio-surface); color: var(--lectio-text); }
.status-pill .icon { position: absolute; right: 0.375rem; pointer-events: none; }
.book-place { display: flex; align-items: center; gap: 0.875rem; }
.book-place-line { font-family: var(--lectio-font-serif); font-weight: 600; font-size: 1.125rem; color: var(--lectio-heading); font-variant-numeric: tabular-nums; }
.progress-page { flex: none; width: 4.5rem; height: 4.5rem; }
.progress-page-sheet { fill: var(--lectio-surface); stroke: var(--lectio-border); stroke-width: 1.5; }
.progress-page-ribbon { fill: var(--lectio-primary); }
.progress-page-figure { fill: var(--lectio-heading); font-family: var(--lectio-font-serif); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.progress-page-figure.is-full { font-size: 13px; }
.book-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.875rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--lectio-border);
}
.book-figures dt { font-size: 0.8125rem; font-weight: 500; color: var(--lectio-text-muted); }
.book-figures dd { margin: 0; }
.book-figure { font-family: var(--lectio-font-serif); font-weight: 600; font-size: 1.125rem; line-height: 1.4; color: var(--lectio-heading); font-variant-numeric: tabular-nums; }
.book-figure-note { font-size: 0.8125rem; color: var(--lectio-text-muted); }
.js-panel[hidden] { display: none !important; } /* over d-flex */
.book-menu-options .favorite-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; }
.book-actions { flex: none; }

/* --- feedback ------------------------------------------------------------------------------- */
.feedback-list { margin: 0; }
.feedback-item { border-top: 1px solid var(--lectio-border); padding: 0.75rem 0; }
.feedback-item:last-child { border-bottom: 1px solid var(--lectio-border); }
.feedback-item summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.75rem; cursor: pointer; }
.feedback-title { font-family: var(--lectio-font-serif); font-weight: 600; flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
