/* ==================================================================
   zhuojiekuang.github.io
   Type: Fraunces (display), Source Serif 4 (text), Inter (UI),
         JetBrains Mono (code / data labels)
   ================================================================== */

:root {
  --paper: #fbf9f4;
  --paper-2: #f3f0e8;
  --paper-3: #ebe6da;
  --ink: #15140f;
  --ink-2: #3d3a33;
  --muted: #7a746a;
  --rule: #e3ded2;
  --rule-strong: #cfc8b8;
  --accent: #c2481a;          /* links, marks, drop caps */
  --accent-ink: #9c3712;
  --accent-wash: #f6e7dd;
  --s1: #2f5fd0;              /* data series 1 (validated vs --paper) */
  --s2: #d0581f;              /* data series 2 */
  --code-bg: #f1ede4;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 8px 28px -12px rgba(40, 30, 10, .18);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --text: 680px;
  --wide: 980px;
  --max: 1240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131210; --paper-2: #1b1a17; --paper-3: #24221e;
    --ink: #ece7dd; --ink-2: #c9c3b6; --muted: #8f897e;
    --rule: #2c2a25; --rule-strong: #3d3a33;
    --accent: #e8875a; --accent-ink: #f0a17b; --accent-wash: #2d1f17;
    --s1: #6b8ce8; --s2: #d96a30;
    --code-bg: #1d1b18;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131210; --paper-2: #1b1a17; --paper-3: #24221e;
  --ink: #ece7dd; --ink-2: #c9c3b6; --muted: #8f897e;
  --rule: #2c2a25; --rule-strong: #3d3a33;
  --accent: #e8875a; --accent-ink: #f0a17b; --accent-wash: #2d1f17;
  --s1: #6b8ce8; --s2: #d96a30;
  --code-bg: #1d1b18;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.66;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent-wash); color: var(--ink); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); }
img, video, canvas, svg { max-width: 100%; }
img, video { height: auto; }

/* ---------- chrome ---------- */

.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 50; pointer-events: none; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-inner {
  max-width: var(--max); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 28px; flex-wrap: wrap;
}
.site-name {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 560; font-size: 1.12rem; letter-spacing: -0.01em;
  color: var(--ink); font-variation-settings: "opsz" 40;
}
.site-name:hover { color: var(--ink); }
.site-name .mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 34% 36%, var(--s2) 0 30%, transparent 32%), radial-gradient(circle at 68% 66%, var(--s1) 0 26%, transparent 28%);
  box-shadow: inset 0 0 0 1px var(--rule-strong);
}
.site-nav { display: flex; align-items: center; gap: 2px; font-family: var(--sans); font-size: 0.82rem; flex-wrap: wrap; }
.site-nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 999px; }
.site-nav a:hover { color: var(--ink); background: var(--paper-2); }
.site-nav a[aria-current] { color: var(--ink); background: var(--paper-3); }
.theme-toggle {
  margin-left: 6px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rule);
  background: transparent; color: var(--ink-2); display: inline-grid; place-items: center; cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }

.site-footer { margin-top: 120px; border-top: 1px solid var(--rule); background: var(--paper-2); }
.footer-inner {
  max-width: var(--max); margin: 0 auto; padding: 36px 20px 44px;
  display: grid; grid-template-columns: 1fr auto; gap: 18px 40px;
  font-family: var(--sans); font-size: 0.84rem; color: var(--muted);
}
.footer-inner p { margin: 0; }
.footer-name { font-family: var(--display); font-size: 1.1rem; color: var(--ink); margin-bottom: 4px !important; }
.footer-links { display: flex; gap: 18px; align-items: start; }
.footer-links a { color: var(--ink-2); }
.footer-links a:hover { color: var(--accent); }
.colophon { grid-column: 1 / -1; font-size: 0.76rem; border-top: 1px dashed var(--rule-strong); padding-top: 14px; }
@media (max-width: 600px) { .footer-inner { grid-template-columns: 1fr; } }

/* ---------- shared type ---------- */

