:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.09);
  --blue: #2424b8;
  --blue-soft: rgba(36, 36, 184, 0.07);
  --red: #d7262e;
  --accent: var(--blue);
  --on-accent: #ffffff;
  --grid: rgba(0, 0, 0, 0.05);
  --bar: rgba(251, 251, 253, 0.72);
  --track: rgba(0, 0, 0, 0.06);
  --well: #f2f2f5;
  --before: #c9c9d1;
  --shadow: 0 1px 2px rgba(16, 16, 60, 0.05), 0 12px 32px -16px rgba(16, 16, 60, 0.22);
  --band: #1b1b8c;
  --band-text: #ffffff;
  --band-muted: rgba(255, 255, 255, 0.72);
  --panel: #0c0d16;
  --panel-text: #f5f5f7;
  --panel-muted: #a3a6b4;
  --panel-line: rgba(255, 255, 255, 0.14);
  --panel-grid: rgba(140, 140, 255, 0.08);
  --node: #161827;
  --node-core: #23237a;
  --node-gate: #13341f;
  --gate: #4cc38a;
  --panel-accent: #9a9aff;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: max(16px, env(safe-area-inset-left));
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* Card system: one scale for every small part (2026-10-06 polish) */
  --r-card: 20px; --r-well: 12px; --r-node: 8px; --r-chip: 6px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --label: 600 0.6875rem/1 var(--sans); --tr-label: 0.06em;
  --hair: color-mix(in srgb, var(--muted) 45%, transparent);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090d;
    --surface: #14141b;
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --line: rgba(255, 255, 255, 0.1);
    --blue: #9a9aff;
    --blue-soft: rgba(154, 154, 255, 0.1);
    --red: #ff5e64;
    --on-accent: #09090d;
    --grid: rgba(255, 255, 255, 0.05);
    --bar: rgba(9, 9, 13, 0.7);
    --track: rgba(255, 255, 255, 0.07);
    --well: #1d1d26;
    --before: #4a4a57;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 16px 40px -20px rgba(0, 0, 0, 0.8);
    --band: #15155f;
    --panel: #101120;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 100%/1.55 var(--sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 0.3s, color 0.3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 16px; z-index: 20; background: var(--surface); padding: 8px 12px; }

.col { max-width: 46rem; margin: 0 auto; padding: 0 var(--gutter); }
.wide { position: relative; max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter); }

/* Translucent bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.bar-in {
  max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter);
  height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.mark {
  font: 600 0.8125rem/1 var(--mono); letter-spacing: 0.04em; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px;
}
.mark:hover { text-decoration: none; border-color: var(--accent); }
.bar ul { display: flex; gap: clamp(12px, 3vw, 28px); margin: 0; padding: 0; list-style: none; }
.bar ul a { color: var(--muted); font-size: 0.875rem; letter-spacing: 0.005em; }
.bar ul a:hover { color: var(--text); text-decoration: none; }

/* Background layers */
.layer { position: absolute; inset: -20% 0; pointer-events: none; will-change: transform; }
.grid {
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 70% 30%, #000 20%, transparent 70%);
  mask-image: radial-gradient(ellipse 70% 70% at 70% 30%, #000 20%, transparent 70%);
}
.wash {
  inset: 0; will-change: auto;
  background:
    radial-gradient(36rem 24rem at 92% 0%, color-mix(in srgb, var(--red) 12%, transparent), transparent 70%),
    radial-gradient(48rem 30rem at 70% 10%, var(--blue-soft), transparent 70%);
}

/* Hero */
.hero { position: relative; overflow: hidden; padding: clamp(36px, 6vw, 72px) 0 clamp(40px, 5vw, 64px); border-bottom: 1px solid var(--line); }
.hero.small { padding: clamp(56px, 10vw, 112px) 0 48px; border: 0; }
.hero-in { position: relative; }
.hero:not(.small) .hero-in {
  display: grid; grid-template-columns: minmax(0, 19rem) minmax(0, 44rem); grid-template-areas: "name name" "id intro";
  gap: clamp(28px, 4vw, 48px) clamp(32px, 6vw, 96px); align-items: start;
}
.nameplate { grid-area: name; }
.id { grid-area: id; }
.intro { grid-area: intro; }
.id .place { margin-top: 0; }
.nameplate { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 28px); }
.portrait {
  flex: none; display: block; width: clamp(72px, 9vw, 120px); height: auto; aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line), 0 0 0 5px var(--bg), 0 0 0 6px color-mix(in srgb, var(--blue) 35%, transparent), 0 14px 30px -12px rgba(20, 20, 120, 0.45);
}
h1 {
  font-size: clamp(2.25rem, 6vw, 5rem); line-height: 0.98; letter-spacing: -0.04em;
  font-weight: 750; margin: 0;
}
.hero.small h1 { font-size: clamp(2rem, 6vw, 3.5rem); }
.headline {
  font-size: clamp(1rem, 1.9vw, 1.375rem); line-height: 1.3; letter-spacing: -0.01em;
  color: var(--muted); margin: 10px 0 0; font-weight: 500;
}
.place { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 0; padding: 0; font: 0.8125rem/1.3 var(--mono); }
.place li { margin: 0; color: var(--muted); padding: 6px 0; }
.place li + li {
  color: var(--text); padding: 6px 11px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line);
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin: 20px 0 0; }
.btn {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font: 600 0.9375rem/1 var(--sans); text-decoration: none;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--blue) 80%, transparent);
  transition: transform 0.2s var(--ease), filter 0.2s;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn:active { transform: scale(0.97); transition-duration: 0.1s; }
