/* SLOP — editorial type system. Restraint, book faces, one accent. No template tropes. */

/* Self-hosted book serif (Source Serif 4, variable). Shipped locally so the page
   typesets the same on every device instead of falling back to whatever serif the OS has. */
@font-face {
  font-family: "Source Serif 4 Variable";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("/public/fonts/source-serif-4-latin-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4 Variable";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("/public/fonts/source-serif-4-latin-italic.woff2") format("woff2");
}

:root {
  --paper:      #f5f1e8;
  --paper-2:    #efe9dc;
  --ink:        #1a1714;
  --ink-soft:   #574f44;
  --ink-faint:  #8a8073;
  --accent:     #7a1f1f;   /* oxblood — the cost, the ink-and-blood register */
  --accent-2:   #5c1717;
  --rule:       #d9d0bf;
  --rule-soft:  #e6ddcc;
  --paper-card: #fbf8f1;

  --serif: "Source Serif 4 Variable", "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --mono:  "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --measure: 37rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  /* book-grade typography: kerning, ligatures, contextual alternates, hung punctuation */
  font-feature-settings: "kern" 1, "liga" 1, "clig" 1, "calt" 1;
  font-kerning: normal;
  hanging-punctuation: first allow-end last;
}

/* Old-style (text) figures in the serif reading column read as a real book sets numbers;
   the sans UI (stats, nav, chapter numbers) keeps lining figures via its own rules. */
.reading, .lede, .hero .epigraph p, .chap-epigraph p, .reading blockquote, .preview {
  font-variant-numeric: oldstyle-nums proportional-nums;
}

::selection { background: rgba(122, 31, 31, 0.16); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 1.1rem clamp(1rem, 5vw, 3rem);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: saturate(1.1) blur(6px);
}
.brand {
  font-family: var(--sans); font-weight: 800; letter-spacing: 0.18em;
  font-size: 0.95rem; color: var(--ink); text-transform: uppercase;
}
.brand:hover { color: var(--accent); text-decoration: none; }
.topbar nav { display: flex; gap: 1.4rem; font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0.04em; }
.topbar nav a { color: var(--ink-soft); text-transform: uppercase; }

main { display: block; }
body.wide main { /* reader uses its own widths */ }

/* ---------- landing ---------- */
.hero {
  max-width: 46rem; margin: 0 auto; padding: clamp(2rem, 7vw, 4rem) 1.5rem 1rem;
  text-align: center;
}
.booktitle {
  font-family: var(--sans); font-weight: 900;
  font-size: clamp(4.5rem, 17vw, 9rem); letter-spacing: -0.02em; line-height: 0.9;
  margin: 0; color: var(--ink);
}
.subtitle {
  font-style: italic; font-size: clamp(1.15rem, 3.5vw, 1.6rem); color: var(--ink-soft);
  margin: 1rem auto 0; max-width: 30rem;
}
.epigraph {
  margin: 3rem auto 0; max-width: 26rem; border: 0; padding: 0;
}
.epigraph p {
  font-style: italic; font-size: 1.35rem; color: var(--ink); margin: 0;
}
.epigraph cite {
  display: block; margin-top: 0.8rem; font-style: normal; font-family: var(--sans);
  font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint);
}

.lede {
  max-width: var(--measure); margin: 3.5rem auto 0; padding: 0 1.5rem;
}
.lede p { margin: 0 0 1.2rem; }
.lede p:first-child { font-size: 1.2rem; }
.lede p:first-child::first-letter {
  float: left; font-weight: 700; font-size: 3.4rem; line-height: 0.78;
  padding: 0.2rem 0.6rem 0 0; color: var(--accent);
}
.begin { text-align: center; margin-top: 2rem !important; }
.begin a { font-family: var(--sans); font-weight: 600; font-size: 1.05rem; }
.pull-phrase {
  text-align: center; font-style: italic;
  font-size: clamp(1.15rem, 3vw, 1.4rem); color: var(--ink);
  margin: 2rem 0 !important; padding: 1.4rem 0;
  border-top: 1px solid var(--rule-soft); border-bottom: 1px solid var(--rule-soft);
}
.stakes-line {
  text-align: center; font-family: var(--sans); font-size: 0.82rem;
  color: var(--ink-faint); letter-spacing: 0.03em; font-style: italic;
  margin-top: 0.7rem !important;
}

