/* Geist (Vercel) self-hosted from website/assets/fonts so the reader works
   offline behind the service worker and never waits on a third-party CDN.
   font-display: swap keeps text readable while the woff2 files load. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/geist-sans-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/geist-sans-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/geist-sans-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../assets/fonts/geist-sans-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../assets/fonts/geist-mono-latin-600-normal.woff2") format("woff2");
}

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #5c5c5c;
  --line: #0a0a0a;
  --line-soft: #d9d9d9;
  --card: #fafafa;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Reader preferences (see the Aa panel). JS overrides these five inline on
     :root; these are the defaults a first visit and the Reset button use. */
  --reader-font: var(--sans);
  --reader-font-size: 16px;
  --reader-leading: 1.7;
  --reader-measure: 72ch;
  --reader-weight: 400;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #f5f5f5;
    --muted: #a6a6a6;
    --line: #f5f5f5;
    --line-soft: #333333;
    --card: #111111;
  }
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #5c5c5c;
  --line: #0a0a0a;
  --line-soft: #d9d9d9;
  --card: #fafafa;
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #a6a6a6;
  --line: #f5f5f5;
  --line-soft: #333333;
  --card: #111111;
}
:root[data-theme="sepia"] {
  --bg: #f6f0df;
  --fg: #433422;
  --muted: #7a6a4f;
  --line: #433422;
  --line-soft: #ddd0b4;
  --card: #efe6cf;
}

/* Map go-pretty-pdf's theme variable contract onto the site's own palette so
   the book content participates in the same light/dark toggle. Fonts are
   deliberately left alone here — those come from the theme's own <style>
   block (go-pretty-pdf.yml's pinned font stack) and are what should match
   the PDF. */
:root {
  --pdf-bg: var(--bg);
  --pdf-text: var(--fg);
  --pdf-muted: var(--muted);
  --pdf-primary: var(--fg);
  --pdf-accent: var(--fg);
  --pdf-surface: var(--card);
  --pdf-surface-2: var(--card);
  --pdf-border: var(--line-soft);
  --pdf-info: var(--fg);
  --pdf-warn: var(--fg);
  --pdf-success: var(--fg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
}

/* Prism grayscale theme. Code renders as a varied gray ramp so token kinds
   (keywords, functions, types, properties, variables, strings, numbers,
   comments) are visually distinct without any hue — like monochrome Go code
   in an editor. Shades are derived from the site's foreground/background
   with color-mix, so the ramp stays correct in light, dark and sepia. */
code[class*="language-"],
pre[class*="language-"] {
  color: color-mix(in srgb, var(--fg) 72%, var(--bg));
  text-shadow: none;
  background: none;
  font-family: var(--mono);
}
.token.keyword, .token.boolean {
  color: var(--fg);
  font-weight: 600;
}
.token.function, .token.function-variable {
  color: color-mix(in srgb, var(--fg) 90%, var(--bg));
}
.token.builtin, .token.class-name, .token.maybe-class-name {
  color: color-mix(in srgb, var(--fg) 83%, var(--bg));
}
.token.property, .token.attribute {
  color: color-mix(in srgb, var(--fg) 76%, var(--bg));
}
.token.string, .token.char, .token.attr-value, .token.regex {
  color: color-mix(in srgb, var(--fg) 65%, var(--bg));
}
.token.number, .token.symbol, .token.constant {
  color: color-mix(in srgb, var(--fg) 56%, var(--bg));
}
.token.operator, .token.punctuation {
  color: color-mix(in srgb, var(--fg) 72%, var(--bg));
}
.token.comment, .token.prolog, .token.doctype, .token.cdata {
  color: var(--muted);
  font-style: italic;
}
pre[class*="language-"]::selection,
code[class*="language-"]::selection,
code[class*="language-"] .token::selection {
  text-shadow: none;
}

/* Fixed reading-progress bar along the very top of the viewport. */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  z-index: 60;
  background: var(--fg);
  pointer-events: none;
}

img, table, video { max-width: 100%; height: auto; }
table { display: block; overflow-x: auto; white-space: nowrap; }
pre { overflow-x: auto; max-width: 100%; }
code { word-wrap: break-word; overflow-wrap: break-word; }
.reader-content { word-wrap: break-word; overflow-wrap: break-word; }
a { color: inherit; }

/* Modern typography and motion. Everything here degrades gracefully on
   older browsers and is disabled outright by prefers-reduced-motion. */
