/* Reading shell — tolstoy.life docs
   One stylesheet for every served page: the doc pages (reading shell),
   INDEX.html, and the work-reader pages. Themes via html[data-theme].
   Visual source of truth: _generated/design/session-reader-ui-drafts-2026-07-03/
   reader-ui-drafts.html (Draft 3 windowed + Draft 5 focus/overlay). */

:root {
  --font-scale: 1;
  --measure: 56ch;
  --measure-wide: 52rem;
  /* Read-along wash: the page background nudged toward the ink — subtle,
     theme-aware (darkens on light themes, lightens on dark). */
  --rl-wash: color-mix(in srgb, var(--paper) 88%, var(--ink));

  --ink: #1e1a17;
  --ink-soft: #4a4038;
  --paper: #faf7f2;
  --surface: #ffffff;
  --ground: #e7e0d3;
  --panel: #f4eee3;
  --rule: #d9d1c5;
  --rule-soft: #e4dccd;
  --accent: #6b4423;
  --accent-soft: #8c6a4a;
  --hl: #fbef9d;                 /* read-along wash */
  --ctl-border: #c9bda6;         /* control borders */
  --sw-off: #d8ccb5;             /* switch-off track */
  --slider-track: #ddd2bd;
  --transport-bg: #efe7d9;
  --wash-tint: rgba(107, 68, 35, 0.06);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino,
           "URW Palladio L", P052, Charter, Georgia, "Times New Roman", serif;
}

html[data-theme="sepia"] {
  --ink: #46351f;
  --ink-soft: #6d5a3e;
  --paper: #f4ecd8;
  --surface: #faf4e4;
  --panel: #ede2c6;
  --rule: #ddceab;
  --rule-soft: #e6dab9;
  --accent: #7a5230;
  --accent-soft: #97744e;
  --hl: #fbef9d;
  --ctl-border: #bfae8d;
  --sw-off: #d3c4a4;
  --slider-track: #d8c9a8;
  --transport-bg: #eee3c9;
  --wash-tint: rgba(122, 82, 48, 0.07);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #d9d2c7;
  --ink-soft: #a89f92;
  --paper: #17140f;
  --surface: #221d15;
  --panel: #241f17;
  --rule: #3a342a;
  --rule-soft: #322c23;
  --accent: #c89a6a;
  --accent-soft: #a5825e;
  --hl: rgba(251, 239, 157, 0.22);
  --ctl-border: #4a4234;
  --sw-off: #4a4234;
  --slider-track: #453e31;
  --transport-bg: #1e1a13;
  --wash-tint: rgba(200, 154, 106, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

/* Fluid type: well-set on a laptop or a 27" display with no setting touched.
   --font-scale is the user's fine-tune from Tools → Display. */
html {
  font-size: calc(clamp(19px, 16px + 0.5vw, 24px) * var(--font-scale));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0; padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Icons (inline SVG symbols injected by serve.py) */
.ic {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
  display: inline-block;
}

/* ── Reading progress hairline (2px: soft track + accent fill) ── */
#progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--rule-soft);
  z-index: 400;
}
#progress .fill { height: 100%; width: 0; background: var(--accent); }

/* ── Top bar: Contents · title ⁄ Notes · Focus · Tools(gear) ── */
#topbar {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 9px 16px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule-soft);
  z-index: 300;
  transition: opacity 0.35s;
}
#topbar .tb-group { display: flex; align-items: center; gap: 12px; min-width: 0; }
#topbar button {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 3px; cursor: pointer;
  color: var(--accent-soft);
}
#topbar button:hover { color: var(--accent); }
#topbar .gear {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--accent); color: var(--paper);
}
#topbar .gear:hover { color: var(--paper); filter: brightness(1.15); }
#topbar .gear .ic { width: 15px; height: 15px; }
#topbar .tb-title {
  font-family: var(--serif); font-size: 14px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#topbar a {
  font-family: var(--sans); font-size: 12px;
  color: var(--accent-soft); text-decoration: none; white-space: nowrap;
}
#topbar a:hover { color: var(--accent); }
#topbar .tb-crumb {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  overflow: hidden; white-space: nowrap;
}
#topbar .tb-crumb .sep { color: var(--ctl-border); font-family: var(--sans); font-size: 12px; }
#topbar .tb-crumb .here {
  font-family: var(--serif); font-size: 14px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis;
}
#topbar .tb-crumb a.here:hover { color: var(--accent); }
#topbar a.tb-read {
  border: 1px solid var(--accent-soft); border-radius: 999px;
  padding: 2px 10px; color: var(--accent);
}
#topbar a.tb-read:hover { border-color: var(--accent); }
#topbar .tb-div { color: var(--ctl-border); font-size: 12px; user-select: none; }
#topbar .tb-crumb .sub {
  font-family: var(--serif); font-size: 14px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 40rem) {
  #topbar .tb-home, #topbar .tb-lib, #topbar .tb-div { display: none; }
}

