/* ==========================================================================
   Mithun Veluru — design system
   A near-black canvas, white display type pulled tight, charcoal surfaces.
   White pills for primary actions only; everything secondary is plain
   text. Blue is functional only: focus, selection, the highlighted path in a
   diagram. Nothing animates in: content is there when the page is.
   ========================================================================== */

@font-face {
  font-family: "Geist";
  src: url("/assets/fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/assets/fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  interpolate-size: allow-keywords;

  /* canvas + surfaces */
  --bg: #08090a;
  --surface: #111214;
  --surface-2: #191a1d;
  --surface-3: #222327;
  /* ink */
  --fg: #f5f5f3;
  --fg-2: #a0a0a0;
  --fg-3: #808080; /* #747474 measures 4.3:1 on --bg; this clears AA for small text on --surface too */
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  /* the one functional accent, and its legible-on-dark tint for text */
  --accent: #0099ff;
  --accent-ink: #7cc4ff;

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* type scale (desktop target in px) */
  --t-hero: clamp(2.75rem, 7.4vw, 5.75rem);   /* 92 */
  --t-h1: clamp(3rem, 8vw, 6.25rem);           /* 100, case-study titles */
  --t-h2: clamp(2.25rem, 4.9vw, 4rem);          /* 64 */
  --t-h3: clamp(1.625rem, 2.6vw, 2.25rem);      /* 36 */
  --t-lead: clamp(1.0625rem, 1.35vw, 1.25rem);  /* 20 */
  --t-body: 1rem;
  --t-small: 0.9375rem;
  --t-meta: 0.75rem;

  /* 5px spacing scale */
  --s-1: 0.3125rem;  /* 5 */
  --s-2: 0.625rem;   /* 10 */
  --s-3: 0.9375rem;  /* 15 */
  --s-4: 1.25rem;    /* 20 */
  --s-5: 1.875rem;   /* 30 */
  --s-6: 2.5rem;     /* 40 */
  --s-7: 3.75rem;    /* 60 */
  --s-8: 5rem;       /* 80 */
  --s-9: 6.25rem;    /* 100 */

  /* radii */
  --r-sm: 10px;
  --r-md: 15px;
  --r-lg: 20px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* layout */
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --max: 75rem; /* 1200 */
  --gap: clamp(0.9375rem, 1.6vw, 1.25rem);
  --section: clamp(4.5rem, 9vw, 6.25rem);

  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-mid: 420ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
  background: var(--bg);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  min-height: 100svh;
  /* No background here: html carries it. A body background would paint over a body-level field. */
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3, h4, p, pre { margin: 0; font-weight: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; left: var(--gutter); top: var(--s-3); z-index: 100;
  padding: var(--s-2) var(--s-4); border-radius: var(--r-pill);
  background: var(--fg); color: var(--bg); font-size: var(--t-small); font-weight: 500;
  transform: translateY(-200%); transition: transform var(--t-fast) var(--ease);
}
.skip:focus { transform: none; }

/* ---------- primitives ---------- */
.wrap { width: 100%; max-width: calc(var(--max) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }

.mono, .eyebrow {
  font-family: var(--mono);
  font-size: var(--t-meta);
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-3);
  font-feature-settings: "zero";
}
.eyebrow { margin-bottom: var(--s-4); }

.link {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--t-mid) var(--ease), color var(--t-fast);
}
.link:hover, .link:focus-visible { background-size: 100% 1px; }

.arrow {
  display: inline-block; width: 0.8em; height: 0.8em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: square;
  transition: transform var(--t-mid) var(--ease);
}

kbd {
  font: 500 0.6875rem/1 var(--mono);
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--fg-2);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  font-size: var(--t-small);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform 120ms var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn .arrow { width: 0.7em; height: 0.7em; }
.btn--primary { background: var(--fg); color: var(--bg); }
.btn--primary:hover { background: #fff; }

/* Secondary actions are text, not capsules. */
.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  font-size: var(--t-small);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg-2);
  transition: color var(--t-fast);
}
.text-link:hover { color: var(--fg); }
.text-link .arrow { width: 0.7em; height: 0.7em; }
.text-link:hover .arrow { transform: translate(1px, -1px); }
.btn--sm { min-height: 36px; padding: 0 var(--s-3); font-size: 0.875rem; }
@media (pointer: coarse) { .btn--sm { min-height: 44px; } }

