/* ==========================================================================
   ojus1.github.io — one system
   Paper ground, warm ink, one vermilion accent. Newsreader for reading,
   Geist Mono for labels, code and data. Hairlines, not boxes.
   ========================================================================== */

@font-face { font-family: "Newsreader"; src: url(/assets/fonts/newsreader-opsz.woff2) format("woff2-variations"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Newsreader"; src: url(/assets/fonts/newsreader-opsz-italic.woff2) format("woff2-variations"); font-weight: 200 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(/assets/fonts/geist-mono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url(/assets/fonts/geist-mono-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #fbf6ec;
  --bg-alt: #f2eadc;
  --surface: #fffbf4;
  --ink: #2b2016;
  --ink-2: #4a3d31;
  --muted: #786a5c;
  --rule: rgb(43 32 22 / 0.13);
  --rule-strong: rgb(43 32 22 / 0.3);
  --accent: #c43d16;
  --accent-ink: #a83312;
  --accent-soft: rgb(196 61 22 / 0.1);
  --logo-sun: #e08a2b;
  --on-accent: #fff8f3;
  --series-1: #c43d16;
  --series-2: #2f6f8f;
  --series-3: #6e7f3a;
  --series-4: #a8741a;
  --series-5: #7a6a5c;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --t-hero: clamp(2.5rem, 1.4rem + 3.6vw, 4.5rem);
  --t-h1: clamp(2.25rem, 1.5rem + 2.6vw, 3.75rem);
  --t-h2: clamp(1.625rem, 1.3rem + 1vw, 2.125rem);
  --t-h3: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --t-lead: clamp(1.1875rem, 1.1rem + 0.35vw, 1.375rem);
  --t-body: 1.1875rem;   /* 19px serif reads like 16-17px sans */
  --t-small: 1rem;
  --t-label: 0.8125rem;  /* 13px mono */

  --wrap: 1240px;
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 2.5rem);
  --measure: 40rem;
  --r-sm: 4px;
  --r-md: 8px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --m-in: 150ms;
  --m-out: 120ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0a;
    --bg-alt: #161614;
    --surface: #111110;
    --ink: #f1eee8;
    --ink-2: #cfcabf;
    --muted: #9b968b;
    --rule: rgb(235 231 222 / 0.12);
    --rule-strong: rgb(235 231 222 / 0.26);
    --accent: #ff6a2b;
    --accent-ink: #ff8550;
    --accent-soft: rgb(255 106 43 / 0.13);
    --logo-sun: #f0993a;
    --on-accent: #1a0d07;
    --series-1: #ff6a2b;
    --series-2: #6fb3d2;
    --series-3: #a9bd6a;
    --series-4: #e2b250;
    --series-5: #b3a596;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0a;
  --bg-alt: #161614;
  --surface: #111110;
  --ink: #f1eee8;
  --ink-2: #cfcabf;
  --muted: #9b968b;
  --rule: rgb(235 231 222 / 0.12);
  --rule-strong: rgb(235 231 222 / 0.26);
  --accent: #ff6a2b;
  --accent-ink: #ff8550;
  --accent-soft: rgb(255 106 43 / 0.13);
  --logo-sun: #f0993a;
  --on-accent: #1a0d07;
  --series-1: #ff6a2b;
  --series-2: #6fb3d2;
  --series-3: #a9bd6a;
  --series-4: #e2b250;
  --series-5: #b3a596;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body)/1.6 var(--serif);
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video, canvas { display: block; max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3, h4 { font-weight: 450; letter-spacing: -0.02em; line-height: 1.12; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
button { font: inherit; color: inherit; }

.skip { position: absolute; left: var(--gutter); top: -100px; z-index: 100; background: var(--ink); color: var(--bg); padding: .6rem 1rem; font: 500 var(--t-label) var(--mono); border-radius: var(--r-sm); text-decoration: none; }
.skip:focus { top: .75rem; }

/* labels: mono, sentence case, never tracked caps */
.kicker, .byline dt, .section__note, .index__n, .index__meta, .toc__title, .code__bar, .field__bar, .fig__label, .pager__dir, .facts dt, .colophon, .nav, .widget__bar, .stat__k {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
}

/* ---------- links & buttons ---------- */
a { color: inherit; }
.prose a:not(.fn-ref a):not(.footnote-backref), .link {
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat,
              linear-gradient(var(--rule-strong), var(--rule-strong)) 0 100% / 100% 1px no-repeat;
  transition: background-size var(--m-out) var(--ease), color var(--m-out) var(--ease);
  padding-bottom: 1px;
}
.prose a:not(.fn-ref a):not(.footnote-backref):hover, .link:hover { background-size: 100% 1px, 100% 1px; color: var(--accent-ink); transition-duration: var(--m-in); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 44px; padding: 0 1.25rem;
  background: var(--ink); color: var(--bg);
  font: 500 .875rem/1 var(--mono);
  text-decoration: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
  transition: transform var(--m-out) var(--ease), background-color var(--m-out) var(--ease);
}
.btn::after { content: ""; width: 12px; height: 1px; background: currentColor; box-shadow: 0 0 0 0 currentColor; transition: transform var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-1px); background: color-mix(in oklab, var(--ink) 86%, var(--accent)); transition-duration: var(--m-in); }
  .btn:hover::after { transform: translateX(3px); }
}
.btn:active { transform: translateY(1px) scale(.985); transition-duration: 90ms; }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.btn--ghost::after { display: none; }
@media (hover: hover) and (pointer: fine) { .btn--ghost:hover { background: var(--bg-alt); } }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- masthead ---------- */
.masthead { position: sticky; top: 0; z-index: 20; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--rule); }
.masthead__inner { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { display: inline-flex; align-items: center; gap: .625rem; text-decoration: none; font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; min-height: 44px; }
.wordmark__mark { width: 38px; height: auto; aspect-ratio: 300 / 216; flex: none; color: var(--ink); }
.nav { display: flex; align-items: center; gap: .25rem; color: var(--muted); }
.nav a { position: relative; text-decoration: none; padding: 0 .625rem; min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); transition: color var(--m-out) var(--ease); }
.nav a::after { content: ""; position: absolute; left: .625rem; right: .625rem; bottom: 10px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform var(--m-out) var(--ease); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav a:hover::after { transform: scaleX(1); transition-duration: var(--m-in); }
.nav a[aria-current="page"]::after { transform: scaleX(1); height: 2px; background: var(--accent); }
.theme-toggle { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--muted); border-radius: var(--r-sm); transition: color var(--m-out) var(--ease), transform var(--m-out) var(--ease); }
.theme-toggle:hover { color: var(--ink); }
.theme-toggle svg { transition: transform 300ms var(--ease); }
:root[data-theme="dark"] .theme-toggle svg { transform: rotate(180deg); }
@media (max-width: 560px) { .nav a[href^="https://github"] { display: none; } .wordmark { font-size: 1rem; } }