.on-request { margin: var(--s-3) 0 0; font-size: 0.8125rem; line-height: 1.4; color: var(--muted); max-width: 22rem; }
.contact { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 0.9375rem; }
.contact li { margin: 0; }
.now-pill { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px; font: 0.8125rem/1.3 var(--mono); color: var(--muted); }
.now-pill .k { color: var(--red); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 18%, transparent); }
.lede { font-size: clamp(1.1875rem, 1.9vw, 1.4375rem); line-height: 1.4; letter-spacing: -0.012em; font-weight: 500; margin: 0; text-wrap: pretty; }
.more { margin: 8px 0 0; color: color-mix(in srgb, var(--text) 82%, var(--muted)); line-height: 1.65; }
.more p { margin: 0; }
.more summary {
  display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; list-style: none;
  font: 600 0.9375rem/1 var(--sans); color: var(--accent);
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; width: 7px; height: 7px; margin-left: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); transition: transform 0.2s var(--ease); }
.more[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.more[open] p { margin-top: 4px; }

/* Sections */
.sec { padding: clamp(64px, 9vw, 112px) 0; }
.sec + .sec { padding-top: 0; }
.hero + .sec { padding-top: clamp(48px, 6vw, 80px); }
.eyebrow {
  font: 500 0.75rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px;
}
.eyebrow .idx { color: var(--red); }
h2 {
  font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.04; letter-spacing: -0.035em;
  margin: 0 0 clamp(28px, 4vw, 44px); font-weight: 750; text-wrap: balance;
}
h3 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -0.01em; margin: 0; }
ul { padding-left: 1.2em; }
li { margin: 0.4em 0; }
li::marker { color: var(--muted); }
.sub { color: var(--muted); margin: 4px 0 0; }
.dates, .when { font: 0.8125rem/1.4 var(--mono); color: var(--muted); }

/* Selected impact */
.cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.case {
  position: relative; display: flex; flex-direction: column; gap: var(--s-5);
  background: var(--surface); border-radius: var(--r-card); padding: var(--s-5);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
@media (min-width: 1001px) { .case { padding: var(--s-6); } }
.case .a, .case .b { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.case.wide { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-5) var(--s-6); align-items: start; }

/* One label recipe for every small uppercase label; only the eyebrow colour differs. */
.where, .mini figcaption, .case dt, .lane .ll, .tag, .zero .cap {
  font: var(--label); letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--muted);
}
.where { color: var(--blue); margin: 0 0 var(--s-1); }
.case h3 { font-size: clamp(1.375rem, 2.4vw, 1.75rem); letter-spacing: -0.03em; line-height: 1.12; }
.case dl { margin: 0; display: grid; gap: var(--s-4); }
.case dt { margin: 0 0 var(--s-1); }
.case dd { margin: 0; line-height: 1.5; }
.case .res dd { font-weight: 600; letter-spacing: -0.01em; }
.note { margin: 0; padding-top: var(--s-4); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; line-height: 1.45; }
.tag {
  display: inline-flex; align-items: center; margin-right: var(--s-2); padding: 4px 7px; border-radius: var(--r-chip);
  position: relative; top: -1px; color: var(--blue); background: var(--blue-soft);
}