h1, h2, h3, h4 { font-family: var(--display); font-weight: 560; letter-spacing: -0.012em; line-height: 1.16; color: var(--ink); }
h1 { font-variation-settings: "opsz" 144; }
h2 { font-variation-settings: "opsz" 72; }
p, ul, ol, blockquote, table, figure, pre, dl { margin: 0 0 1.15em; }
strong { font-weight: 600; }

.kicker {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500; letter-spacing: 0.02em;
  color: var(--muted); margin: 0 0 18px;
}
.kicker a { color: var(--accent); }
.kicker span { color: var(--muted); }
.dek { font-family: var(--serif); font-size: 1.24rem; line-height: 1.5; color: var(--ink-2); margin: 0 0 28px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--sans); font-size: 0.76rem; font-weight: 500;
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: 4px 11px; color: var(--ink-2);
  background: var(--paper);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.chip {
  display: inline-block; font-family: var(--sans); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 4px; background: var(--paper-3); color: var(--ink-2);
}
.chip.accent { background: var(--accent-wash); color: var(--accent-ink); }

/* ---------- article layout ---------- */

.article { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.article-header { max-width: var(--text); margin: 76px auto 56px; }
.article-header h1 { font-size: clamp(2.3rem, 5.2vw, 3.5rem); max-width: min(880px, calc(100vw - 40px)); width: max-content; margin: 0 0 22px; font-weight: 500; }
@supports not (width: max-content) { .article-header h1 { width: auto; } }
.article-header .authors { font-family: var(--sans); font-size: 0.95rem; color: var(--ink-2); margin: -6px 0 20px; }
.article-header .authors strong { color: var(--ink); }
.article-header .links { margin-top: 22px; }

.byline {
  display: flex; flex-wrap: wrap; gap: 14px 34px; margin: 0;
  padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 0.84rem;
}
.byline div { display: flex; flex-direction: column; gap: 2px; }
.byline dt { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.byline dd { margin: 0; color: var(--ink); }

.article-body { display: grid; grid-template-columns: 1fr minmax(0, var(--text)) 1fr; }
.article-body > .prose { grid-column: 2; grid-row: 1; min-width: 0; }
.toc {
  grid-column: 1; grid-row: 1; justify-self: end; align-self: start;
  position: sticky; top: 92px; width: 190px; margin-right: 72px;
  font-family: var(--sans); font-size: 0.8rem; line-height: 1.4;
}
.toc-title { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); counter-reset: toc; }
.toc li { margin: 0; counter-increment: toc; }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 1.5px solid transparent; color: var(--muted); }
.toc a::before { content: counter(toc, decimal-leading-zero); font-family: var(--mono); font-size: 0.66rem; margin-right: 8px; opacity: .75; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--accent); }
.toc:not(:has(li)) { display: none; }
@media (max-width: 1180px) { .toc { display: none; } }

.article-footer {
  max-width: var(--text); margin: 72px auto 0; padding-top: 20px; border-top: 1px solid var(--rule);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-family: var(--sans); font-size: 0.84rem; color: var(--muted);
}

/* ---------- prose ---------- */

.prose { counter-reset: sec fig sn; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.7rem; margin: 2.3em 0 0.65em; position: relative; font-weight: 540; }
.prose h3 { font-size: 1.26rem; margin: 1.9em 0 0.5em; font-weight: 560; }
.prose h4 { font-family: var(--sans); font-size: 0.95rem; font-weight: 600; margin: 1.6em 0 0.4em; }
.technical .prose h2 { counter-increment: sec; }
.technical .prose h2::before {
  content: counter(sec, decimal-leading-zero);
  position: absolute; left: -62px; top: 0.62em;
  font-family: var(--mono); font-size: 0.74rem; font-weight: 500; letter-spacing: 0.02em; color: var(--accent);
}
@media (max-width: 860px) {
  .technical .prose h2::before { position: static; display: block; margin-bottom: 6px; }
}