/* ---------- field (WebGL atmosphere, heroes only) ---------- */
.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s var(--ease);
}
.field.is-on { opacity: 1; }
/* No WebGL2: a still frame of the same field (rendered by tools/make-og.sh). */
.no-field .hero,
.no-field .cs-hero {
  background: url("/assets/field-still.webp") right center / cover no-repeat;
}

/* Controls that only make sense with their script. */
html:not(.js) [data-palette-open],
html:not(.js) [data-copy] { display: none; }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background-color var(--t-mid) var(--ease), border-color var(--t-mid) var(--ease);
}
.nav.is-solid {
  background: rgba(8, 9, 10, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  border-bottom-color: var(--line);
}
.nav__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-4);
  height: 4rem;
}
.nav__brand { justify-self: start; font-size: var(--t-small); font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; }
.nav__links { display: flex; gap: var(--s-1); }
.nav__links a, .nav__ext {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-pill);
  font-size: 0.875rem;
  color: var(--fg-2);
  transition: color var(--t-fast), background-color var(--t-fast);
}
.nav__links a:hover, .nav__ext:hover { color: var(--fg); }
.nav__links a[aria-current="true"] { color: var(--fg); }
.nav__ext .arrow { width: 0.65em; height: 0.65em; }
.nav__ext:hover .arrow { transform: translate(1px, -1px); }
.nav__actions { justify-self: end; display: flex; align-items: center; gap: var(--s-2); }
.nav__menu { display: none; align-items: center; min-height: 44px; padding: 0 var(--s-2); font-size: 0.875rem; font-weight: 500; }

@media (max-width: 820px) {
  .nav__inner { grid-template-columns: 1fr auto; }
  .nav__links, .nav__ext { display: none; }
  .nav__menu { display: inline-flex; }
}

/* ==========================================================================
   Home
   ========================================================================== */

/* ---------- hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: min(100svh, 58rem);
  display: grid;
  align-items: end;
}
/* Keeps the type side calm; the field reads strongest on the open right. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(8, 9, 10, 0.92) 0%, rgba(8, 9, 10, 0.6) 38%, rgba(8, 9, 10, 0) 68%),
    linear-gradient(0deg, var(--bg) 0%, rgba(8, 9, 10, 0) 34%);
}
.hero__inner { padding-block: 9rem clamp(3.5rem, 8vw, 6rem); }
.hero__title {
  max-width: 13em;
  font-size: var(--t-hero);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.05em;
  margin-left: -0.04em;
}
.hero__title span { display: block; color: var(--fg-2); }
.hero__lead {
  margin-top: var(--s-5);
  max-width: 34rem;
  font-size: var(--t-lead);
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--fg-2);
}
.hero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); margin-top: var(--s-6); }

@media (max-width: 760px) {
  .hero::before { background: linear-gradient(180deg, rgba(8, 9, 10, 0.25) 0%, rgba(8, 9, 10, 0.75) 45%, var(--bg) 100%); }
  .hero__inner { padding-top: 12rem; }
}

/* ---------- sections ---------- */
.section { padding-top: var(--section); }
.head { margin-bottom: var(--s-7); }
.head__title {
  max-width: 17ch;
  font-size: var(--t-h2);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.head__title--sm { font-size: var(--t-h3); letter-spacing: -0.035em; }
.head__lead {
  margin-top: var(--s-4);
  max-width: 34rem;
  font-size: var(--t-lead);
  line-height: 1.5;
  color: var(--fg-2);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--s-6) clamp(2rem, 6vw, 5rem);
  align-items: start;
}
.split .head { margin-bottom: 0; position: sticky; top: 6rem; }
.split .head__title { font-size: var(--t-h3); letter-spacing: -0.035em; line-height: 1.1; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .split .head { position: static; }
}

/* ---------- work: the centerpiece ---------- */
.work {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}
.project {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--t-mid) var(--ease), background-color var(--t-mid) var(--ease);
}
.project:hover { border-color: var(--line-2); background: #131416; }
.project:focus-visible { outline-offset: 4px; border-radius: var(--r-lg); }

.project__text {
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 3vw, 2.25rem);
}
.project__kind { font: 400 var(--t-meta)/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.project__title {
  margin-top: var(--s-3);
  font-size: var(--t-h3);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  view-transition-name: var(--vt);
}
.project__desc { margin-top: var(--s-3); max-width: 32rem; font-size: var(--t-small); line-height: 1.55; color: var(--fg-2); }
.project__meta { margin-top: var(--s-4); font: 400 var(--t-meta)/1.5 var(--mono); letter-spacing: 0.02em; color: var(--fg-3); }
.project__go {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
}
.project:hover .project__go .arrow, .project:focus-visible .project__go .arrow { transform: translateX(4px); }
.project__go--ext .arrow { width: 0.7em; height: 0.7em; }
.project:hover .project__go--ext .arrow, .project:focus-visible .project__go--ext .arrow { transform: translate(2px, -2px); }

/* Smaller projects without a case study: same cards, linking to source. */
.also { margin-top: var(--s-7); }

/* The preview stage: the only place colour is allowed. */
.stage {
  position: relative;
  display: flex;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0) 0 0 / 20px 20px,
    #0d0e10;
  border-bottom: 1px solid var(--line);
}