/* stakes / trust strip */
.stakes-strip {
  margin: 4.5rem auto 0; padding: 3rem 1.5rem; background: var(--paper-2);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.strip-label {
  text-align: center; font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-faint); margin: 0 0 2rem;
}
.stakes {
  max-width: 56rem; margin: 0 auto; display: grid; gap: 1.6rem 2.4rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.stake { border-left: 2px solid var(--accent); padding-left: 1rem; }
.stake h3 { font-family: var(--sans); font-size: 0.98rem; font-weight: 700; margin: 0 0 0.35rem; }
.stake p { font-size: 0.95rem; line-height: 1.5; color: var(--ink-soft); margin: 0; }

/* contents */
.contents { max-width: 42rem; margin: 4.5rem auto 5rem; padding: 0 1.5rem; }
.section-rule, .movement-head {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.1em;
}
.section-rule {
  font-size: 0.9rem; color: var(--ink); border-bottom: 2px solid var(--ink);
  padding-bottom: 0.6rem; margin: 0 0 0.6rem;
}
.contents .meta, .meta {
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink-faint); margin: 0 0 1.8rem;
}
.movement-head {
  font-size: 0.78rem; color: var(--accent); margin: 2.4rem 0 0.8rem;
}
.toc { display: flex; flex-direction: column; }
.toc-row {
  display: grid; grid-template-columns: 2.4rem 1fr; align-items: baseline; gap: 0.9rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--rule-soft); color: var(--ink);
}
.toc-row:hover { text-decoration: none; background: var(--paper-card); }
.toc-num { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-faint); text-align: right; }
.toc-title { font-size: 1.1rem; }
.toc-row:hover .toc-title { color: var(--accent); }
.toc-words { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); }

/* ---------- reader ---------- */
/* Wide container so the side-by-side editor has room; prose blocks are re-narrowed to --measure. */
.chapter { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1.5rem 4rem; position: relative; }
.chap-toolbar, .chap-head, .reading, .chapnav { max-width: var(--measure); margin-left: auto; margin-right: auto; }

.chap-toolbar {
  display: flex; align-items: center; gap: 0.8rem;
  margin: 0.5rem auto 2.5rem; padding-bottom: 0.8rem;
}
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.seg-btn {
  font-family: var(--sans); font-size: 0.8rem; padding: 0.34rem 0.95rem; border: 0;
  background: transparent; color: var(--ink-soft); cursor: pointer;
}
.seg-btn.is-on { background: var(--ink); color: var(--paper); }
.notes-toggle {
  font-family: var(--sans); font-size: 0.8rem; padding: 0.34rem 0.85rem;
  border: 1px solid var(--rule); border-radius: 999px; background: transparent;
  color: var(--ink-soft); cursor: pointer;
}
.notes-toggle:hover { border-color: var(--accent); color: var(--accent); }
.note-count:not(:empty) {
  display: inline-block; min-width: 1.1rem; margin-left: 0.2rem; padding: 0 0.3rem;
  background: var(--accent); color: var(--paper); border-radius: 999px; font-size: 0.7rem;
}
.save-state { font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint); margin-left: auto; }
.edit-hint { font-family: var(--sans); font-size: 0.74rem; font-style: italic; color: var(--ink-faint); margin-left: auto; }
.save-state.dirty { color: var(--accent); }
.save-state.saved { color: #3a6b3a; }

.chap-head { margin-bottom: 2.2rem; }
.chap-eyebrow {
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 0.5rem;
}
.chap-title { font-size: clamp(2rem, 6vw, 2.9rem); line-height: 1.08; margin: 0; font-weight: 700; letter-spacing: -0.01em; }

.reading {
  font-size: 1.16rem;
  text-align: justify;
  text-justify: inter-word;
  -webkit-hyphens: auto;
  hyphens: auto;
  /* break words aggressively so justification fills lines instead of opening rivers of space:
     hyphenate words of 4+ chars, keeping >=2 chars before the break and >=2 after */
  -webkit-hyphenate-limit-before: 2;
  -webkit-hyphenate-limit-after: 2;
  hyphenate-limit-chars: 4 2 2;
}
.reading > p:first-of-type::first-letter {
  float: left; font-family: var(--serif); font-weight: 700; font-size: 3.6rem; line-height: 0.72;
  padding: 0.32rem 0.55rem 0 0; color: var(--accent);
}
.reading p { margin: 0 0 1.25rem; text-wrap: pretty; }
.reading em { font-style: italic; }
.reading strong { font-weight: 700; }
.reading h2 { font-size: 1.5rem; margin: 2.4rem 0 1rem; }
.reading hr {
  border: 0; text-align: center; margin: 2.4rem 0; color: var(--ink-faint);
}
.reading hr::before { content: "✦"; font-size: 0.9rem; letter-spacing: 0.5em; }
.reading blockquote {
  margin: 1.6rem 0; padding-left: 1.2rem; border-left: 3px solid var(--rule);
  color: var(--ink-soft); font-style: italic;
}
.reading a { border-bottom: 1px solid rgba(122,31,31,0.3); }

/* footnotes */
.footnotes { margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--rule); font-size: 0.96rem; color: var(--ink-soft); }
.footnotes hr { display: none; }
.footnote-ref a { font-size: 0.78em; color: var(--accent); border: 0; }
.footnotes ol { padding-left: 1.2rem; }
.footnotes li { margin-bottom: 0.7rem; }
/* Offset anchor scroll targets under the sticky topbar (~4.5rem tall) */
.footnotes li[id], .footnote-ref[id], sup.footnote-ref { scroll-margin-top: 4.5rem; }