.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 0.18em; }
.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li { margin: 0.32em 0; padding-left: 0.2em; }
.prose li::marker { color: var(--muted); }
.prose hr { border: 0; text-align: center; margin: 2.6em 0; }
.prose hr::after { content: "· · ·"; letter-spacing: 0.6em; color: var(--muted); }
.prose blockquote { margin-left: 0; padding: 0.2em 0 0.2em 1.2em; border-left: 2px solid var(--accent); color: var(--ink-2); font-style: italic; }

/* drop cap + small-caps lead-in: first paragraph of technical posts */
.dropcap > p:first-of-type::first-letter {
  font-family: var(--display); font-weight: 600; font-style: normal;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 0;
  float: left; font-size: 5.3em; line-height: 0.8; margin: 0.06em 0.085em -0.04em -0.02em;
  color: var(--accent);
}
.dropcap > p:first-of-type::first-line { font-variant-caps: small-caps; letter-spacing: 0.035em; }

code, kbd, pre { font-family: var(--mono); }
:not(pre) > code { font-size: 0.8em; background: var(--code-bg); padding: 0.12em 0.38em; border-radius: 4px; border: 1px solid var(--rule); }
pre {
  font-size: 0.78rem; line-height: 1.6; background: var(--code-bg); border: 1px solid var(--rule);
  padding: 16px 18px; border-radius: 8px; overflow-x: auto;
}
pre code { background: none; border: 0; padding: 0; }

table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.86rem; display: block; overflow-x: auto; margin: 1.6em 0; }
thead th { border-bottom: 1.5px solid var(--ink); }
th { text-align: left; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 8px 14px 8px 0; }
td { padding: 9px 14px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); }
td.num, th.num { text-align: right; }

/* figures */
figure { margin: 2.4em 0; }
figure img, figure video { display: block; margin: 0 auto; border-radius: 4px; }
.prose > p > img { display: block; margin: 1.2em auto; border-radius: 4px; }
figcaption { font-family: var(--sans); font-size: 0.8rem; line-height: 1.5; color: var(--muted); margin-top: 12px; }
figcaption strong { color: var(--ink-2); font-weight: 600; }
.technical .prose figure:has(figcaption) { counter-increment: fig; }
.technical .prose figcaption::before { content: "Figure " counter(fig) "   "; font-weight: 600; color: var(--ink); white-space: pre; }
figure.wide { width: min(var(--wide), calc(100vw - 40px)); margin-left: 50%; transform: translateX(-50%); }
figure.half { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
figure.half figcaption { grid-column: 1 / -1; }
figure.row { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 10px; align-items: end; }
figure.row figcaption { grid-column: 1 / -1; }
figure.row .cell { text-align: center; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
figure.row .cell img { width: 100%; margin-bottom: 6px; image-rendering: pixelated; }
@media (max-width: 600px) {
  figure.half { grid-template-columns: 1fr; }
  figure.row { --cols: 3 !important; }
}

/* margin notes: <span class="sidenote">…</span> inside a paragraph */
.sn-ref { font-family: var(--sans); font-size: 0.66em; font-weight: 600; color: var(--accent); vertical-align: super; line-height: 0; margin-left: 1px; }
.sidenote {
  float: right; clear: right; width: 230px; margin: 0.3em -290px 1em 0;
  font-family: var(--sans); font-size: 0.78rem; line-height: 1.5; color: var(--ink-2);
  padding-left: 12px; border-left: 1px solid var(--rule-strong);
}
.sidenote .sn-num { font-weight: 600; color: var(--accent); margin-right: 4px; }
@media (max-width: 1180px) {
  .sidenote { float: none; display: block; width: auto; margin: 0.8em 0 0.8em 0.2em; background: var(--paper-2); border-left: 2px solid var(--accent); padding: 8px 12px; border-radius: 0 6px 6px 0; }
}

.callout, .tldr {
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px;
  padding: 18px 22px; margin: 0 0 2.2em; font-size: 0.98rem; color: var(--ink-2);
}
.tldr { border-left: 3px solid var(--accent); }
.callout > :last-child, .tldr > :last-child { margin-bottom: 0; }

.footnotes { font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); border-top: 1px solid var(--rule); margin-top: 3em; padding-top: 1em; }

mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: 1.2em 0 !important; }