.stage > .panel, .stage > .shot {
  position: relative;
  z-index: 1;
  transition: transform 700ms var(--ease);
}
.project:hover .stage > .panel, .project:hover .stage > .shot { transform: translateY(-6px); }

/* A screenshot bleeds off the stage's lower right, like a window on a desk. */
.shot {
  align-self: flex-end;
  width: 90%;
  height: auto;
  margin: 10% 0 -1px auto;
  border: 1px solid var(--line-2);
  border-right: 0;
  border-bottom: 0;
  border-radius: var(--r-sm) 0 0 0;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.75);
  filter: brightness(0.88); /* the products are light-themed; keep them from out-shining the page */
}

/* A terminal panel: real output, quoted from each README. */
.panel {
  align-self: center;
  width: min(100% - 2 * var(--s-5), 32rem);
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.panel__bar {
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
}
.panel__bar b { font: 400 0.6875rem/1 var(--mono); letter-spacing: 0.03em; color: var(--fg-3); }
.panel__body {
  padding: var(--s-3);
  font: 400 clamp(0.625rem, 1vw, 0.75rem)/1.75 var(--mono);
  color: var(--fg-2);
  white-space: pre;
  overflow: hidden;
}
.panel__body .hi { color: var(--fg); }
.panel__body .ac { color: #fff; background: rgba(255, 255, 255, 0.07); }
.panel__body .lo { color: var(--fg-3); }

/* Wide: text and stage side by side. */
.project--wide { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.project--wide .project__text { justify-content: flex-end; padding: clamp(1.5rem, 4vw, 3rem); }
.project--wide .stage { aspect-ratio: auto; min-height: 26rem; border-bottom: 0; border-left: 1px solid var(--line); }
.project--wide .project__title { font-size: clamp(2rem, 3.6vw, 3rem); }
.project--flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.project--flip .stage { order: -1; border-left: 0; border-right: 1px solid var(--line); }

@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; }
  .project--wide, .project--flip { display: flex; flex-direction: column; }
  .project--wide .stage { order: -1; aspect-ratio: 16 / 10; min-height: 0; border: 0; border-bottom: 1px solid var(--line); }
  .stage:has(> .panel) { aspect-ratio: auto; padding-block: var(--s-5); }
}

/* ---------- about ---------- */
.about__lead { font-size: var(--t-lead); line-height: 1.5; letter-spacing: -0.01em; color: var(--fg); max-width: 36rem; }
.principles { margin-top: var(--s-6); border-top: 1px solid var(--line); counter-reset: p; }
.principles li {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--line);
  counter-increment: p;
}
.principles li::before { content: counter(p, decimal-leading-zero); grid-row: span 2; font: 400 var(--t-meta)/2 var(--mono); color: var(--fg-3); }
.principles h3 { font-size: 1.0625rem; font-weight: 500; letter-spacing: -0.015em; }
.principles p { margin-top: var(--s-1); max-width: 36rem; font-size: var(--t-small); line-height: 1.55; color: var(--fg-2); }

/* ---------- experience ---------- */
.roles { border-top: 1px solid var(--line); }
.role {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: var(--s-4);
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--line);
}
.role__when { font: 400 var(--t-meta)/2 var(--mono); color: var(--fg-3); font-feature-settings: "tnum"; }
.role__org { font-size: 1.25rem; font-weight: 500; letter-spacing: -0.025em; line-height: 1.3; }
.role__org span { display: block; font-size: var(--t-small); font-weight: 400; letter-spacing: -0.005em; color: var(--fg-2); }
.role__where { margin-top: var(--s-2); font: 400 var(--t-meta)/1.5 var(--mono); letter-spacing: 0.02em; color: var(--fg-3); }
.role__desc { margin-top: var(--s-3); max-width: 38rem; font-size: var(--t-small); line-height: 1.6; color: var(--fg-2); }
@media (max-width: 560px) { .role { grid-template-columns: 1fr; gap: var(--s-1); } }

