/* ==========================================================================
   roystonlim.com design system
   Tokens → base → chrome → hero → sections → pages → motion → responsive.
   Pages carry a strict CSP: no inline styles, so everything lives here.
   ========================================================================== */

/* Design tokens ---------------------------------------------------------- */
:root {
  color-scheme: light;
  --bg: hsl(40 33% 96%);
  --bg-2: hsl(40 28% 93%);
  --surface: hsl(0 0% 100%);
  --surface-2: hsl(40 30% 97%);
  --ink: hsl(224 32% 10%);
  --ink-2: hsl(224 12% 32%);
  --ink-3: hsl(224 8% 42%);
  --line: hsl(40 16% 86%);
  --line-2: hsl(40 12% 74%);
  --accent: hsl(20 92% 38%);
  --accent-ink: hsl(0 0% 100%);
  --accent-soft: hsl(30 92% 91%);
  --flow: hsl(176 82% 24%);
  --flow-soft: hsl(174 46% 89%);
  --deny: hsl(4 72% 45%);
  --btn-bg: var(--ink);
  --btn-ink: var(--bg);
  --glow-1: hsl(30 96% 60% / 0.28);
  --glow-2: hsl(174 70% 44% / 0.18);
  --rings: hsl(224 30% 20% / 0.07);
  --plate-hi: hsl(0 0% 100%);
  --plate: hsl(40 26% 95%);
  --plate-l: hsl(40 16% 86%);
  --plate-r: hsl(40 13% 79%);
  --plate-edge: hsl(40 9% 64%);
  --plate-shadow: hsl(224 30% 18% / 0.18);
  --grain: 0.07;
  --shadow-1: 0 1px 1px hsl(224 30% 20% / 0.04), 0 6px 18px hsl(224 30% 20% / 0.06);
  --shadow-2: 0 2px 4px hsl(224 30% 20% / 0.05), 0 28px 60px hsl(224 30% 20% / 0.14);
  --radius: 20px;
  --radius-sm: 12px;
  --wrap: 1180px;
  --header-h: 64px;
  --font-display: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: hsl(224 28% 6%);
    --bg-2: hsl(224 24% 8%);
    --surface: hsl(224 20% 10%);
    --surface-2: hsl(224 18% 13%);
    --ink: hsl(40 30% 94%);
    --ink-2: hsl(222 13% 72%);
    --ink-3: hsl(222 10% 58%);
    --line: hsl(224 16% 16%);
    --line-2: hsl(224 13% 27%);
    --accent: hsl(38 96% 60%);
    --accent-ink: hsl(224 40% 7%);
    --accent-soft: hsl(36 58% 15%);
    --flow: hsl(172 68% 56%);
    --flow-soft: hsl(174 40% 14%);
    --deny: hsl(6 92% 67%);
    --btn-bg: var(--accent);
    --btn-ink: var(--accent-ink);
    --glow-1: hsl(34 96% 55% / 0.16);
    --glow-2: hsl(176 80% 45% / 0.12);
    --rings: hsl(40 30% 94% / 0.055);
    --plate-hi: hsl(224 16% 21%);
    --plate: hsl(224 18% 14%);
    --plate-l: hsl(224 20% 10%);
    --plate-r: hsl(224 22% 7.5%);
    --plate-edge: hsl(224 12% 34%);
    --plate-shadow: hsl(0 0% 0% / 0.55);
    --grain: 0.09;
    --shadow-1: 0 1px 1px hsl(0 0% 0% / 0.3), 0 6px 18px hsl(0 0% 0% / 0.28);
    --shadow-2: 0 2px 4px hsl(0 0% 0% / 0.3), 0 28px 60px hsl(0 0% 0% / 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: hsl(224 28% 6%);
  --bg-2: hsl(224 24% 8%);
  --surface: hsl(224 20% 10%);
  --surface-2: hsl(224 18% 13%);
  --ink: hsl(40 30% 94%);
  --ink-2: hsl(222 13% 72%);
  --ink-3: hsl(222 10% 58%);
  --line: hsl(224 16% 16%);
  --line-2: hsl(224 13% 27%);
  --accent: hsl(38 96% 60%);
  --accent-ink: hsl(224 40% 7%);
  --accent-soft: hsl(36 58% 15%);
  --flow: hsl(172 68% 56%);
  --flow-soft: hsl(174 40% 14%);
  --deny: hsl(6 92% 67%);
  --btn-bg: var(--accent);
  --btn-ink: var(--accent-ink);
  --glow-1: hsl(34 96% 55% / 0.16);
  --glow-2: hsl(176 80% 45% / 0.12);
  --rings: hsl(40 30% 94% / 0.055);
  --plate-hi: hsl(224 16% 21%);
  --plate: hsl(224 18% 14%);
  --plate-l: hsl(224 20% 10%);
  --plate-r: hsl(224 22% 7.5%);
  --plate-edge: hsl(224 12% 34%);
  --plate-shadow: hsl(0 0% 0% / 0.55);
  --grain: 0.09;
  --shadow-1: 0 1px 1px hsl(0 0% 0% / 0.3), 0 6px 18px hsl(0 0% 0% / 0.28);
  --shadow-2: 0 2px 4px hsl(0 0% 0% / 0.3), 0 28px 60px hsl(0 0% 0% / 0.5);
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
/* Film grain: gives flat surfaces some tooth. */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: url("/assets/img/grain.svg"); opacity: var(--grain);
}
img, svg { max-width: 100%; display: block; }
img { height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.05; margin: 0; font-weight: 600; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 120;
  background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--radius-sm);
}
.skip:focus { top: 1rem; }
.mono { font-family: var(--font-mono); }