html { scrollbar-gutter: stable; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
@supports (text-wrap: balance) {
  .reader-content h1, .reader-content h2, .reader-content h3,
  .part-card h2, .newsletter-box h2, .topic-block h2 { text-wrap: balance; }
  .reader-content p, .reader-content li { text-wrap: pretty; }
}

/* Cross-document View Transitions: navigating between chapters cross-fades
   the page while the top bar and progress bar stay put, so the reader feels
   like one continuous document instead of a series of page loads. Supported
   in Chromium and Safari; ignored elsewhere. */
@view-transition { navigation: auto; }
.reader-top { view-transition-name: reader-top; }
.reading-progress { view-transition-name: reading-progress; }
::view-transition-old(root) { animation: nwg-fade-out 0.16s ease both; }
::view-transition-new(root) { animation: nwg-fade-in 0.22s ease both; }
@keyframes nwg-fade-out { to { opacity: 0; } }
@keyframes nwg-fade-in { from { opacity: 0; } }

/* Opt-in theme cross-fade, toggled by reader.js for ~300ms around a theme
   change so the palette swaps smoothly without animating every interaction. */
html.theme-anim,
html.theme-anim * {
  transition: background-color 0.28s ease, color 0.28s ease,
    border-color 0.28s ease, fill 0.28s ease !important;
}

/* Back-to-top control, injected by reader.js once the page is scrollable. */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.back-to-top.visible { opacity: 1; transform: none; pointer-events: auto; }
.back-to-top:hover { opacity: 0.82; }

/* Current chapter in the sidebar TOC. */
.toc-part a[aria-current="page"] {
  background: var(--card);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--fg);
}
.toc-part a { transition: background-color 0.15s ease; }
.chapter-nav-prev, .chapter-nav-next { transition: transform 0.18s ease; }
.chapter-nav-prev:hover { transform: translateX(-2px); }
.chapter-nav-next:hover { transform: translateX(2px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  @view-transition { navigation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .back-to-top, .chapter-nav-prev, .chapter-nav-next { transition: none; }
  html.theme-anim, html.theme-anim * { transition: none !important; }
}

.reader-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 20px;
  background: var(--bg);
  font-family: var(--sans);
}
.reader-top-left { display: flex; align-items: center; gap: 14px; }
.brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.brand span { color: var(--muted); }
.reader-top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reader-top-actions a {
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
}
#search-open, #prefs-toggle, #focus-toggle, #sidebar-toggle,
#notes-toggle, #print-pdf {
  font-family: var(--mono);
  font-size: 12px;
  background: transparent;
  color: var(--fg);
  border: none;
  padding: 5px 10px;
  cursor: pointer;
}
#sidebar-toggle { padding: 5px 8px; }
#search-open kbd {
  font-family: var(--mono);
  border: none;
  border-radius: 2px;
  padding: 0 4px;
  margin-left: 4px;
  font-size: 10px;
}
#prefs-toggle, #focus-toggle, #search-open, #sidebar-toggle,
#notes-toggle, #print-pdf { transition: none; }
#prefs-toggle:hover, #focus-toggle:hover, #search-open:hover, #sidebar-toggle:hover,
#notes-toggle:hover, #print-pdf:hover { opacity: 0.7; }
#focus-toggle.active, #notes-toggle.active { background: var(--fg); color: var(--bg); }
#prefs-toggle[aria-expanded="true"] { background: var(--fg); color: var(--bg); }

/* Reading settings popover. One small panel instead of a row of buttons:
   typeface, exact size, line height, measure, weight, justification, theme. */
.prefs-panel {
  position: fixed;
  top: 62px;
  right: 20px;
  z-index: 45;
  width: 292px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--mono);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}