/* Zen: chrome fades when idle, returns on mouse-move. */
body.zen #topbar, body.zen #transport { opacity: 0; pointer-events: none; }
body.zen.chrome #topbar, body.zen.chrome #transport { opacity: 1; pointer-events: auto; }

/* ── Document header / main column ── */
header.doc-header {
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 2.6rem 1.5rem 1.8rem;
  border-bottom: 1px solid var(--rule);
}
header.doc-header .eyebrow {
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-soft); font-style: italic; margin: 0 0 0.8rem;
}
header.doc-header h1 {
  font-size: 2.2rem; line-height: 1.15; margin: 0 0 0.5rem;
  font-weight: 600; letter-spacing: -0.012em;
  text-wrap: balance;
}
header.doc-header .meta {
  font-size: 0.85rem; color: var(--ink-soft); margin: 0;
  font-variant-numeric: oldstyle-nums;
}

main {
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 2.2rem 1.5rem 6rem;
}
body[data-kind="work"] main { padding-bottom: 9rem; }

/* ── Typography ── */
h1 { font-size: 2.2rem; line-height: 1.15; margin: 0 0 1rem; font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h2 { font-size: 1.6rem; line-height: 1.25; margin: 3rem 0 0.4rem; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 1.18rem; line-height: 1.3; margin: 2.4rem 0 0.6rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; margin: 1.6rem 0 0.4rem; }
p { margin: 0 0 1.1rem; hyphens: auto; -webkit-hyphens: auto; }
main p { position: relative; }
ol, ul { padding-left: 1.4rem; margin: 0 0 1.3rem; }
li { margin-bottom: 0.55rem; }
li > ol, li > ul { margin-top: 0.4rem; margin-bottom: 0.2rem; }
strong { font-weight: 600; }
em { font-style: italic; }
a { color: var(--accent); text-decoration: underline;
    text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
blockquote {
  margin: 1.4rem 0; padding: 0 0 0 1.2rem;
  border-left: 2px solid var(--accent-soft);
  color: var(--ink-soft); font-style: italic;
}
hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }


/* Parallel excerpt card: a Russian passage and its English, always shown together.
   Used on the restored-text page; the orthography (pre-reform vs modern) still
   marks restored vs published across cards. */
.pair {
  margin: 1.5rem 0;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}
.pair .pair-cap {
  margin: 0; padding: 0.5rem 1.2rem;
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-soft); font-style: normal;
  border-bottom: 1px solid var(--rule-soft);
  background: color-mix(in srgb, var(--paper) 60%, var(--rule) 40%);
}
.pair .ru, .pair .en { padding: 1rem 1.2rem; }
.pair .ru p:first-child, .pair .en p:first-child { margin-top: 0; }
.pair .ru p:last-child, .pair .en p:last-child { margin-bottom: 0; }
.pair .en {
  border-top: 1px solid var(--rule-soft);
  background: var(--rl-wash);
  color: var(--ink-soft);
  font-size: 0.94rem;
}