/* Header ----------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background 0.3s;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.nav { display: flex; align-items: center; gap: 0.75rem; min-height: var(--header-h); }
.brand {
  display: inline-flex; align-items: center; gap: 0.65rem;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; text-decoration: none; letter-spacing: -0.01em;
}
.brand:hover { color: var(--ink); }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font: 600 0.68rem/1 var(--font-mono); letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.18);
  transition: transform 0.4s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.nav-links { display: flex; align-items: center; gap: 0.15rem; margin-left: auto; }
.nav-links a {
  position: relative; text-decoration: none; font-size: 0.92rem; font-weight: 500; color: var(--ink-2);
  padding: 0.45rem 0.75rem; border-radius: 10px; transition: background 0.2s, color 0.2s;
}
.nav-links a:hover, .nav-links a[aria-current="page"], .nav-links a.active { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.icon-btn {
  display: inline-grid; place-items: center; height: 36px; min-width: 36px; padding: 0 0.6rem;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: transform 0.2s var(--ease), background 0.2s, color 0.2s;
  box-shadow: 0 1px 0 hsl(0 0% 100% / 0.04) inset;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn kbd { font: 500 0.72rem/1 var(--font-mono); letter-spacing: 0.02em; }
.theme-toggle svg { width: 17px; height: 17px; transition: transform 0.5s var(--ease); }
.theme-toggle:hover svg { transform: rotate(40deg); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
/* Reading progress, driven by --p (0 to 1) from main.js. */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); }

/* Section rail (wide screens) -------------------------------------------- */
.rail { display: none; }
@media (min-width: 1500px) {
  .rail {
    display: grid; gap: 0.2rem; position: fixed; z-index: 40; top: 50%; transform: translateY(-50%);
    left: max(1.25rem, calc((100vw - var(--wrap)) / 2 - 10.5rem));
  }
  .rail a {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.32rem 0; text-decoration: none;
    font: 500 0.7rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
    transition: color 0.25s;
  }
  .rail a::before { content: ""; width: 14px; height: 1px; background: currentColor; transition: width 0.35s var(--ease); }
  .rail a:hover { color: var(--ink); }
  .rail a.active { color: var(--ink); }
  .rail a.active::before { width: 34px; background: var(--accent); }
}