.prefs-panel[hidden] { display: none; }
.prefs-panel:focus { outline: none; }
.prefs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.prefs-head button {
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.prefs-group { display: flex; flex-direction: column; gap: 6px; }
.prefs-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.prefs-seg { display: grid; grid-auto-flow: column; gap: 0; }
.prefs-seg button {
  border: 1px solid var(--line-soft);
  border-left-width: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 0;
  cursor: pointer;
}
.prefs-seg button:first-child { border-left-width: 1px; }
.prefs-seg button.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.prefs-range {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.prefs-range output {
  color: var(--muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.prefs-range input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  accent-color: var(--fg);
}
.prefs-checks { display: flex; gap: 16px; font-size: 11px; }
.prefs-checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.prefs-checks input { accent-color: var(--fg); margin: 0; }
.prefs-reset {
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px;
  cursor: pointer;
}
.prefs-reset:hover { color: var(--fg); border-color: var(--fg); }

.reader-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 56px);
}
/* Grid items default to min-width:auto, so a wide <pre> or an SVG used to
   force the whole page sideways instead of scrolling inside its own box. */
.reader-layout > * { min-width: 0; }
html.sidebar-collapsed .reader-layout { grid-template-columns: 1fr; }
html.sidebar-collapsed .reader-sidebar { display: none; }
html.sidebar-collapsed .reader-content { margin: 0 auto; }

/* The sidebar grows to its full natural height (no inner scroll box on
   desktop); the page scrolls as a whole. Only the mobile drawer keeps its
   own scroll, since it is a fixed overlay. */
.reader-sidebar {
  padding: 20px 16px;
  font-family: var(--sans);
}
.reader-sidebar::-webkit-scrollbar {
  width: 6px;
}
.reader-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.reader-sidebar::-webkit-scrollbar-thumb {
  background: var(--line-soft);
  border-radius: 3px;
}
.reader-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Focus mode: hide the sidebar, regardless of the sidebar-collapsed
   setting. Content already expands full-width by default (see base
   .reader-content), so focus mode only removes the drawer. */
html.focus-mode .reader-layout { grid-template-columns: 1fr; }
html.focus-mode .reader-sidebar { display: none; }

html.justify-text .reader-content { text-align: justify; hyphens: auto; }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: color-mix(in srgb, var(--fg) 35%, transparent);
}
html.sidebar-open .sidebar-scrim { display: block; }
.toc-part { margin-bottom: 18px; }
.toc-part-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.toc-part-title a { min-width: 0; }
.toc-part-toggle,
.toc-item-toggle,
.toc-hidden-chip {
  flex-shrink: 0;
  font-family: var(--mono);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
}
.toc-part-toggle:hover, .toc-item-toggle:hover, .toc-hidden-chip:hover {
  color: var(--fg);
}
.toc-part-toggle:focus-visible,
.toc-item-toggle:focus-visible,
.toc-hidden-chip:focus-visible { outline: 1px solid var(--line); }
.toc-part-toggle {
  font-size: 10px;
  line-height: 1;
  padding: 2px 4px;
}
.toc-hidden-chip {
  font-size: 10px;
  line-height: 1;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 2px 7px;
}
.toc-hidden-chip:hover { border-color: var(--line); }
.toc-part.collapsed > ul { display: none; }
.toc-part ul { list-style: none; margin: 0; padding: 0; }
.toc-part li {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.toc-part li > a { flex: 1; min-width: 0; }
.toc-part li.collapsed { display: none; }
.toc-item-toggle {
  font-size: 11px;
  line-height: 1;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.toc-part li:hover .toc-item-toggle,
.toc-item-toggle:focus-visible { opacity: 1; }
.toc-part a {
  display: block;
  padding: 4px 6px;
  margin: 1px 0;
  font-size: 13px;
  text-decoration: none;
  border-radius: 2px;
}
.toc-part a:hover { background: var(--card); }
body[data-current-part] .toc-part { opacity: 0.55; }
body[data-current-part] .toc-part[data-part] a { font-weight: 400; }
.toc-part[data-part].current-part { opacity: 1; }
.toc-part[data-part].current-part .toc-part-title { color: var(--fg); }

/* Read-progress checkmarks, applied by reader.js from localStorage. Shared
   by the sidebar chapter links and the part-index chapter-list links. */
.toc-part a.read, .chapter-list a.read { opacity: 0.6; }
.toc-part a.read { text-decoration: line-through; }
.toc-part a.read::after,
.chapter-list a.read .chapter-list-title::after {
  content: " \2713";
  text-decoration: none;
  opacity: 1;
}

/* "Browse by Topic" entry at the top of the sidebar. */
.toc-topics-link { margin-bottom: 18px; }
.toc-topics-link a {
  display: block;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--fg);
}
.toc-topics-link a:hover { border-color: var(--line); background: var(--card); }

/* Topics index page. */
.topic-block { margin-bottom: 28px; }
.topic-block h2 { font-size: 1.15rem; }
.topic-block > p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.topic-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-family: var(--sans);
}
.topic-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.topic-part {
  flex-shrink: 0;
  width: 150px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.topic-list a { color: var(--fg); text-decoration: none; }
.topic-list a:hover { text-decoration: underline; }

.topics-card .part-idx { font-size: 16px; }

/* Newsletter signup box (reader index). */
.newsletter-box {
  margin-top: 40px;
  padding: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--card);
  text-align: center;
  font-family: var(--sans);
}
.newsletter-box h2 { font-size: 17px; margin: 0 0 8px; }
.newsletter-box p { font-size: 13px; color: var(--muted); margin: 0 auto 16px; max-width: 520px; }
.newsletter-box .subscribe-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.newsletter-box input[type="email"] {
  font-family: var(--mono);
  font-size: 13px;
  padding: 8px 12px;
  min-width: 240px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  background: var(--bg);
  color: var(--fg);
}
.newsletter-box .subscribe-form button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--fg);
  color: var(--bg);
  cursor: pointer;
}
.newsletter-box .subscribe-form button:disabled { opacity: 0.6; }
.newsletter-box .subscribe-status { font-family: var(--mono); font-size: 12px; min-height: 16px; margin: 8px auto 0; }
.newsletter-box .subscribe-alt { font-family: var(--mono); font-size: 11px; margin-top: 12px; }
.newsletter-box .subscribe-alt a { color: var(--muted); }
.newsletter-box .newsletter-actions { margin: 0 0 10px; }
.newsletter-box .btn-rss {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
}
.newsletter-box .btn-rss:hover { opacity: 0.85; }