/* Footnotes are collapsed by default so a reader can skip straight to the next chapter;
   they open on click of the summary, or automatically when a footnote reference is followed. */
.footnotes-collapse { margin-top: 3rem; border-top: 1px solid var(--rule); scroll-margin-top: 4.5rem; }
.footnotes-collapse > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--sans); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-faint); padding: 1.05rem 0 0.2rem;
}
.footnotes-collapse > summary::-webkit-details-marker { display: none; }
.footnotes-collapse > summary::after {
  content: "⌄"; font-size: 1.15rem; line-height: 1; color: var(--ink-faint);
  transition: transform 0.2s ease; transform: translateY(-0.12em);
}
.footnotes-collapse[open] > summary::after { transform: translateY(-0.04em) rotate(180deg); }
.footnotes-collapse > summary:hover, .footnotes-collapse > summary:hover::after { color: var(--accent); }
/* the wrapper now owns the top rule; the inner section drops its own */
.footnotes-collapse > .footnotes { margin-top: 0; padding-top: 0.5rem; border-top: 0; }
/* footnotes are click-to-edit in the authoring build only; the live site leaves them inert */
body:not(.live) .footnotes li:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-radius: 3px; cursor: text; transition: background 0.12s;
}

/* reading progress — a thin line at the very top edge that fills as you scroll a chapter */
.reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--accent); z-index: 25;
  transition: width 0.08s linear; pointer-events: none;
}

/* ---------- share row ---------- */
.share {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem;
  max-width: var(--measure); margin: 2.6rem auto 0; padding: 1.1rem 1.5rem 0;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--sans); font-size: 0.84rem;
}
.share-label {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; color: var(--ink-faint);
}
.share-link {
  color: var(--ink-soft); background: transparent; border: 1px solid var(--rule); cursor: pointer;
  width: 2.1rem; height: 2.1rem; border-radius: 999px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.share-link svg { width: 17px; height: 17px; display: block; }
.share-link:hover { color: var(--accent); border-color: var(--accent); background: var(--paper-card); text-decoration: none; }
/* copy button swaps the link glyph for a check while "Copied" is active */
.share-copy .ico-check { display: none; }
.share-copy.is-copied, .share-ig.is-copied { color: #3a6b3a; border-color: #3a6b3a; }
.share-copy.is-copied .ico-link { display: none; }
.share-copy.is-copied .ico-check { display: block; }
html[data-theme="dark"] .share-copy.is-copied,
html[data-theme="dark"] .share-ig.is-copied { color: #8fbf8a; border-color: #8fbf8a; }

.chapnav {
  display: flex; justify-content: space-between; gap: 1rem; margin-top: 3.5rem;
  padding-top: 1.4rem; border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.88rem;
}
.chapnav a { color: var(--ink-soft); }
.chapnav a:hover { color: var(--accent); text-decoration: none; }
.chapnav-top {
  margin-top: 0; margin-bottom: 1.6rem;
  padding-top: 0; padding-bottom: 1.1rem;
  border-top: 0; border-bottom: 1px solid var(--rule);
}

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; }
.editor-pane { display: flex; flex-direction: column; min-width: 0; }
.pane-label {
  font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 0.5rem;
}
.pane-label code { font-family: var(--mono); text-transform: none; color: var(--accent); font-size: 0.92em; }
#md {
  font-family: var(--mono); font-size: 0.86rem; line-height: 1.6; color: var(--ink);
  background: var(--paper-card); border: 1px solid var(--rule); border-radius: 4px;
  padding: 1rem; min-height: 65vh; resize: vertical; width: 100%;
}
#md:focus { outline: 2px solid rgba(122,31,31,0.35); border-color: var(--accent); }
.preview {
  background: var(--paper-card); border: 1px solid var(--rule-soft); border-radius: 4px;
  padding: 1.2rem 1.4rem; min-height: 65vh; overflow-y: auto; font-size: 1.02rem;
}
.preview h1 { font-size: 1.6rem; }
.preview hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }
.editor-actions { display: flex; gap: 0.7rem; margin-top: 0.9rem; }
.btn-primary {
  font-family: var(--sans); font-size: 0.88rem; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 4px; padding: 0.55rem 1.2rem;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-ghost {
  font-family: var(--sans); font-size: 0.88rem; cursor: pointer;
  background: transparent; color: var(--ink-soft); border: 1px solid var(--rule); border-radius: 4px; padding: 0.55rem 1.1rem;
}

/* ---------- notes panel ---------- */
.notes-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(24rem, 90vw);
  background: var(--paper-card); border-left: 1px solid var(--rule); z-index: 30;
  padding: 1.4rem; overflow-y: auto; box-shadow: -16px 0 40px rgba(26,23,20,0.12);
}
.notes-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.notes-head h2 { font-family: var(--sans); font-size: 0.95rem; margin: 0; }
.x { background: 0; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--ink-faint); }
#noteForm textarea {
  width: 100%; min-height: 5rem; font-family: var(--serif); font-size: 1rem; padding: 0.7rem;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); resize: vertical;
}
#noteForm { margin-bottom: 1.4rem; }
#noteForm .btn-primary { margin-top: 0.6rem; }
.notes-list { list-style: none; padding: 0; margin: 0; }
.notes-list li {
  border-left: 2px solid var(--accent); padding: 0.5rem 0 0.5rem 0.8rem; margin-bottom: 1rem;
}
.notes-list p { margin: 0 0 0.3rem; font-size: 1rem; }
.notes-list time { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); }
.notes-list .del { float: right; font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); background: 0; border: 0; cursor: pointer; }
.notes-list .del:hover { color: var(--accent); }