/* ---------- interactive figures ---------- */

.demo {
  width: min(var(--wide), calc(100vw - 40px)); margin: 2.8em 0 2.8em 50%; transform: translateX(-50%);
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: 14px; padding: 18px 20px 16px;
  box-shadow: var(--shadow);
}
.demo.narrow { width: min(760px, calc(100vw - 40px)); }
.demo-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap;
  font-family: var(--sans); margin-bottom: 14px;
}
.demo-head .demo-title { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.demo-head .demo-tag {
  font-size: 0.64rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
}
.demo-head .demo-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.demo-panel { min-width: 0; }
.demo .label { display: block; font-family: var(--sans); font-size: 0.74rem; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.demo canvas { width: 100%; aspect-ratio: 1 / 1; display: block; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; touch-action: none; }
.demo svg { display: block; width: 100%; height: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; }
.demo-controls { display: flex; flex-wrap: wrap; gap: 12px 26px; align-items: center; margin-top: 14px; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-2); }
.demo-controls label { display: inline-flex; gap: 10px; align-items: center; }
.demo-controls .val { font-family: var(--mono); font-size: 0.76rem; color: var(--ink); min-width: 3.2em; }
.demo button {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.demo button.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.demo button:hover { opacity: .88; }
.demo .demo-note { font-family: var(--sans); font-size: 0.8rem; line-height: 1.5; color: var(--muted); margin: 12px 0 0; }
.demo .readout { font-family: var(--sans); font-size: 0.84rem; color: var(--ink); margin: 12px 0 0; min-height: 1.3em; }
.demo .key { display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-2); }
.demo .key i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.demo .legend { margin: 0 0 8px; }
@media (max-width: 640px) { .demo-grid { grid-template-columns: 1fr; } .demo { padding: 14px; } }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 150px; height: 18px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: var(--rule-strong); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--rule-strong); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px; border-radius: 50%; background: var(--paper); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--paper); border: 2px solid var(--accent); }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; transform: translate(-50%, calc(-100% - 10px));
  background: var(--ink); color: var(--paper); font-family: var(--sans); font-size: 0.74rem; line-height: 1.35;
  padding: 6px 9px; border-radius: 6px; white-space: nowrap; opacity: 0; transition: opacity .1s;
}

/* ---------- pages ---------- */

.page { max-width: calc(var(--text) + 40px); margin: 0 auto; padding: 0 20px; }
.page-wide { max-width: calc(var(--wide) + 40px); }
.page-header { max-width: var(--text); margin: 76px 0 52px; }
.page-header h1 { font-size: clamp(2.4rem, 5.4vw, 3.6rem); font-weight: 500; margin: 0 0 18px; }
.page-body .inline-link, .page-body p a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 0.18em; }

.group-label {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--sans); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  margin: 56px 0 18px;
}
.group-label::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.group-label:first-child { margin-top: 0; }
.group-note { font-family: var(--sans); font-size: 0.86rem; color: var(--muted); margin: -6px 0 22px; }

