:root {
  --bg: #fdfcf8;
  --fg: #1d1d1b;
  --muted: #6b6a64;
  --rule: #e3e0d6;
  --accent: #2f5d8a;
  --code-bg: #f3f1ea;
  --todo-bg: #f6f2e2;
  --todo-fg: #7a6a2e;
  --accent-bg: #e6eef6;
  --good: #3d7a4a;
  --bad: #a4493d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --fg: #e4e2dc;
    --muted: #96948d;
    --rule: #2e3035;
    --accent: #8db5dc;
    --code-bg: #212328;
    --todo-bg: #2a2719;
    --todo-fg: #d2bf7a;
    --accent-bg: #1f2c3a;
    --good: #7fbf8c;
    --bad: #e08a7e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 19px/1.6 Charter, 'Bitstream Charter', 'Iowan Old Style', 'Sitka Text', Cambria, Georgia, serif;
}
main, header.site { max-width: 42rem; margin: 0 auto; padding: 0 1.25rem; }
header.site { padding-top: 1.5rem; font-size: 0.95rem; }
header.site a { color: var(--muted); text-decoration: none; font-variant: small-caps; letter-spacing: 0.04em; }
main { padding-bottom: 5rem; }

h1, h2, h3 { line-height: 1.25; font-weight: 600; }
h1 { font-size: 2rem; margin: 2.5rem 0 0.25rem; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 0.5rem; }
h3 { font-size: 1.15rem; margin: 2rem 0 0.5rem; }
a { color: var(--accent); }
p.meta, div.meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 2rem; }
.draft { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--todo-fg); background: var(--todo-bg); padding: 0.05rem 0.4rem; border-radius: 3px; }
p.lede { color: var(--muted); margin-top: 2.5rem; }
ul.posts { list-style: none; padding: 0; }
ul.posts li { margin: 1.5rem 0; }
ul.posts a { font-size: 1.2rem; text-decoration: none; }
ul.posts div.meta { margin: 0.2rem 0 0; }

blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }
hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
code { font: 0.85em/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }
pre { background: var(--code-bg); padding: 0.9rem 1rem; border-radius: 4px; overflow-x: auto; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; margin: 1.5rem 0; font-size: 0.92rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--rule); padding: 0.35rem 0.8rem 0.35rem 0; text-align: left; vertical-align: top; }
img, svg, video { max-width: 100%; height: auto; }
figure { margin: 2rem 0; }
figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 0.5rem; }

/* the lower-level details: <details><summary>…</summary> … </details> */
details { margin: 1.5rem 0; padding: 0.6rem 1rem; border: 1px solid var(--rule); border-radius: 4px; font-size: 0.95rem; }
details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: 0.5rem; }

/* math */
.katex { font-size: 1.05em; }
eq { display: inline; }
section.eqno, .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }

/* [[figure: …]] placeholders */
.figure-todo { margin: 2rem 0; padding: 1.5rem 1rem; text-align: center; border: 2px dashed var(--todo-fg); border-radius: 6px; background: var(--todo-bg); color: var(--todo-fg); font-size: 0.95rem; }

/* footnotes */
.footnotes { font-size: 0.9rem; color: var(--muted); }
.footnotes-sep { margin-top: 3rem; }

/* figures: inline SVG ([[svg: …]]), drawn in the page's colours */
figure.fig { margin: 2.2rem 0; }
figure.fig svg { display: block; width: 100%; height: auto; font-family: inherit; }
figure.fig svg text { fill: var(--fg); font-size: 14px; }
figure.fig svg .mut { fill: var(--muted); }
figure.fig svg .acc { fill: var(--accent); }
figure.fig svg .good { fill: var(--good); }
figure.fig svg .bad { fill: var(--bad); }
figure.fig svg .small { font-size: 12px; }
figure.fig svg .big { font-size: 16px; }
figure.fig svg .b { font-weight: 600; }
figure.fig svg .it { font-style: italic; }
figure.fig svg .bx { fill: var(--code-bg); stroke: var(--rule); stroke-width: 1.2; }
figure.fig svg .bx-acc { fill: var(--accent-bg); stroke: var(--accent); stroke-width: 1.2; }
figure.fig svg .bx-good { fill: var(--code-bg); stroke: var(--good); stroke-width: 1.4; }
figure.fig svg .bx-bad { fill: var(--code-bg); stroke: var(--bad); stroke-width: 1.4; }
figure.fig svg .ln { stroke: var(--muted); stroke-width: 1.4; fill: none; }
figure.fig svg .ln-acc { stroke: var(--accent); stroke-width: 1.6; fill: none; }
figure.fig svg .ln-faint { stroke: var(--muted); stroke-width: 1; fill: none; opacity: 0.45; stroke-dasharray: 4 4; }
figure.fig svg .dash { stroke-dasharray: 5 4; }
figure.fig svg .head { fill: var(--muted); }
figure.fig svg .head-acc { fill: var(--accent); }
figure.fig svg .dot { fill: var(--fg); }
figure.fig svg .dot-acc { fill: var(--accent); }
figure.fig svg .hollow { fill: var(--bg); stroke: var(--muted); stroke-width: 1.4; }
figure.fig svg .grid { stroke: var(--rule); stroke-width: 1; }
figure.fig svg [class*="step"] { transition: opacity 0.35s; }
.fig-controls { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.fig-controls button {
  font: inherit; font-size: 0.85rem; color: var(--accent); background: var(--accent-bg);
  border: 1px solid var(--accent); border-radius: 4px; padding: 0.2rem 0.7rem; cursor: pointer;
}
.fig-controls button:disabled { opacity: 0.4; cursor: default; }
