@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/source-serif-4-latin.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --bg: #f8f4ec;
  --surface: #fffdf8;
  --surface-2: #f1ebdf;
  --ink: #2a251f;
  --ink-2: #554c41;
  --muted: #6b6155;
  --line: #e2d9c9;
  --accent: #2d6a5a;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe4;
  --accent-line: #2d6a5a;
  --warn-bg: #fbecd2;
  --warn-ink: #6e4510;
  --danger: #a3352a;
  --band: rgba(45, 106, 90, 0.12);
  --focus: #1f5fbf;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.06), 0 2px 8px rgba(60, 45, 20, 0.05);
  --serif: 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 12px;
  --gutter: 16px;
  --col: 640px;
  --bottom-nav: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #1b1916;
    --surface: #24211d;
    --surface-2: #2d2924;
    --ink: #eee7dc;
    --ink-2: #d2c9bb;
    --muted: #b0a696;
    --line: #3b362f;
    --accent: #84c9b4;
    --accent-ink: #10231d;
    --accent-soft: #23362f;
    --accent-line: #84c9b4;
    --warn-bg: #3a2c16;
    --warn-ink: #f2cf98;
    --danger: #f08e83;
    --band: rgba(132, 201, 180, 0.14);
    --focus: #8fb8ff;
    --shadow: none;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #1b1916;
  --surface: #24211d;
  --surface-2: #2d2924;
  --ink: #eee7dc;
  --ink-2: #d2c9bb;
  --muted: #b0a696;
  --line: #3b362f;
  --accent: #84c9b4;
  --accent-ink: #10231d;
  --accent-soft: #23362f;
  --accent-line: #84c9b4;
  --warn-bg: #3a2c16;
  --warn-ink: #f2cf98;
  --danger: #f08e83;
  --band: rgba(132, 201, 180, 0.14);
  --focus: #8fb8ff;
  --shadow: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  overflow-wrap: break-word;
  padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; font-weight: 600; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); text-underline-offset: 2px; }
[data-theme] a, a { color: var(--accent); }
img, svg { max-width: 100%; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.3em; border-radius: 4px; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.icon-sm { width: 16px; height: 16px; vertical-align: -2px; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.875rem; }
.lead { font-size: 1.05rem; color: var(--ink-2); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: grid; gap: 8px; }
.stack > * { min-width: 0; }

/* Header ------------------------------------------------------------------ */
.site-header { background: var(--bg); border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  color: var(--ink); font-family: var(--serif); font-weight: 600; font-size: 1.1rem; min-height: 44px;
}
.brand-icon { color: var(--accent); width: 24px; height: 24px; }
.top-nav { display: none; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.why-link { font-size: 0.9rem; padding: 10px 6px; min-height: 44px; display: inline-flex; align-items: center; }
.icon-button {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  color: var(--ink-2);
}
.icon-button:hover { background: var(--surface-2); }
.icon-button[aria-current='page'] { color: var(--accent); }

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottom-nav); color: var(--muted); text-decoration: none; font-size: 0.75rem;
}
.bottom-link[aria-current='page'] { color: var(--accent); font-weight: 600; }
.bottom-link .icon { width: 22px; height: 22px; }

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .top-nav { display: flex; gap: 4px; margin-left: 16px; }
  .top-link {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 44px;
    border-radius: 999px; color: var(--ink-2); text-decoration: none; font-size: 0.95rem;
  }
  .top-link .icon { width: 18px; height: 18px; }
  .top-link:hover { background: var(--surface-2); }
  .top-link[aria-current='page'] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
}

/* Page ------------------------------------------------------------------- */
.page { max-width: var(--col); margin: 0 auto; padding: 20px var(--gutter) 32px; }
.site-footer {
  max-width: var(--col); margin: 0 auto; padding: 16px var(--gutter) 32px;
  color: var(--muted); font-size: 0.8rem; border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 1.1rem; }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 14px; border-radius: 10px; }
.loading { color: var(--muted); }
/* Reserve room while the page script renders so the footer doesn't jump. */
.today, .catch-up, .plan-list { min-height: 100vh; }
.badge {
  display: inline-block; font: 600 0.7rem/1 var(--sans); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--ink); padding: 4px 8px; border-radius: 999px; vertical-align: 2px;
}

