:root {
  --bg: #fbfaf7;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --line: #dddad2;
  --panel: #ffffff;
  --code-bg: #f4f2ec;
  --accent: #c2410c;
  --accent2: #2563eb;
  --good: #15803d;
  --bad: #b91c1c;
  --grid: #e7e4dc;
  --b0: #e9e6de;
  --b1: #1d1d1f;
  --series: #2563eb, #c2410c, #15803d, #7c3aed;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --fg: #ececee;
    --muted: #9a9aa2;
    --line: #2e2e33;
    --panel: #1b1b1f;
    --code-bg: #1f1f24;
    --accent: #fb923c;
    --accent2: #60a5fa;
    --good: #4ade80;
    --bad: #f87171;
    --grid: #2a2a30;
    --b0: #2a2a30;
    --b1: #ececee;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--fg); font: 16px/1.55 var(--sans); }
body { margin: 0; }
a { color: var(--accent2); }
header.site {
  display: flex; gap: 1.2rem; align-items: baseline; flex-wrap: wrap;
  padding: 0.8rem 1.5rem; border-bottom: 1px solid var(--line);
}
header.site .logo { font-weight: 700; color: var(--fg); text-decoration: none; font-size: 1.1rem; }
header.site nav { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.92rem; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover, header.site nav a[aria-current] { color: var(--fg); }
main { max-width: 1480px; margin: 0 auto; padding: 1.5rem; }
main > h1 { margin: 0.2rem 0 0.4rem; font-size: 1.8rem; }
.lede { color: var(--muted); max-width: 60rem; margin-top: 0; }
.prose { max-width: 48rem; }
.prose h2 { font-size: 1.2rem; margin-top: 2rem; }
code, pre { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 4px; }
table { border-collapse: collapse; font-size: 0.92rem; }
th, td { border-bottom: 1px solid var(--line); padding: 0.3rem 0.7rem 0.3rem 0; text-align: left; vertical-align: top; }
footer { color: var(--muted); font-size: 0.85rem; padding: 2rem 1.5rem; border-top: 1px solid var(--line); margin-top: 3rem; }

/* The lab: figure beside the editor on wide screens. */
#lab { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; margin: 1.2rem 0; align-items: start; }
@media (max-width: 1200px) { #lab { grid-template-columns: minmax(0, 1fr); } }
.figure, .editor {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; min-width: 0;
  display: flex; flex-direction: column;
}
svg.fig { width: 100%; height: auto; display: block; font-family: var(--sans); }
.bar {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  padding: 0.45rem 0.6rem; border-top: 1px solid var(--line); font-size: 0.85rem;
}
.editor .bar { border-top: 0; border-bottom: 1px solid var(--line); }
.bar .extra { display: contents; }
.bar .edited { color: var(--accent); font-size: 0.8rem; margin-right: auto; }
.bar strong { font-family: var(--mono); font-weight: 600; }
.bar .speed { color: var(--muted); min-width: 2.5rem; }
button, select {
  font: inherit; font-size: 0.85rem; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 5px; padding: 0.2rem 0.6rem; cursor: pointer;
}
button:hover { border-color: var(--muted); }
input[type=range] { width: 6rem; vertical-align: middle; }

.code { position: relative; display: flex; flex: 1; min-height: 28rem; max-height: 44rem; overflow: hidden; background: var(--code-bg); }
.gutter {
  margin: 0; padding: 0.7rem 0.5rem 0.7rem 0.6rem; color: var(--muted); text-align: right; user-select: none;
  line-height: 1.5; font-size: 13px; min-width: 2.6rem; opacity: 0.7;
}
.edit { position: relative; flex: 1; overflow: hidden; }
.edit textarea, .edit .hl {
  position: absolute; inset: 0; margin: 0; padding: 0.7rem; border: 0;
  font: 13px/1.5 var(--mono); tab-size: 2; white-space: pre; overflow-wrap: normal; letter-spacing: 0;
}
.edit textarea {
  width: 100%; height: 100%; resize: none; outline: none; background: transparent;
  color: transparent; caret-color: var(--fg); overflow: auto;
}
.edit .hl { pointer-events: none; color: var(--fg); overflow: visible; }
.tk-c { color: var(--muted); font-style: italic; }
.tk-s { color: var(--good); }
.tk-n { color: var(--accent); }
.tk-k { color: var(--accent2); font-weight: 600; }
.tk-h { color: #a21caf; }
@media (prefers-color-scheme: dark) { .tk-h { color: #e879f9; } }
.status { font: 12.5px/1.4 var(--mono); padding: 0.45rem 0.7rem; border-top: 1px solid var(--line); min-height: 2.1rem; }
.status.err { color: var(--bad); }
.status.ok { color: var(--good); }
.banner {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  border: 1px solid var(--accent); border-radius: 8px; padding: 0.6rem 0.8rem; margin-top: 1rem;
}
.banner span { margin-right: auto; }

/* SVG text and marks. */
svg.fig text { fill: var(--fg); font-size: 12px; }
svg.fig .muted { fill: var(--muted); }
svg.fig .mono { font-family: var(--mono); }
svg.fig .title { font-weight: 600; font-size: 13px; }
svg.fig .axis { stroke: var(--line); }
svg.fig .gridline { stroke: var(--grid); }
svg.fig .accent { fill: var(--accent); }
svg.fig .accent2 { fill: var(--accent2); }

/* Index cards. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.8rem; margin: 0.8rem 0 2rem; }
.cards a {
  display: block; border: 1px solid var(--line); border-radius: 8px; padding: 0.8rem 1rem;
  text-decoration: none; color: var(--fg); background: var(--panel);
}
.cards a:hover { border-color: var(--muted); }
.cards a strong { display: block; margin-bottom: 0.2rem; }
.cards a span { color: var(--muted); font-size: 0.9rem; }