/* ---------- shared layout ---------- */
.section, .hero, .missing, .post__head, .pager, .colophon__inner { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.measure { max-width: var(--measure); }

.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; color: var(--muted); margin-bottom: 1.5rem; }
.kicker__tag { color: var(--accent-ink); display: inline-flex; align-items: center; gap: .5rem; }
.kicker__tag::before { content: ""; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

/* ---------- home: hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); align-items: center; min-height: min(calc(100svh - 60px), 820px); padding-block: clamp(3rem, 8vh, 6rem); }
.hero__title { font-size: var(--t-hero); font-weight: 400; letter-spacing: -0.035em; line-height: 1.02; max-width: 13ch; font-variation-settings: "opsz" 72; }
.hero__lead { font-size: var(--t-lead); color: var(--ink-2); max-width: 34rem; margin-top: 1.75rem; line-height: 1.5; }
.hero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; margin-top: 2.25rem; font-family: var(--mono); font-size: .875rem; }
.hero__actions .link { min-height: 44px; display: inline-flex; align-items: center; background-position: 0 calc(100% - 12px), 0 calc(100% - 12px); }
.hero__field { margin: 0; position: relative; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); overflow: hidden; aspect-ratio: 4 / 3.4; }
.field { width: 100%; height: calc(100% - 41px); }
.field__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 41px; display: flex; justify-content: space-between; align-items: center; padding: 0 .5rem 0 1rem; border-top: 1px solid var(--rule); color: var(--muted); background: var(--surface); }
.field__label::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: .5rem; vertical-align: 1px; animation: blink 2.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.field__pause, .widget__btn { font: 400 var(--t-label) var(--mono); background: none; border: 1px solid var(--rule); border-radius: var(--r-sm); color: var(--ink-2); padding: 0 .75rem; height: 30px; cursor: pointer; transition: background-color var(--m-out) var(--ease), border-color var(--m-out) var(--ease); }
.field__pause:hover, .widget__btn:hover { background: var(--bg-alt); border-color: var(--rule-strong); }
.field__pause::before { content: ""; position: absolute; inset: -7px 0; }
.field__pause { position: relative; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding-block: 3rem 3.5rem; gap: 2.5rem; }
  .hero__title { max-width: 16ch; }
  .hero__field { aspect-ratio: 4 / 3; }
}

/* hero entrance: once, on load */
@media (prefers-reduced-motion: no-preference) {
  [data-enter] .hero__text > * { animation: rise 700ms var(--ease-enter) both; }
  [data-enter] .hero__text > :nth-child(2) { animation-delay: 60ms; }
  [data-enter] .hero__text > :nth-child(3) { animation-delay: 160ms; }
  [data-enter] .hero__text > :nth-child(4) { animation-delay: 220ms; }
  [data-enter] .hero__field { animation: settle 900ms var(--ease-enter) both 80ms; }
  .post__head > * { animation: rise 600ms var(--ease-enter) both; }
  .post__head > :nth-child(2) { animation-delay: 50ms; }
  .post__head > :nth-child(3) { animation-delay: 110ms; }
  .post__head > :nth-child(4) { animation-delay: 160ms; }
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes settle { from { opacity: 0; transform: scale(.98); } }

/* ---------- home: sections ---------- */
.section { padding-block: clamp(3.5rem, 9vh, 6.5rem); background: linear-gradient(var(--rule), var(--rule)) var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px no-repeat; }
.section__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 2rem; }
.section__title { font-size: var(--t-h2); }
.section__note { color: var(--muted); }

.index { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-strong); }
.index__row { border-bottom: 1px solid var(--rule); }
.index__link { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) 12rem; gap: 1.5rem; align-items: baseline; padding: 1.75rem 0; text-decoration: none; position: relative; }
.index__n { color: var(--muted); font-variant-numeric: tabular-nums; transition: color var(--m-out) var(--ease); }
.index__body { display: grid; gap: .5rem; }
.index__title { font-size: var(--t-h3); letter-spacing: -0.015em; line-height: 1.2; font-weight: 450; }
.index__title { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 200ms var(--ease); width: fit-content; }
.index__sum { color: var(--ink-2); font-size: 1.0625rem; max-width: 38rem; line-height: 1.5; }
.index__meta { display: grid; gap: .25rem; color: var(--muted); text-align: right; justify-items: end; }
@media (hover: hover) and (pointer: fine) {
  .index__link:hover .index__title { background-size: 100% 1px; }
  .index__link:hover .index__n { color: var(--accent-ink); }
}
@media (max-width: 760px) {
  .index__link { grid-template-columns: 1fr; gap: .625rem; padding: 1.5rem 0; }
  .index__n { display: none; }
  .index__meta { grid-row: 1; text-align: left; justify-items: start; grid-auto-flow: column; justify-content: start; gap: 1rem; }
}