/* ---------- stack: a technical index ---------- */
.stack {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--s-6) var(--gap);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}
.stack h3 { margin-bottom: var(--s-3); font: 400 var(--t-meta)/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.stack li { padding-block: 0.2rem; font-size: var(--t-small); }
@media (max-width: 900px) { .stack { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stack { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- contact ---------- */
#contact { padding-bottom: var(--section); }
.cta {
  position: relative;
  padding: clamp(2rem, 6vw, 4.5rem);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background:
    radial-gradient(70% 120% at 100% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    var(--surface);
  overflow: hidden;
}
.cta__title { font-size: var(--t-h2); font-weight: 500; line-height: 1; letter-spacing: -0.045em; }
.cta__lead { margin-top: var(--s-4); max-width: 30rem; font-size: var(--t-lead); line-height: 1.5; color: var(--fg-2); }
.cta__mail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); margin-top: var(--s-6); }
.cta__mail a { font-size: clamp(1.375rem, 3.2vw, 2.25rem); font-weight: 500; letter-spacing: -0.035em; line-height: 1.15; overflow-wrap: anywhere; }
.cta__copy { min-height: 44px; font: 400 var(--t-meta)/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); transition: color var(--t-fast); }
.cta__copy:hover { color: var(--fg); }
.cta__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); margin-top: var(--s-6); }

/* ---------- footer ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-3) var(--s-5);
  padding-block: var(--s-5);
  /* the rule spans the content column, not the gutters */
  background: linear-gradient(var(--line), var(--line)) var(--gutter) 0 / calc(100% - 2 * var(--gutter)) 1px no-repeat;
  font-size: 0.8125rem;
  color: var(--fg-3);
}
.foot nav { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.foot a { color: var(--fg-2); transition: color var(--t-fast); }
.foot a:hover { color: var(--fg); }

/* ==========================================================================
   Case studies
   ========================================================================== */
.cs-hero { position: relative; isolation: isolate; overflow: hidden; }
.cs-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(8, 9, 10, 0.92) 0%, rgba(8, 9, 10, 0.55) 42%, rgba(8, 9, 10, 0) 72%),
    linear-gradient(0deg, var(--bg) 0%, rgba(8, 9, 10, 0) 40%);
}
@media (max-width: 760px) {
  .cs-hero::before { background: linear-gradient(180deg, rgba(8, 9, 10, 0.2) 0%, rgba(8, 9, 10, 0.8) 50%, var(--bg) 100%); }
}
.cs-hero__inner {
  min-height: min(86svh, 50rem);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: 6rem;
  padding-bottom: var(--s-6);
}
.cs-hero__top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.cs-hero__top a {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  color: var(--fg-2);
  transition: color var(--t-fast);
}
.cs-hero__top a:hover { color: var(--fg); }
.cs-hero__top a .arrow { transform: rotate(180deg); }
.cs-hero__top a:hover .arrow { transform: rotate(180deg) translateX(3px); }
.cs-hero__main { align-self: end; padding-block: var(--s-7) var(--s-6); }
.cs-title {
  font-size: var(--t-h1);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.055em;
  margin-left: -0.045em;
  view-transition-name: var(--vt);
}
.cs-sub {
  margin-top: var(--s-5);
  max-width: 36rem;
  font-size: var(--t-lead);
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--fg-2);
}
.spec {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--s-4) var(--gap);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: rgba(17, 18, 20, 0.88);
}
.spec > div { grid-column: span 2; min-width: 0; }
.spec > div.wide { grid-column: span 4; }
.spec dt { margin-bottom: var(--s-1); }
.spec dd { font-size: 0.875rem; line-height: 1.5; color: var(--fg); }
.spec dd a { display: inline-flex; gap: var(--s-1); align-items: center; margin-right: var(--s-3); }
.spec dd .arrow { width: 0.65em; height: 0.65em; }
@media (max-width: 900px) {
  .spec > div, .spec > div.wide { grid-column: span 6; }
}

.cs {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  padding-top: var(--s-8);
}
.toc { grid-column: 1 / span 3; }
.toc ol { position: sticky; top: 6rem; display: grid; gap: 2px; }
.toc a {
  display: flex;
  gap: var(--s-3);
  padding-block: var(--s-1);
  color: var(--fg-3);
  transition: color var(--t-fast);
}
.toc a:hover, .toc a[aria-current="true"] { color: var(--fg); }
.cs__body { grid-column: 4 / span 8; min-width: 0; }
@media (max-width: 900px) {
  .toc { display: none; }
  .cs__body { grid-column: 1 / -1; }
}

