/* ── Tokens ─────────────────────────────────────────────────────────────────
   Dark only: the figures embedded in posts hardcode a dark palette.
   Black, white and one blue. The orange is kept for warning callouts only. */
:root {
  --bg: #000000;
  --bg-raise: #101113;
  --bg-sink: #0a0a0b;
  --ink: #ffffff;
  --text: #dcdde0;
  --muted: #9c9ea6;
  --rule: #202124;
  --rule-strong: #3b3d43;
  --blue: #4da3ff;
  --blue-soft: #a8d1ff;
  --blue-deep: #1f6fd6;
  --warn: #d95926;

  --font-serif: 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --page: 66rem;
  --measure: 44rem;
  --gutter: clamp(1.25rem, 5vw, 2.5rem);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote, pre {
  margin: 0;
}

ul, ol {
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

a {
  color: var(--blue);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--blue-soft);
  text-decoration-color: currentColor;
}

a:focus-visible,
button:focus-visible,
video:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 2px;
}

strong, b {
  font-weight: 650;
  color: var(--ink);
}

img, video, svg {
  max-width: 100%;
}

::selection {
  background: var(--blue-deep);
  color: #fff;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--blue);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Small mono label used above titles and for metadata */
.kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
  color: var(--blue);
}

.kicker a {
  color: inherit;
  text-decoration: none;
}

.kicker a:hover {
  color: var(--ink);
}

/* ── Masthead, footer ───────────────────────────────────────────────────── */
.masthead,
main {
  width: 100%;
  max-width: calc(var(--page) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* No side padding, so the top rule lines up with the content edge */
.site-foot {
  width: calc(100% - 2 * var(--gutter));
  max-width: var(--page);
  margin-inline: auto;
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.4rem 1.2rem;
}

.masthead-name {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.masthead nav ul,
.site-foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.6rem;
  list-style: none;
}

.masthead nav a,
.site-foot a {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding-block: 0.35rem;
  border-bottom: 2px solid transparent;
}

.masthead nav a:hover,
.site-foot a:hover {
  color: var(--ink);
}

.masthead nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--blue);
}

main {
  flex: 1 0 auto;
  min-width: 0;
  padding-block: clamp(1.5rem, 5vw, 3.5rem) clamp(3rem, 8vw, 5rem);
}

.site-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.4rem 2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ── Page furniture shared by home, writing, projects, about ────────────── */
.page-head {
  max-width: 40rem;
  margin-bottom: clamp(2rem, 5vw, 3.25rem);
}

.page-head h1 {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.page-lede {
  margin-top: 0.9rem;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text);
  text-wrap: balance;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label a {
  color: var(--blue);
  text-decoration: none;
}

.section-label a:hover {
  color: var(--ink);
}

main > section + section {
  margin-top: clamp(2.75rem, 7vw, 4.5rem);
}

/* ── Home ───────────────────────────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  align-items: center;
  gap: clamp(1.75rem, 5vw, 4rem);
  padding-bottom: clamp(2.75rem, 7vw, 4.5rem);
}

.hero h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.7rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.02;
}

.hero-lede {
  margin-top: 1.25rem;
  max-width: 34rem;
  font-size: 1.2rem;
  line-height: 1.55;
  text-wrap: balance;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  background: var(--blue);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  border-radius: 2px;
}

.btn:hover {
  background: var(--blue-soft);
  color: var(--bg);
}

/* Three looping greetings, laid out as one large print and two small ones */
.postcards {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}

.postcards video {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-raise);
  border-radius: 2px;
}

.postcards video:first-of-type {
  grid-row: 1 / span 2;
}