.about__grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(2rem, 6vw, 6rem); }
.about__text p + p { margin-top: 1.1em; }
.facts { margin: 0; display: grid; gap: 0; border-top: 1px solid var(--rule-strong); }
.facts > div { display: grid; grid-template-columns: 5rem 1fr; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.facts dt { color: var(--muted); padding-top: .25rem; }
.facts dd { margin: 0; font-size: var(--t-small); line-height: 1.5; }
@media (max-width: 760px) { .about__grid { grid-template-columns: 1fr; } }

/* ---------- footer ---------- */
.colophon { border-top: 1px solid var(--rule); margin-top: 0; color: var(--muted); }
.colophon__inner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; min-height: 88px; }
.colophon nav { display: flex; gap: .25rem; }
.colophon a { text-decoration: none; padding: 0 .625rem; min-height: 44px; display: inline-flex; align-items: center; transition: color var(--m-out) var(--ease); }
.colophon a:hover { color: var(--ink); }

/* ---------- 404 ---------- */
.missing { min-height: calc(100svh - 60px - 89px); display: flex; flex-direction: column; justify-content: center; gap: 1.5rem; padding-block: 4rem; }
.missing .kicker { margin: 0; }
.missing__title { font-size: var(--t-h1); }
.missing__lead { color: var(--ink-2); max-width: 32rem; }