figure { margin: 1.8rem 0; }
.img-withheld { display: block; padding: 1rem; margin: 1.8rem 0 .5rem; border: 1px dashed var(--rule-soft); color: var(--ink-soft); font-size: .85rem; text-align: center; }
main img {
  max-width: 100%; height: auto; display: block;
  margin: 1.8rem auto 0.5rem;
  border: 1px solid var(--rule); border-radius: 2px;
  background: var(--surface);
}
main img + em, figcaption {
  display: block; font-size: 0.82rem; color: var(--ink-soft);
  font-style: italic; text-align: center; margin: 0 auto 1.4rem;
  max-width: var(--measure);
}

code, kbd, samp {
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--wash-tint);
  padding: 0.08em 0.34em;
  border-radius: 2px;
}
pre {
  background: var(--wash-tint);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
  font-size: 0.88rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: inherit; }

table {
  width: 100%; border-collapse: collapse;
  margin: 1.4rem 0 1.8rem; font-size: 0.94rem;
}
th, td {
  text-align: left; padding: 0.6rem 0.8rem 0.6rem 0;
  border-bottom: 1px solid var(--rule); vertical-align: top;
}
th {
  font-weight: 600; font-size: 0.82rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-soft); font-style: italic;
  border-bottom: 1px solid var(--accent-soft);
}

footer {
  max-width: calc(var(--measure) + 3rem);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-style: italic;
  text-align: center;
}