.postcards figcaption {
  grid-column: 1 / -1;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

/* ── Series shelf ───────────────────────────────────────────────────────── */
.shelf {
  list-style: none;
}

.series {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1rem clamp(1.5rem, 5vw, 4rem);
  padding-block: 1.75rem;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 1rem;
}

.series-name {
  margin-top: 0.4rem;
  font-size: 1.75rem;
  letter-spacing: -0.015em;
  line-height: 1.12;
}

.series-name a {
  color: inherit;
  text-decoration: none;
}

.series-name a:hover {
  color: var(--blue);
}

.series-blurb {
  margin-top: 0.55rem;
  max-width: 30rem;
  color: var(--text);
}

.vols {
  list-style: none;
  align-self: start;
}

.vols a {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
}

.vols li:first-child a {
  border-top: 0;
  padding-top: 0.15rem;
}

.vol-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.vols a:hover .vol-num {
  color: var(--blue);
}

.vols a:hover .vol-chapter {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* Home: two columns of series, numerals as tiles, chapter titles hidden */
.shelf--compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(1.5rem, 5vw, 4rem);
}

.shelf--compact .series {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.1rem;
}

.shelf--compact .series-name {
  font-size: 1.5rem;
}

.shelf--compact .vols {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shelf--compact .vols a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.shelf--compact .vols li:first-child a {
  padding-top: 0;
  border-top: 1px solid var(--rule-strong);
}

.shelf--compact .vols a:hover {
  background: var(--blue);
  border-color: var(--blue);
}

.shelf--compact .vols a:hover .vol-num {
  color: var(--bg);
}

.shelf--compact .vol-num {
  color: var(--ink);
}

.shelf--compact .vol-chapter {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Post list (everything that is not a series volume) ─────────────────── */
.post-list {
  list-style: none;
}

.post-list li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  align-items: baseline;
  gap: 1rem;
  padding-block: 1.05rem;
  border-bottom: 1px solid var(--rule);
}

.post-list time {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-list a {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
}

.post-list a:hover {
  color: var(--blue);
}

.post-list p {
  margin-top: 0.2rem;
  max-width: 38rem;
  color: var(--text);
}

/* ── Post page ──────────────────────────────────────────────────────────── */
.post-page {
  max-width: var(--measure);
  margin-inline: auto;
}

.post-head {
  margin-bottom: 2rem;
}

.post-head h1 {
  margin-top: 0.6rem;
  font-size: clamp(2.1rem, 6vw, 3.1rem);
  letter-spacing: -0.022em;
  line-height: 1.06;
}

.post-head .kicker + h1 {
  margin-top: 0.5rem;
}

.meta {
  margin-top: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.book-meta {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
}

.post {
  font-size: 1.1875rem;
  line-height: 1.68;
  overflow-wrap: break-word;
}

.post p {
  margin-bottom: 1.25em;
}

.post ul,
.post ol,
.post dl {
  margin: 0 0 1.25em 1.3em;
}

.post li {
  padding-left: 0.2em;
  margin-bottom: 0.5em;
  line-height: 1.6;
}

.post li > ul,
.post li > ol {
  margin-top: 0.5em;
  margin-bottom: 0;
}

.post h2,
.post h3,
.post h4,
.post h5 {
  scroll-margin-top: 1rem;
}

/* Section heading: a short blue rule above stands in for a chapter break */
.post h2 {
  margin: 2.4em 0 0.7em;
  font-size: 1.62rem;
  letter-spacing: -0.015em;
}

.post h2::before {
  content: '';
  display: block;
  width: 2.5rem;
  height: 2px;
  margin-bottom: 0.85rem;
  background: var(--blue);
}

.post h3 {
  margin: 2em 0 0.6em;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.post h4 {
  margin: 1.7em 0 0.5em;
  font-size: 1.08rem;
}

/* Some posts start their sections at '##' instead of '#'. With no h2 on the
   page, promote each level one step so every post looks the same. */
.post:not(:has(h2)) h3 {
  margin: 2.4em 0 0.7em;
  font-size: 1.62rem;
  letter-spacing: -0.015em;
}

.post:not(:has(h2)) h3::before {
  content: '';
  display: block;
  width: 2.5rem;
  height: 2px;
  margin-bottom: 0.85rem;
  background: var(--blue);
}

.post:not(:has(h2)) h4 {
  margin: 2em 0 0.6em;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
}

.post:not(:has(h2)) hr:has(+ h3) {
  display: none;
}

.post h5 {
  margin: 1.5em 0 0.5em;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.post hr {
  height: 0;
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

/* Authors often type --- before a new section; the heading's blue bar already
   marks that break, so the rule would double up. */
.post hr:has(+ h2) {
  display: none;
}

.post blockquote {
  margin: 1.6em 0;
  padding: 0.1em 0 0.1em 1.25em;
  border-left: 2px solid var(--rule-strong);
  color: var(--ink);
  font-style: italic;
}

.post blockquote p:last-child {
  margin-bottom: 0;
}

.post blockquote em {
  font-style: normal;
}

.post img {
  display: block;
  height: auto;
  margin: 1.9em auto;
  border-radius: 3px;
}

.post iframe,
.post video,
.post embed,
.post object {
  max-width: 100%;
}

.post sup,
.post sub {
  font-size: 0.72em;
  line-height: 0;
}

.center {
  display: block;
  margin: 0 auto;
  text-align: center;
}

/* Code */
code,
pre,
kbd,
samp {
  font-family: var(--font-mono);
}

.post code {
  padding: 0.12em 0.36em;
  font-size: 0.82em;
  background: var(--bg-raise);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
}

.post pre {
  margin: 1.6em 0;
  padding: 1.05em 1.2em;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-sink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 0.86rem;
  line-height: 1.6;
}

.post pre code {
  display: block;
  width: max-content;
  min-width: 100%;
  padding: 0;
  font-size: inherit;
  background: none;
  border: 0;
  white-space: pre;
  overflow-wrap: normal;
  color: var(--text);
}

/* Rouge tokens */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cd, .highlight .ch { color: #7f838c; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kc, .highlight .ow { color: #4da3ff; }
.highlight .kt, .highlight .nc, .highlight .nn, .highlight .nb, .highlight .bp { color: #e0b454; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sd, .highlight .sh, .highlight .sx, .highlight .sr, .highlight .se, .highlight .si { color: #6cc7a1; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il, .highlight .no { color: #c9a2f2; }
.highlight .nf, .highlight .fm, .highlight .nt, .highlight .na, .highlight .nd { color: #a8d1ff; }
.highlight .nv, .highlight .vi, .highlight .vg, .highlight .vc { color: #ececee; }
.highlight .o, .highlight .p { color: #a9abb2; }
.highlight .gd { color: #f08a5d; }
.highlight .gi { color: #6cc7a1; }
.highlight .err { color: inherit; background: none; }

/* Tables: block + overflow so wide ones scroll instead of breaking the page */
.post table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1.6em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 0.95em;
  color: var(--text);
}

.post th,
.post td {
  padding: 0.6em 0.9em;
  border-bottom: 1px solid var(--rule);
  line-height: 1.45;
  text-align: left;
  vertical-align: top;
}

.post th {
  border-bottom-color: var(--rule-strong);
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
}

.post table mjx-container {
  color: inherit;
}

/* Callouts (definitions, warnings) */
.post .note,
.post .warn {
  margin: 1.5em 0;
  padding: 0.85em 1.1em;
  border-left: 2px solid var(--blue);
  background: rgba(77, 163, 255, 0.08);
  color: var(--ink);
}

.post .warn {
  border-left-color: var(--warn);
  background: rgba(217, 89, 38, 0.1);
}

.post .note > p:last-child,
.post .warn > p:last-child {
  margin-bottom: 0;
}

.post .note ol {
  list-style: decimal;
  margin: 0.4em 0 0.2em 1.2em;
}

.post .note li {
  margin: 0.45em 0;
}

/* Book reviews */
.book-cover {
  max-width: 300px;
  display: block;
  margin: 1.5em auto;
}

.book-img {
  max-width: 100%;
  display: block;
  margin: 1.5em auto;
}

/* Interactive figures set their own palette; give them a neutral UI face
   so labels and controls stay crisp at 13px next to the serif text. */
.post .pv,
.post .gv,
.post .mviz,
.post .cs-stage,
.post .vx-fig {
  font-family: var(--font-ui);
}

/* Volume switcher: posts open with "*Series:* **I** · [II](…) · [III](…)".
   The series name is already in the kicker, so the label is hidden;
   font-size: 0 drops the " · " separators between the tiles. */
.post > p:first-child:has(> em:first-child):has(> strong) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 2.4rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0;
}

.post > p:first-child:has(> em:first-child):has(> strong) > em:first-child {
  display: none;
}

.post > p:first-child:has(> em:first-child):has(> strong) > a,
.post > p:first-child:has(> em:first-child):has(> strong) > strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.post > p:first-child:has(> em:first-child):has(> strong) > a:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.post > p:first-child:has(> em:first-child):has(> strong) > strong {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--bg);
}

/* MathJax: long display equations scroll inside themselves */
mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

mjx-container[jax="CHTML"][display="true"] {
  display: block;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}

mjx-container[jax="CHTML"]:not([display="true"]) {
  display: inline;
  vertical-align: baseline;
}

.mermaid {
  max-width: 100%;
  margin: 1.6em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Post footer: previous / next volume */
.post-foot {
  margin-top: 4rem;
}

.vol-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-block: 1px solid var(--rule-strong);
}

.vol-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.25rem 0;
  color: var(--ink);
  text-decoration: none;
}

.vol-nav .vol-nav-next {
  grid-column: 2;
  padding-left: 1.5rem;
  text-align: right;
  align-items: flex-end;
}

.vol-nav .vol-nav-prev {
  grid-column: 1;
  padding-right: 1.5rem;
  border-right: 1px solid var(--rule);
}

.vol-nav-title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.25;
}

.vol-nav a:hover .vol-nav-title {
  color: var(--blue);
}

.post-foot-links {
  margin-top: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-foot-links a {
  color: var(--muted);
  text-decoration: none;
}

.post-foot-links a:hover {
  color: var(--ink);
}

/* ── About ──────────────────────────────────────────────────────────────── */
.about {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1.75rem, 6vw, 4.5rem);
  max-width: 56rem;
}

.about-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
}

.about-lede {
  font-size: clamp(1.7rem, 4.2vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--ink);
  text-wrap: balance;
}

.about-body {
  margin-top: 1.5rem;
  max-width: 36rem;
  font-size: 1.15rem;
  line-height: 1.65;
}

.about-body p + p {
  margin-top: 1.1em;
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

/* ── Projects (generated by scripts/update_selected_works_stats.py) ─────── */
.works-section + .works-section {
  margin-top: clamp(2.25rem, 6vw, 3.5rem);
}

.works-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 clamp(1.5rem, 5vw, 4rem);
  list-style: none;
}

.work {
  padding-block: 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.work-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.work-title a {
  color: var(--ink);
  text-decoration: none;
}

.work-title a:hover {
  color: var(--blue);
}

.work-desc {
  margin-top: 0.4rem;
  color: var(--text);
}

.work-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1.25rem;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.work-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.lang-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.lang-dot.python   { background: #3572A5; }
.lang-dot.julia    { background: #a270ba; }
.lang-dot.shell    { background: #4eaa25; }
.lang-dot.js       { background: #c0a80e; }
.lang-dot.ts       { background: #3178c6; }
.lang-dot.css      { background: #563d7c; }
.lang-dot.wasm     { background: #6460ee; }
.lang-dot.jupyter  { background: #DA5B0B; }
.lang-dot.notes    { background: #e8a838; }

/* ── Small screens ──────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .postcards {
    max-width: 30rem;
  }

  .series {
    grid-template-columns: minmax(0, 1fr);
  }

  .shelf--compact,
  .works-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  body {
    font-size: 1rem;
  }

  .post {
    font-size: 1.0625rem;
    line-height: 1.65;
  }

  .post ul,
  .post ol {
    margin-left: 1.15em;
  }

  .post pre {
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    border-inline: 0;
    border-radius: 0;
    font-size: 0.8rem;
  }

  .post table {
    font-size: 0.86em;
  }

  .post th,
  .post td {
    padding: 0.5em 0.6em;
  }

  .post-list li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.2rem;
  }

  .about {
    grid-template-columns: minmax(0, 1fr);
  }

  .about-photo {
    max-width: 11rem;
  }

  .vol-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .vol-nav .vol-nav-prev,
  .vol-nav .vol-nav-next {
    grid-column: 1;
    padding-inline: 0;
    border-right: 0;
  }

  .vol-nav-prev + .vol-nav-next {
    border-top: 1px solid var(--rule);
  }

  .post mjx-container[jax="CHTML"][display="true"] {
    font-size: 86%;
    padding-bottom: 6px;
  }

  /* Tagged equations get an inline min-width from MathJax; drop it so they
     scroll inside their own box like every other display equation. */
  .post mjx-container[jax="CHTML"][display="true"] {
    min-width: 0 !important;
  }

  /* MathJax 3 cannot break an inline formula across lines. On a phone a long
     one would widen the whole page, so let just its paragraph scroll. */
  .post p:has(mjx-container),
  .post li:has(mjx-container) {
    overflow-x: auto;
    overflow-y: hidden;
  }

  /* Interactive figures authored with fixed desktop heights */
  #karatsuba-viz {
    height: 300px !important;
  }

  #fft-viz {
    height: 340px !important;
  }

  #karatsuba-phase-label,
  #fft-phase-label {
    font-size: 10px !important;
    top: 8px !important;
  }

  #karatsuba-count-label,
  #fft-info-label {
    font-size: 9px !important;
    bottom: 8px !important;
  }

  .post div[style*="height: 600px"],
  .post div[style*="height:600px"] {
    height: 300px !important;
  }

  .post div[style*="height: 500px"],
  .post div[style*="height:500px"] {
    height: 260px !important;
  }

  .post div[style*="height: 450px"],
  .post div[style*="height:450px"] {
    height: 240px !important;
  }

  .post div[style*="min-height: 650px"],
  .post div[style*="min-height:650px"] {
    min-height: 400px !important;
  }

  .post div[style*="position: absolute"] {
    max-width: 85vw !important;
    font-size: 10px !important;
    padding: 6px !important;
  }

  .post div[style*="min-width: 300px"],
  .post div[style*="min-width:300px"] {
    min-width: 100% !important;
    height: 250px !important;
  }

  .post select {
    max-width: 100% !important;
    font-size: 11px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── Print: ink on paper, no chrome ─────────────────────────────────────── */
@media print {
  :root {
    --bg: #fff;
    --bg-raise: #f4f4f4;
    --bg-sink: #f4f4f4;
    --ink: #000;
    --text: #111;
    --muted: #555;
    --rule: #ccc;
    --rule-strong: #999;
    --blue: #000;
    --blue-soft: #000;
    --warn: #000;
  }

  .masthead nav,
  .site-foot,
  .post-foot,
  .skip-link,
  .postcards {
    display: none;
  }

  .post {
    font-size: 11pt;
  }

  .post pre,
  .post img,
  .post table {
    break-inside: avoid;
  }

  .post h2,
  .post h3 {
    break-after: avoid;
  }
}