/* notes page */
.notes-page { max-width: 42rem; margin: 2rem auto 5rem; padding: 0 1.5rem; }
.notes-group { margin-top: 2rem; }
.notes-group h2 { font-family: var(--sans); font-size: 1.05rem; margin: 0 0 0.6rem; }
.hint { font-style: italic; }

/* ---------- footer ---------- */
.sitefoot {
  border-top: 1px solid var(--rule); margin-top: 4rem; padding: 2rem 1.5rem;
  text-align: center;
}
.sitefoot p { font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint); max-width: 34rem; margin: 0 auto; }

@media (max-width: 800px) {
  .editor { grid-template-columns: 1fr; }
  .editor-pane:nth-child(2) { display: none; } /* hide preview on narrow; toggle keeps edit usable */
}

/* ---------- epigraph page (bare leaf) ---------- */
body.bare { display: flex; flex-direction: column; min-height: 100vh; }
body.bare main { flex: 1; display: flex; align-items: center; justify-content: center; }
.epigraph-leaf { text-align: center; max-width: 32rem; padding: 2rem 1.5rem; }
.epigraph-big { border: 0; margin: 0; padding: 0; }
.epigraph-big p {
  font-style: italic; font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.3; color: var(--ink); margin: 0;
}
.epigraph-big cite {
  display: block; margin-top: 1.4rem; font-style: normal; font-family: var(--sans);
  font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint);
}
.leaf-continue {
  display: inline-block; margin-top: 3.5rem; font-family: var(--sans); font-size: 0.9rem;
  letter-spacing: 0.04em; color: var(--ink-soft);
}
.leaf-continue:hover { color: var(--accent); text-decoration: none; }

/* ---------- simple content pages (about / download / print / donate) ---------- */
.leaf.page { max-width: var(--measure); margin: 3rem auto 4rem; padding: 0 1.5rem; }
.leaf-title {
  font-family: var(--sans); font-weight: 800; font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: -0.01em; margin: 0 0 1.5rem; padding-bottom: 0.8rem; border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
.leaf.page h2 { font-size: 1.3rem; margin: 2.2rem 0 0.8rem; color: var(--accent); }
.leaf.page p { margin: 0 0 1.2rem; }
.about-page p, .about-page .about-lede { text-align: justify; text-justify: inter-word; }
.about-portrait { float: right; width: 168px; height: auto; border-radius: 10px; margin: 0.4rem 0 1rem 1.6rem; }
@media (max-width: 540px) { .about-portrait { float: none; display: block; margin: 0 auto 1.2rem; } }
.actions-col { display: flex; flex-direction: column; gap: 0.7rem; margin: 1.8rem 0; max-width: 28rem; }
.actions-col .btn-primary { text-align: center; padding: 0.7rem 1.2rem; }
.btn-primary.disabled {
  background: transparent; color: var(--ink-faint); border: 1px dashed var(--rule);
  cursor: default; pointer-events: none;
}
.pending {
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink-faint); font-style: italic;
  border-left: 2px solid var(--rule); padding-left: 0.9rem;
}