/* ── Editorial marks (CriticMarkup) ── */
del { color: #a03b2e; background: rgba(160, 59, 46, 0.07); text-decoration: line-through; text-decoration-thickness: 1px; }
ins { color: #2e6b3f; background: rgba(46, 107, 63, 0.07); text-decoration: none; }
html[data-theme="dark"] del { color: #d98a7c; background: rgba(217, 138, 124, 0.1); }
html[data-theme="dark"] ins { color: #8fc79f; background: rgba(143, 199, 159, 0.1); }
.critic.comment {
  font-size: 0.85em; color: var(--accent-soft); font-style: italic;
  background: var(--wash-tint); padding: 0 0.3em; border-radius: 2px;
}
mark.critic { background: var(--hl); color: inherit; }

/* ── Layers (works only): the page opens bare, apparatus off until summoned ── */
html:not([data-l-cuts="on"]) body[data-kind="work"] del { display: none; }
html:not([data-l-cuts="on"]) body[data-kind="work"] ins { color: inherit; background: none; }
html:not([data-l-cuts="on"]) body[data-kind="work"] .critic.comment { display: none; }
html:not([data-l-wikilinks="on"]) body[data-kind="work"] a.wikilink {
  color: inherit; text-decoration: none; pointer-events: none; cursor: text;
}
html:not([data-l-footnotes="on"]) body[data-kind="work"] :is(.noteref, .footnote-ref, .work-notes, .footnote) { display: none; }

a.wikilink {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}

/* An entity with no page written yet. Most entities are in this state — the
   vault is a universe, not a queue — so this reads as "not yet", not as an
   error: muted rather than coloured, and the underline breaks up. */
a.wikilink-missing {
  color: var(--ink-soft);
  border-bottom-color: var(--rule);
  border-bottom-style: dashed;
}

/* Footnote marker */
:is(a.noteref, a.footnote-ref, a.note-back, a.footnote-backref) { text-decoration: none; }
a.noteref sup { font-size: 13px; color: var(--accent); margin-left: 2px; }

/* ── Work reader: sentences, notes ── */
.sentence { border-radius: 2px; }
.sentence.rl-active, h2.rl-active {
  background: var(--rl-wash);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.sentence.rl-active { padding: 1px 0; }   /* ⚠ inline only: on the block h2 the padding adds height and shifts the page */
body[data-kind="work"][data-audio="true"] .sentence,
body[data-kind="work"][data-audio="true"] main h2 { cursor: pointer; }

.work-notes { margin-top: 3rem; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
.work-notes aside { font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 0.8rem; }
.work-notes a.note-back { color: var(--accent); text-decoration: none; }
.work-notes .notes-by { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 1rem; }
:is(a.noteref, .work-notes aside) { scroll-margin-block: 30vh; }   /* land mid-screen, clear of the top bar */

/* ── TOC drawer (upper-left) ── */
#toc-drawer {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: min(19rem, 85vw);
  background: var(--panel);
  border-right: 1px solid var(--rule-soft);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  z-index: 350;
  overflow-y: auto;
  padding: 1.1rem 1.3rem 2rem;
  font-family: var(--sans);
}
#toc-drawer.open { transform: none; box-shadow: 0 0 32px rgba(0,0,0,0.14); }
#toc-drawer h2 {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  font-style: italic; color: var(--accent-soft); margin: 0 0 0.9rem; font-weight: 400;
}
#toc-drawer ol { list-style: none; padding: 0; margin: 0; }
#toc-drawer li { margin: 0; }
#toc-drawer li.toc-h3 a { padding-left: 1rem; font-size: 12px; }
#toc-drawer a {
  display: block; padding: 0.45rem 0.3rem;
  font-family: var(--serif); font-size: 0.85rem; color: var(--ink);
  text-decoration: none; border-bottom: 1px solid var(--rule-soft);
  line-height: 1.35;
}
#toc-drawer a:hover { color: var(--accent); }
#toc-drawer h2.work {
  font-family: var(--serif); font-size: 15px; font-weight: 600; font-style: normal;
  letter-spacing: 0; text-transform: none; color: var(--ink); margin: 0 0 0.9rem;
}
#toc-drawer .hub { list-style: none; padding: 0; margin: 0 0 1.4rem; }
#toc-drawer .hub li { margin: 0; }
#toc-drawer .hub a.current { color: var(--accent); font-weight: 600; cursor: default; }
#toc-drawer h3.onpage {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-style: italic;
  color: var(--accent-soft); font-weight: 400; margin: 0 0 0.5rem;
}

/* ── Panels: shared chrome ── */
.panel-close {
  position: absolute; top: 0.5rem; right: 0.7rem;
  font-size: 15px; line-height: 1;
  background: none; border: none; cursor: pointer;
  color: var(--accent-soft); padding: 0.3rem;
  font-family: var(--sans);
}
.panel-close:hover { color: var(--ink); }

/* Tools floats above the page — in the margin on a wide screen, over the
   text on a narrow one. The reading column never moves. */
#tools-overlay {
  position: fixed; right: 16px; top: 50px;
  width: 240px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--ctl-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  padding: 12px 14px 14px;
  z-index: 360;
  display: none;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
}
#tools-overlay.open { display: block; }
#tools-overlay h3 {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  font-style: italic; color: var(--accent-soft);
  margin: 14px 0 8px; font-weight: 400;
}
#tools-overlay h3:first-of-type { margin-top: 2px; }
.tool-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin: 0 0 11px; font-size: 13px;
}
.tool-row:last-child { margin-bottom: 0; }
.tool-row output {
  font-variant-numeric: tabular-nums; font-size: 11px; color: var(--accent);
}
label.tool-row { cursor: pointer; margin: 0; padding: 6px 0; }
.tool-slider { margin: 0 0 12px; }
.tool-slider .tool-row { margin-bottom: 6px; }

/* Text size stepper (− Aa +) */
.stepper {
  display: inline-flex; align-items: center; gap: 13px;
  border: 0.5px solid var(--ctl-border); border-radius: 8px;
  padding: 3px 11px; color: var(--accent);
}
.stepper button {
  font-family: var(--sans); font-size: 14px; line-height: 1;
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); opacity: 0.55;
}
.stepper button:hover { opacity: 1; }
.stepper .aa { font-family: var(--serif); font-weight: 500; font-size: 13px; }

