/* ==========================================================================
   haoranzhu.com — hand-written, no framework.
   Palette is sampled from the portrait: warm black, bone, camel, vermilion.
   Motion is opt-in via html[data-motion="on"], which defaults to the user's
   prefers-reduced-motion setting and can be toggled on the page.
   ========================================================================== */

@font-face { font-family: "Anybody"; src: url("/static/fonts/anybody-var.woff2") format("woff2"); font-weight: 100 900; font-stretch: 50% 150%; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("/static/fonts/archivo-var.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("/static/fonts/fraunces-italic-var.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/jetbrains-mono-var.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --ink: #141413;
  --ink-2: #1d1c1a;
  --ink-3: #2a2825;
  --bone: #efe9df;
  --camel: #c9a47e;
  --red: #ea4a2e;

  --bg: var(--ink);
  --fg: var(--bone);
  --accent: var(--red);

  --pad: clamp(1rem, 3.4vw, 3.25rem);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --expo: cubic-bezier(.16, 1, .3, 1);

  --f-display: "Anybody", "Archivo", "Arial Narrow", sans-serif;
  --f-text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

.theme-bone { --bg: var(--bone); --fg: var(--ink); --accent: var(--red); }
.theme-red { --bg: var(--red); --fg: var(--ink); --accent: var(--bone); }
.theme-camel { --bg: var(--camel); --fg: var(--ink); --accent: #a02812; }
.theme-ink { --bg: var(--ink-2); --fg: var(--bone); --accent: var(--red); }

:root, [class*="theme-"] {
  --dim: color-mix(in oklab, var(--fg) 64%, var(--bg));
  --line: color-mix(in oklab, var(--fg) 17%, transparent);
  --wash: color-mix(in oklab, var(--fg) 6%, transparent);
}
[class*="theme-"] { background: var(--bg); color: var(--fg); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5rem; background: var(--ink); }
html[data-motion="on"] { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 1.0625rem/1.55 var(--f-text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: clip; }
body::after { content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none; background: url("/static/img/grain.png"); background-size: 96px; opacity: .045; }
img, svg, canvas { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
em { font-family: var(--f-serif); font-style: italic; font-weight: 300; letter-spacing: -.01em; }
::selection { background: var(--red); color: var(--ink); }
.theme-red ::selection { background: var(--ink); color: var(--bone); }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 2px; }

.mono { font: 500 .75rem/1.45 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; top: .75rem; left: .75rem; z-index: 200; padding: .6rem 1rem; background: var(--bone); color: var(--ink); border-radius: 999px; font-weight: 600; translate: 0 -200%; }
.skip:focus { translate: 0 0; }
.i { width: 1em; height: 1em; flex: none; }
.i--up { rotate: 180deg; }

/* ---------- shared pieces ---------- */
.eyebrow { display: flex; align-items: center; gap: .9rem; color: var(--dim); }
.eyebrow .idx { display: inline-grid; place-items: center; min-width: 2.1rem; padding: .2rem .45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--fg); }

.sec-head { display: grid; gap: 1.5rem; padding: 0 var(--pad); margin-bottom: clamp(2.5rem, 6vw, 5rem); }
.sec-title, .contact__title { font-family: var(--f-display); font-weight: 900; font-stretch: 68%; text-transform: uppercase; line-height: .86; letter-spacing: -.012em; font-size: clamp(3.75rem, 1.25rem + 11.5vw, 13rem); text-wrap: balance; }
.sec-lede { max-width: 34rem; font-size: 1.1875rem; color: var(--dim); text-wrap: pretty; }
.l, .hl { display: block; overflow: clip; padding-block: .09em; margin-block: -.09em; }
.l > span, .hl > span { display: block; }

.btn { display: inline-flex; align-items: center; gap: .65rem; padding: .95rem 1.45rem; border-radius: 999px; border: 1px solid var(--fg); font-weight: 600; font-size: .9375rem; line-height: 1.2; transition: background-color .3s, color .3s, border-color .3s; }
.btn--solid { background: var(--fg); color: var(--bg); }
.btn--solid:hover { background: var(--red); border-color: var(--red); color: var(--ink); }
.btn--ink { background: var(--ink); border-color: var(--ink); color: var(--bone); }
.btn--ink:hover { background: var(--red); border-color: var(--red); color: var(--ink); }

.link { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; padding-bottom: .15rem; background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; transition: background-size .5s var(--expo); }
.link:hover { background-size: 0 1px; background-position: 100% 100%; }
.link .i { transition: translate .4s var(--expo); }
.link:hover .i { translate: .15em -.15em; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tags li { font: 500 .6875rem/1.3 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; padding: .35rem .65rem; border: 1px solid var(--line); border-radius: 999px; }


.motion-toggle { display: inline-flex; align-items: center; gap: .5rem; font: 500 .75rem/1.45 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px; }
.motion-toggle::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; border: 1px solid currentColor; }
.motion-toggle[aria-pressed="true"]::before { background: currentColor; }
.motion-toggle::after { content: "off"; }
.motion-toggle[aria-pressed="true"]::after { content: "on"; }

/* ---------- progress ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60; background: var(--red); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
@supports (animation-timeline: scroll()) {
  html[data-motion="on"] .progress { animation: grow-x auto linear both; animation-timeline: scroll(root); }
}
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- nav ---------- */
.nav { position: fixed; top: .875rem; left: 50%; translate: -50% 0; z-index: 50; display: flex; align-items: center; gap: .125rem; padding: .3125rem; border-radius: 999px; background: color-mix(in oklab, var(--ink) 74%, transparent); -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5); border: 1px solid rgb(239 233 223 / .14); color: var(--bone); font-size: .875rem; font-weight: 500; white-space: nowrap; transition: translate .6s var(--expo); }
.nav.is-hidden:not(:focus-within) { translate: -50% calc(-100% - 1.5rem); }
.nav__logo { display: inline-flex; align-items: center; gap: .55rem; padding: .5rem .9rem .5rem .6rem; font-weight: 700; letter-spacing: -.01em; }
.nav__mark { width: 1.25rem; height: 1.25rem; }
.nav__links { display: flex; }
.nav__links a { padding: .5rem .8rem; border-radius: 999px; color: rgb(239 233 223 / .72); transition: color .25s, background-color .25s; }
.nav__links a:hover, .nav__links a[aria-current="true"] { color: var(--bone); background: rgb(239 233 223 / .1); }
.nav__cta { margin-left: .375rem; padding: .5rem 1rem; border-radius: 999px; background: var(--bone); color: var(--ink); font-weight: 650; transition: background-color .25s; }
.nav__cta:hover { background: var(--red); }
.nav__menu { display: none; padding: .5rem 1rem; border-radius: 999px; background: var(--bone); color: var(--ink); font-weight: 650; }
@media (max-width: 52rem) {
  .nav { left: var(--pad); right: var(--pad); translate: none; justify-content: space-between; }
  .nav.is-hidden:not(:focus-within) { translate: 0 calc(-100% - 1.5rem); }
  .nav__links, .nav__cta { display: none; }
  .nav__menu { display: block; }
}

.menu { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 1.25rem var(--pad) 2rem; border: 0; background: var(--ink); color: var(--bone); opacity: 0; transition-property: opacity, display, overlay; transition-duration: .25s; transition-timing-function: ease-out; transition-behavior: allow-discrete; }
.menu[open] { display: grid; grid-template-rows: auto 1fr auto; opacity: 1; }
@starting-style { .menu[open] { opacity: 0; } }
.menu::backdrop { background: var(--ink); }
.menu__bar { display: flex; justify-content: space-between; align-items: center; color: rgb(239 233 223 / .6); }
.menu__close { padding: .5rem 1rem; border-radius: 999px; background: var(--bone); color: var(--ink); font-weight: 650; font-size: .875rem; }
.menu__links { display: grid; align-content: center; }
.menu__links a { display: flex; align-items: baseline; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid rgb(239 233 223 / .14); font: 900 clamp(2.75rem, 15vw, 5rem)/1 var(--f-display); font-stretch: 62%; text-transform: uppercase; }
.menu__links a span { color: var(--red); }
html[data-motion="on"] .menu[open] .menu__links a { animation: rise .7s var(--expo) both; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(1) { animation-delay: 40ms; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(2) { animation-delay: 80ms; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(3) { animation-delay: 120ms; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(4) { animation-delay: 160ms; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(5) { animation-delay: 200ms; }
html[data-motion="on"] .menu[open] .menu__links a:nth-child(6) { animation-delay: 240ms; }
@keyframes rise { from { opacity: 0; translate: 0 1.5rem; } }
.menu__foot { color: rgb(239 233 223 / .6); text-transform: none; }

/* ---------- hero ---------- */
.hero { position: relative; isolation: isolate; min-height: 100svh; display: grid; grid-template-rows: auto 1fr auto; padding: 5.75rem var(--pad) 0; overflow: clip; }
.hero > * { min-width: 0; }
.hero__field { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.hero__top { display: flex; justify-content: space-between; gap: 1rem; color: var(--dim); }
.hero__loc { text-align: right; }
.hero__mid { align-self: center; max-width: 46rem; padding-block: 2rem; }
.hero__line { font: 560 clamp(2.5rem, 1.1rem + 5.4vw, 6rem)/.98 var(--f-text); font-stretch: 84%; letter-spacing: -.035em; }
.hero__line em { color: var(--camel); letter-spacing: -.03em; }
.hero__sub { max-width: 31rem; margin-top: 1.5rem; font-size: 1.125rem; color: var(--dim); text-wrap: pretty; }
.hero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; margin-top: 2rem; }
.hero__name { position: relative; margin-inline: -.02em; padding-bottom: .05em; font-family: var(--f-display); font-weight: 900; font-stretch: 78%; font-size: clamp(4rem, 21vw, 32rem); line-height: .76; text-transform: uppercase; white-space: nowrap; -webkit-user-select: none; user-select: none; }
.hero__name .line { display: inline-block; }
.hero__name .line + .line { margin-left: .14em; }
.hero__name.is-stacked .line { display: block; width: max-content; margin-left: 0; }
.hero__name.is-stacked { line-height: .8; }
.hero__name .ch { display: inline-block; }

.hud { position: absolute; right: var(--pad); top: 50%; translate: 0 -62%; width: 17.5rem; padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--line); border-radius: .75rem; background: color-mix(in oklab, var(--ink) 62%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); text-transform: none; letter-spacing: 0; color: var(--dim); }
.hud__title { display: flex; justify-content: space-between; align-items: center; padding-bottom: .7rem; margin-bottom: .6rem; border-bottom: 1px solid var(--line); color: var(--fg); }
.hud__live { display: inline-flex; align-items: center; gap: .4rem; color: var(--red); text-transform: uppercase; letter-spacing: .08em; font-size: .6875rem; }
.hud__live::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: var(--red); }
html[data-motion="on"] .hud__live::before { animation: blink 1.6s steps(2, jump-none) infinite; }
@keyframes blink { to { opacity: .25; } }
.hud dl > div { display: flex; justify-content: space-between; padding: .16rem 0; }
.hud dd { color: var(--fg); font-variant-numeric: tabular-nums; }
.hud .is-hot dt, .hud .is-hot dd { color: var(--red); }
.hud__hint { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .6875rem; line-height: 1.5; }
@media (max-width: 68rem), (hover: none) { .hud { display: none; } }
@media (max-width: 40rem) { .hero { padding-top: 5.25rem; } .hero__mid { padding-block: 1.5rem 2.5rem; } }
@media (max-height: 48rem) and (min-width: 60rem) { .hero__mid { padding-block: 1rem; } .hero__sub { margin-top: 1rem; } .hero__actions { margin-top: 1.25rem; } }

/* ---------- profile ---------- */
.profile { padding: clamp(5rem, 14vw, 12rem) var(--pad) clamp(4rem, 9vw, 8rem); display: grid; gap: clamp(2rem, 4vw, 3.5rem); }
.statement { max-width: 22em; font: 520 clamp(1.875rem, 1rem + 3.4vw, 4.25rem)/1.08 var(--f-text); font-stretch: 86%; letter-spacing: -.028em; text-wrap: pretty; }
.statement b { font: italic 300 1em/1 var(--f-serif); letter-spacing: -.02em; color: var(--camel); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); margin-top: clamp(1rem, 3vw, 3rem); }
.stats li { display: grid; gap: .6rem; align-content: start; padding: 1.5rem 1.5rem 0 0; }
.stats li + li { padding-left: 1.5rem; border-left: 1px solid var(--line); }
.stat__n { font: 900 clamp(3rem, 1.5rem + 5vw, 6.5rem)/.85 var(--f-display); font-stretch: 62%; font-variant-numeric: tabular-nums; }
.stat__l { max-width: 13rem; font-size: .9375rem; line-height: 1.35; color: var(--dim); }
@media (max-width: 46rem) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats li { padding: 1.25rem 1rem 1.5rem 0; }
  .stats li + li { padding-left: 0; border-left: 0; }
  .stats li:nth-child(even) { padding-left: 1rem; border-left: 1px solid var(--line); }
  .stats li:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- stack band ---------- */
.band { padding-block: clamp(1rem, 3vw, 2.5rem) clamp(4rem, 10vw, 9rem); overflow: clip; }
.band__row { width: max-content; font: 900 clamp(3.5rem, 1.5rem + 9vw, 10rem)/.92 var(--f-display); text-transform: uppercase; white-space: nowrap; }
.band__row i { display: inline-block; width: .16em; height: .16em; margin: 0 .2em .28em; background: var(--red); vertical-align: middle; }
.band__row--a { font-stretch: 58%; color: transparent; -webkit-text-stroke: 1.5px var(--bone); }
.band__row--b { font-stretch: 112%; font-weight: 800; color: var(--camel); margin-left: -18vw; }

/* ---------- work ---------- */
/* ---------- now ---------- */
.now { display: grid; gap: clamp(1.75rem, 3.5vw, 3rem) clamp(1.5rem, 3vw, 3rem); padding: 0 var(--pad) clamp(5rem, 12vw, 11rem); }
.now__text { display: grid; gap: 1.5rem; align-content: start; }
.now__title { max-width: 13em; font: 520 clamp(2rem, 1.1rem + 3vw, 3.75rem)/1.04 var(--f-text); font-stretch: 86%; letter-spacing: -.028em; text-wrap: balance; }
.now__title em { display: block; font: italic 300 1em/1.04 var(--f-serif); letter-spacing: -.02em; color: var(--camel); }
.now__lede { max-width: 34rem; font-size: 1.1875rem; color: var(--dim); text-wrap: pretty; }
.now__list { border-top: 1px solid var(--line); margin-top: clamp(.5rem, 2vw, 1.5rem); }
.now__list li { display: grid; grid-template-columns: minmax(7rem, 10rem) 1fr; gap: 1rem; align-items: baseline; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.now__list .mono { color: var(--camel); }
.now__list p { text-wrap: pretty; }
.now__fig { min-width: 0; display: grid; border: 1px solid var(--line); border-radius: clamp(.75rem, 1.2vw, 1.125rem); background: var(--wash); overflow: clip; }
@media (min-width: 60rem) {
  .now { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .now > .eyebrow { grid-column: 1 / -1; }
  .now__text { grid-template-rows: auto auto 1fr; }
  .now__list { align-self: end; }
}
@media (max-width: 30rem) { .now__list li { grid-template-columns: 1fr; gap: .35rem; } }

.demo--agents { grid-template-rows: auto minmax(0, 1fr) auto auto; }
/* .demo.demo--agents so it outranks the generic .demo canvas rule further down. */
.demo.demo--agents canvas { min-height: 18rem; cursor: default; touch-action: auto; }
.agents__trace { display: grid; align-content: end; gap: .2rem; height: 6.6rem; padding: .7rem .9rem; border-top: 1px solid var(--line); font: 500 .75rem/1.45 var(--f-mono); color: var(--dim); overflow: hidden; }
.agents__trace li { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: .6rem; white-space: nowrap; }
.agents__trace span { overflow: hidden; text-overflow: ellipsis; }
.agents__trace b { font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.agents__trace li:last-child { color: var(--fg); }
.agents__trace li:last-child b { color: var(--accent); }
html[data-motion="on"] .agents__trace li { animation: rise .45s var(--expo) both; }
.agents__ctl { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .5rem; padding: .8rem .9rem .9rem; border-top: 1px solid var(--line); transition: background-color .5s; }
.is-waiting .agents__ctl { background: color-mix(in oklab, var(--camel) 9%, transparent); }
.agents__ask { flex: 1 1 15rem; min-height: 1.5em; font-weight: 550; text-wrap: pretty; }
.agents__ctl button { padding: .5rem .95rem; border: 1px solid var(--fg); border-radius: 999px; font-size: .875rem; font-weight: 550; transition: background-color .25s, color .25s, border-color .25s, opacity .25s; }
.agents__ctl button.is-primary { background: var(--fg); color: var(--bg); }
.agents__ctl button:hover:not(:disabled) { background: var(--red); border-color: var(--red); color: var(--ink); }
.agents__ctl button:disabled { opacity: .3; cursor: default; }
.agents__tally { flex-basis: 100%; min-height: 1lh; color: var(--dim); font-size: .6875rem; font-variant-numeric: tabular-nums; }

.work { padding-bottom: clamp(4rem, 9vw, 8rem); }
.work .sec-head { grid-template-columns: 1fr auto; align-items: end; }
.work .sec-head .eyebrow { grid-column: 1 / -1; }
@media (max-width: 60rem) { .work .sec-head { grid-template-columns: 1fr; } }

.projects { display: grid; gap: 1rem; padding: 0 clamp(.5rem, 1.6vw, 1.5rem); }
.project { border-radius: clamp(1rem, 2vw, 1.75rem); background: none; }
.project__inner { position: relative; display: grid; gap: 1.5rem; padding: clamp(1.25rem, 2.6vw, 2.5rem); border-radius: inherit; background: var(--bg); color: var(--fg); overflow: clip; transform-origin: 50% 0; }
.theme-ink .project__inner { border: 1px solid var(--line); }
.project__inner::after { content: ""; position: absolute; inset: 0; background: var(--ink); opacity: calc(var(--cover, 0) * .6); pointer-events: none; }
.project__info { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; container-type: inline-size; }
.project__idx { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.project__idx span { color: var(--dim); text-align: right; }
.project__title { margin-top: .5rem; font: 900 clamp(2.75rem, var(--ts, 14.5cqi), 11rem)/.86 var(--f-display); font-stretch: 60%; text-transform: uppercase; letter-spacing: -.01em; overflow-wrap: break-word; }
.project__kicker { font: 500 clamp(1.25rem, 1rem + 1vw, 1.75rem)/1.15 var(--f-text); font-stretch: 88%; letter-spacing: -.02em; }
.project__desc { max-width: 36rem; color: var(--dim); text-wrap: pretty; }
.project__links { display: flex; flex-wrap: wrap; gap: .75rem 1.75rem; margin-top: auto; padding-top: .75rem; }
.project__demo { min-width: 0; min-height: 24rem; display: grid; border-radius: clamp(.75rem, 1.2vw, 1.125rem); border: 1px solid var(--line); background: var(--wash); overflow: clip; }

@media (min-width: 60rem) {
  .project__inner { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(1.5rem, 3vw, 3rem); }
}
@media (min-width: 60rem) and (min-height: 42rem) {
  .project { position: sticky; top: calc(4.5rem + var(--i) * .875rem); }
  .project__inner { height: calc(100svh - 4.5rem - 3 * .875rem - 1.25rem); max-height: 52rem; scale: calc(1 - var(--cover, 0) * .05); }
  .project__demo { min-height: 0; }
}

/* demos */
.demo { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; min-width: 0; font-size: .9375rem; }
.demo__bar { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); color: var(--dim); font-size: .6875rem; }
.demo__bar span:first-child { color: var(--fg); }
.demo__bar span:last-child { text-align: right; }
/* contain: size stops the canvas's own pixel buffer from feeding back into layout. Without it, Safari
   treats height:100% as auto, sizes the row from the buffer, fitCanvas enlarges the buffer, and it runs away. */
.demo canvas { display: block; width: 100%; height: auto; align-self: stretch; contain: size; min-height: clamp(18rem, 46vw, 24rem); touch-action: pan-y; cursor: crosshair; }
.demo__read { padding: .7rem .9rem; border-top: 1px solid var(--line); min-height: 2.6rem; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.demo__read b { color: var(--accent); font-weight: 700; }

.demo--chat { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.chat__log { display: flex; flex-direction: column; gap: .7rem; padding: 1rem .9rem; overflow-y: auto; height: 23rem; scrollbar-width: thin; overscroll-behavior: contain; }
@media (min-width: 60rem) and (min-height: 42rem) { .chat__log { height: auto; } }
.chat__log > :first-child { margin-top: auto; }
.msg { max-width: 88%; padding: .65rem .85rem; border-radius: .9rem; line-height: 1.45; }
.msg--user { align-self: flex-end; background: var(--fg); color: var(--bg); border-bottom-right-radius: .25rem; }
.msg--bot { align-self: flex-start; border: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 60%, white); border-bottom-left-radius: .25rem; }
.msg--bot .who { display: block; margin-bottom: .25rem; font: 600 .6875rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.msg pre { margin: .55rem 0 .15rem; padding: .6rem .7rem; border-radius: .5rem; background: var(--ink); color: var(--bone); font: 400 .78rem/1.55 var(--f-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg code { font: 500 .85em var(--f-mono); }
.msg .caret { display: inline-block; width: .5em; height: 1em; margin-left: .1em; vertical-align: -.15em; background: var(--accent); }
html[data-motion="on"] .msg { animation: rise .5s var(--expo) both; }
.chat__memory { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; border-top: 1px solid var(--line); min-height: 2.5rem; color: var(--dim); font-size: .6875rem; }
.chat__chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chat__chips span { padding: .15rem .5rem; border-radius: 999px; background: var(--accent); color: var(--bone); text-transform: none; letter-spacing: 0; }
html[data-motion="on"] .chat__chips span { animation: pop .5s var(--expo) both; }
@keyframes pop { from { scale: .6; opacity: 0; } }
.chat__prompts { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem .9rem .9rem; border-top: 1px solid var(--line); }
.chat__prompts button { padding: .5rem .85rem; border: 1px solid var(--fg); border-radius: 999px; font-size: .875rem; font-weight: 550; text-align: left; transition: background-color .25s, color .25s, opacity .25s; }
.chat__prompts button:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
.chat__prompts button:disabled { opacity: .35; cursor: default; }

.demo--hash { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.hash__field { display: grid; gap: .35rem; padding: .9rem .9rem 1rem; border-bottom: 1px solid var(--line); }
.hash__field span { font-size: .6875rem; color: var(--dim); }
.hash__field input { width: 100%; padding: .1rem 0 .35rem; border: 0; border-bottom: 2px solid var(--fg); border-radius: 0; background: none; font: 600 clamp(1.05rem, .9rem + .6vw, 1.4rem)/1.3 var(--f-text); font-stretch: 88%; letter-spacing: -.01em; }
.hash__field input:focus-visible { outline: 0; border-bottom-color: var(--accent); }
.hash__table { display: grid; grid-auto-rows: minmax(2.35rem, 1fr); align-content: stretch; }
.hash__table > li { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); align-items: center; border-bottom: 1px solid var(--line); transition: background-color .5s; }
.hash__table > li.is-hit { background: color-mix(in oklab, var(--accent) 22%, transparent); transition-duration: 0s; }
.hash__table .slot { align-self: stretch; display: grid; place-items: center; border-right: 1px solid var(--line); font: 600 .75rem var(--f-mono); }
.hash__chain { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .1rem; padding: .3rem .7rem; min-width: 0; }
.hash__chain .node { display: inline-flex; align-items: center; gap: .35rem; padding: .16rem .5rem; border-radius: .35rem; background: var(--fg); color: var(--bg); font: 500 .78rem/1.3 var(--f-mono); }
.hash__chain .node sup { font-size: .68rem; opacity: .7; line-height: 1; }
.hash__chain .arr { margin: 0 .25rem; font: 500 .8rem var(--f-mono); }
.hash__chain .nil { font: 400 .72rem var(--f-mono); color: var(--dim); opacity: .7; }
html[data-motion="on"] .hash__chain .node { animation: pop .45s var(--expo) both; }
html[data-motion="on"] .hash__chain .node.is-bump { animation: bump .4s var(--ease); }
@keyframes bump { 40% { scale: 1.14; } }
.hash__stats { padding: .7rem .9rem; text-transform: none; letter-spacing: 0; min-height: 2.6rem; }

/* ---------- research ---------- */
.research { position: relative; overflow-x: clip; padding: clamp(4.5rem, 10vw, 9rem) var(--pad); display: grid; gap: clamp(2rem, 4vw, 3.5rem); }
.research__head { display: flex; justify-content: space-between; align-items: start; }
.stamp { position: relative; width: clamp(6.5rem, 12vw, 10.5rem); aspect-ratio: 1; margin: -1rem 0 -3rem; flex: none; color: var(--red); }
.stamp svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stamp text { font: 700 15.2px var(--f-mono); letter-spacing: .04em; fill: currentColor; }
.research__title { max-width: 19em; font: 600 clamp(1.875rem, 1rem + 3.9vw, 5rem)/1.02 var(--f-text); font-stretch: 80%; letter-spacing: -.03em; text-wrap: balance; }
.research__title em { letter-spacing: -.025em; }
.research__meta { display: grid; grid-template-columns: 2.2fr 1fr 2fr 1.4fr; border-top: 1px solid var(--line); }
.research__meta > div { display: grid; gap: .5rem; align-content: start; padding: 1.1rem 1.5rem 0 0; }
.research__meta dt { color: var(--dim); }
.research__meta dd { line-height: 1.4; }
.research__points { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2.5vw, 2.5rem); }
.research__points li { display: grid; gap: .9rem; align-content: start; padding: 1.25rem; border: 1px solid var(--line); border-radius: 1rem; }
.research__points span { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--ink); color: var(--bone); }
.research__points p { font-size: 1.125rem; line-height: 1.4; text-wrap: pretty; }
@media (max-width: 56rem) {
  .research__meta { grid-template-columns: 1fr 1fr; }
  .research__meta > div { padding-bottom: 1rem; }
  .research__points { grid-template-columns: 1fr; }
}
@media (max-width: 32rem) { .research__meta { grid-template-columns: 1fr; } }

/* ---------- experience ---------- */
.experience { padding: clamp(5rem, 11vw, 10rem) 0 clamp(3rem, 7vw, 6rem); }
.xp { border-top: 1px solid var(--line); }
.xp__row { border-bottom: 1px solid var(--line); }
.xp__head { position: relative; isolation: isolate; display: grid; grid-template-columns: 11rem minmax(0, 1.15fr) minmax(0, 1fr) 1.5rem; align-items: center; gap: 1.5rem; padding: clamp(1.1rem, 2.2vw, 1.9rem) var(--pad); list-style: none; transition: color .3s; }
.xp__head::-webkit-details-marker { display: none; }
summary.xp__head { cursor: pointer; }
.xp__head::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--bone); scale: 1 0; transform-origin: 50% 100%; transition: scale .5s var(--expo); }
.xp__when { color: var(--dim); transition: color .3s; }
.xp__org { font: 650 clamp(1.5rem, 1rem + 2.1vw, 3rem)/1 var(--f-text); font-stretch: 76%; letter-spacing: -.025em; transition: translate .5s var(--expo); }
.xp__role { color: var(--dim); line-height: 1.35; transition: color .3s; }
.xp__plus { position: relative; width: 1.1rem; height: 1.1rem; justify-self: end; }
.xp__plus::before, .xp__plus::after { content: ""; position: absolute; left: 0; top: 50%; width: 100%; height: 2px; margin-top: -1px; background: currentColor; transition: rotate .5s var(--expo); }
.xp__plus::after { rotate: 90deg; }
details[open] .xp__plus::after { rotate: 0deg; }
@media (hover: hover) {
  .xp__head:hover { color: var(--ink); }
  .xp__head:hover::before { scale: 1 1; }
  .xp__head:hover .xp__when, .xp__head:hover .xp__role { color: color-mix(in oklab, var(--ink) 70%, var(--bone)); }
  .xp__head:hover .xp__org { translate: .75rem 0; }
}
.xp__body { display: grid; gap: 1rem; padding: .25rem var(--pad) 2rem calc(var(--pad) + 12.5rem); max-width: 68rem; }
.xp__body ul { display: grid; gap: .5rem; }
.xp__body li { position: relative; padding-left: 1.25rem; color: var(--dim); text-wrap: pretty; }
.xp__body a { color: var(--fg, currentColor); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.xp__org a { text-decoration: none; }
.xp__org a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .12em; }
.xp__body li::before { content: ""; position: absolute; left: 0; top: .62em; width: .4rem; height: .4rem; background: var(--red); }
.xp__stack { color: var(--camel); text-transform: none; letter-spacing: 0; }
@supports (interpolate-size: allow-keywords) {
  html[data-motion="on"] { interpolate-size: allow-keywords; }
  html[data-motion="on"] .xp details::details-content { block-size: 0; overflow: clip; transition: block-size .6s var(--expo), content-visibility .6s; transition-behavior: allow-discrete; }
  html[data-motion="on"] .xp details[open]::details-content { block-size: auto; }
}
@media (max-width: 56rem) {
  .xp__head { grid-template-columns: minmax(0, 1fr) 1.5rem; gap: .4rem 1rem; }
  .xp__when, .xp__org, .xp__role { grid-column: 1; }
  .xp__plus { grid-column: 2; grid-row: 1 / span 3; }
  .xp__body { padding-left: var(--pad); }
}

/* ---------- about ---------- */
.about { padding: clamp(4rem, 9vw, 8rem) 0 clamp(5rem, 11vw, 10rem); }
.about__grid { display: grid; gap: clamp(2rem, 5vw, 5rem); padding: 0 var(--pad); }
@media (min-width: 60rem) {
  .about__grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .portrait { position: sticky; top: 5.5rem; }
}
.portrait__frame { position: relative; aspect-ratio: 1200 / 1261; border-radius: 1rem; overflow: clip; background: #141414; border: 1px solid var(--line); }
.portrait__frame img, .portrait__frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.portrait__frame canvas { opacity: 0; transition: opacity .6s; }
.portrait.is-live canvas { opacity: 1; }
.portrait.is-live.is-resolved canvas { opacity: 0; }
.portrait figcaption { display: flex; justify-content: space-between; gap: 1rem; margin-top: .8rem; color: var(--dim); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.about__text { display: grid; gap: 1.25rem; max-width: 42rem; }
.about__text > p { color: var(--dim); text-wrap: pretty; }
.about__text > .about__lead { color: var(--fg); font: 520 clamp(1.625rem, 1.1rem + 1.9vw, 2.75rem)/1.1 var(--f-text); font-stretch: 86%; letter-spacing: -.028em; margin-bottom: .5rem; text-wrap: balance; }
.caps { margin-top: 1.5rem; border-top: 1px solid var(--line); }
.caps li { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: 1rem; padding: 1.35rem 0; border-bottom: 1px solid var(--line); }
.caps li > span { color: var(--red); padding-top: .3rem; }
.caps h3 { font: 650 1.375rem/1.15 var(--f-text); font-stretch: 84%; letter-spacing: -.02em; margin-bottom: .4rem; }
.caps p { color: var(--dim); text-wrap: pretty; }
.kit { display: grid; gap: .8rem; margin-top: 1rem; }
.kit > p { color: var(--dim); }
.kit > p:not(:first-child) { margin-top: .7rem; }
.about__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.75rem; margin-top: 1.25rem; }
.about__text > .about__cta { color: var(--fg); }

/* ---------- contact ---------- */
.contact { position: relative; padding: clamp(4.5rem, 10vw, 9rem) var(--pad) 1.5rem; display: grid; gap: clamp(2rem, 4.5vw, 4rem); }
.contact .eyebrow { color: color-mix(in oklab, var(--ink) 78%, var(--red)); }
.contact__title em { font-family: var(--f-serif); font-weight: 300; font-stretch: 100%; text-transform: none; letter-spacing: -.035em; font-size: .92em; }
.contact__mail { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.mail { font: 650 clamp(1.75rem, .6rem + 5.6vw, 6.25rem)/1.05 var(--f-text); font-stretch: 74%; letter-spacing: -.035em; overflow-wrap: anywhere; background: linear-gradient(currentColor, currentColor) 0 100% / 100% .06em no-repeat; padding-bottom: .08em; transition: background-size .6s var(--expo); }
.mail:hover { background-size: 0 .06em; background-position: 100% 100%; }
.copy { padding: .6rem 1rem; border: 1px solid var(--ink); border-radius: 999px; transition: background-color .25s, color .25s; }
.copy:hover, .copy.is-done { background: var(--ink); color: var(--bone); }
.contact__grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.contact__grid li { display: grid; gap: .5rem; align-content: start; padding: 1.1rem 1.5rem 0 0; font-size: 1.125rem; font-weight: 550; }
.contact__grid li > .mono { color: color-mix(in oklab, var(--ink) 72%, var(--red)); }
.contact__grid a { display: inline-flex; align-items: center; gap: .35rem; justify-self: start; overflow-wrap: anywhere; }
.contact__grid a:hover { text-decoration: underline; text-underline-offset: .2em; }
@media (max-width: 56rem) { .contact__grid { grid-template-columns: 1fr 1fr; } .contact__grid li { padding-bottom: 1rem; } }
@media (max-width: 30rem) { .contact__grid { grid-template-columns: 1fr; } }
.contact__foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem 2rem; margin-top: clamp(1rem, 4vw, 3rem); padding-top: 1.25rem; border-top: 1px solid var(--line); text-transform: none; letter-spacing: 0; }
.contact__tools { display: flex; align-items: center; gap: 1.25rem; }
.contact__tools a { display: inline-flex; align-items: center; gap: .4rem; }
.contact__tools a:hover { text-decoration: underline; text-underline-offset: .2em; }

/* ---------- 404 ---------- */
.lost { position: relative; isolation: isolate; min-height: 100svh; display: grid; grid-template-rows: 1fr auto; padding: 5.75rem var(--pad) 0; overflow: clip; }
.lost__mid { align-self: center; display: grid; gap: 1.5rem; justify-items: start; max-width: 40rem; }
.nav--bare { justify-content: space-between; }
.nav--bare .nav__cta { display: inline-block; } /* the 404 has no menu button, so keep Home visible on phones */

/* ==========================================================================
   Motion (opt-in)
   ========================================================================== */
html.js[data-motion="on"] [data-reveal] { opacity: 0; translate: 0 1.75rem; transition: opacity .9s var(--ease) var(--d, 0s), translate 1.2s var(--expo) var(--d, 0s); }
html.js[data-motion="on"] [data-reveal].in { opacity: 1; translate: 0 0; }

html.js[data-motion="on"] :is(.l, .hl) > span { translate: 0 112%; transition: translate 1.25s var(--expo); }
html.js[data-motion="on"] :is(.l, .hl):nth-child(2) > span { transition-delay: .09s; }
html.js[data-motion="on"] .in :is(.l, .hl) > span { translate: 0 0; }
html.js[data-motion="on"] .hero__line .hl > span { transition-delay: .25s; }
html.js[data-motion="on"] .hero__line .hl:nth-child(2) > span { transition-delay: .36s; }

html.js[data-motion="on"] .hero__top, html.js[data-motion="on"] .hud { opacity: 0; transition: opacity 1.2s var(--ease) .7s; }
html.js[data-motion="on"] .hero.is-ready :is(.hero__top, .hud) { opacity: 1; }
html.js[data-motion="on"] .nav { animation: nav-in 1s var(--expo) .5s both; }
@keyframes nav-in { from { opacity: 0; top: -3rem; } }

@supports ((animation-timeline: view()) and (animation-range: entry)) {
  /* Profile statement lights up word by word as it crosses the viewport. */
  html[data-motion="on"] .statement { view-timeline: --statement block; }
  html[data-motion="on"] .statement .w { animation: word-in linear both; animation-timeline: --statement; animation-range: cover calc(12% + 38% * var(--i) / var(--n)) cover calc(20% + 38% * var(--i) / var(--n)); }

  /* Stack band drifts sideways with the scroll. */
  html[data-motion="on"] .band__row--a { animation: drift-a linear both; animation-timeline: view(); animation-range: cover; }
  html[data-motion="on"] .band__row--b { animation: drift-b linear both; animation-timeline: view(); animation-range: cover; }

  /* Hero recedes as you leave it. */
  html[data-motion="on"] .hero { view-timeline: --hero block; }
  html[data-motion="on"] .hero > .hero__mid { animation: hero-mid-out linear both; animation-timeline: --hero; animation-range: exit 0% exit 80%; }
  html[data-motion="on"] .hero > .hero__name { animation: hero-name-out linear both; animation-timeline: --hero; animation-range: exit 0% exit 100%; }

  /* Research stamp turns with the page. */
  html[data-motion="on"] .stamp__ring { animation: turn linear both; animation-timeline: view(); animation-range: cover; }
}
@keyframes word-in { from { opacity: .16; } }
@keyframes drift-a { from { translate: 0 0; } to { translate: -32% 0; } }
@keyframes drift-b { from { translate: -14% 0; } to { translate: 14% 0; } }
@keyframes hero-mid-out { to { translate: 0 -22%; opacity: 0; } }
@keyframes hero-name-out { to { translate: 0 26%; } }
@keyframes turn { from { rotate: -60deg; } to { rotate: 200deg; } }

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

/* Touch screens: drop the full-screen grain layer and the nav's backdrop blur.
   Both are composited over animated canvases every frame, which phones feel as scroll jank. */
.hint-touch { display: none; }
@media (hover: none) {
  .hint-pointer { display: none; }
  .hint-touch { display: inline; }
  body::after { display: none; }
  .nav { -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in oklab, var(--ink) 94%, transparent); }
}

/* Narrow screens: live readouts wrap between one and two lines as their numbers change.
   Reserve two lines so the cards (and everything below them) stop jumping. */
@media (max-width: 48rem) {
  .demo__read { min-height: calc(2lh + 1.4rem + 1px); }
  .hash__stats { min-height: calc(2lh + 1.4rem); }
  .agents__ask { flex-basis: 100%; min-height: 2lh; }
  .chat__memory { min-height: 4rem; }
}