/* ---------- per-chapter epigraph ---------- */
.chap-epigraph {
  margin: 1.6rem 0 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--rule); border-top: 0;
  max-width: 28rem;
}
.chap-epigraph p { font-style: italic; color: var(--ink-soft); margin: 0 0 0.4rem; font-size: 1.05rem; }
.chap-epigraph cite {
  font-style: normal; font-family: var(--sans); font-size: 0.74rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- stats / forest view ---------- */
.stats-page { max-width: 52rem; margin: 2.5rem auto 5rem; padding: 0 1.5rem; }
.stats-title {
  font-family: var(--sans); font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.2rem);
  letter-spacing: -0.01em; margin: 0 0 1.8rem; padding-bottom: 0.7rem; border-bottom: 2px solid var(--ink);
}
.stat-totals {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem;
}
.stat-total-item { text-align: center; }
.stat-big {
  display: block; font-family: var(--sans); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1; color: var(--ink); letter-spacing: -0.02em;
}
.stat-lbl {
  display: block; font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-faint); margin-top: 0.35rem;
}
.stat-progress-bar {
  height: 5px; background: var(--rule); border-radius: 999px; margin-bottom: 3rem; overflow: hidden;
}
.stat-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.stat-section { margin-bottom: 2.5rem; }
.stat-movement {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent); margin: 0 0 0.8rem;
  display: flex; justify-content: space-between; align-items: baseline;
}
.stat-movement-words { font-weight: 400; color: var(--ink-faint); }
.stat-rows { display: flex; flex-direction: column; gap: 0.3rem; }
.stat-row {
  display: grid; grid-template-columns: 3.5rem 1fr 8rem 4rem;
  align-items: center; gap: 0.6rem; padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.stat-label {
  font-family: var(--sans); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); white-space: nowrap;
}
.stat-label:hover { color: var(--accent); text-decoration: none; }
.stat-title { font-size: 0.98rem; color: var(--ink); }
.stat-bar-wrap { background: var(--rule-soft); border-radius: 999px; height: 4px; overflow: hidden; }
.stat-bar { height: 100%; background: var(--accent); border-radius: 999px; opacity: 0.65; }
.stat-words {
  font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint);
  text-align: right; white-space: nowrap;
}
@media (max-width: 600px) {
  .stat-totals { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: 3rem 1fr 3rem; }
  .stat-bar-wrap { display: none; }
}