/* Sliders (line length, audio scrub): thin track, round knob.
   The fill left of the knob is painted by JS as a gradient. */
input[type="range"].track {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: var(--slider-track);
  outline: none; margin: 4px 0 0; padding: 0;
  width: 100%; display: block; cursor: pointer;
}
input[type="range"].track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: none;
}
input[type="range"].track::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: none;
}

/* Switch toggles (Layers) */
input.sw {
  -webkit-appearance: none; appearance: none;
  width: 34px; height: 20px; border-radius: 10px;
  background: var(--sw-off); border: none; margin: 0;
  position: relative; flex: none; cursor: pointer;
  transition: background 0.15s;
}
input.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper);
  transition: left 0.15s;
}
input.sw:checked { background: var(--accent); }
input.sw:checked::after { left: 16px; }

/* Theme dots */
.dots { display: inline-flex; gap: 8px; }
button.dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 0.5px solid var(--ctl-border); padding: 0; cursor: pointer;
}
button.dot.paper { background: #faf7f2; }
button.dot.sepia { background: #efe2c6; }
button.dot.dark { background: #2c2620; }
button.dot[aria-pressed="true"] { border: 1.5px solid var(--accent); }

/* Version segmented control */
.seg {
  display: flex;
  border: 0.5px solid var(--ctl-border); border-radius: 8px;
  overflow: hidden; font-size: 12px; font-family: var(--sans);
}
.seg a {
  flex: 1; text-align: center; padding: 5px 10px;
  color: var(--accent); text-decoration: none;
  border-left: 0.5px solid var(--ctl-border);
}
.seg a:first-child { border-left: 0; }
.seg a.current { background: var(--accent); color: var(--paper); }

/* ── Notes panel (slide-in) ── */
#notes-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: min(24rem, 94vw);
  background: var(--panel);
  border-left: 1px solid var(--rule-soft);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 370;
  overflow-y: auto;
  padding: 1.1rem 1.3rem 2rem;
  font-family: var(--sans);
  font-size: 13px;
}
#notes-panel.open { transform: none; box-shadow: 0 0 32px rgba(0,0,0,0.14); }
#notes-panel h2 {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  font-style: italic; color: var(--accent-soft); margin: 0 0 0.9rem; font-weight: 400;
}
#notes-list { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.note-entry {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.7rem 0.2rem;
  cursor: pointer;
}
.note-entry:hover { background: var(--wash-tint); }
.note-entry.flash { animation: entry-flash 1.2s; }
.note-quote {
  font-family: var(--serif); font-size: 12.5px; color: var(--ink-soft); font-style: italic;
  border-left: 2px solid var(--accent-soft); padding-left: 0.55rem;
  margin: 0 0 0.35rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.note-body { margin: 0; white-space: pre-wrap; color: var(--ink); }
.note-meta { font-size: 11px; color: var(--ink-soft); margin-top: 0.3rem; display: flex; gap: 0.6rem; align-items: baseline; }
.note-meta button {
  background: none; border: none; cursor: pointer;
  color: var(--ink-soft); font-family: var(--sans); font-size: 11px;
}
.note-meta .note-edit, .note-meta .note-save { margin-left: auto; }
.note-meta .note-edit:hover, .note-meta .note-save:hover { color: var(--accent); }
.note-meta .note-save { color: var(--accent); font-weight: 600; }
.note-meta .note-del:hover { color: #a03b2e; }
.note-entry textarea {
  width: 100%; font-family: var(--sans); font-size: 13px; line-height: 1.5;
  border: 0.5px solid var(--ctl-border); border-radius: 6px; padding: 0.5rem 0.6rem;
  background: var(--paper); color: var(--ink);
  resize: vertical; min-height: 4rem; outline: none; margin: 0.2rem 0 0.1rem;
}
.note-entry textarea:focus { border-color: var(--accent); }
.notes-empty { color: var(--ink-soft); font-style: italic; }
.notes-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.notes-actions button {
  font-family: var(--sans); font-size: 12px; padding: 4px 11px;
  border: 0.5px solid var(--ctl-border); border-radius: 16px;
  background: var(--paper); color: var(--accent); cursor: pointer;
}
.notes-actions button:hover { border-color: var(--accent); }
.notes-actions button.danger:hover { background: #a03b2e; border-color: #a03b2e; color: #fff; }
#notes-send-row:not([hidden]) { margin-top: .6rem; display: grid; gap: .4rem; }
#notes-send-row input { width: 100%; font: inherit; padding: .4rem; }
.notes-send-note { color: var(--ink-soft); font-family: var(--sans); font-size: 12px; margin: 0; }

/* ── Annotations in the text: underline + margin marker (the wash channel is
      read-along's — the two must coexist on the same sentence). ── */
mark.annotation {
  background: none;
  color: inherit;
  border-bottom: 2px solid var(--accent);
  cursor: pointer;
  padding: 0 1px;
}
mark.annotation:hover { background: var(--wash-tint); }
mark.annotation.needs-fix { border-bottom-style: dashed; }
mark.annotation.needs-fix::after { content: "🔧"; font-size: 0.72em; vertical-align: super; margin-left: 1px; opacity: 0.8; }
mark.annotation.needs-audio-fix { border-bottom-style: dashed; }
mark.annotation.needs-audio-fix::after { content: "🔊"; font-size: 0.72em; vertical-align: super; margin-left: 1px; opacity: 0.8; }
mark.annotation.needs-fix.needs-audio-fix:not(.ann-cont)::after { content: "🔧🔊"; }
mark.annotation.ann-cont::after { content: none; }
mark.annotation.flash { animation: entry-flash 1.2s; }
/* Margin marker: a thin bar beside any line-block that carries a note. */
main :is(p, li, blockquote, h2, h3):has(mark.annotation)::before {
  content: ""; position: absolute; left: -1.05rem; top: 0.35em; bottom: 0.35em;
  width: 3px; border-radius: 2px; background: var(--accent-soft); opacity: 0.55;
}
main :is(li, blockquote, h2, h3):has(mark.annotation) { position: relative; }

@keyframes entry-flash {
  0%, 45% { background: var(--hl); }
  100% { background: transparent; }
}

.ann-fix { display: flex; align-items: center; gap: 0.4rem; font-size: 12px; color: var(--ink-soft); margin: 0.5rem 0 0; cursor: pointer; user-select: none; }
.ann-fix input { margin: 0; accent-color: var(--accent); }

#ann-popover {
  position: fixed;
  z-index: 380;
  background: var(--panel);
  border: 1px solid var(--ctl-border);
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.16);
  padding: 0.9rem 1rem;
  width: 22rem; max-width: calc(100vw - 2rem);
  display: none;
  font-family: var(--sans);
}
#ann-popover .ann-quote {
  font-family: var(--serif); font-size: 12.5px; color: var(--ink-soft); font-style: italic;
  margin: 0 0 0.6rem; border-left: 2px solid var(--accent-soft);
  padding-left: 0.6rem; line-height: 1.4; max-height: 3.5rem; overflow: hidden;
}
#ann-popover textarea {
  width: 100%; font-family: var(--sans); font-size: 13px; line-height: 1.5;
  border: 0.5px solid var(--ctl-border); border-radius: 6px; padding: 0.5rem 0.6rem;
  background: var(--paper); color: var(--ink);
  resize: vertical; min-height: 4rem; outline: none;
}
#ann-popover textarea:focus { border-color: var(--accent); }
#ann-popover .ann-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; justify-content: flex-end; }
#ann-popover button {
  font-family: var(--sans); font-size: 12px; padding: 4px 11px;
  border-radius: 16px; cursor: pointer; border: 0.5px solid var(--ctl-border);
  background: var(--paper); color: var(--accent);
}
#ann-popover button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--paper); font-weight: 600;
}
#ann-popover button.primary:hover { filter: brightness(1.15); }
#ann-popover button:not(.primary):hover { border-color: var(--accent); }