/* Per-card connection diagram: HTML, so text stays native size on a phone */
.mini { margin: 0; padding: var(--s-4); border-radius: var(--r-well); background: var(--well); display: grid; gap: var(--s-4); }
@media (min-width: 1001px) {
  /* Four or more lanes: two columns, so a wide card is not twice as tall as its text. */
  .case.wide .mini.many { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .case.wide .mini.many figcaption { grid-column: 1 / -1; }
  .case.wide .mini.many .lane:nth-of-type(2) { padding-top: 0; border-top: 0; }
}
.lane .ll { margin: 0 0 var(--s-2); }
.lane + .lane { padding-top: var(--s-4); border-top: 1px solid var(--line); }
.lane > ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; }
.lane > ol > li { margin: 0; width: 100%; display: flex; justify-content: center; }

/* Three node ranks: core (filled), out (accent ring), node (hairline). Chips step back. */
.nodes { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }
.nodes li {
  margin: 0; padding: 6px 10px; border-radius: var(--r-node); text-align: center;
  font: 500 0.8125rem/1.25 var(--sans); letter-spacing: -0.01em;
  background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line);
}
.nodes.core li { background: var(--blue); color: var(--on-accent); font-weight: 600; box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--blue) 70%, transparent); }
.nodes.out li { font-weight: 600; box-shadow: 0 0 0 1.5px var(--blue); }
.nodes.chip li { font: 400 0.75rem/1.25 var(--sans); letter-spacing: 0; padding: 4px 8px; border-radius: var(--r-chip); background: transparent; }

/* Connectors: 1px stem, vector arrowhead, caption on a well-coloured halo that breaks the line. */
.link { position: relative; min-height: 28px; display: flex; justify-content: center; }
.link::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 6px; width: 1px; margin-left: -0.5px; background: var(--hair); }
.link::after {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 10px; height: 6px; margin-left: -5px; background: var(--hair);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.link span {
  position: relative; z-index: 1; align-self: center; margin: 6px 0 12px; padding: 2px 6px; background: var(--well); max-width: 90%;
  font: 400 0.75rem/1.3 var(--sans); color: var(--muted); text-align: center;
}

/* Before/after meters: both are real bars on one scale; the value always sits just past its bar. */
.viz { margin: 0; }
.bars + .bars { margin-top: var(--s-4); }
.bl { font: 400 0.8125rem/1.35 var(--sans); color: var(--muted); margin: 0 0 var(--s-2); }
.meter { --max: 62%; position: relative; height: 28px; }
.meter + .meter { margin-top: var(--s-1); }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--max); border-radius: var(--r-node); transform-origin: left center; }
.meter.before .fill { background: var(--before); }
/* Width, not scaleX, so the rounded end keeps its true radius. */
.meter.after .fill { background: var(--blue); width: calc(var(--max) * var(--r)); transition: width 1.2s var(--ease) 0.15s; }
.meter .val {
  position: relative; display: flex; align-items: center; height: 100%; padding-left: calc(var(--max) + 10px);
  font: 600 0.8125rem/1 var(--sans); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap;
}
.meter.after .val { padding-left: calc(var(--max) * var(--r) + 10px); transition: padding-left 1.2s var(--ease) 0.15s; }
.legend { display: flex; align-items: center; gap: 6px; margin: var(--s-3) 0 0; font: 400 0.75rem/1 var(--sans); color: var(--muted); }
.legend .k { width: 10px; height: 10px; border-radius: 3px; background: var(--before); }
.legend .k.after { margin-left: var(--s-3); background: var(--blue); }