/* ---------- footer nav ---------- */
.footnav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.4rem; margin-bottom: 1rem;
  font-family: var(--sans); font-size: 0.82rem; letter-spacing: 0.03em;
}
.footnav a { color: var(--ink-soft); }
.footnav a:hover { color: var(--accent); text-decoration: none; }
.colophon { font-family: var(--sans); font-size: 0.76rem; color: var(--ink-faint); max-width: 34rem; margin: 0 auto; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  font-family: var(--sans); font-size: 1rem; line-height: 1; cursor: pointer;
  background: transparent; border: 1px solid var(--rule); border-radius: 999px;
  width: 1.9rem; height: 1.9rem; color: var(--ink-soft); padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .ticon { width: 15px; height: 15px; display: none; }
html:not([data-theme="dark"]) .theme-toggle .ticon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .ticon-sun { display: block; }

/* ---------- dark theme ---------- */
html[data-theme="dark"] {
  --paper:      #15120e;
  --paper-2:    #1d1813;
  --paper-card: #1c1712;
  --ink:        #ece3d3;
  --ink-soft:   #b6ab97;
  --ink-faint:  #877c69;
  --accent:     #d08368;   /* oxblood lifted to a warm clay so it reads on dark paper */
  --accent-2:   #e6a085;
  --rule:       #38312a;
  --rule-soft:  #2a241e;
}
html[data-theme="dark"] body { background: var(--paper); }
html[data-theme="dark"] ::selection { background: rgba(208, 131, 104, 0.22); }
html[data-theme="dark"] .save-state.saved { color: #8fbf8a; }
html[data-theme="dark"] .reading a { border-bottom-color: rgba(208, 131, 104, 0.4); }
html[data-theme="dark"] .btn-primary { color: #15120e; } /* dark text on the clay accent for contrast */

/* ---------- balanced display lines ---------- */
.booktitle, .subtitle { text-wrap: balance; }

/* ---------- collapsible Contents ---------- */
.contents-disclosure summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.9rem; color: var(--ink);
  border-bottom: 2px solid var(--ink); padding-bottom: 0.6rem;
}
.contents-disclosure summary::-webkit-details-marker { display: none; }
.contents-disclosure summary::after {
  content: "⌄"; font-size: 1.25rem; line-height: 1; color: var(--ink-soft); transition: transform 0.2s ease;
  transform: translateY(-0.15em);
}
.contents-disclosure[open] summary::after { transform: translateY(-0.05em) rotate(180deg); }
.contents-disclosure summary:hover { color: var(--accent); }
.contents-disclosure summary:hover::after { color: var(--accent); }
.contents-disclosure[open] summary { margin-bottom: 0.4rem; }

/* ---------- hamburger menu ---------- */
.menu-toggle {
  font-size: 1.35rem; line-height: 1; background: transparent; border: 0; cursor: pointer;
  color: var(--ink); padding: 0.1rem 0.3rem;
}
.menu-toggle:hover { color: var(--accent); }
.menu {
  position: absolute; top: 100%; right: clamp(1rem, 5vw, 3rem); margin-top: 0.5rem;
  background: var(--paper-card); border: 1px solid var(--rule); border-radius: 7px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.18); padding: 0.5rem; min-width: 12.5rem;
  display: flex; flex-direction: column; gap: 0.05rem; z-index: 40;
}
.menu[hidden] { display: none; }
.menu a {
  font-family: var(--sans); font-size: 0.9rem; color: var(--ink-soft); padding: 0.55rem 0.7rem; border-radius: 4px;
}
.menu a:hover { background: var(--paper-2); color: var(--accent); text-decoration: none; }
.menu .theme-toggle {
  width: auto; height: auto; border: 0; border-top: 1px solid var(--rule); border-radius: 0;
  justify-content: flex-start; font-family: var(--sans); font-size: 0.9rem;
  padding: 0.6rem 0.7rem; margin-top: 0.3rem; color: var(--ink-soft);
}
.menu .theme-toggle:hover { color: var(--accent); }

/* ---------- header contents dropdown ---------- */
.topbar-right { display: flex; align-items: center; gap: 0.55rem; }
.dropdown { position: relative; }
.dropdown-btn {
  font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-soft); background: transparent; border: 1px solid var(--rule); border-radius: 999px;
  padding: 0.34rem 0.85rem; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
}
.dropdown-btn:hover { border-color: var(--accent); color: var(--accent); }
.dropdown-btn .chev { font-size: 1rem; line-height: 1; transition: transform 0.2s ease; }
.dropdown-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.dropdown-panel {
  position: absolute; top: 100%; right: 0; margin-top: 0.5rem; width: 22rem; max-width: 84vw;
  max-height: 70vh; overflow-y: auto; background: var(--paper-card); border: 1px solid var(--rule);
  border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,0.2); padding: 0.5rem; z-index: 50;
}
.dropdown-panel[hidden] { display: none; }
.dd-chapters { display: flex; flex-direction: column; }
.dd-chapters a {
  display: grid; grid-template-columns: 1.8rem 1fr; gap: 0.6rem; align-items: baseline;
  padding: 0.4rem 0.6rem; border-radius: 4px; color: var(--ink);
}
.dd-chapters a:hover { background: var(--paper-2); text-decoration: none; }
.dd-chapters a:hover .dd-ttl { color: var(--accent); }
.dd-num { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); text-align: right; }
.dd-ttl { font-size: 0.98rem; }
.dd-divider { height: 1px; background: var(--rule); margin: 0.5rem 0.3rem; }
.dd-util {
  display: block; font-family: var(--sans); font-size: 0.84rem; color: var(--ink-soft);
  padding: 0.4rem 0.6rem; border-radius: 4px;
}
.dd-util:hover { background: var(--paper-2); color: var(--accent); text-decoration: none; }