/* research entries */
.entries { display: grid; gap: 8px; }
.entry {
  display: grid; grid-template-columns: 220px 1fr; gap: 26px; align-items: start;
  padding: 16px; margin: 0 -16px; border-radius: 14px; transition: background .15s;
}
.entry:hover { background: var(--paper-2); }
.entry-thumb {
  display: block; position: relative; aspect-ratio: 16 / 10; background: #fff; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.entry:hover .entry-thumb { transform: translateY(-2px); box-shadow: var(--shadow); }
.entry-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.thumb-text {
  display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; text-align: center; padding: 10px;
  font-family: var(--mono); font-size: 0.9rem; color: var(--accent-ink);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--accent) 26%, transparent) 1px, transparent 1.5px) 0 0 / 12px 12px,
    var(--accent-wash);
}
.entry-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.entry-meta .venue { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }
.entry h3 { margin: 0 0 6px; font-size: 1.22rem; line-height: 1.25; font-weight: 540; }
.entry h3 a { color: var(--ink); }
.entry h3 a:hover { color: var(--accent); }
.entry .authors { font-family: var(--sans); font-size: 0.84rem; color: var(--muted); margin: 0 0 8px; }
.entry .authors strong { color: var(--ink); font-weight: 600; }
.entry p.blurb { font-size: 0.96rem; color: var(--ink-2); margin: 0 0 12px; line-height: 1.55; }
@media (max-width: 680px) {
  .entry { grid-template-columns: 1fr; gap: 14px; }
  .entry-thumb { max-width: 360px; }
  .entry-thumb:has(.thumb-text) { display: none; }
}

/* post lists (archive) */
.year-group { display: grid; grid-template-columns: 120px 1fr; gap: 0 24px; padding: 4px 0 18px; border-top: 1px solid var(--rule); }
.year-group > h3 { margin: 16px 0 0; font-size: 1.5rem; font-weight: 380; color: var(--muted); font-variation-settings: "opsz" 144; }
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { margin: 0; padding: 14px 0; border-bottom: 1px dashed var(--rule); display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; align-items: baseline; }
.post-list li:last-child { border-bottom: 0; }
.post-list a.title { color: var(--ink); font-family: var(--display); font-size: 1.14rem; font-weight: 520; line-height: 1.3; text-decoration: none; }
.post-list a.title:hover { color: var(--accent); }
.post-list time { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.post-list .desc { grid-column: 1 / -1; font-size: 0.92rem; color: var(--ink-2); line-height: 1.5; }
.post-list .badge { font-family: var(--sans); font-size: 0.64rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); margin-left: 8px; vertical-align: middle; }
@media (max-width: 600px) { .year-group { grid-template-columns: 1fr; } }

/* writing cards (home) */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.card {
  display: flex; flex-direction: column; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; background: var(--paper);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--rule-strong); color: var(--ink); }
.card-img { position: relative; aspect-ratio: 16 / 9; background: #fff; border-bottom: 1px solid var(--rule); overflow: hidden; }
.card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-img img.contain { object-fit: contain; padding: 10px; }
.card-img img.pixel { image-rendering: pixelated; object-fit: contain; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { font-family: var(--sans); font-size: 0.74rem; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 1.2rem; line-height: 1.25; font-weight: 540; }
.card p { margin: 0; font-size: 0.9rem; color: var(--ink-2); line-height: 1.5; }
.card .demo-flag { font-family: var(--sans); font-size: 0.64rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }

/* ---------- home ---------- */

.home { max-width: calc(var(--wide) + 40px); margin: 0 auto; padding: 0 20px; }
.hero { margin: 40px 0 0; position: relative; }
.hero canvas { display: block; width: 100%; height: clamp(110px, 19vw, 210px); cursor: pointer; }
.hero h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hero-caption {
  display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap;
  font-family: var(--sans); font-size: 0.76rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 8px;
}
.hero-caption button { all: unset; cursor: pointer; color: var(--accent); font-weight: 500; }
.hero-caption button:hover { text-decoration: underline; }
.hero-caption button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.hero-controls { display: inline-flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.shape-toggle { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--rule); }
.shape-toggle button { color: var(--ink-2); font-weight: 500; padding: 3px 11px; border-radius: 999px; }
.shape-toggle button:hover { text-decoration: none; color: var(--ink); }
.shape-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.intro { display: grid; grid-template-columns: 1fr 240px; gap: 60px; margin-top: 48px; }
.intro p { font-size: 1.1rem; color: var(--ink-2); line-height: 1.62; }
.intro p.lead { font-size: 1.32rem; color: var(--ink); line-height: 1.48; }
.intro p a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: .18em; color: var(--ink); }
.intro p a:hover { color: var(--accent); }
.seeking {
  font-family: var(--sans); font-size: 0.92rem; line-height: 1.5; color: var(--ink);
  background: var(--accent-wash); border-radius: 10px; padding: 14px 16px; margin-top: 8px;
}
.seeking strong { color: var(--accent-ink); }
.seeking a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: .18em; }
.spec { font-family: var(--sans); font-size: 0.82rem; }
.spec img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; margin-bottom: 18px; display: block; }
.spec dl { margin: 0; display: grid; gap: 12px; }
.spec dt { font-size: 0.64rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.spec dd { margin: 2px 0 0; color: var(--ink); line-height: 1.4; }
.spec dd a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: .18em; }
.spec dd a:hover { color: var(--accent); }
@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; gap: 28px; }
  .spec { display: grid; grid-template-columns: 110px 1fr; gap: 18px; align-items: start; }
  .spec img { margin: 0; }
}

