:root {
  color-scheme: light dark;
  --ink: #16181d;
  --muted: #6b7280;
  --rule: #e5e7eb;
  --paper: #fcfcfa;
  --link: #8a3b12;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e6e1;
    --muted: #9aa0aa;
    --rule: #2b2f37;
    --paper: #14161a;
    --link: #e5a273;
  }
}

* { box-sizing: border-box; }

html { font-size: 18px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

header.site, footer.site, main {
  width: min(var(--measure), 100% - 3rem);
  margin-inline: auto;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 1.75rem 0 1rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  font-variant: small-caps;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
}

nav { display: flex; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
nav a:hover { color: var(--link); text-decoration: underline; }

main { padding: 2.5rem 0 4rem; }

h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 0.5rem; font-weight: 600; }
h2 { font-size: 1.3rem; margin: 2.75rem 0 0.6rem; font-weight: 600; }

p { margin: 0 0 1rem; }
p.lede { color: var(--muted); font-size: 1.05rem; margin-bottom: 2rem; }

ul { margin: 0 0 1.25rem; padding-left: 1.2rem; }
li { margin-bottom: 0.35rem; }

a { color: var(--link); }

/* Formulas before the SVG arrives: the TeX source, dimmed, so the page never
   reflows from empty space into a picture. */
.math {
  color: var(--muted);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.math svg {
  max-width: 100%;
  /* the endpoint's inline SVG carries its own vertical-align */
}

/* Once the picture is in, the placeholder's monospace fallback must not shrink it. */
.math.done {
  font-family: inherit;
  color: inherit;
}

.math.done:not(.math-display) { font-size: 1em; }

.math-display {
  display: block;
  text-align: center;
  margin: 1.75rem 0;
  font-size: 1.1em;
}

.math.failed {
  color: #b42318;
  white-space: pre-wrap;
}

blockquote {
  margin: 1.5rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}
blockquote p { margin: 0; }

footer.site {
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
footer.site p { margin: 0; }

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.86em;
}