.cs-sec { padding-bottom: var(--s-9); }
.cs-sec > .mono:first-child { display: block; }
.cs-sec h2 {
  margin: var(--s-3) 0 var(--s-5);
  max-width: 20ch;
  font-size: clamp(2rem, 3.6vw, 3rem);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.045em;
}
.prose { display: grid; gap: var(--s-4); max-width: 42rem; }
.prose p { color: var(--fg-2); }
.prose p strong { color: var(--fg); font-weight: 500; }
.prose code, .cs code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}
.code {
  margin: var(--s-1) 0 0;
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font: 400 0.8125rem/1.75 var(--mono);
  color: var(--fg-2);
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.code .lo { color: var(--fg-3); }
.code .hi { color: var(--fg); }
.code .ac { color: var(--accent-ink); }
.prose ul { display: grid; gap: var(--s-3); }
.prose li { position: relative; padding-left: var(--s-5); color: var(--fg-2); }
.prose li::before { content: ""; position: absolute; left: 0; top: 0.8em; width: 0.75rem; height: 1px; background: var(--fg-3); }
.prose li strong { color: var(--fg); font-weight: 500; }
.lede { font-size: var(--t-lead); line-height: 1.5; color: var(--fg) !important; letter-spacing: -0.01em; }

/* Numbered engineering notes */
.notes { margin-top: var(--s-6); border-top: 1px solid var(--line); counter-reset: n; }
.notes li {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 0 var(--s-3);
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--line);
  counter-increment: n;
}
.notes li::before { content: counter(n, decimal-leading-zero); grid-row: span 2; font: 400 var(--t-meta)/2 var(--mono); color: var(--fg-3); }
.notes li > * { grid-column: 2; min-width: 0; }
.notes .code { margin-top: var(--s-3); }
.notes h3 { margin-bottom: var(--s-2); font-size: 1.125rem; font-weight: 500; letter-spacing: -0.02em; }
.notes p { max-width: 42rem; color: var(--fg-2); }

/* Tradeoffs: question, then the call */
.calls { margin-top: var(--s-6); border-top: 1px solid var(--line); }
.calls > div {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--s-5);
  padding-block: var(--s-5);
  border-bottom: 1px solid var(--line);
}
.calls dt { font-size: 1.0625rem; font-weight: 500; line-height: 1.4; letter-spacing: -0.015em; }
.calls dd { font-size: var(--t-small); color: var(--fg-2); }
.calls dd strong { color: var(--fg); font-weight: 500; }
@media (max-width: 760px) { .calls > div { grid-template-columns: 1fr; gap: var(--s-2); } }