/* nested TOC sub-dropdown inside the nav panel */
.dd-toc summary {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--sans); font-size: 0.84rem; color: var(--ink-soft);
  padding: 0.4rem 0.6rem; border-radius: 4px;
  cursor: pointer; list-style: none; user-select: none;
}
.dd-toc summary::-webkit-details-marker { display: none; }
.dd-toc summary::after { content: "›"; font-size: 1.1rem; opacity: 0.55; transition: transform 0.18s; }
.dd-toc[open] summary::after { transform: rotate(90deg); }
.dd-toc summary:hover { background: var(--paper-2); color: var(--accent); }
.dd-toc-inner { display: flex; flex-direction: column; }
.dd-toc-inner a {
  display: grid; grid-template-columns: 1.8rem 1fr; gap: 0.6rem; align-items: baseline;
  padding: 0.35rem 0.6rem 0.35rem 1.2rem; border-radius: 4px; color: var(--ink);
}
.dd-toc-inner a:hover { background: var(--paper-2); text-decoration: none; }
.dd-toc-inner a:hover .dd-ttl { color: var(--accent); }
.dd-mov-head {
  font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent);
  padding: 0.7rem 0.6rem 0.2rem 1.2rem;
}

/* ---------- paragraph inline editor ---------- */
/* Click any paragraph / heading / blockquote / footnote in the reading view to edit its markdown. */
/* Edit-cue only: the published (body.live) site never highlights paragraphs on hover/click. */
body:not(.live) .reading p:hover, body:not(.live) .reading h2:hover, body:not(.live) .reading h3:hover, body:not(.live) .reading blockquote:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-radius: 3px; cursor: text; outline: none;
  transition: background 0.12s;
}
.para-edit-wrap { margin: 0 0 1.25rem; }
.para-edit-ta {
  display: block; width: 100%; box-sizing: border-box;
  font-family: var(--serif); font-size: 1.1rem; line-height: 1.62; color: var(--ink);
  background: var(--paper-card); border: 1.5px solid var(--accent); border-radius: 4px;
  padding: 0.55rem 0.7rem; resize: none; outline: none; min-height: 3rem;
}
.para-edit-ta:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(122,31,31,0.12); }
.para-edit-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.para-save-btn {
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 4px; padding: 0.3rem 0.85rem;
}
.para-save-btn:hover { background: var(--accent-2); }
.para-save-btn:disabled { opacity: 0.55; cursor: default; }
.para-cancel-btn {
  font-family: var(--sans); font-size: 0.8rem; cursor: pointer;
  background: transparent; color: var(--ink-soft); border: 1px solid var(--rule);
  border-radius: 4px; padding: 0.3rem 0.75rem;
}
.para-cancel-btn:hover { border-color: var(--ink-faint); color: var(--ink); }
.para-edit-hint {
  font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); margin-left: 0.3rem;
}