/* Buttons ---------------------------------------------------------------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font: 600 1rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.primary:hover { filter: brightness(1.08); }
.button.ghost { background: transparent; }
.button.small { min-height: 44px; padding: 6px 12px; font-size: 0.9rem; }
.button.big { width: 100%; padding: 14px 18px; font-size: 1.05rem; margin-top: 8px; }
.button.mark { width: 100%; margin-top: 8px; }
.button.danger { color: var(--danger); border-color: currentColor; background: transparent; }
a.button.primary { color: var(--accent-ink); }

/* Progress ---------------------------------------------------------------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress.thin { height: 6px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Today ------------------------------------------------------------------ */
.today-header h1 { font-size: 1.45rem; margin-bottom: 4px; }
.today-header .day-num { color: var(--accent); white-space: nowrap; }
.today-header .personal { margin: 0 0 6px; color: var(--ink-2); }
.today-header .progress { margin-bottom: 4px; }
.today-header { margin-bottom: 16px; }
.status { padding: 10px 14px; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.status.behind { background: var(--warn-bg); color: var(--warn-ink); }
.status.behind a { color: inherit; font-weight: 700; }
.status.ahead { color: var(--muted); padding: 0 2px; font-size: 0.9rem; }
.welcome { border-color: var(--accent-line); background: var(--accent-soft); }
.welcome p:first-child { font-family: var(--serif); font-size: 1.1rem; }
.celebrate { border-color: var(--accent-line); text-align: center; }

.group-label {
  font: 600 0.75rem/1.2 var(--sans); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 12px 0 6px;
}
.chip-group:first-of-type .group-label { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; flex-direction: column; justify-content: center; min-height: 44px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  text-decoration: none; color: var(--ink); max-width: 100%;
}
.chip:hover { border-color: var(--accent-line); }
.chip-ref { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; line-height: 1.25; }
.chip-primary .chip-ref { font-size: 1.35rem; }
.chip-words { font-size: 0.78rem; color: var(--muted); }
.chip-state { color: var(--accent); display: inline-flex; }
.chip.is-read { border-color: var(--accent-line); }
.chip { position: relative; }
.chip-state { position: absolute; top: 6px; right: 6px; }
.chip.is-read { padding-right: 32px; }
.psalm-note { font-size: 0.9rem; color: var(--ink-2); margin: 6px 0 0; font-style: italic; font-family: var(--serif); }
.estimate { text-align: center; color: var(--muted); margin: 8px 0 0; font-size: 0.95rem; }
.reading.is-done .done-line, .done-line { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.done-line .icon { width: 24px; height: 24px; }
.done-line span { color: var(--ink); }
.tomorrow { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; }
.tomorrow .ref { font-family: var(--serif); font-weight: 600; }
.book-context { margin: 8px 0 16px; color: var(--ink-2); font-size: 0.95rem; }
.book-context p { margin-bottom: 6px; }
.day-nav { display: flex; justify-content: space-between; gap: 8px; }
.day-nav .button { flex: 1; }
.makeup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.makeup-item { display: grid; gap: 6px; grid-template-columns: 1fr auto; align-items: start; border-top: 1px solid var(--line); padding-top: 12px; }
.makeup-item:first-child { border-top: 0; padding-top: 0; }
.makeup-main { display: grid; }
.makeup-main .ref { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.sittings { grid-column: 1 / -1; font-size: 0.9rem; }
.sittings summary { cursor: pointer; min-height: 32px; color: var(--ink-2); }
.sittings ol { margin: 4px 0 0; padding-left: 1.4em; }

/* Plan ------------------------------------------------------------------- */
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-head h1 { margin: 0; }
.tabs { display: flex; gap: 4px; margin: 12px 0; border-bottom: 1px solid var(--line); }
[role='tab'] {
  font: 600 1rem var(--sans); background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 10px 16px; min-height: 44px; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
[role='tab'][aria-selected='true'] { color: var(--ink); border-bottom-color: var(--accent); }
.plan-tools { display: grid; gap: 8px; margin-bottom: 8px; }
.search input, input[type='date'], textarea, input[type='search'] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[type='date'] { width: auto; max-width: 100%; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0; gap: 2px; background: var(--surface); flex-wrap: wrap; }
.segmented legend { font-weight: 600; padding: 0 4px; margin-bottom: 4px; }
fieldset.segmented:has(legend:not(.visually-hidden)) { display: block; border: 0; padding: 0; background: none; }
.segmented label { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 8px; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--accent-soft); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); }
fieldset.segmented:has(legend:not(.visually-hidden)) label { border: 1px solid var(--line); margin-right: 4px; }

.month-title {
  position: sticky; top: 0; z-index: 5; background: var(--bg); margin: 0;
  padding: 12px 0 8px; font-size: 1.15rem; border-bottom: 1px solid var(--line);
}
.day-list { list-style: none; margin: 0 0 8px; padding: 0; }
/* Only lay out the months near the viewport (365 rows is a lot for a phone). */
.month { content-visibility: auto; contain-intrinsic-size: auto 2700px; }
.day-row { border-bottom: 1px solid var(--line); scroll-margin-top: 56px; }
.day-row-main { display: flex; align-items: stretch; gap: 4px; }
.check { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.check.small input { width: 20px; height: 20px; }
.row-toggle {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit; font: inherit;
  padding: 10px 4px; cursor: pointer; display: grid; grid-template-columns: auto 1fr; column-gap: 10px;
}
.row-date { font-weight: 700; }
.row-day { color: var(--muted); font-size: 0.85rem; justify-self: end; align-self: center; }
.row-refs { grid-column: 1 / -1; font-family: var(--serif); font-size: 1.02rem; }
.row-meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; }
.row-state { color: var(--ink-2); }
.row-state .icon { width: 14px; height: 14px; color: var(--accent); vertical-align: -2px; margin-right: 2px; }
.day-row.is-today { background: var(--accent-soft); border-radius: 10px; border-bottom-color: transparent; }
.today-badge { font: 600 0.7rem var(--sans); background: var(--accent); color: var(--accent-ink); padding: 2px 6px; border-radius: 999px; vertical-align: 2px; margin-left: 4px; text-transform: uppercase; }
.day-detail { padding: 4px 8px 14px 48px; }
.segments { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.segment { display: flex; align-items: center; gap: 4px; }
.start-marker { margin: 8px 0 0; padding: 6px 10px; font-size: 0.85rem; font-weight: 600; color: var(--accent); border-left: 3px solid var(--accent); }
.grace-divider { list-style: none; padding: 6px 10px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px dashed var(--line); text-align: center; }
.is-filtered { display: none !important; }

.book-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.book-row { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.book-row.is-gospel { border-left: 4px solid var(--accent); }
.book-head { display: flex; align-items: center; gap: 8px; }
.book-name { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; }
.book-pct { margin-left: auto; font-size: 0.85rem; color: var(--muted); display: inline-flex; gap: 2px; align-items: center; }
.book-pct .icon { width: 16px; height: 16px; color: var(--accent); }
.book-meta { font-size: 0.85rem; color: var(--muted); margin: 2px 0 6px; }

@media (min-width: 1024px) {
  body[data-page='plan'] .page { max-width: 760px; }
}

/* Catch up --------------------------------------------------------------- */
.options { display: grid; gap: 0; }
.option.is-suggested { border: 2px solid var(--accent-line); }
.option-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.option-letter {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); font: 700 0.9rem var(--sans); border: 1px solid var(--line);
}
.option-lead { color: var(--ink-2); }
.preview-list { padding-left: 1.2em; margin: 8px 0 12px; font-size: 0.95rem; }
.preview-list li { margin-bottom: 4px; }
.preview-list li.is-heavy { color: var(--danger); }
.preview-date { font-weight: 600; }
ol.preview-list { list-style: none; padding: 0; }
.warning { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; }
.slider { display: grid; gap: 4px; margin: 8px 0; }
.slider input { width: 100%; accent-color: var(--accent); min-height: 44px; }
.slider output { font-weight: 700; }

/* Settings --------------------------------------------------------------- */
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }
.history-list, .past-list { padding-left: 1.2em; margin: 0 0 12px; }
.danger-zone { border-color: var(--line); }
textarea { font: 0.85rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
input[type='file'] { font: inherit; width: 100%; max-width: 100%; min-height: 44px; }

/* About ------------------------------------------------------------------ */
.prose { font-family: var(--serif); font-size: 1.08rem; line-height: 1.65; }
.prose h1 { font-size: 1.8rem; }
.prose h2 { margin-top: 1.4em; }
.prose h2[id] { scroll-margin-top: 16px; }
.prose .card, .prose .charts { font-family: var(--sans); font-size: 1rem; line-height: 1.5; }
.charts { margin: 24px 0; }
.chart { margin: 0 0 16px; }
.chart figcaption { font-size: 0.9rem; margin-bottom: 4px; }
.chart-plot { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .band { fill: var(--band); }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .tick { fill: var(--muted); font: 13px var(--sans); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-tip {
  position: absolute; top: -6px; transform: translateY(-100%); pointer-events: none; white-space: nowrap;
  background: var(--ink); color: var(--bg); font-size: 0.8rem; padding: 4px 8px; border-radius: 6px;
}
.chart-key { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.band-swatch { width: 18px; height: 12px; background: var(--band); border: 1px solid var(--line); border-radius: 3px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 8px 0; }
.compare-table caption { text-align: left; font-weight: 600; margin-bottom: 6px; }
.compare-table th, .compare-table td { padding: 6px 3px; border-bottom: 1px solid var(--line); text-align: right; }
.compare-table th[scope='row'], .compare-table thead th:first-child { text-align: left; font-weight: 600; }
.compare-table thead th { color: var(--muted); font-weight: 600; vertical-align: bottom; }
.numbers { padding-left: 1.2em; margin: 0; }
.numbers li { margin-bottom: 6px; }

/* Toast ------------------------------------------------------------------ */
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(var(--bottom-nav) + 12px + env(safe-area-inset-bottom)); z-index: 30; display: flex; justify-content: center; pointer-events: none; padding: 0 var(--gutter); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 520px;
  background: var(--ink); color: var(--bg); padding: 6px 6px 6px 16px; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast button { background: none; border: 0; color: inherit; font: 600 0.95rem var(--sans); min-height: 44px; min-width: 44px; padding: 0 10px; cursor: pointer; border-radius: 8px; }
.toast .toast-action { text-decoration: underline; }
@media (min-width: 768px) { .toast-region { bottom: 24px; } }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .toast { animation: toast-in 0.18s ease-out; }
  @keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
}

/* Print: compact two-column checklist ------------------------------------ */
@media print {
  @page { margin: 12mm; }
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #bbb; }
  body { font-size: 8.5pt; padding: 0; background: #fff; color: #000; }
  .site-header, .bottom-nav, .site-footer, .toast-region, .tabs, .plan-tools, #print-plan, .skip-link, #panel-books { display: none !important; }
  .page { max-width: none; padding: 0; }
  .plan-head h1 { font-size: 13pt; margin-bottom: 6pt; }
  .plan-head h1::after { content: ' — ESV word-balanced, one year'; font-weight: 400; font-size: 9pt; }
  #panel-days[hidden] { display: block !important; }
  .plan-list { column-count: 2; column-gap: 8mm; }
  .month { break-inside: auto; content-visibility: visible; }
  .month-title { position: static; font-size: 10pt; padding: 4pt 0 2pt; break-after: avoid; }
  .is-filtered { display: revert !important; }
  .day-row { break-inside: avoid; background: none !important; border-bottom: 0.5pt solid #ccc; }
  .day-row-main { align-items: center; }
  .check { min-width: 14pt; min-height: 0; }
  .check input { width: 9pt; height: 9pt; }
  .row-toggle { padding: 1.5pt 0; display: flex; gap: 4pt; flex-wrap: wrap; }
  .row-date { min-width: 30pt; }
  .row-day, .row-meta, .today-badge, .start-marker, .day-detail, .grace-divider { display: none !important; }
  .row-refs { font-size: 8.5pt; }
}