/* ==========================================================================
   Post
   ========================================================================== */
.post__head { padding-block: clamp(3rem, 9vh, 6rem) 2.5rem; }
.post__title { font-size: var(--t-h1); font-weight: 400; letter-spacing: -0.03em; line-height: 1.04; max-width: 20ch; font-variation-settings: "opsz" 72; }
.post__dek { font-size: var(--t-lead); color: var(--ink-2); max-width: 40rem; margin-top: 1.25rem; line-height: 1.45; font-style: italic; }
.byline { display: flex; flex-wrap: wrap; gap: 0; margin: 2.5rem 0 0; border-top: 1px solid var(--rule-strong); }
.byline > div { padding: .875rem 2.5rem .875rem 0; margin-right: 2.5rem; border-right: 1px solid var(--rule); }
.byline > div:last-child { border-right: 0; }
.byline dt { color: var(--muted); margin-bottom: .2rem; }
.byline dd { margin: 0; font-size: var(--t-small); }
@media (max-width: 640px) { .byline > div { border-right: 0; padding-right: 0; margin-right: 1.75rem; } }

/* three-column reading grid: contents | text | margin notes */
.post__grid {
  --col-l: 13rem; --col-r: 15rem; --gap: clamp(2rem, 3.5vw, 3.5rem);
  max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: var(--col-l) minmax(0, var(--measure)) var(--col-r);
  column-gap: var(--gap);
  justify-content: center;
  background: linear-gradient(var(--rule), var(--rule)) var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px no-repeat;
  padding-top: 3rem;
}
.toc { grid-column: 1; }
.prose { grid-column: 2; position: relative; min-width: 0; }

.toc__details { position: sticky; top: 5.5rem; }
.toc__title { color: var(--muted); list-style: none; cursor: pointer; margin-bottom: .75rem; }
.toc__title::-webkit-details-marker { display: none; }
.toc__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .125rem; font-size: .9375rem; line-height: 1.35; }
.toc__item a { display: grid; grid-template-columns: 1.75rem 1fr; padding: .3rem 0; color: var(--muted); text-decoration: none; transition: color var(--m-out) var(--ease); }
.toc__item--h3 a { padding-left: 1.75rem; grid-template-columns: 1fr; font-size: .875rem; }
.toc__n { font-family: var(--mono); font-size: .75rem; padding-top: .15rem; }
.toc__item a:hover { color: var(--ink); }
.toc__item a.is-current { color: var(--ink); }
.toc__item a.is-current .toc__n { color: var(--accent-ink); }

@media (max-width: 1240px) {
  .post__grid { grid-template-columns: minmax(0, var(--measure)) var(--col-r); justify-content: center; }
  .toc { grid-column: 1; grid-row: 1; margin-bottom: 2.5rem; }
  .prose { grid-column: 1; grid-row: 2; }
  .toc__details { position: static; border: 1px solid var(--rule); border-radius: var(--r-md); padding: .875rem 1.125rem; }
  .toc__details:not([open]) .toc__title { margin: 0; }
  .toc__title::after { content: " +"; }
  .toc__details[open] .toc__title::after { content: " −"; }
}
@media (max-width: 1000px) {
  .post__grid { grid-template-columns: minmax(0, var(--measure)); }
}