#ann-tooltip {
  position: fixed; z-index: 390;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans);
  font-size: 12.5px; line-height: 1.5;
  padding: 0.6rem 0.85rem; border-radius: 6px;
  max-width: 22rem; box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  pointer-events: none; display: none; white-space: pre-wrap;
}

/* ── Audio transport (slim, bottom, only when read-along exists) ── */
#transport {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 14px;
  background: var(--transport-bg);
  border-top: 1px solid var(--rule-soft);
  z-index: 300;
  font-family: var(--sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
  transition: opacity 0.35s;
}
#transport #rl-play {
  width: 28px; height: 28px; border-radius: 50%;
  border: 0.5px solid var(--ctl-border);
  background: var(--paper); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: none; padding: 0;
}
#transport #rl-play .ic { width: 14px; height: 14px; }
#transport #rl-play:hover { border-color: var(--accent); }
/* ⚠ A fingertip missing the 28px button hits the seek slider and jumps the audio — 44px hit area, same look. */
@media (pointer: coarse) {
  #transport #rl-play, #transport #rl-speed { position: relative; }
  #transport #rl-play::after, #transport #rl-speed::after {
    content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: max(100%, 44px); height: 44px;
  }
}
#transport input[type="range"].track {
  flex: 1; min-width: 4rem; height: 3px; margin: 0;
}
#transport input[type="range"].track::-webkit-slider-thumb {
  width: 9px; height: 9px; background: var(--accent-soft);
}
#transport input[type="range"].track::-moz-range-thumb {
  width: 9px; height: 9px; background: var(--accent-soft);
}
#transport .rl-section { min-width: 3.2em; text-align: center; }
#transport .rl-time { color: var(--accent-soft); }
#transport #rl-speed {
  font-family: var(--sans); font-size: 11px; color: var(--accent);
  border: 0.5px solid var(--ctl-border); border-radius: 6px;
  background: none; padding: 2px 7px; cursor: pointer; white-space: nowrap;
}
#transport #rl-speed:hover { border-color: var(--accent); }
#transport a { color: var(--accent-soft); text-decoration: none; font-size: 14px; display: inline-flex; }
#transport a:hover { color: var(--accent); }
@media (max-width: 34rem) { #transport .rl-time { display: none; } }

/* ═══ INDEX.html (list pages) — unchanged look ═══ */
.site-header {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 1.4rem 1.5rem 1rem;
  display: flex; align-items: baseline; gap: 1.2rem;
  border-bottom: 1px solid var(--rule);
}
.site-header a.home {
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-soft); text-decoration: none; font-style: italic;
  white-space: nowrap;
}
.site-header a.home:hover { color: var(--accent); }
.breadcrumb { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb span { color: var(--rule); margin: 0 0.3em; }

.featured-section { max-width: var(--measure-wide); margin: 1rem auto 2.5rem; padding: 0 1.5rem; }
.featured-card {
  display: block; padding: 1.7rem 1.9rem;
  background: var(--wash-tint);
  border: 1px solid var(--accent-soft); border-radius: 4px;
  text-decoration: none; color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.featured-card:hover { border-color: var(--accent); color: var(--ink); }
.featured-card .eyebrow {
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-soft); font-style: italic; margin: 0 0 0.7rem;
}
.featured-card .card-title { font-size: 1.42rem; font-weight: 600; margin: 0 0 0.4rem; line-height: 1.25; letter-spacing: -0.005em; }
.featured-card .card-meta { font-size: 0.82rem; color: var(--ink-soft); font-style: italic; margin: 0 0 0.85rem; }
.featured-card .card-lede { font-size: 0.97rem; color: var(--ink); line-height: 1.55; margin: 0; }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.8rem; margin: 0 0 2.5rem;
}
.index-card {
  display: block; padding: 1rem 1.1rem;
  background: var(--wash-tint);
  border: 1px solid var(--rule); border-radius: 3px;
  text-decoration: none; color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.index-card:hover { border-color: var(--accent-soft); color: var(--ink); }
.index-card .card-title { font-size: 0.97rem; font-weight: 600; margin: 0 0 0.25rem; line-height: 1.3; }
.index-card .card-meta { font-size: 0.78rem; color: var(--ink-soft); font-style: italic; }
.index-card .card-lede { font-size: 0.85rem; color: var(--ink-soft); margin: 0.35rem 0 0; line-height: 1.45; }

.section-label {
  font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-soft); font-style: italic;
  margin: 2.5rem 0 0.8rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

.year-label {
  font-size: 1.05rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-soft); font-style: italic; font-weight: 400;
  margin: 3rem 0 0.6rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: oldstyle-nums;
}
.post-list { list-style: none; padding: 0; margin: 0 0 2rem; }
.post-entry { margin: 0; border-bottom: 1px solid var(--rule); }
.post-entry:last-child { border-bottom: none; }
.post-entry a { display: block; padding: 0.95rem 0; text-decoration: none; color: var(--ink); transition: background 0.15s; }
.post-entry a:hover { background: var(--wash-tint); }
.post-row { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.post-entry time { font-size: 0.82rem; color: var(--ink-soft); font-style: italic; font-variant-numeric: oldstyle-nums; flex: 0 0 6rem; }
.post-title { font-size: 1.02rem; font-weight: 600; color: var(--ink); flex: 1 1 auto; line-height: 1.3; }
.post-folder { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-soft); font-style: italic; }
.post-lede { font-size: 0.9rem; color: var(--ink-soft); margin: 0.35rem 0 0 7rem; line-height: 1.5; }
@media (max-width: 30rem) {
  .post-entry time { flex-basis: 100%; }
  .post-lede { margin-left: 0; }
}