.continue-reading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  padding: 14px 18px;
  margin-bottom: 28px;
  font-family: var(--sans);
}
.continue-reading .cr-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}
.continue-reading .cr-title { font-size: 14.5px; font-weight: 600; }
.continue-reading a.btn-continue {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--bg);
  background: var(--fg);
  padding: 8px 14px;
  white-space: nowrap;
}

.reader-content {
  padding: 40px clamp(16px, 2.5vw, 48px);
  width: 100%;
  /* The measure cap is the main comfort control: ~72 characters is the
     classic book line. ch resolves in the chosen typeface, so the cap moves
     with it; the extra 96px is the horizontal padding (border-box). */
  max-width: calc(var(--reader-measure) + 96px);
  margin-inline: auto;
  font-family: var(--reader-font);
  font-size: var(--reader-font-size);
}
.reader-content :first-child { margin-top: 0; }

/* Body typography the Aa panel drives. Weight and line height are applied
   to running text only, so headings keep their own tight leading and
   emphasis (<strong>, <b>) still reads as emphasis. */
.reader-content p,
.reader-content li,
.reader-content dd,
.reader-content blockquote {
  font-weight: var(--reader-weight);
  line-height: var(--reader-leading);
}

/* Re-declare the theme's own heading sizes as em multiples of the chosen
   reading size -- the theme hardcodes fixed pt values, and sets the pinned
   monospace stack on headings, which would ignore the typeface control. */
.reader-content h1,
.reader-content h2,
.reader-content h3,
.reader-content h4,
.reader-content h5 { font-family: var(--reader-font); }
.reader-content h1 { font-size: 1.7em; }
.reader-content h2 { font-size: 1.33em; }
.reader-content h3 { font-size: 1.14em; }
.reader-content h4 { font-size: 1.05em; }
.reader-content h5 { font-size: 1em; }
.reader-content pre,
.reader-content code { font-family: var(--mono); }
.reader-content pre { font-size: 0.95em; }
.reader-content code { font-size: 0.92em; }
.reader-content pre code { font-size: 1em; }
/* The Bold toggle is for prose; code keeps its own weight. */
.reader-content code { font-weight: 400; }

/* go-pretty-pdf's own stylesheet sets @page/print rules that are harmless
   on screen; only the print-oriented forced-page-break behavior on H1 is
   worth softening for continuous scrolling. */
.reader-content h1 {
  page-break-before: avoid;
  break-before: avoid;
  border-top: 1px solid var(--line-soft);
  padding-top: 40px;
  margin-top: 40px;
}
.reader-content section h1 {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.crumb-sep { margin: 0 4px; }
.crumb-current { color: var(--fg); }
.reading-time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Per-chapter share bar (social deep-links + copy). */
.share-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-family: var(--mono);
  font-size: 12px;
}
.share-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 2px;
}
.share-link {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--fg);
  text-decoration: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.share-link:hover { border-color: var(--line); background: var(--card); }
.share-copy { font-family: var(--mono); }