/* prose rhythm */
.prose > * + * { margin-top: 1.25em; }
.prose h2 { font-size: var(--t-h2); margin-top: 2.6em; scroll-margin-top: 5rem; }
.prose h3 { font-size: var(--t-h3); margin-top: 2em; scroll-margin-top: 5rem; }
.prose h2 + *, .prose h3 + * { margin-top: .75em; }
.prose h2 .header-anchor, .prose h3 .header-anchor { text-decoration: none; }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--muted); font-family: var(--mono); font-size: .85em; }
.prose blockquote { margin-inline: 0; padding-left: 1.25rem; border-left: 2px solid var(--accent); color: var(--ink-2); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 3rem; }
.prose :not(pre) > code { font-family: var(--mono); font-size: .8em; background: var(--bg-alt); padding: .12em .35em; border-radius: 3px; border: 1px solid var(--rule); }
.prose .lede::first-letter { float: left; font-size: 4.1em; line-height: .82; padding: .07em .1em 0 0; font-weight: 400; font-variation-settings: "opsz" 72; color: var(--ink); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.prose th { font: 400 var(--t-label) var(--mono); color: var(--muted); text-align: left; padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--rule-strong); }
.prose td { padding: .6rem .75rem .6rem 0; border-bottom: 1px solid var(--rule); }
.prose td.num, .prose th.num { text-align: right; }

/* breakout widths for figures */
.fig.wide { margin-right: calc(-1 * (var(--col-r, 0px) + var(--gap, 0px))); }
@media (max-width: 1000px) { .fig.wide { margin-right: 0; } }

/* math */
.katex { font-size: 1.04em; }
.katex-display { margin: 1.75em 0; overflow-x: auto; overflow-y: hidden; padding: .25em 0; }
.katex-display > .katex { font-size: 1.12em; }

/* margin notes */
.fn-ref { font: 500 .66em var(--mono); line-height: 0; vertical-align: super; }
.fn-ref a { text-decoration: none; color: var(--accent-ink); padding: 0 .1em; }
.sidenote { position: absolute; left: calc(100% + var(--gap)); width: var(--col-r); font-size: .875rem; line-height: 1.5; color: var(--muted); }
.sidenote__n { font: 500 .75rem var(--mono); color: var(--accent-ink); margin-right: .35rem; }
.sidenote p { display: inline; }
.has-sidenotes .footnotes { display: none; }
.footnotes { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: var(--t-small); color: var(--ink-2); }
.footnotes__title { font: 400 var(--t-label) var(--mono); color: var(--muted); letter-spacing: 0; margin-bottom: 1rem; }
.footnotes__list { padding-left: 1.25rem; }
.footnotes__list li + li { margin-top: .6rem; }
.footnote-backref { text-decoration: none; color: var(--muted); font-family: var(--mono); }

/* code */
.code { margin: 1.75em 0; border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.code__bar { display: flex; justify-content: space-between; align-items: center; padding: 0 .375rem 0 1rem; height: 40px; border-bottom: 1px solid var(--rule); color: var(--muted); }
.code__name::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 1px; background: var(--rule-strong); margin-right: .625rem; vertical-align: 1px; }
.code__copy { font: 400 var(--t-label) var(--mono); color: var(--muted); background: none; border: 0; border-radius: var(--r-sm); height: 32px; padding: 0 .625rem; cursor: pointer; position: relative; transition: color var(--m-out) var(--ease), background-color var(--m-out) var(--ease); }
.code__copy::before { content: ""; position: absolute; inset: -6px 0; }
.code__copy:hover { color: var(--ink); background: var(--bg-alt); }
.code__copy.is-done { color: var(--accent-ink); }
.code pre.shiki { margin: 0; padding: 1rem 1.125rem 1.125rem; overflow-x: auto; font: 400 .8125rem/1.7 var(--mono); background: transparent !important; tab-size: 2; }
.code pre.shiki code { font: inherit; }
.shiki span { color: var(--shiki-light); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); } }
:root[data-theme="dark"] .shiki span { color: var(--shiki-dark); }