/* ── Wiki index (/research/wiki/) ── */
.wiki-index section { margin-block-start: 2.5rem; }
.wiki-index h2 { font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); border-block-end: 1px solid var(--rule); padding-block-end: 0.4rem; }
.wiki-index ul { list-style: none; padding: 0; margin: 0; }
.wiki-index li { padding-block: 0.75rem; border-block-end: 1px solid var(--rule-soft); }
.wiki-index li > a { font-size: 1.15em; text-decoration: none; }
.wiki-index li > a:hover { text-decoration: underline 1px; text-underline-offset: 2px; }
.wiki-index li p { margin: 0.2rem 0 0; color: var(--ink-soft); font-size: 0.92em; line-height: 1.45; }

/* Set-off document (serve.py SET_OFF): a text the work quotes whole, on the theme's lighter surface. */
.set-off { background: var(--surface); border: 1px solid var(--rule-soft); border-radius: 4px; padding: 1.1rem 1.25rem 0.5rem; margin: 1.6rem -0.25rem; }
.set-off .set-off-title { text-align: center; font-variant-caps: all-small-caps; letter-spacing: 0.05em; margin-block: 0 0.2rem; }
.set-off .set-off-title + p:not(.set-off-title) { margin-top: 1rem; }
.set-off .qa-q { margin-top: 1.4rem; }
.set-off :is(.qa-q, .qa-a) > .sentence:first-child > em:first-child { font-style: normal; font-weight: 600; }
.set-off .set-off-source { font-family: var(--sans); font-size: 0.78rem; color: var(--ink-soft); border-top: 1px solid var(--rule-soft); padding-top: 0.5rem; margin-top: 1.2rem; }