/* Copy-link-to-heading glyph shown on hover over h2/h3. */
.heading-link {
  opacity: 0;
  margin-left: 8px;
  font-size: 0.75em;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--mono);
}
h2:hover > .heading-link, h3:hover > .heading-link,
.heading-link:focus-visible { opacity: 1; }
.heading-link:hover { color: var(--fg); }

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--sans);
}
.chapter-nav-prev, .chapter-nav-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--fg);
  max-width: 45%;
}
.chapter-nav-next { text-align: right; margin-left: auto; }
.chapter-nav-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.chapter-nav-title { font-size: 14px; font-weight: 600; }
.chapter-nav-prev:hover .chapter-nav-title,
.chapter-nav-next:hover .chapter-nav-title { text-decoration: underline; }

.copy-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--fg);
  color: var(--bg);
  padding: 10px 16px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.copy-toast.visible { opacity: 1; }

/* Notes panel (per-page notes saved in localStorage). */
.notes-panel {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: min(360px, 90vw);
  z-index: 45;
  background: var(--bg);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
}
.notes-panel[hidden] { display: none; }
.notes-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
#notes-close {
  background: none;
  border: none;
  color: var(--fg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
#notes-text {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
}
.notes-panel-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-height: 20px;
}
.notes-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--fg) 30%, transparent);
}
.notes-scrim[hidden] { display: none; }

.chapter-list {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  font-family: var(--sans);
}
.chapter-list li { border-bottom: 1px solid var(--line-soft); }
.chapter-list a { display: block; padding: 14px 0; text-decoration: none; color: var(--fg); }
.chapter-list a:hover .chapter-list-title { text-decoration: underline; }
.chapter-list-title { display: block; font-size: 15px; font-weight: 600; }
.chapter-list-excerpt { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }

.part-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  margin-top: 28px;
}
.part-card {
  background: var(--card);
  color: var(--fg);
  text-decoration: none;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--sans);
}
.part-card:hover { background: var(--bg); }
.part-idx { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.part-card h2 { font-size: 17px; margin: 0; }
.part-card p { font-size: 13.5px; color: var(--muted); margin: 0; flex: 1; }
.part-count { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.palette {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.palette[hidden] { display: none; }
.palette-box {
  width: min(560px, 90vw);
  background: var(--bg);
  border: 1px solid var(--line);
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
}
#palette-input {
  font-family: var(--mono);
  font-size: 14px;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--fg);
  outline: none;
}
#palette-results { overflow-y: auto; }
.palette-result {
  display: block;
  padding: 10px 16px;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 1px solid var(--line-soft);
}
.palette-result:hover, .palette-result.active { background: var(--card); }
.palette-result .pr-title { font-size: 13.5px; font-weight: 600; }
.palette-result .pr-meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin: 2px 0; }
.palette-result .pr-excerpt { font-size: 12px; color: var(--muted); }
.palette-empty { padding: 16px; font-size: 13px; color: var(--muted); font-family: var(--mono); }

@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .part-grid { grid-template-columns: 1fr; }
  .chapter-nav { flex-direction: column; gap: 12px; }
  .chapter-nav-prev, .chapter-nav-next { max-width: 100%; text-align: left; margin-left: 0; }

  .reader-top { padding: 0 12px; height: 52px; }
  .reader-top-left { gap: 10px; }
  .brand { font-size: 13px; }
  .reader-top-actions { gap: 6px; }
  .reader-top-actions a { font-size: 11px; }
  #search-open, #prefs-toggle, #focus-toggle, #sidebar-toggle,
  #notes-toggle, #print-pdf { font-size: 11px; padding: 4px 8px; }
  #sidebar-toggle { padding: 4px 6px; }
  #search-open kbd { display: none; }

  .reader-sidebar {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 30;
    background: var(--bg);
    padding: 16px 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-soft) transparent;
  }
  .notes-panel { top: 52px; width: min(320px, 92vw); }
  .reader-sidebar::-webkit-scrollbar {
    width: 6px;
  }
  .reader-sidebar::-webkit-scrollbar-track {
    background: transparent;
  }
  .reader-sidebar::-webkit-scrollbar-thumb {
    background: var(--line-soft);
    border-radius: 3px;
  }
  .reader-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
  }
  html.sidebar-open .reader-sidebar { display: block; }

  .reader-content { padding: 24px 16px; overflow-x: hidden; }
  .reader-content pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .breadcrumb { font-size: 11px; margin-bottom: 18px; }
  .continue-reading { padding: 12px 14px; margin-bottom: 20px; }
  .continue-reading .cr-title { font-size: 13px; }
  .continue-reading a.btn-continue { font-size: 11px; padding: 6px 12px; }
  .chapter-nav { margin-top: 40px; padding-top: 18px; }
  .chapter-nav-title { font-size: 13px; }
  .chapter-list-title { font-size: 14px; }
  .chapter-list-excerpt { font-size: 12px; }
  .part-card { padding: 16px; }
  .part-card h2 { font-size: 15px; }
  .part-card p { font-size: 12.5px; }
  .toc-part a { font-size: 12px; padding: 3px 5px; }
  .toc-part-title { font-size: 10px; }

  .reader-top-actions a[href$="index.html"] { display: none; }
}