/* figures & widgets */
.fig { margin: 2.25em 0; }
.fig__frame { border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.fig__cap { margin-top: .875rem; font-size: .9375rem; line-height: 1.5; color: var(--muted); max-width: var(--measure); }
.fig__label { color: var(--ink); margin-right: .5rem; }
.widget__bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding: .625rem 1rem; border-bottom: 1px solid var(--rule); color: var(--muted); min-height: 52px; }
.widget__bar--foot { border-bottom: 0; border-top: 1px solid var(--rule); }
.widget__body { padding: 1rem; }
.widget__spacer { flex: 1; }

.ctrl { display: inline-flex; align-items: center; gap: .625rem; }
.ctrl output { color: var(--ink); min-width: 3ch; font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 140px; height: 28px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(var(--accent), var(--accent)) 0 / var(--p, 50%) 100% no-repeat, var(--rule-strong); border-radius: 1px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--rule-strong); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); transition: transform var(--m-out) var(--ease); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--ink); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

.chips { display: inline-flex; flex-wrap: wrap; gap: .375rem; }
.chip { font: 400 var(--t-label) var(--mono); display: inline-flex; align-items: center; gap: .4rem; height: 30px; padding: 0 .625rem; border: 1px solid var(--rule); border-radius: 999px; background: none; color: var(--ink-2); cursor: pointer; transition: opacity var(--m-out) var(--ease), border-color var(--m-out) var(--ease), background-color var(--m-out) var(--ease); position: relative; }
.chip::after { content: ""; position: absolute; inset: -7px -2px; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip:hover { border-color: var(--rule-strong); }
.chip[aria-pressed="false"] { opacity: .45; }
.chip[aria-pressed="true"].chip--solo { background: var(--bg-alt); border-color: var(--rule-strong); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); border-top: 1px solid var(--rule); }
.stat { padding: .875rem 1rem; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: 0; }
.stat__k { color: var(--muted); display: block; }
.stat__v { font: 400 1.5rem/1.2 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* charts (d3) */
.chart { position: relative; width: 100%; }
.chart svg { overflow: visible; width: 100%; height: auto; }
.chart .axis text { font: 400 11px var(--mono); fill: var(--muted); }
.chart .axis path, .chart .axis line { stroke: var(--rule-strong); }
.chart .grid line { stroke: var(--rule); }
.chart .grid path { display: none; }
.chart .axis-label { font: 400 11px var(--mono); fill: var(--muted); }
.chart .series { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; transition: opacity 200ms var(--ease); }
.chart .series.is-dim { opacity: .14; }
.chart .crosshair { stroke: var(--rule-strong); stroke-dasharray: 2 3; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: var(--bg); font: 400 12px/1.5 var(--mono); padding: .5rem .625rem; border-radius: var(--r-sm); white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); opacity: 0; transition: opacity 120ms var(--ease); }
.tip.is-on { opacity: 1; }
.tip b { font-weight: 500; }
.tip i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .4rem; background: var(--c); }