/* ---------- support microcopy + contact form ---------- */
.microcopy { font-family: var(--serif); font-style: italic; font-size: 0.98rem; color: var(--ink-soft); margin: 1.2rem 0 0; }
.contact-form { display: flex; flex-direction: column; gap: 1.1rem; max-width: 30rem; margin: 1.6rem 0; }
.contact-form label { display: flex; flex-direction: column; gap: 0.35rem; font-family: var(--sans); font-size: 0.84rem; color: var(--ink-soft); }
.contact-form .opt { color: var(--ink-faint); }
.contact-form input, .contact-form textarea {
  font-family: var(--serif); font-size: 1rem; color: var(--ink); background: var(--paper-card);
  border: 1px solid var(--rule); border-radius: 4px; padding: 0.6rem 0.7rem; width: 100%;
}
.contact-form input:focus, .contact-form textarea:focus { outline: 2px solid rgba(122,31,31,0.32); border-color: var(--accent); }
.contact-form .btn-primary { align-self: flex-start; }
.form-status { font-family: var(--sans); font-size: 0.85rem; min-height: 1.2em; margin: 0.2rem 0 0; }
.form-status.ok { color: #3a6b3a; }
.form-status.err { color: var(--accent); }
html[data-theme="dark"] .form-status.ok { color: #8fbf8a; }

/* ---------- reader highlights (the e-book feature) ---------- */
mark.hl {
  background: rgba(214, 168, 52, 0.34);
  color: inherit;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease;
}
mark.hl:hover { background: rgba(214, 168, 52, 0.52); }
html[data-theme="dark"] mark.hl { background: rgba(224, 184, 92, 0.26); }
html[data-theme="dark"] mark.hl:hover { background: rgba(224, 184, 92, 0.42); }

/* ---------- landing orientation ---------- */
.book-kicker {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 0.72rem; color: var(--ink-faint); margin: 0 0 1.1rem;
}
.lede .access {
  margin: 1.7rem auto 0; text-align: center; max-width: 32rem;
  font-family: var(--sans); font-size: 0.86rem; color: var(--ink-faint);
}
.lede .access-secondary {
  margin-top: 0.4rem;
  font-size: 0.78rem; opacity: 0.7;
}

/* Justify the landing prose to read like the book's set pages (matches .reading). */
.lede p {
  text-align: justify;
  text-justify: inter-word;
  -webkit-hyphens: auto; hyphens: auto;
  -webkit-hyphenate-limit-before: 2; -webkit-hyphenate-limit-after: 2;
  hyphenate-limit-chars: 4 2 2;
}

/* Orientation line — one calm sentence telling a first-time visitor what this site is. */
.book-orient {
  max-width: 30rem; margin: 1.4rem auto 0;
  font-family: var(--sans); font-size: 0.92rem; line-height: 1.5; color: var(--ink-soft);
}

/* ---------- landing CTAs ---------- */
.cta { max-width: var(--measure); margin: 2.6rem auto 0; padding: 0 1.5rem; }
/* Read online sits full-width on top; the ebook/print pair splits the row beneath it.
   All three share one height and one color; hierarchy comes from layout, not weight. */
.cta-stack { max-width: 26rem; margin: 0 auto; display: flex; flex-direction: column; gap: 0.6rem; }
.cta-pair { display: flex; gap: 0.6rem; }
.cta-btn {
  box-sizing: border-box; min-height: 3rem; flex-shrink: 0; padding: 0 1.1rem;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--sans); font-size: 0.92rem; font-weight: 600; letter-spacing: 0.01em;
  border-radius: 6px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
/* Read online (top, full width): rust/primary */
.cta-stack > .cta-btn { width: 100%; color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.cta-stack > .cta-btn:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; text-decoration: none; }
html[data-theme="dark"] .cta-stack > .cta-btn,
html[data-theme="dark"] .cta-stack > .cta-btn:hover { color: #15120e; }
/* ebook + print (paired below): secondary background */
.cta-pair > .cta-btn { flex: 1 1 0; min-width: 0; color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule); }
.cta-pair > .cta-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.cta-note {
  font-family: var(--sans); font-size: 0.82rem; color: var(--ink-faint);
  max-width: 30rem; margin: 1.2rem auto 0; line-height: 1.5; text-align: center;
}
.edit-hint-landing {
  display: block; text-align: center; margin: 0.9rem auto 0;
  font-family: var(--sans); font-size: 0.72rem; font-style: italic; color: var(--ink-faint);
}

/* ---------- header dropdown: share cluster ---------- */
.dd-share { padding: 0.4rem 0.6rem 0.2rem; }
.dd-share-label {
  display: block; font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.5rem;
}
.dd-share-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dd-share .share-link { width: 2rem; height: 2rem; }

/* ---------- landing click-to-edit (writes to front-matter.md) ---------- */
.fm-edit { cursor: text; border-radius: 4px; transition: background 0.12s, box-shadow 0.12s; }
.fm-edit:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 5%, transparent);
}
span.fm-edit { padding: 0 0.1rem; }
.fm-edit-wrap { margin: 0.6rem auto; max-width: var(--measure); text-align: left; }
.fm-edit-ta {
  display: block; width: 100%; box-sizing: border-box;
  font-family: var(--serif); font-size: 1.05rem; line-height: 1.55; color: var(--ink);
  background: var(--paper-card); border: 1.5px solid var(--accent); border-radius: 4px;
  padding: 0.55rem 0.7rem; resize: none; outline: none; min-height: 2.6rem;
}
.fm-edit-ta:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(122,31,31,0.12); }
.fm-edit-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.fm-save-btn {
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 4px; padding: 0.3rem 0.85rem;
}
.fm-save-btn:hover { background: var(--accent-2); }
.fm-save-btn:disabled { opacity: 0.55; cursor: default; }
html[data-theme="dark"] .fm-save-btn { color: #15120e; }
.fm-cancel-btn {
  font-family: var(--sans); font-size: 0.8rem; cursor: pointer;
  background: transparent; color: var(--ink-soft); border: 1px solid var(--rule);
  border-radius: 4px; padding: 0.3rem 0.75rem;
}
.fm-cancel-btn:hover { border-color: var(--ink-faint); color: var(--ink); }
.fm-edit-hint { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-faint); margin-left: 0.3rem; }

@media (max-width: 520px) {
  .cta-pair { flex-direction: column; }
}