@media (max-width: 560px) {
  .reader-top { height: 48px; padding: 0 10px; }
  .brand { font-size: 12px; }
  .reader-top-actions { gap: 4px; flex-wrap: nowrap; }
  /* The two marketing links are the first thing to go when the bar has to
     fit on a phone; the reading controls stay. */
  .reader-top-actions a { display: none; }
  #search-open, #prefs-toggle, #focus-toggle, #sidebar-toggle,
  #notes-toggle, #print-pdf { font-size: 10px; padding: 3px 6px; }
  #sidebar-toggle { padding: 3px 5px; font-size: 14px; }
  #focus-toggle { display: none; }
  .prefs-panel { top: 54px; left: 10px; right: 10px; width: auto; }

  .reader-sidebar { top: 48px; width: min(280px, 88vw); padding: 12px 10px; }
  .notes-panel { top: 48px; }

  .reader-content { padding: 20px 12px; overflow-x: hidden; }
  .reader-content pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .reader-content h1 { margin-top: 32px; padding-top: 32px; }

  .breadcrumb { font-size: 10px; margin-bottom: 14px; }
  .continue-reading { flex-direction: column; align-items: flex-start; gap: 10px; padding: 10px 12px; }
  .continue-reading .cr-label { font-size: 10px; }
  .continue-reading .cr-title { font-size: 12px; }
  .continue-reading a.btn-continue { width: 100%; text-align: center; font-size: 10px; padding: 6px 10px; }

  .chapter-nav { margin-top: 32px; padding-top: 14px; gap: 10px; }
  .chapter-nav-label { font-size: 10px; }
  .chapter-nav-title { font-size: 12px; }

  .chapter-list a { padding: 12px 0; }
  .chapter-list-title { font-size: 13px; }
  .chapter-list-excerpt { font-size: 11px; margin-top: 3px; }

  .part-card { padding: 14px; gap: 6px; }
  .part-idx { font-size: 11px; }
  .part-card h2 { font-size: 14px; }
  .part-card p { font-size: 12px; }
  .part-count { font-size: 10px; }

  .toc-part { margin-bottom: 14px; }
  .toc-part-title { font-size: 9px; margin-bottom: 4px; }
  .toc-part a { font-size: 11px; padding: 2px 4px; }

  .palette-box { width: 95vw; max-height: 70vh; }
  #palette-input { font-size: 13px; padding: 12px 14px; }
  .palette-result { padding: 8px 14px; }
  .palette-result .pr-title { font-size: 12.5px; }
  .palette-result .pr-meta { font-size: 10px; }
  .palette-result .pr-excerpt { font-size: 11px; }
}

@media (max-width: 380px) {
  .reader-top { padding: 0 8px; }
  .reader-top-actions { gap: 3px; }
  #search-open, #prefs-toggle, #sidebar-toggle, #notes-toggle, #print-pdf { font-size: 9px; padding: 3px 5px; }
  .reader-content { padding: 16px 10px; overflow-x: hidden; }

  .continue-reading { padding: 8px 10px; }
}

/* Shared footer: subscribe, agent context, license. Present on every page so
   the feed is one click from anywhere, not just from the reader index. */
.reader-footer {
  border-top: 1px solid var(--line-soft);
  margin-top: 44px;
  padding: 22px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.reader-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
}
.reader-footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.reader-footer a { color: var(--muted); text-decoration: none; }
.reader-footer a:hover { color: var(--fg); }

/* ---------------------------------------------------------------------------
   Modern flat UI pass.
   Depth comes from 1px borders and background steps, never shadows. Shared
   radii keep every surface in the same visual family.
--------------------------------------------------------------------------- */
:root {
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  color-scheme: light dark;
}
:root[data-theme="sepia"] { color-scheme: light; }

/* Translucent sticky chrome instead of an opaque bar. */
.reader-top {
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line-soft);
}
.brand { letter-spacing: -0.01em; }