.section { margin-top: 100px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 26px; gap: 16px; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 2rem; font-weight: 460; }
.section-head h2 em { font-style: italic; font-weight: 360; color: var(--muted); }
.section-head a { font-family: var(--sans); font-size: 0.84rem; color: var(--ink-2); white-space: nowrap; }
.section-head a:hover { color: var(--accent); }

/* projects page */
.projects h2 { font-size: 1.7rem; font-weight: 480; margin: 2.4em 0 1em; padding-top: 18px; border-top: 1px solid var(--rule); }
.projects > h2:first-child { margin-top: 0; }
.project { margin: 0 0 2.2em; }
.project h3 { margin: 0 0 6px; font-size: 1.2rem; font-weight: 540; }
.project .plinks { font-family: var(--sans); font-size: 0.78rem; font-weight: 500; margin-left: 10px; white-space: nowrap; }
.project ul { font-size: 0.97rem; color: var(--ink-2); margin-bottom: 0.6em; padding-left: 1.2em; }
.project img, .project video { display: block; margin: 14px 0 0; border-radius: 8px; border: 1px solid var(--rule); }
.compact { columns: 2; column-gap: 36px; font-size: 0.94rem; padding-left: 1.1em; color: var(--ink-2); }
.compact li { break-inside: avoid; margin: 0 0 .5em; }
@media (max-width: 600px) { .compact { columns: 1; } }

/* courses */
table.courses { display: table; font-size: 0.92rem; }
table.courses td:first-child { font-family: var(--serif); font-size: 1rem; }
table.courses td:first-child a { color: var(--ink); text-decoration: none; }
table.courses td:first-child a:hover { color: var(--accent); }
table.courses td.group { font-family: var(--sans); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding-top: 28px; border-bottom: 1.5px solid var(--ink); }
.meter { display: inline-flex; gap: 3px; vertical-align: middle; }
.meter i { width: 9px; height: 9px; border-radius: 2px; background: var(--rule); }
.meter i.on { background: var(--ink-2); }
.meter i.half { background: linear-gradient(90deg, var(--ink-2) 50%, var(--rule) 50%); }
.meter.fun i.on { background: var(--accent); }
.meter.fun i.half { background: linear-gradient(90deg, var(--accent) 50%, var(--rule) 50%); }

/* ---------- syntax (rouge) ---------- */
.highlight .c, .highlight .c1, .highlight .cm { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc, .highlight .ow { color: var(--accent); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sd { color: #4f7a3a; }
.highlight .mi, .highlight .mf, .highlight .m { color: var(--s1); }
.highlight .nf, .highlight .fm { color: var(--ink); font-weight: 500; }
.highlight .nb, .highlight .bp { color: #2f6f8f; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* raster figures are mostly white-background plots: soften them in dark mode */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prose img, :root:not([data-theme="light"]) .card-img img, :root:not([data-theme="light"]) .entry-thumb img { filter: brightness(.88) contrast(1.02); } }
:root[data-theme="dark"] .prose img, :root[data-theme="dark"] .card-img img, :root[data-theme="dark"] .entry-thumb img { filter: brightness(.88) contrast(1.02); }
.section-head + .year-group { border-top: 0; }