/* LLM widget */
.chat { display: flex; flex-direction: column; min-height: 420px; }
.chat__log { flex: 1; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; max-height: 460px; overflow-y: auto; font-size: 1.0625rem; line-height: 1.55; }
.chat__msg { max-width: 92%; }
.chat__msg--user { align-self: flex-end; background: var(--bg-alt); border: 1px solid var(--rule); padding: .5rem .875rem; border-radius: 12px 12px 3px 12px; }
.chat__msg--bot { align-self: flex-start; white-space: pre-wrap; }
.chat__msg--bot.is-streaming::after { content: ""; display: inline-block; width: .5em; height: 1em; background: var(--accent); margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
.chat__msg--sys { align-self: stretch; color: var(--muted); font: 400 var(--t-label)/1.6 var(--mono); border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: .875rem 1rem; }
.chat__form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--rule); }
.chat__input { flex: 1; min-width: 0; min-height: 44px; padding: 0 .875rem; font: 400 1rem var(--serif); color: var(--ink); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease); }
.chat__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { font: 400 var(--t-label) var(--mono); color: var(--ink); background: var(--bg); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); height: 36px; padding: 0 .5rem; max-width: 100%; }
.progress { height: 2px; background: var(--rule); position: relative; overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); transition: width 200ms linear; }
.dot-status { display: inline-flex; align-items: center; gap: .5rem; }
.dot-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot-status[data-state="ready"]::before { background: #3c9a5f; }
.dot-status[data-state="busy"]::before { background: var(--accent); animation: blink 1s steps(1) infinite; }
.dot-status[data-state="error"]::before { background: #c0392b; }

/* attention animation & video */
.attn { width: 100%; height: auto; touch-action: pan-y; }
.video { width: 100%; height: auto; background: #0e0e0c; aspect-ratio: 16 / 9; }

/* matrix diagram */
.mat-svg text { font: 400 11px var(--mono); fill: var(--muted); }
.mat-svg .m-w { fill: var(--bg-alt); stroke: var(--rule-strong); }
.mat-svg .m-a, .mat-svg .m-b { fill: var(--accent-soft); stroke: var(--accent); }
.mat-svg rect { transition: width 200ms var(--ease), height 200ms var(--ease), x 200ms var(--ease); }

/* cite + pager */
.cite { margin-top: 4.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.prose .cite__title { font-size: var(--t-label); margin-top: 0; }
.cite__title { font: 400 var(--t-label) var(--mono); color: var(--muted); letter-spacing: 0; }
.cite .code { margin-top: 1rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); padding-block: 0 5rem; margin-top: 4rem; }
.pager__link { display: grid; gap: .5rem; text-decoration: none; padding: 1.25rem 0; border-top: 1px solid var(--rule-strong); }
.pager__link--next { text-align: right; }
.pager__dir { color: var(--muted); }
.pager__title { font-size: var(--t-h3); letter-spacing: -0.015em; line-height: 1.2; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 200ms var(--ease); justify-self: start; }
.pager__link--next .pager__title { justify-self: end; background-position: 100% 100%; }
.pager__link:hover .pager__title { background-size: 100% 1px; }
@media (max-width: 640px) { .pager { grid-template-columns: 1fr; } .pager__link--next { text-align: left; } .pager__link--next .pager__title { justify-self: start; } }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---------- widget details ---------- */
.btn--sm { min-height: 36px; padding: 0 .875rem; font-size: var(--t-label); }
.btn--sm::after { display: none; }
.widget__bar .btn--sm { position: relative; }
.widget__bar .btn--sm::before { content: ""; position: absolute; inset: -4px 0; }
.chart .tip { transform: translate(-50%, 0); white-space: pre; }
.fig__frame .chart { padding-top: .25rem; }

/* dotted ground inside interactive frames, a nod to graph paper */
.widget__body { background-image: radial-gradient(var(--rule) 1px, transparent 1.2px); background-size: 16px 16px; background-position: 8px 8px; }

.attn { display: grid; gap: .375rem; padding: .5rem 0; font-family: var(--mono); font-size: var(--t-label); }
.attn__row { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) 3.25rem; align-items: center; gap: .875rem; }
.attn__tok { color: var(--ink-2); text-align: right; }
.attn__bar { height: 18px; background: var(--bg-alt); border-radius: 2px; overflow: hidden; }
.attn__bar i { display: block; height: 100%; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform 160ms var(--ease); }
.attn__v { color: var(--muted); font-variant-numeric: tabular-nums; }
.attn__row.is-query .attn__tok { color: var(--accent-ink); }
.attn__row.is-query .attn__tok::before { content: "→ "; }
.attn__row.is-masked { opacity: .35; }
.attn__row.is-masked .attn__bar { background: repeating-linear-gradient(-45deg, var(--rule) 0 1px, transparent 1px 6px); }

.lora__cv { width: 100%; height: clamp(220px, 34vw, 340px); }
.descent__cv { width: 100%; height: clamp(260px, 42vw, 420px); cursor: crosshair; }
.descent.widget__body, .lora.widget__body { padding: .5rem; }

.fig__frame[data-llm] { background: var(--surface); }
.chat__log { min-height: 260px; }
.stats .stat__v output { color: inherit; }
@media (max-width: 560px) { .widget__bar .select { flex: 1 1 100%; order: 3; } input[type="range"] { width: 110px; } }