#search-open, #prefs-toggle, #focus-toggle, #sidebar-toggle,
#notes-toggle, #print-pdf, .reader-top-actions a {
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, color 0.15s ease;
}
#prefs-toggle:hover, #focus-toggle:hover, #search-open:hover,
#sidebar-toggle:hover, #notes-toggle:hover, #print-pdf:hover,
.reader-top-actions a:hover { opacity: 1; background: var(--card); }
#search-open kbd {
  background: var(--card);
  border-radius: 4px;
  padding: 1px 5px;
}
#focus-toggle.active, #notes-toggle.active,
#prefs-toggle[aria-expanded="true"] { border-radius: var(--radius-sm); }

/* Sidebar and table of contents. */
.toc-topics-link a {
  border-radius: var(--radius);
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.toc-part a { border-radius: var(--radius-sm); }
.toc-part-toggle, .toc-item-toggle, .toc-hidden-chip {
  border-radius: var(--radius-sm);
}
.toc-part-toggle:hover, .toc-item-toggle:hover, .toc-hidden-chip:hover {
  background: var(--card);
}

/* Cards and lists. */
.part-grid {
  gap: 12px;
  border: none;
  background: none;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.part-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.part-card:hover { background: var(--card); border-color: var(--fg); }
.chapter-list a {
  border-radius: var(--radius-sm);
  padding-inline: 10px;
  transition: background-color 0.15s ease;
}
.chapter-list a:hover { background: var(--card); }
.topic-list li { border-bottom: 1px solid var(--line-soft); }

/* Controls. */
.share-link, .prefs-seg button, .prefs-reset,
.newsletter-box input[type="email"], .newsletter-box .subscribe-form button,
.newsletter-box .btn-rss, .continue-reading a.btn-continue {
  border-radius: var(--radius-sm);
}
.share-link { transition: background-color 0.15s ease, border-color 0.15s ease; }
.share-link:hover { background: var(--card); }
.prefs-seg button:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.prefs-seg button:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Overlays: panels, palette, notes drawers. */
.prefs-panel, .palette-box { border-radius: var(--radius-lg); }
.notes-panel { border-radius: var(--radius-lg) 0 0 var(--radius-lg); }
.palette-box { overflow: hidden; }
.palette-result:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* Chapter navigation as two flat cards. */
.chapter-nav { border-top: none; padding-top: 0; }
.chapter-nav-prev, .chapter-nav-next {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.chapter-nav-prev:hover, .chapter-nav-next:hover {
  background: var(--card);
  border-color: var(--fg);
}

/* Book content: code, inline code, quotes, tables, media. */
.reader-content pre {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px 16px;
}
.reader-content :not(pre) > code {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.reader-content blockquote {
  border-left: 2px solid var(--line);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--card);
  padding: 10px 16px;
}
.reader-content table {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.reader-content th { background: var(--card); }
.reader-content th, .reader-content td { padding: 8px 12px; }
.reader-content img, .reader-content video { border-radius: var(--radius); }
.reader-content h1, .reader-content h2,
.reader-content h3, .reader-content [id] { scroll-margin-top: 76px; }

/* Accessibility: a skip link that only appears on keyboard focus. */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}
.skip-link:focus { transform: none; }

/* Copy button on every code block, revealed on hover or keyboard focus. */
.reader-content pre { position: relative; }
.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  user-select: none;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
pre:hover > .copy-code, .copy-code:focus-visible { opacity: 1; }
.copy-code:hover { background: var(--card); }

/* "New version" banner, fed by the service worker's update detection. */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 90;
  width: min(680px, calc(100vw - 32px));
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius-lg);
  font-family: var(--sans);
  font-size: 13px;
  animation: nwg-fade-in 0.2s ease both;
}
.ub-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ub-actions { display: flex; gap: 6px; flex-shrink: 0; }
.update-banner button {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.update-banner button:hover { background: var(--card); }
.update-banner .ub-all {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--fg);
}
.update-banner .ub-all:hover { background: var(--card); }
.update-banner .ub-refresh {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.update-banner .ub-close { border: none; font-size: 14px; padding: 2px 6px; }
.ub-list {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  max-height: 40vh;
  overflow-y: auto;
}
.ub-entry { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.ub-entry:last-child { border-bottom: none; }
.ub-entry-head { display: flex; align-items: baseline; gap: 8px; }
.ub-date {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.ub-subject { font-weight: 600; font-size: 12.5px; }
.ub-chapters { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ub-chapters a { color: var(--muted); }
.ub-chapters a:hover { color: var(--fg); }
@media (max-width: 560px) {
  .update-banner { bottom: 10px; }
  .ub-main { align-items: flex-start; }
}

/* GitHub discussion block at the end of every chapter. */
.gh-actions {
  margin-top: 32px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  font-family: var(--sans);
}
.gh-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.gh-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.gh-link {
  font-family: var(--mono);
  font-size: 11.5px;
  text-decoration: none;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.gh-link:hover { border-color: var(--fg); background: var(--card); }
.gh-stars { color: var(--muted); }
.gh-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.gh-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.gh-btn:hover { background: var(--fg); color: var(--bg); }
.gh-rate {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.gh-rate button {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--fg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
}
.gh-rate button:hover {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.gh-issues {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.gh-issue {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
}
.gh-issue a { text-decoration: none; }
.gh-issue a:hover { text-decoration: underline; }
.gh-issue .meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
}
.gh-none { color: var(--muted); font-size: 12px; }

/* Reading settings v2: comfort presets, code scale and hyphenation. */
:root { --reader-code-scale: 1; --reader-letter: 0em; --reader-para: 1; }
.reader-content pre { font-size: calc(0.95em * var(--reader-code-scale)); }
.reader-content { letter-spacing: var(--reader-letter); }
.reader-content p,
.reader-content blockquote {
  margin-bottom: calc(0.6em * var(--reader-para));
}
html.high-contrast {
  --muted: var(--fg);
  --line-soft: var(--fg);
  --card: var(--bg);
}
html.wide-mode .reader-content {
  max-width: min(100%, 1200px);
}
html.hyphenate .reader-content p,
html.hyphenate .reader-content li,
html.hyphenate .reader-content blockquote { hyphens: auto; -webkit-hyphens: auto; }
.prefs-panel { width: 320px; }
.prefs-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.prefs-presets button {
  font-family: var(--mono);
  font-size: 11px;
  padding: 7px 4px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.prefs-presets button:hover { background: var(--card); border-color: var(--fg); }
.prefs-checks { flex-wrap: wrap; gap: 10px 16px; }
.prefs-range output { font-variant-numeric: tabular-nums; }
.prefs-shortcuts {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.prefs-shortcuts kbd {
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 1px 4px;
  font-family: var(--mono);
  font-size: 9.5px;
}

/* Sidebar tools: chapter filter, saved chapters and reading progress. */
.toc-tools { margin-bottom: 12px; }
#toc-filter {
  width: 100%;
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
}
#toc-filter:focus { outline: 2px solid var(--fg); outline-offset: 1px; }
.toc-progress {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.toc-bookmarks { margin-bottom: 16px; }
.toc-bookmarks ul { list-style: none; margin: 4px 0 0; padding: 0; }
.toc-bookmarks a {
  display: block;
  padding: 3px 6px;
  font-size: 12.5px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-bookmarks a:hover { background: var(--card); }
.bookmark-btn {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 4px 10px;
  margin: 0 0 14px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}
.bookmark-btn:hover { border-color: var(--fg); background: var(--card); }
.bookmark-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* What's new: the commit-generated changelog page. */
.changelog-entry { border-top: 1px solid var(--line-soft); padding: 18px 0; }
.changelog-entry:first-of-type { border-top: none; padding-top: 0; }
.changelog-date {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.changelog-date code { font-size: 10px; }
.changelog-entry h2 { font-size: 1.05em; margin: 6px 0 8px; }
.changelog-list { margin: 0; padding-left: 18px; font-size: 0.92em; }
.changelog-list li { margin: 3px 0; }

/* Print: strip the app chrome so "Save as PDF" (or Ctrl+P) produces a
   clean, single-chapter document. */
@media print {
  .reader-top, .reader-sidebar, .sidebar-scrim, .notes-panel, .notes-scrim,
  .palette, .prefs-panel, .reader-footer, .reading-progress, .share-bar,
  .chapter-nav, .breadcrumb, .heading-link, #copy-toast, .read-sentinel { display: none !important; }
  body { background: #ffffff; color: #000000; }
  .reader-layout { display: block; }
  .reader-content {
    max-width: none;
    width: 100%;
    padding: 0;
    font-size: 11pt;
  }
  .reader-content h1 { border-top: none; page-break-before: auto; }
  .reader-content section h1 { page-break-before: auto; }
  pre { white-space: pre-wrap; word-wrap: break-word; }
  a { color: #000000; }
}