.zero { display: grid; align-items: center; min-height: 104px; padding: var(--s-4) 20px; border-radius: var(--r-well); background: var(--well); }
.zero { grid-template-columns: auto 40px auto; justify-content: center; gap: var(--s-4); }
.zero .from { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.zero s { text-decoration-color: var(--muted); text-decoration-thickness: 1px; }
.arrow { height: 1px; background: var(--hair); position: relative; }
.zero .to { margin: 0; display: flex; align-items: baseline; gap: var(--s-2); }
.zero .big { font-size: 3.5rem; line-height: 1; font-weight: 750; letter-spacing: -0.04em; color: var(--blue); }

@media (max-width: 760px) {
  /* Lists of several parts sit in a tidy two-column grid instead of a tag cloud. */
  .nodes:has(li:nth-child(2)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .meter { --max: 52%; }
}
@media (prefers-color-scheme: dark) {
  .nodes.core li { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
}

/* Scroll reveal: only when site.js adds .motion, so content shows without JS */
.motion .reveal { transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.motion .reveal:not(.in) { opacity: 0; transform: translateY(18px); }
.motion .case:not(.in) .meter.after .fill { width: var(--max); }
.motion .case:not(.in) .meter.after .val { padding-left: calc(var(--max) + 10px); }

/* Timeline */
.timeline { position: relative; }
.job { display: grid; grid-template-columns: 10.5rem 1fr; gap: 24px; padding: 0 0 40px; }
.job .when { padding-top: 3px; }
.job .what { position: relative; padding-left: 24px; border-left: 1px solid var(--line); }
.job .what::before {
  content: ""; position: absolute; left: -5px; top: 7px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--blue);
}
.job.now .what::before { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 18%, transparent); }
.job.now .when { color: var(--red); }
.job h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
.job:last-child { padding-bottom: 0; }
.org { color: var(--muted); margin: 4px 0 0; }
.job ul { margin: 10px 0 0; }
.job.compact p:last-child { margin-bottom: 0; }
.job.compact h3 { font-size: 1.0625rem; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 16px; }
.skill { background: var(--surface); border-radius: var(--r-card); padding: var(--s-5); box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.skill h3 { font-size: 0.9375rem; margin-bottom: 12px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  margin: 0; font: 400 0.8125rem/1.25 var(--sans); padding: 4px 9px; border-radius: var(--r-chip);
  background: var(--blue-soft); color: var(--text);
}

/* Credentials */
.creds { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 32px; }
.creds h3 { font-size: 0.9375rem; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { margin: 0 0 14px; }
.plain span { display: block; color: var(--muted); font-size: 0.9375rem; }

/* Breakouts */
.breakout { position: relative; overflow: hidden; padding: clamp(64px, 9vw, 112px) 0; }

.breakout.scale { background: var(--band); color: var(--band-text); padding: clamp(48px, 7vw, 88px) 0; }
.breakout.scale::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(40rem 20rem at 100% 0%, color-mix(in srgb, #ff2b33 30%, transparent), transparent 70%);
}
.eyebrow.on-band { color: var(--band-muted); }
.eyebrow.on-band .idx { color: #ff8a8f; }
.stats { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.stat { display: flex; flex-direction: column; gap: 6px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.22); }
.stat .v {
  font-size: clamp(2.75rem, 4.2vw, 3.75rem); line-height: 1; letter-spacing: -0.045em; font-weight: 750;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat .l { font: 600 0.9375rem/1.4 var(--sans); }
.stat .w { font: 0.75rem/1.4 var(--mono); color: var(--band-muted); }

.breakout.dark { background: var(--panel); color: var(--panel-text); --grid: var(--panel-grid); }
.breakout.dark h2 { color: var(--panel-text); margin-bottom: 8px; }
.breakout.dark .eyebrow { color: var(--panel-muted); }
.breakout.dark .eyebrow .idx { color: #ff8a8f; }
.breakout.dark .sub { color: var(--panel-accent); font-size: 1.0625rem; margin-bottom: 20px; }
.arch-copy ul { color: color-mix(in srgb, var(--panel-text) 82%, var(--panel-muted)); margin: 0; }
.arch-copy li::marker { color: var(--panel-muted); }
.arch-wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 80px); align-items: center; }
.gates {
  margin: 20px 0; padding: 16px 18px; border-radius: 16px;
  background: rgba(76, 195, 138, 0.07); box-shadow: 0 0 0 1px rgba(76, 195, 138, 0.3);
}
.gl { margin: 0 0 10px; font: 600 0.6875rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--gate); }
.gates ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 30px; }
.gates li { position: relative; margin: 0; padding: 7px 12px; border-radius: 999px; background: var(--node-gate); box-shadow: 0 0 0 1px var(--gate); font-weight: 600; font-size: 0.9375rem; }
.gates li + li::before { content: "→"; position: absolute; left: -22px; color: var(--gate); font-weight: 400; }
.breakout figure { margin: 0; }
.arch { display: block; width: 100%; max-width: 30rem; height: auto; margin: 0 auto; font-family: var(--sans); }
.arch .n rect { fill: var(--node); stroke: var(--panel-line); }
.arch .n.core rect { fill: var(--node-core); stroke: var(--panel-accent); }
.arch .n.gate rect { fill: var(--node-gate); stroke: var(--gate); }
.arch .n.store rect { fill: transparent; stroke: var(--panel-line); stroke-dasharray: 4 3; }
.arch .n.chip rect { fill: transparent; }
.arch .t { fill: var(--panel-text); font-size: 12.5px; font-weight: 600; text-anchor: middle; }
.arch .s { fill: var(--panel-muted); font: 10.5px var(--mono); text-anchor: middle; }
.arch .chip .t { font-size: 11.5px; font-weight: 500; }
.arch .edge { fill: none; stroke: var(--panel-muted); stroke-width: 1.25; opacity: 0.7; }
.arch .edge.link { stroke-dasharray: 3 3; }
.arch .arrowhead { fill: var(--panel-muted); }
.arch .zone { fill: rgba(255, 255, 255, 0.02); stroke: var(--panel-line); stroke-dasharray: 5 4; }
.arch .zl { fill: var(--panel-muted); font: 10px var(--mono); letter-spacing: 0.12em; }

/* Phone version of the diagram: same nodes, native text size */
.flow { display: none; }
.flow .row { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; position: relative; }
.flow .row + .row, .flow .zone { margin-top: 22px; }
.flow .row + .row::before, .flow .zone::before {
  content: ""; position: absolute; left: 50%; top: -18px; width: 2px; height: 14px; margin-left: -1px;
  background: var(--panel-muted); opacity: 0.6;
}
.flow .n {
  flex: 1 1 0; min-width: 0; margin: 0; padding: 10px 8px; border-radius: 10px; text-align: center;
  background: var(--node); box-shadow: 0 0 0 1px var(--panel-line);
}
.flow .n.core { background: var(--node-core); box-shadow: 0 0 0 1px var(--panel-accent); }
.flow .n.gate { background: var(--node-gate); box-shadow: 0 0 0 1px var(--gate); }
.flow .n.store { background: transparent; box-shadow: none; outline: 1px dashed var(--panel-line); outline-offset: -1px; }
.flow .n.chip { background: transparent; padding: 8px 4px; }
.flow .t { display: block; font-weight: 600; font-size: 0.9375rem; line-height: 1.25; }
.flow .chip .t { font-weight: 500; font-size: 0.8125rem; }
.flow .s { display: block; margin-top: 3px; font: 0.75rem/1.3 var(--mono); color: var(--panel-muted); }
.flow .zone { position: relative; padding: 14px 10px 12px; border-radius: 16px; outline: 1px dashed var(--panel-line); outline-offset: -1px; background: rgba(255, 255, 255, 0.02); }
.flow .zone .row:first-of-type { margin-top: 0; }
.flow .zone .row:first-of-type::before { display: none; }
.flow .zl { margin: 0 0 10px; font: 0.6875rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--panel-muted); }

/* Code example page */
.code { margin: 0 0 32px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.code-bar { padding: 10px 16px; border-bottom: 1px solid var(--line); font: 0.75rem/1 var(--mono); color: var(--muted); }
.code pre { margin: 0; padding: 16px 0; overflow-x: auto; font: 0.8125rem/1.6 var(--mono); counter-reset: ln; }
.code code span { display: block; padding: 0 16px; white-space: pre; }
.code code span::before {
  counter-increment: ln; content: counter(ln); display: inline-block; width: 2.5em; margin-right: 16px;
  text-align: right; color: var(--muted); opacity: 0.6; user-select: none;
}
.code figcaption { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--muted); }
.meta { font: 0.8125rem/1.4 var(--mono); color: var(--muted); margin: 10px 0 0; }
.hero.small .lede { margin-top: 24px; max-width: 40rem; }

.foot { border-top: 1px solid var(--line); padding: 32px 0 48px; font-size: 0.875rem; color: var(--muted); }
.foot .col { display: flex; justify-content: space-between; gap: 16px; }
.foot p { margin: 0; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; }
  .hero:not(.small) .hero-in { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "id" "intro"; }
}

@media (max-width: 760px) {
  /* Stack the review gates so the arrow never wraps away from its pill. */
  .gates ol { flex-direction: column; align-items: flex-start; gap: 26px; }
  .gates li + li::before { content: "↓"; left: 14px; top: -24px; }
  .cases { grid-template-columns: minmax(0, 1fr); }
  .case.wide { grid-template-columns: minmax(0, 1fr); }
  .arch-wrap { grid-template-columns: minmax(0, 1fr); }
  .arch { display: none; }
  .flow { display: block; }
  .job { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .job .when { padding-left: 24px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body { transition: none; }
  .layer { transform: none !important; will-change: auto; }
  .btn, .meter.after .fill, .meter.after .val { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .bar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: currentColor; --muted: var(--text); }
}
@media print {
  .bar, .layer, .skip { display: none; }
  .breakout.dark, .breakout.scale { background: none; color: inherit; }
}