/* Buttons and tags ------------------------------------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1.3rem; border-radius: 13px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.97rem; line-height: 1.1; letter-spacing: -0.005em; text-decoration: none; cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn .arrow { display: inline-block; transition: transform 0.3s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn-primary {
  background: var(--btn-bg); color: var(--btn-ink);
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.28), inset 0 -1px 0 hsl(0 0% 0% / 0.18), var(--shadow-1);
}
.btn-primary:hover { color: var(--btn-ink); transform: translateY(-2px); box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.28), inset 0 -1px 0 hsl(0 0% 0% / 0.18), var(--shadow-2); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.btn-ghost:hover { color: var(--ink); background: var(--surface); border-color: var(--ink-3); transform: translateY(-2px); }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font-size: 0.82rem; font-weight: 500; padding: 0.3rem 0.65rem; border-radius: 8px;
  background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-2);
}
.tag-live {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font: 500 0.72rem/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--flow-soft); color: var(--flow);
}
.tag-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Hero ------------------------------------------------------------------- */
.hero { position: relative; padding-block: clamp(2.5rem, 5.5vw, 4.5rem) 0; isolation: isolate; }
.hero-bg { position: absolute; inset: calc(var(--header-h) * -1) 0 0 0; z-index: -1; overflow: hidden; pointer-events: none; }
/* Two soft light sources and a set of propagation rings behind the figure. */
.hero-bg::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(46rem 34rem at 78% 34%, var(--glow-1), transparent 68%),
    radial-gradient(40rem 30rem at 8% 88%, var(--glow-2), transparent 70%);
}
.hero-bg::after {
  content: ""; position: absolute; inset: -20%;
  background: repeating-radial-gradient(circle at 74% 46%, transparent 0 95px, var(--rings) 95px 96px);
  -webkit-mask-image: radial-gradient(circle at 74% 46%, #000 0, transparent 58%);
  mask-image: radial-gradient(circle at 74% 46%, #000 0, transparent 58%);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); gap: clamp(2rem, 4vw, 4rem); align-items: center; }
.eyebrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem;
  font: 500 0.74rem/1.4 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.eyebrow span + span::before { content: ""; display: inline-block; width: 22px; height: 1px; background: var(--line-2); vertical-align: middle; margin-right: 0.9rem; }
.eyebrow b { font-weight: 500; color: var(--ink); }
.hero h1 {
  margin-top: 1.4rem;
  font-size: clamp(2.6rem, 1.1rem + 5.1vw, 5.1rem);
  font-weight: 600; line-height: 0.98; letter-spacing: -0.045em;
}
.hero h1 em {
  font-family: var(--font-serif); font-style: italic; font-weight: 400;
  font-size: 1.08em; letter-spacing: -0.02em; color: var(--accent); padding-right: 0.04em;
}
.lede { margin-top: 1.6rem; font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem); line-height: 1.6; color: var(--ink-2); max-width: 54ch; }
.cta { margin-top: 2.2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

/* Figure: the isometric platform, built by hero.js into .fig-stage. */
.fig { margin: 0; position: relative; }
html:not(.js) .fig { display: none; }
.fig-head, .fig-foot { font: 500 0.7rem/1.5 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.fig-head { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.fig-head span:first-child { color: var(--ink); }
.fig-stage { aspect-ratio: 480 / 650; max-height: min(74vh, 660px); margin-inline: auto; perspective: 1100px; }
.fig-stage svg {
  width: 100%; height: 100%; overflow: visible;
  transform: rotateX(calc(var(--py, 0) * -2.5deg)) rotateY(calc(var(--px, 0) * 3.5deg));
  transition: transform 0.5s var(--ease);
}
.fig-foot { border-top: 1px solid var(--line); padding-top: 0.8rem; display: grid; gap: 0.7rem; }
.fig-caption {
  min-height: 3.2em; font: 400 0.92rem/1.5 var(--font-body); letter-spacing: 0; text-transform: none; color: var(--ink-2);
  transition: opacity 0.25s;
}
.fig-caption.swap { opacity: 0; }
.fig-caption b { font: 500 0.7rem/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-right: 0.6rem; }
.fig-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; }
.fig-stats div { display: flex; gap: 0.5rem; align-items: baseline; }
.fig-stats dd { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2ch; }
.fig-stats .key { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 0.1rem; }
.key-gov { background: var(--accent); } .key-deny { background: var(--deny); } .key-raw { background: var(--flow); }

/* Isometric scene parts */
.iso text { font-family: var(--font-mono); font-weight: 500; }
.iso .top { fill: url(#plate-grad); stroke: var(--plate-edge); stroke-width: 1; stroke-linejoin: round; transition: fill 0.35s; }
.iso .side-l { fill: var(--plate-l); stroke: var(--plate-edge); stroke-width: 1; stroke-linejoin: round; }
.iso .side-r { fill: var(--plate-r); stroke: var(--plate-edge); stroke-width: 1; stroke-linejoin: round; }
.iso .inset { fill: none; stroke: var(--plate-edge); stroke-opacity: 0.35; stroke-width: 1; }
.iso .shadow { fill: var(--plate-shadow); filter: url(#soft); }
.iso .tint { fill: var(--accent); opacity: 0; transition: opacity 0.35s; pointer-events: none; }
.iso .label { font-size: 11.5px; letter-spacing: 0.14em; fill: var(--ink-2); transition: fill 0.35s; pointer-events: none; }
.iso .plate { cursor: pointer; transition: transform 0.45s var(--ease); }
.iso .plate.on { transform: translateY(-5px); }
.iso .plate.on .tint { opacity: 0.16; }
.iso .plate.on .label { fill: var(--ink); }
.iso .plate.outside .top, .iso .plate.outside .side-l, .iso .plate.outside .side-r { stroke-dasharray: 3 3; }
.iso .tile-top { fill: var(--plate-hi); stroke: var(--plate-edge); stroke-width: 0.8; }
.iso .tile-side { fill: var(--plate-r); stroke: var(--plate-edge); stroke-width: 0.8; }
.iso .pipe { stroke: var(--plate-edge); stroke-width: 1; stroke-dasharray: 1 4; stroke-linecap: round; }
.iso .pkt .halo { opacity: 0.22; }
.iso .pkt.raw { fill: var(--flow); }
.iso .pkt.gov { fill: var(--accent); }
.iso .pkt.deny { fill: var(--deny); }
.iso .perimeter { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 5 5; stroke-linecap: round; }
.iso path.perimeter { animation: perimeter 1.6s linear infinite; }
@keyframes perimeter { to { stroke-dashoffset: -10; } }
.iso .perimeter-label { font-size: 9.5px; letter-spacing: 0.16em; fill: var(--ink-3); }
.iso .egress { stroke: var(--ink-3); stroke-width: 1; }
.iso .egress-out { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 4; }
.iso .net-label { font-size: 9.5px; letter-spacing: 0.16em; fill: var(--ink-3); }
.iso .gate circle { fill: var(--bg); stroke: var(--deny); stroke-width: 1.2; }
.iso .gate path { stroke: var(--deny); stroke-width: 1.4; stroke-linecap: round; }
.iso .gate { transform-box: fill-box; transform-origin: center; cursor: pointer; }
.iso .gate.hit { animation: gate-hit 0.6s var(--ease); }
.iso .gate.on circle { fill: var(--deny); }
.iso .gate.on path { stroke: var(--bg); }
.iso .enter { animation: plate-in 0.9s var(--ease) both; }
.iso .d1 { animation-delay: 0.08s; } .iso .d2 { animation-delay: 0.16s; } .iso .d3 { animation-delay: 0.24s; }
.iso .d4 { animation-delay: 0.32s; } .iso .d5 { animation-delay: 0.5s; }
.iso .fade { animation: fade-in 1s ease 0.6s both; }
#plate-grad .g0 { stop-color: var(--plate-hi); }
#plate-grad .g1 { stop-color: var(--plate); }
@keyframes plate-in { from { opacity: 0; transform: translateY(-34px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes gate-hit { 30% { transform: scale(1.55); } }

/* Spec strip under the hero */
.specs {
  margin-top: clamp(2.5rem, 5vw, 4rem);
  display: grid; grid-template-columns: 1.25fr 1.35fr 1.2fr 1.2fr 0.8fr;
  border-block: 1px solid var(--line);
}
.specs div { padding: 1.15rem 1.25rem 1.25rem; border-left: 1px solid var(--line); }
.specs div:first-child { border-left: 0; padding-left: 0; }
.specs dt { font: 500 0.68rem/1.4 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.specs dd { margin-top: 0.4rem; font-size: 0.93rem; line-height: 1.45; color: var(--ink); font-weight: 500; text-wrap: balance; }

/* Sections --------------------------------------------------------------- */
section { padding-block: clamp(4.5rem, 9vw, 8rem); }
.hero { padding-bottom: 0; }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.9rem 2rem; align-items: end; margin-bottom: clamp(2rem, 4vw, 3.25rem); }
.kicker {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 0.8rem;
  font: 500 0.74rem/1.4 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.kicker .num { color: var(--accent); }
.kicker::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-head h2 { font-size: clamp(2rem, 1.2rem + 3vw, 3.4rem); letter-spacing: -0.04em; max-width: 22ch; }
.section-head h2 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 1.08em; letter-spacing: -0.02em; }
.section-head .sub { grid-column: 1; color: var(--ink-2); max-width: 56ch; font-size: 1.05rem; }
.section-head .more { font-weight: 500; font-size: 0.95rem; text-decoration: none; white-space: nowrap; color: var(--ink-2); padding-bottom: 0.35rem; }
.section-head .more:hover { color: var(--accent); }
.band { background: var(--bg-2); border-block: 1px solid var(--line); }

/* Browser frame around a screenshot */
.browser {
  position: relative; display: block; text-decoration: none; overflow: hidden;
  border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: transform 0.6s var(--ease), box-shadow 0.6s;
}
.browser-bar {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.browser-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); }
.browser-url {
  margin-left: 0.6rem; flex: 1; min-width: 0; padding: 0.22rem 0.7rem; border-radius: 7px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  font: 400 0.7rem/1.5 var(--font-mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browser img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; transition: transform 0.9s var(--ease); }
.browser-cta {
  position: absolute; right: 1rem; bottom: 1rem; padding: 0.6rem 0.95rem; border-radius: 11px;
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 600; font-size: 0.88rem;
  box-shadow: var(--shadow-2); opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s, transform 0.35s var(--ease);
}
a.browser:hover img { transform: scale(1.03); }
a.browser:hover .browser-cta { opacity: 1; transform: none; }

/* Featured work */
.feature { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(1.75rem, 4vw, 4rem); align-items: center; }
.feature-shot { perspective: 1600px; }
.feature .browser { transform: rotateY(7deg) rotateX(2deg); transform-origin: left center; }
.feature:hover .browser { transform: none; }
.feature-body { display: flex; flex-direction: column; gap: 1.1rem; }
.feature-body h3 { font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.3rem); letter-spacing: -0.035em; line-height: 1.08; }
.feature-body h3 a, .card h3 a { text-decoration: none; }
.feature-body > p { color: var(--ink-2); }
.steps { display: grid; border-top: 1px solid var(--line); }
.steps li { display: grid; grid-template-columns: 2.4rem 1fr; align-items: baseline; padding: 0.7rem 0; border-bottom: 1px solid var(--line); font-size: 0.97rem; }
.steps li span { font: 500 0.72rem/1 var(--font-mono); letter-spacing: 0.08em; color: var(--accent); }
.feature-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; }
.note { margin-top: 2.5rem; color: var(--ink-3); font-size: 0.92rem; }

/* Practice: pattern cards with a schematic each */
.patterns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.pattern {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform 0.45s var(--ease), box-shadow 0.45s, border-color 0.3s;
}
.pattern:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
/* Soft light that follows the pointer (--mx/--my set by main.js). */
.spot::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s;
  background: radial-gradient(22rem circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--ink) 7%, transparent), transparent 62%);
}
.spot:hover::before { opacity: 1; }
.pattern > * { position: relative; z-index: 1; }
.pattern-fig { margin: 0.6rem 0.6rem 0; padding: 1.5rem 1.25rem; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.pattern-fig svg { width: 100%; height: auto; }
.pattern-body { padding: 1.4rem 1.6rem 1.7rem; display: grid; gap: 0.6rem; }
.pattern-k { font: 500 0.7rem/1.4 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); }
.pattern-k span { color: var(--accent); }
.pattern h3 { font-size: 1.45rem; letter-spacing: -0.03em; }
.pattern p:not(.pattern-k) { color: var(--ink-2); font-size: 1rem; }
.pattern-wide { grid-column: 1 / -1; flex-direction: row; align-items: center; }
.pattern-wide .pattern-body { grid-template-columns: 14rem 1fr; align-items: baseline; gap: 0.6rem 2rem; width: 100%; }
.pattern-wide .pattern-k { grid-column: 1 / -1; }

/* Schematics (inline SVG in the pattern cards) */
.sch text { font: 500 9px var(--font-mono); letter-spacing: 0.08em; fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }
.sch .n { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; }
.sch .n-key { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.sch .t-key { fill: var(--accent); }
.sch .n-ghost { fill: none; stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 3; }
.sch .t-dim { fill: var(--ink-3); }
.sch .ta-s { text-anchor: start; }
.sch .w { fill: none; stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 3 3; }
.sch .ah { fill: var(--ink-3); }
.sch .w-x { fill: none; stroke: var(--deny); stroke-width: 1.2; stroke-dasharray: 2 3; }
.sch .x circle { fill: var(--bg-2); stroke: var(--deny); stroke-width: 1.2; }
.sch .x path { stroke: var(--deny); stroke-width: 1.4; stroke-linecap: round; }
.sch .bar-bg { fill: color-mix(in srgb, var(--ink) 8%, transparent); }
.sch .bar { fill: var(--ink-3); }
.sch .bar-key { fill: var(--accent); }
.sch .dot { fill: var(--ink-3); }
.pattern:hover .sch .w { animation: march 0.7s linear infinite; }
@keyframes march { to { stroke-dashoffset: -6; } }

/* Skills as a layered stack */
.stack { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1); }
.stack-row {
  position: relative; display: grid; grid-template-columns: 6.5rem minmax(0, 15rem) minmax(0, 1fr); gap: 1rem 1.5rem; align-items: center;
  padding: 1.5rem 1.75rem; border-top: 1px solid var(--line); transition: background 0.3s;
}
.stack-row:first-child { border-top: 0; }
.stack-row:hover { background: var(--surface-2); }
.stack-row .lvl { display: flex; align-items: center; gap: 0.8rem; font: 500 0.74rem/1 var(--font-mono); letter-spacing: 0.1em; color: var(--ink-3); transition: color 0.3s; }
.glyph { width: 40px; height: 40px; flex: none; }
.glyph .gl { fill: var(--surface-2); stroke: var(--line-2); stroke-width: 1; stroke-linejoin: round; }
.glyph .gl-on { fill: var(--accent); stroke: var(--accent); stroke-width: 1; stroke-linejoin: round; }
.stack-row:hover .lvl { color: var(--accent); }
.stack-row h3 { font-size: 1.3rem; letter-spacing: -0.025em; }
.stack-row .tag { transition: background 0.3s, color 0.3s, transform 0.3s var(--ease); }
.stack-row:hover .tag { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.stack-row .tag:hover { transform: translateY(-2px); }

/* Experience ------------------------------------------------------------- */
.wave { margin-bottom: clamp(2rem, 4vw, 3rem); color: var(--ink-3); }
.wave svg { width: 100%; height: auto; overflow: visible; }
.wave .sig { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.wave .stem { stroke: var(--accent); stroke-width: 1.2; }
.wave .smp { fill: var(--accent); }
.wave .axis { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 4; }
.wave text { font: 500 9px var(--font-mono); letter-spacing: 0.14em; fill: var(--ink-3); }
.timeline { display: grid; }
.role { position: relative; display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 2rem; padding-block: 2rem; border-top: 1px solid var(--line); }
.role:last-child { border-bottom: 1px solid var(--line); }
.role .when { font: 500 0.82rem/1.5 var(--font-mono); letter-spacing: 0.04em; color: var(--ink-3); padding-top: 0.3rem; }
.role .when b { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); margin-right: 0.7rem; vertical-align: 1px; }
.role.current .when b { background: var(--accent); }
.role h3 { font-size: clamp(1.3rem, 1rem + 1vw, 1.7rem); letter-spacing: -0.03em; }
.role .where { color: var(--ink-2); margin-top: 0.45rem; font-size: 0.98rem; }
.role ul { margin-top: 1rem; display: grid; gap: 0.5rem; color: var(--ink-2); max-width: 68ch; }
.role li { padding-left: 1.2rem; position: relative; }
.role li::before { content: ""; position: absolute; left: 0; top: 0.72em; width: 7px; height: 1px; background: var(--ink-3); }
.role li strong { color: var(--ink); font-weight: 600; }
.role .role-note { margin-top: 1rem; color: var(--ink-2); max-width: 68ch; }

/* Contact and footer ----------------------------------------------------- */
.contact { position: relative; text-align: center; overflow: hidden; isolation: isolate; }
.contact::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38rem 22rem at 50% 110%, var(--glow-1), transparent 70%),
    repeating-radial-gradient(circle at 50% 120%, transparent 0 95px, var(--rings) 95px 96px);
}
.contact .kicker { justify-content: center; }
.contact .kicker::after { display: none; }
.contact h2 { margin-top: 1.2rem; font-size: clamp(2.2rem, 1rem + 4.6vw, 4.4rem); letter-spacing: -0.045em; line-height: 1; }
.contact h2 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 1.08em; letter-spacing: -0.02em; color: var(--accent); }
.contact p:not(.kicker) { color: var(--ink-2); margin: 1.4rem auto 0; max-width: 52ch; font-size: 1.1rem; }
.contact .cta { justify-content: center; }
.site-footer { border-top: 1px solid var(--line); padding-block: 1.6rem; color: var(--ink-3); font: 400 0.74rem/1.6 var(--font-mono); letter-spacing: 0.04em; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 0.5rem 1.5rem; flex-wrap: wrap; }

/* Projects gallery ------------------------------------------------------- */
.page { position: relative; isolation: isolate; }
.page > .hero-bg { bottom: auto; height: 46rem; }
.page > .hero-bg::after { display: none; }
.page-head { position: relative; padding-block: clamp(3rem, 7vw, 5.5rem) 2rem; }
.page-head h1 { margin-top: 1.2rem; font-size: clamp(2.6rem, 1.2rem + 5vw, 4.6rem); letter-spacing: -0.045em; line-height: 1; }
.page-head h1 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 1.08em; letter-spacing: -0.02em; color: var(--accent); }
.page-head p:not(.eyebrow) { margin-top: 1.3rem; color: var(--ink-2); max-width: 58ch; font-size: 1.12rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.75rem; }
.chip {
  font: inherit; font-size: 0.88rem; font-weight: 500; padding: 0.45rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1.5rem; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow 0.45s, transform 0.45s var(--ease), border-color 0.3s;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-4px); border-color: var(--line-2); }
.card > * { position: relative; z-index: 1; }
.card .browser { margin: 0.6rem 0.6rem 0; border-radius: 14px; box-shadow: none; }
.card-body { padding: 1.4rem 1.6rem 1.6rem; display: flex; flex-direction: column; gap: 0.85rem; flex: 1; }
.card h3 { font-size: 1.4rem; letter-spacing: -0.03em; line-height: 1.12; }
.card p { color: var(--ink-2); font-size: 0.98rem; }
.card .feature-actions { margin-top: auto; padding-top: 0.5rem; }
.grid.single { grid-template-columns: minmax(0, 1fr); }
.grid.single .card { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
.grid.single .card .browser { margin: 0.6rem; }
.grid.single .card-body { padding: 2rem 2.25rem; }
.grid.single .card h3 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); }

/* Viewer ----------------------------------------------------------------- */
.viewer-page { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-bar {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 1rem; padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--surface); min-height: 54px;
}
.viewer-bar a {
  font-size: 0.88rem; font-weight: 500; text-decoration: none; white-space: nowrap; color: var(--ink-2);
  padding: 0.4rem 0.75rem; border-radius: 9px; border: 1px solid var(--line-2); transition: color 0.2s, background 0.2s;
}
.viewer-bar a:hover { color: var(--ink); background: var(--surface-2); }
.viewer-bar .title { font: 600 1rem/1.2 var(--font-display); letter-spacing: -0.015em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.viewer-bar .title::before { content: "Live demo"; font: 500 0.66rem/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--flow); margin-right: 0.8rem; vertical-align: 1px; }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.viewer-msg { margin: auto; text-align: center; padding: 2rem; color: var(--ink-2); }

/* 404 -------------------------------------------------------------------- */
.nf { min-height: 100dvh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 0; padding-block: 4rem; }
.nf .eyebrow { justify-content: center; color: var(--deny); }
.nf h1 { margin-top: 1.2rem; font-size: clamp(2.4rem, 1rem + 5vw, 4.4rem); letter-spacing: -0.045em; line-height: 1; }
.nf h1 em { font-family: var(--font-serif); font-style: italic; font-weight: 400; font-size: 1.08em; letter-spacing: -0.02em; }
.nf > p:not(.eyebrow) { margin-top: 1.3rem; color: var(--ink-2); font-size: 1.1rem; }
.nf .cta { justify-content: center; }

/* Command menu ----------------------------------------------------------- */
.palette {
  width: min(92vw, 560px); margin: 14vh auto auto; padding: 0; border: 1px solid var(--line-2); border-radius: 18px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); overflow: hidden;
}
.palette::backdrop { background: hsl(224 30% 4% / 0.6); }
.palette[open] { animation: palette-in 0.25s var(--ease); }
@keyframes palette-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } }
.palette-input {
  width: 100%; padding: 1.05rem 1.25rem; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  font: inherit; font-size: 1.05rem; color: var(--ink); outline: none;
}
.palette-input::placeholder { color: var(--ink-3); }
.palette-list { max-height: min(60vh, 440px); overflow: auto; padding: 0.4rem; }
.palette-item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.7rem 0.85rem; border-radius: 10px;
  cursor: pointer; font-size: 0.97rem;
}
.palette-item small { font: 500 0.66rem/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.palette-item[aria-selected="true"] { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.palette-item[aria-selected="true"] small { color: var(--accent); }
.palette-empty { padding: 1.2rem 0.85rem; color: var(--ink-3); font-size: 0.95rem; }
.palette-foot { display: flex; gap: 1.2rem; padding: 0.65rem 1.25rem; border-top: 1px solid var(--line); font: 500 0.66rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

/* Motion ----------------------------------------------------------------- */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.reveal.r1 { transition-delay: 0.08s; } .reveal.r2 { transition-delay: 0.16s; } .reveal.r3 { transition-delay: 0.24s; }
.rise { animation: rise 0.9s var(--ease) both; }
.rise.r1 { animation-delay: 0.08s; } .rise.r2 { animation-delay: 0.16s; } .rise.r3 { animation-delay: 0.24s; } .rise.r4 { animation-delay: 0.4s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  .feature .browser { transform: none; }
  .fig-stats { display: none; } /* the counters only make sense while packets move */
}

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .fig { max-width: 520px; width: 100%; margin-inline: auto; }
  .fig-stage { max-height: none; }
  .feature, .grid.single .card { grid-template-columns: minmax(0, 1fr); }
  .feature .browser { transform: none; }
  .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .specs div { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .specs div:nth-child(-n+2) { border-top: 0; }
  .specs div:nth-child(even) { padding-left: 1.25rem; border-left: 1px solid var(--line); }
  .specs div:last-child { grid-column: 1 / -1; }
  .stack-row { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .stack-row .tags { grid-column: 2; }
  .grid.single .card .browser { margin: 0.6rem 0.6rem 0; }
  .grid.single .card-body { padding: 1.4rem 1.6rem 1.6rem; }
}
@media (max-width: 760px) {
  .patterns { grid-template-columns: minmax(0, 1fr); }
  .pattern-wide .pattern-body { grid-template-columns: minmax(0, 1fr); }
  .section-head { grid-template-columns: minmax(0, 1fr); }
  .role { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
  #palette-open { display: none; }
}
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .nav-links a.opt { display: none; }
  .nav-links a { padding-inline: 0.55rem; }
  .brand-name { display: none; }
  .hero h1 { letter-spacing: -0.04em; }
  .pattern-fig { padding: 1.1rem 0.75rem; }
  .pattern-body { padding: 1.2rem 1.25rem 1.4rem; }
  .stack-row { grid-template-columns: minmax(0, 1fr); padding: 1.25rem; gap: 0.6rem; }
  .stack-row .tags { grid-column: 1; }
  .viewer-bar .title { display: none; }
  .viewer-bar { justify-content: space-between; }
}

/* Utilities -------------------------------------------------------------- */
.flush-top { padding-top: 0; }
.tight-top { padding-top: 0.5rem; }