/* Results */
.results {
  width: 100%;
  margin-top: var(--s-5);
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  font-size: var(--t-small);
  overflow: hidden;
}
.results th, .results td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: baseline; }
.results tr:last-child td { border-bottom: 0; }
.results th { font: 400 var(--t-meta)/1.5 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.results td { color: var(--fg-2); }
.results td:last-child { color: var(--fg); font-feature-settings: "tnum"; text-align: right; }
.results th:last-child { text-align: right; }
@media (min-width: 561px) { .results td:last-child { white-space: nowrap; } }
.caveat { margin-top: var(--s-4); max-width: 42rem; color: var(--fg-3); font-size: 0.875rem; }

/* Figures: diagrams and screenshots */
.figure { margin-top: var(--s-6); }
.figure__frame {
  position: relative;
  padding: clamp(1rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.07) 1px, transparent 0) 0 0 / 20px 20px,
    var(--surface);
}
.figure__frame--shot { padding: 0; background: var(--surface); overflow: hidden; }
.figure__frame--shot img { width: 100%; height: auto; }
.figure figcaption { display: flex; gap: var(--s-3); margin-top: var(--s-3); text-transform: none; letter-spacing: 0.01em; }
.figure figcaption b { color: var(--fg-2); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.figure--scroll .figure__frame { overflow-x: auto; }
@media (max-width: 560px) {
  .figure--scroll svg { min-width: 30rem; }
  .figure--scroll figcaption span::after { content: " Scroll sideways for the whole figure."; color: var(--fg-3); }
}

/* Diagram language: hairline nodes, one highlighted path, mono labels */
.dg { width: 100%; max-width: 34rem; height: auto; margin-inline: auto; font-family: var(--mono); overflow: visible; }
.dg text { font-size: 11px; letter-spacing: 0.04em; fill: var(--fg-2); text-anchor: middle; }
.dg .t-l { text-anchor: start; }
.dg .t-hi { fill: var(--fg); font-family: var(--sans); font-size: 13px; letter-spacing: -0.01em; }
.dg .t-lo { fill: var(--fg-3); font-size: 9.5px; }
.dg .t-ac { fill: var(--accent-ink); }
.dg .n { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 1; rx: 8px; }
.dg .n-ac { fill: var(--surface-2); stroke: rgba(0, 153, 255, 0.7); stroke-width: 1; rx: 8px; }
.dg .n-dash { fill: none; stroke: var(--line-2); stroke-dasharray: 3 3; rx: 8px; }
.dg .e { fill: none; stroke: var(--fg-3); stroke-width: 1; marker-end: url(#ah); }
.dg .e-ac { fill: none; stroke: var(--accent-ink); stroke-width: 1.25; marker-end: url(#ah-ac); }
.dg .e-dash { stroke-dasharray: 3 4; }
.dg .ah { fill: var(--fg-3); }
.dg .ah-ac { fill: var(--accent-ink); }
.dg .grp { fill: none; stroke: var(--line-2); stroke-dasharray: 2 4; rx: 12px; }

/* Next / previous */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); padding-bottom: var(--s-8); }
.pager a {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--t-mid) var(--ease), background-color var(--t-mid) var(--ease);
}
.pager a:hover { border-color: var(--line-2); background: #131416; }
.pager a:last-child { text-align: right; }
.pager strong {
  view-transition-name: var(--vt);
  font-family: var(--sans);
  font-size: var(--t-h3);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  text-transform: none;
  color: var(--fg);
}
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager a:last-child { text-align: left; } }

/* ==========================================================================
   Command palette (also the mobile menu)
   ========================================================================== */
.palette {
  width: min(36rem, calc(100vw - 2rem));
  max-height: min(32rem, calc(100svh - 6rem));
  margin: 14vh auto auto;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: rgba(17, 18, 20, 0.96);
  color: var(--fg);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}
html:has(.palette[open]) { overflow: hidden; }
.palette[open] { display: flex; flex-direction: column; animation: pal-in 260ms var(--ease) both; }
.palette::backdrop { background: rgba(4, 5, 6, 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@keyframes pal-in { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }
.palette__field { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); border-bottom: 1px solid var(--line); }
.palette__field svg { width: 0.9rem; height: 0.9rem; color: var(--fg-3); flex: none; }
.palette input {
  flex: 1;
  min-width: 0;
  height: 3.25rem;
  background: none;
  border: 0;
  outline: 0;
  color: var(--fg);
  font: 400 1rem var(--sans);
}
.palette input::placeholder { color: var(--fg-3); }
.palette__list { overflow-y: auto; padding: var(--s-2); }
.palette__group { padding: var(--s-3) var(--s-3) var(--s-1); }
.palette__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  text-align: left;
  color: var(--fg-2);
  border-radius: var(--r-sm);
}
.palette__item[aria-selected="true"] { background: var(--surface-3); color: var(--fg); }
.palette__empty { padding: var(--s-5) var(--s-4); color: var(--fg-3); }
.palette__foot { display: flex; gap: var(--s-4); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); }
@media (hover: none) {
  .palette { margin-top: 4.5rem; max-height: calc(100svh - 6rem); }
  .palette__item { padding-block: var(--s-3); }
  .palette__foot { display: none; }
}

/* ==========================================================================
   404
   ========================================================================== */
.lost { min-height: 100svh; display: grid; align-content: center; justify-items: start; gap: var(--s-4); }
.lost h1 { font-size: var(--t-h1); font-weight: 500; line-height: 0.92; letter-spacing: -0.055em; }
.lost p { max-width: 30rem; color: var(--fg-2); }
.lost nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5); margin-top: var(--s-4); }

/* ==========================================================================
   Navigate: pages cross-fade; a project's name carries across.
   ========================================================================== */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 380ms; animation-timing-function: var(--ease); }
::view-transition-group(*) { animation-duration: 560ms; animation-timing-function: var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
  @view-transition { navigation: none; }
}

@media print {
  .field, .nav { display: none !important; }
  body { background: #fff; color: #000; }
}
