/* Zoey Sun — portfolio v2
   Near-white paper, black ink and a mustard yellow used for tags, buttons and
   subheads (a deeper gold when it is text on a light background). A serif for headings and figures,
   Geist for text, Geist Mono for metadata, and a faint dot grid for pixels and data
   points. Fonts are self-hosted (SIL OFL, see assets/fonts). */

@font-face { font-family: 'Display Serif'; src: url('assets/fonts/newsreader-latin-wght-normal.woff2') format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('assets/fonts/geist-latin-wght-normal.woff2') format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('assets/fonts/geist-mono-latin-wght-normal.woff2') format('woff2-variations'); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #FAFAF7;
  --card: #FFFFFF;
  --plate: #F0F0EB;
  --ink: #141414;
  --ink-2: #3B3B3B;
  --muted: #5F5F5B;
  --line: #E3E3DD;
  --line-strong: #CACAC3;
  --accent: #E2B33C;
  --accent-soft: #F8EDCF;
  --accent-mark: #D6A630;
  --accent-text: #A87F18;
  --on-accent: #141414;
  --focus: #141414;
  --invert-bg: #141414;
  --invert-ink: #F2F2EE;
  --invert-muted: #A6A6A0;
  --dot: rgb(20 20 20 / .16);
  --shadow: 0 1px 2px rgb(20 20 20 / .04), 0 12px 32px -12px rgb(20 20 20 / .14);

  --display: 'Display Serif', 'Iowan Old Style', Georgia, serif;
  --display-weight: 600;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --wrap: 1200px;
  --gutter: clamp(20px, 4vw, 48px);
  --radius: 18px;
  --header-h: 68px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F0F0F;
  --card: #181818;
  --plate: #1F1F1F;
  --ink: #F2F2EE;
  --ink-2: #C8C8C2;
  --muted: #9C9C96;
  --line: #2A2A2A;
  --line-strong: #3B3B3B;
  --accent: #E2B33C;
  --accent-soft: #3A3115;
  --accent-mark: #E2B33C;
  --accent-text: #E2B33C;
  --on-accent: #141414;
  --focus: #E2B33C;
  --invert-bg: #000000;
  --invert-ink: #F2F2EE;
  --invert-muted: #9C9C96;
  --dot: rgb(242 242 238 / .13);
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px -16px rgb(0 0 0 / .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F0F0F;
    --card: #181818;
    --plate: #1F1F1F;
    --ink: #F2F2EE;
    --ink-2: #C8C8C2;
    --muted: #9C9C96;
    --line: #2A2A2A;
    --line-strong: #3B3B3B;
    --accent: #E2B33C;
    --accent-soft: #3A3115;
    --accent-mark: #E2B33C;
    --accent-text: #E2B33C;
    --on-accent: #141414;
    --focus: #E2B33C;
    --invert-bg: #000000;
    --invert-ink: #F2F2EE;
    --invert-muted: #9C9C96;
    --dot: rgb(242 242 238 / .13);
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 16px 40px -16px rgb(0 0 0 / .6);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; font-feature-settings: 'ss01', 'cv11'; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; overflow-x: hidden; }
h1, h2, h3, h4, p, figure, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .22em; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
strong { font-weight: 600; }
cite { font-style: italic; }
::selection { background: var(--accent); color: #141414; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 10px 16px; background: var(--ink); color: var(--bg); border-radius: 8px; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 12px; }
.wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }

.kicker { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mono-caption { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.note { margin-top: 16px; color: var(--muted); font-size: 14px; }

.dot-grid { background-image: radial-gradient(var(--dot) 1px, transparent 1.4px); background-size: 22px 22px; }

/* ---------- Buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px; border-radius: 999px; font-size: 15px; font-weight: 500; text-decoration: none; transition: background-color .2s, color .2s, border-color .2s, transform .2s; }
.button--solid { background: var(--accent); color: #141414; border: 1px solid var(--accent); }
.button--solid:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.button--ghost { border: 1px solid var(--line-strong); background: transparent; color: var(--ink); }
.button--ghost:hover { border-color: var(--ink); }
.button:active { transform: translateY(1px); }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--ink); transition: background-color .2s, border-color .2s; }
.icon-button:hover { border-color: var(--line-strong); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.text-button { border: 0; background: none; padding: 4px 0; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--ink); }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; transition: border-color .25s; }
.site-header.is-scrolled { border-bottom-color: var(--line); }
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 24px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 21px; font-weight: var(--display-weight); line-height: 1; letter-spacing: -.015em; text-decoration: none; white-space: nowrap; }
.wordmark-mark { width: 26px; height: 26px; }
.wordmark-mark .tile { fill: var(--accent); }
.wordmark-mark .px { fill: #141414; }
.wordmark-mark .off { fill: #141414; opacity: .14; }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.site-nav a { position: relative; padding: 8px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14.5px; text-decoration: none; transition: color .2s, background-color .2s; }
.site-nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.site-nav a.is-active { color: var(--ink); }
.site-nav a.is-active::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink); }
.site-nav .nav-ask { margin-left: 8px; border: 1px solid var(--line-strong); color: var(--ink); }
.site-nav .nav-ask:hover { border-color: var(--accent); background: var(--accent); color: #141414; }
.header-tools { display: flex; align-items: center; gap: 4px; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
.menu-toggle { display: none; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(48px, 8vw, 104px) 0 clamp(40px, 6vw, 72px); isolation: isolate; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(var(--dot) 1px, transparent 1.4px); background-size: 22px 22px; -webkit-mask-image: radial-gradient(ellipse 55% 70% at 18% 38%, #000 15%, transparent 72%); mask-image: radial-gradient(ellipse 55% 70% at 18% 38%, #000 15%, transparent 72%); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(48px, 10vw, 144px); align-items: center; }
.hero-copy { grid-column: 2; grid-row: 1; }
.hero h1 { max-width: 13em; font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(2.5rem, 4.6vw, 3.75rem); line-height: 1.06; letter-spacing: -.025em; }
.hero h1 .hl { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: .075em; text-underline-offset: .13em; }
.hero-lede { max-width: 36em; margin-top: 24px; color: var(--ink-2); font-size: clamp(16.5px, 1.4vw, 18px); line-height: 1.62; text-wrap: pretty; }
.now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-top: 22px; font-size: 15px; color: var(--ink-2); }
.now strong { color: var(--ink); font-weight: 550; }
.now-label { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.now-dot { position: relative; top: -1px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-mark); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-mark) 50%, transparent); animation: pulse 2.4s ease-out infinite; flex: none; align-self: center; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-mark) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero-links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 28px; font-size: 14.5px; }
.hero-links a { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); text-decoration: none; transition: color .2s; }
.hero-links a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent-mark); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.hero-links svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.portrait { grid-column: 1; grid-row: 1; justify-self: start; width: 100%; }
.portrait-frame { position: relative; border-radius: 10px; overflow: hidden; background: var(--plate); box-shadow: var(--shadow); aspect-ratio: 813 / 964; }
.portrait-frame img { width: 100%; height: 100%; object-fit: cover; }
.portrait-caption { justify-content: center; margin-top: 16px; text-align: center; }


/* ---------- Sections ---------- */
.section { padding: clamp(72px, 10vw, 128px) 0 0; }
.section-head { margin-bottom: clamp(32px, 5vw, 56px); }
.section-head h2 { font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.section-intro { max-width: 40em; margin-top: 14px; color: var(--ink-2); font-size: 16.5px; text-wrap: pretty; }

/* ---------- Ask ---------- */
.section--ask { padding-top: clamp(40px, 6vw, 72px); }
.ask-panel { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); gap: clamp(28px, 5vw, 64px); padding: clamp(24px, 4vw, 48px); border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: var(--shadow); }
.ask-intro h2 { font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.7rem, 2.6vw, 2.1rem); line-height: 1.12; letter-spacing: -.02em; }
.ask-intro > p { margin-top: 14px; color: var(--ink-2); font-size: 15.5px; }
.chat-status { display: inline-flex; align-items: center; gap: 8px; margin-top: 22px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chat-status.is-ai .status-dot { background: #2E9B5F; box-shadow: 0 0 0 3px color-mix(in srgb, #2E9B5F 22%, transparent); }
.chat { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-width: 0; }
.chat-head { display: flex; align-items: center; justify-content: space-between; }
.chat-head[hidden] { display: none; }
.chat-messages { display: flex; flex-direction: column; gap: 14px; max-height: min(460px, 60vh); overflow-y: auto; padding: 4px 4px 4px 0; scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-messages[hidden] { display: none; }
.message { max-width: 92%; font-size: 15px; line-height: 1.6; animation: rise .35s ease both; }
.message p { white-space: pre-line; }
.message.user { align-self: flex-end; padding: 10px 16px; border-radius: 16px 16px 4px 16px; background: var(--ink); color: var(--bg); }
.message.assistant { align-self: flex-start; display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 12px; row-gap: 6px; color: var(--ink-2); }
.message.assistant > :not(.assistant-icon) { grid-column: 2; }
.assistant-icon { grid-row: 1 / span 3; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #141414; }
.assistant-icon svg { width: 18px; height: 18px; }
.message.waiting p { color: var(--muted); }
.message.streaming p::after { content: ''; display: inline-block; width: 2px; height: 1.05em; margin-left: 3px; vertical-align: -.15em; background: var(--accent-mark); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.message.waiting .assistant-icon { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.message-kind { justify-self: start; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.message-source { justify-self: start; font-size: 13.5px; color: var(--ink); text-decoration-color: var(--accent-mark); text-decoration-thickness: 2px; }
.chat-form { position: relative; display: flex; align-items: flex-end; gap: 10px; padding: 8px 8px 8px 18px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--bg); transition: border-color .2s, box-shadow .2s; }
.chat-form:focus-within { border-color: var(--ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.chat-form textarea { flex: 1; min-height: 40px; max-height: 120px; padding: 9px 0; border: 0; background: transparent; resize: none; outline: none; font-size: 16px; line-height: 1.4; }
.chat-form textarea::placeholder { color: var(--muted); }
.send-button { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--ink); color: var(--bg); transition: background-color .2s; }
.send-button:hover { background: var(--accent); color: #141414; }
.send-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send-button:disabled, .suggestions button:disabled { cursor: progress; opacity: .55; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: 13.5px; color: var(--ink-2); transition: border-color .2s, color .2s, background-color .2s; }
.suggestions button:hover { border-color: var(--ink); background: var(--accent-soft); color: var(--ink); }
.chat-disclosure { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(18px, 2.4vw, 28px); }
.project { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; cursor: pointer; transition: border-color .25s, box-shadow .25s, transform .25s; }
.project:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.project--wide { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.project--flip .project-media { order: 2; }
.project-media { position: relative; aspect-ratio: 3 / 2; overflow: hidden; }
.project--wide .project-media { aspect-ratio: auto; min-height: 420px; }
.plate { background: var(--plate); }
.plate--photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.project:hover .plate--photo img { transform: scale(1.03); }
.plate--canopy { display: grid; place-items: center; padding: 40px; background-image: radial-gradient(var(--dot) 1px, transparent 1.4px); background-size: 22px 22px; }
.plate--duo { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); }
.plate--duo img { min-width: 0; }
.plate--duo .duo-glass { object-position: 100% 100%; background: #fff; }
.specimen { position: relative; padding: 12px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
.specimen::before, .specimen::after { content: ''; position: absolute; width: 14px; height: 14px; border-color: var(--ink); border-style: solid; }
.specimen::before { top: -7px; left: -7px; border-width: 1.5px 0 0 1.5px; }
.specimen::after { bottom: -7px; right: -7px; border-width: 0 1.5px 1.5px 0; }
.specimen img { width: clamp(220px, 24vw, 300px); height: auto; }
.plate-tag { position: absolute; z-index: 3; padding: 4px 8px; border-radius: 6px; background: rgb(27 29 38 / .72); color: #F4F1EA; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; pointer-events: none; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.plate-tag--tl { top: 14px; left: 14px; }
.plate-tag--tr { top: 14px; right: 14px; }
.plate--canopy .plate-tag { background: var(--card); color: var(--muted); border: 1px solid var(--line); }

.project-body { display: flex; flex-direction: column; gap: 14px; padding: clamp(22px, 3vw, 36px); flex: 1; }
.project--wide .project-body { justify-content: center; padding: clamp(28px, 4vw, 52px); }
.project-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.project-num { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #141414; }
.project h3 { font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.35rem, 1.9vw, 1.6rem); line-height: 1.2; letter-spacing: -.015em; }
.project--wide h3 { font-size: clamp(1.6rem, 2.4vw, 2rem); }
.project-summary { color: var(--ink-2); font-size: 15.5px; text-wrap: pretty; }
.project-fact { display: flex; gap: 10px; align-items: baseline; color: var(--ink); font-size: 14px; font-weight: 500; }
.project-fact::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-mark); transform: translateY(-2px); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.project-open { align-self: flex-start; margin-top: auto; padding: 10px 0 0; border: 0; background: none; font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 5px; transition: text-decoration-color .2s, color .2s; }
.project:hover .project-open, .project-open:hover { color: var(--ink); text-decoration-color: var(--accent-mark); text-decoration-thickness: 3px; }

/* Before/after comparison */
.compare { --pos: 50%; position: absolute; inset: 0; overflow: hidden; cursor: ew-resize; touch-action: pan-y; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.compare-top { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.compare-handle { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .15); pointer-events: none; z-index: 2; }
.compare-handle::after { content: ''; position: absolute; top: 50%; left: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231B1D26' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 7-5 5 5 5m6-10 5 5-5 5'/%3E%3C/svg%3E") center / 20px no-repeat; box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.compare-range { position: absolute; inset: 0; z-index: 4; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; -webkit-appearance: none; appearance: none; }
.compare-range:focus-visible + .plate-tag, .compare:has(.compare-range:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

/* Concept diagrams */
.plate--diagram { display: grid; place-items: center; padding: 16px; }
.diagram { width: 100%; height: 100%; max-height: 320px; }
.diagram text { font-family: var(--mono); font-size: 13px; fill: var(--muted); letter-spacing: .02em; }
.diagram .d-small { font-size: 12px; }
.d-node rect, .d-node > path:first-child { fill: var(--card); stroke: var(--line-strong); stroke-width: 1.2; }
.d-node--answer > path:first-child, .d-node--accent rect { stroke: var(--ink); }
.d-ink { stroke: var(--line-strong); stroke-width: 6; stroke-linecap: round; fill: none; }
.d-node--answer .d-ink { stroke: color-mix(in srgb, var(--ink) 22%, transparent); }
.d-chunk { fill: var(--plate) !important; stroke: var(--line-strong) !important; }
.d-hit { fill: var(--accent) !important; stroke: var(--ink) !important; }
.d-cite { fill: var(--accent) !important; stroke: var(--ink) !important; }
.d-flow { fill: none; stroke: var(--ink-2); stroke-width: 1.4; stroke-dasharray: 4 5; animation: flow 1.6s linear infinite; }
.d-loop { stroke: var(--line-strong); }
.d-check { fill: none; stroke: #2E9B5F; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.d-cross { fill: none; stroke: #D14343; stroke-width: 2; stroke-linecap: round; }
.d-person { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.diagram .d-muted { fill: var(--muted); font-style: italic; }
@keyframes flow { to { stroke-dashoffset: -18; } }

/* ---------- Experience ---------- */
/* Columns are sized to their longest entry and shared across rows (subgrid), so the space between them is the same everywhere. */
.timeline { display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); column-gap: clamp(48px, 6vw, 80px); border-top: 1px solid var(--line-strong); }
.role { grid-column: 1 / -1; display: grid; grid-template-columns: 210px minmax(0, 1fr) minmax(0, 1.25fr); grid-template-columns: subgrid; row-gap: 12px; padding: 28px 0; border-bottom: 1px solid var(--line); transition: background-color .25s; }
.role-when { display: flex; flex-direction: column; gap: 4px; font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.role-where { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.role--current .role-when > span:first-child::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--accent-mark); vertical-align: 1px; }
.role h3 { font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.15rem, 1.5vw, 1.3rem); line-height: 1.25; letter-spacing: -.01em; }
.role-org { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.role-desc { color: var(--ink-2); font-size: 15.5px; padding-top: 4px; text-wrap: pretty; }

/* ---------- Research ---------- */
.research-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.research-head { position: sticky; top: calc(var(--header-h) + 32px); margin-bottom: 0; }
.mini-stats { display: flex; gap: 28px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); }
.mini-stats dt { font-family: var(--display); font-size: 1.9rem; font-weight: var(--display-weight); line-height: 1; letter-spacing: -.02em; }
.mini-stats dd { margin-top: 8px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.list-title { display: flex; align-items: center; gap: 14px; margin: 48px 0 6px; font-family: var(--display); font-size: 19px; font-weight: var(--display-weight); letter-spacing: -.01em; color: var(--accent-text); }
.list-title:first-child { margin-top: 0; }
.list-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.pub { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.pub:last-child { border-bottom: 0; }
.pub-year { padding-top: 2px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.pub h4 { font-size: 17px; font-weight: 500; line-height: 1.4; letter-spacing: -.005em; text-wrap: pretty; }
.pub h4 a { text-decoration: none; background: linear-gradient(var(--accent-mark), var(--accent-mark)) 0 100% / 0 3px no-repeat; transition: background-size .35s, color .2s; }
.pub h4 a:hover { background-size: 100% 3px; }
.pub-authors { margin-top: 6px; color: var(--muted); font-size: 14px; }
.pub-authors strong { color: var(--ink); font-weight: 550; }
.pub-venue { margin-top: 4px; color: var(--muted); font-size: 14px; }
.pub-venue cite { font-style: normal; color: var(--ink-2); font-weight: 500; margin-right: 6px; }
.pubs-more { margin-top: 48px; }
.pubs-toggle { margin-top: 24px; }
.pubs-toggle[hidden] { display: none; }
@media screen {
  .js .research-body:not(.is-expanded) .pub--extra, .js .research-body:not(.is-expanded) .pubs-more { display: none; }
}

/* ---------- Toolkit ---------- */
.toolkit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px 32px; }
.tool-group { padding-top: 18px; border-top: 1px solid var(--ink); }
.tool-group dt { font-family: var(--display); font-size: 19px; font-weight: var(--display-weight); letter-spacing: -.01em; color: var(--accent-text); }
.tool-group dd { margin-top: 10px; color: var(--ink-2); font-size: 15.5px; line-height: 1.65; }

/* ---------- Education ---------- */
.edu-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.edu-head { margin-bottom: 0; }
.degrees { border-top: 1px solid var(--line-strong); }
.degree { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: baseline; gap: 20px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.degree-level { justify-self: start; font-family: var(--mono); font-size: 12.5px; font-weight: 500; letter-spacing: .04em; display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #141414; }
.degree h3 { font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.15rem, 1.5vw, 1.3rem); line-height: 1.25; letter-spacing: -.01em; }
.degree p { margin-top: 4px; color: var(--muted); font-size: 14.5px; }
.degree-years { font-family: var(--mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---------- Contact ---------- */
.contact { position: relative; overflow: hidden; isolation: isolate; margin-top: clamp(96px, 12vw, 160px); padding: clamp(80px, 10vw, 128px) 0 clamp(56px, 7vw, 88px); background: var(--invert-bg); color: var(--invert-ink); border-top: 1px solid var(--line); }
.contact::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(rgb(242 242 238 / .12) 1px, transparent 1.4px); background-size: 22px 22px; -webkit-mask-image: radial-gradient(ellipse 55% 80% at 50% 50%, #000 10%, transparent 75%); mask-image: radial-gradient(ellipse 55% 80% at 50% 50%, #000 10%, transparent 75%); }
.contact-inner { display: flex; flex-direction: column; align-items: center; text-align: center; }
.contact .kicker { justify-content: center; color: var(--invert-muted); }
.contact h2 { margin-top: 18px; font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(2.5rem, 5.6vw, 4.1rem); line-height: 1.04; letter-spacing: -.025em; }
.contact h2 .hl { color: var(--accent); }
.contact-lede { max-width: 32em; margin-top: 18px; color: #C8C8C2; font-size: 17px; text-wrap: pretty; }
.contact-links { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 36px; padding-bottom: 72px; }
.contact-chip { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px; border: 1px solid rgb(242 242 238 / .35); border-radius: 999px; color: var(--invert-ink); font-size: 15px; text-decoration: none; cursor: pointer; transition: border-color .2s, background-color .2s, color .2s; }
.contact-chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.contact-chip:hover { border-color: var(--accent); color: var(--accent); }
.email-reveal > .contact-chip { border-color: var(--accent); background: var(--accent); color: #141414; }
.email-reveal > .contact-chip:hover, .email-reveal[open] > .contact-chip { border-color: #F2F2EE; background: #F2F2EE; color: #141414; }
.email-reveal > summary { list-style: none; }
.email-reveal > summary::-webkit-details-marker { display: none; }
.email-address { position: absolute; left: 0; right: 0; bottom: 0; font-size: clamp(1.25rem, 2.4vw, 1.6rem); font-weight: 500; letter-spacing: -.01em; color: var(--invert-ink); user-select: all; animation: rise .3s ease both; }
.email-address::selection { background: var(--accent); color: #141414; }
.contact :focus-visible { outline-color: var(--accent); }

.site-footer { background: var(--invert-bg); color: var(--invert-muted); border-top: 1px solid rgb(236 233 225 / .1); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; padding: 24px 0 28px; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.footer-inner a { color: var(--invert-ink); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }

/* ---------- Case study dialog ---------- */
body.case-open { overflow: hidden; }
.case { position: fixed; inset: 0 0 0 auto; width: min(860px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--bg); color: var(--ink); overflow-y: auto; overscroll-behavior: contain; box-shadow: -24px 0 64px -24px rgb(0 0 0 / .35); }
.case[open] { animation: slide-in .42s cubic-bezier(.2,.75,.2,1); }
.case::backdrop { background: rgb(10 14 12 / .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.case[open]::backdrop { animation: fade-in .3s ease; }
@keyframes slide-in { from { transform: translateX(48px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.case-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(20px, 5vw, 56px); background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.case-body { display: flex; flex-direction: column; gap: 36px; padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 56px) 80px; }
.case-head h2 { margin-top: 14px; font-family: var(--display); font-weight: var(--display-weight); font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.1; letter-spacing: -.02em; outline: none; }
.case-lede { margin-top: 18px; color: var(--ink-2); font-size: clamp(16.5px, 1.5vw, 18px); line-height: 1.6; text-wrap: pretty; }
.case-body section h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 12px; font-family: var(--display); font-size: 19px; font-weight: var(--display-weight); letter-spacing: -.01em; color: var(--accent-text); }
.case-when { display: inline-block; font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.case-body section p { color: var(--ink-2); font-size: 16.5px; }
.case-body section ul { display: grid; gap: 12px; }
.case-body section li { position: relative; padding-left: 22px; color: var(--ink-2); font-size: 16px; line-height: 1.6; }
.case-body section li::before { content: ''; position: absolute; left: 2px; top: calc(.8em - 3px); width: 6px; height: 6px; border-radius: 50%; background: var(--accent-mark); }
.case-body section li strong { color: var(--ink); }
.case-metrics { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.case-metrics > div { flex: 1 1 180px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.case-metrics dt { font-family: var(--display); font-size: 1.75rem; font-weight: var(--display-weight); line-height: 1.1; letter-spacing: -.02em; }
.case-metrics dd { margin-top: 6px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.case-figure { margin: 0; }
.case-figure img { width: 100%; height: auto; border-radius: 12px; background: var(--plate); }
.case-figure figcaption { margin-top: 10px; color: var(--muted); font-size: 13.5px; }
.case-figure--white img { background: #fff; border: 1px solid var(--line); }
.case-figure--canopy { padding: 32px; border-radius: 14px; background: var(--plate); text-align: center; }
.case-figure--canopy img { width: min(100%, 360px); margin-inline: auto; border-radius: 4px; }
.case-figure--diagram { padding: 20px; border-radius: 14px; background: var(--plate); }
.case-figure--diagram .diagram { max-height: none; height: auto; }
.case-figure .compare { position: relative; inset: auto; aspect-ratio: 1; border-radius: 12px; }
.case-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.case-pair .case-figure img { aspect-ratio: 4 / 3; object-fit: cover; }
.case-pair .case-figure--white img { aspect-ratio: auto; object-fit: contain; }
.case-links { display: flex; flex-wrap: wrap; gap: 12px; }
.case-links a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 15px; text-decoration: none; transition: border-color .2s, color .2s; }
.case-links a:hover { border-color: var(--accent); background: var(--accent); color: #141414; }
.case-next { margin-top: 12px; padding-top: 28px; border-top: 1px solid var(--line); }
.case-next-button { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); text-align: left; transition: border-color .2s; }
.case-next-button:hover { border-color: var(--ink); }
.case-next-title { font-family: var(--display); font-size: clamp(1.25rem, 2.4vw, 1.5rem); font-weight: var(--display-weight); line-height: 1.2; letter-spacing: -.015em; }
.case-next-button:hover .case-next-title { text-decoration: underline; text-decoration-color: var(--accent-mark); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; counter-reset: none; }
.flow li { position: relative; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 14.5px; line-height: 1.45; color: var(--ink-2); }
.flow li span { display: block; width: fit-content; margin-bottom: 8px; font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #141414; }

/* ---------- Reveal on scroll ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.js .reveal.is-visible { opacity: 1; transform: none; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .toolkit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline { display: block; }
  .role { grid-template-columns: 180px minmax(0, 1fr); column-gap: 40px; }
  .role-desc { grid-column: 2; }
}
@media (max-width: 920px) {
  .menu-toggle { display: inline-grid; }
  .site-nav { position: absolute; top: calc(var(--header-h) - 6px); left: var(--gutter); right: var(--gutter); display: none; flex-direction: column; align-items: stretch; gap: 2px; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a { padding: 12px 14px; font-size: 16px; border-radius: 10px; }
  .site-nav a.is-active::after { left: auto; right: 14px; top: 50%; bottom: auto; margin: -2px 0 0; }
  .site-nav .nav-ask { margin: 6px 0 0; text-align: center; }
  .header-tools { margin-left: auto; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-copy, .portrait { grid-column: auto; grid-row: auto; }
  .hero-copy { max-width: 40rem; }
  .portrait { justify-self: start; width: min(100%, 380px); }
  .ask-panel { grid-template-columns: 1fr; }
  .projects { grid-template-columns: 1fr; }
  .project--wide { grid-template-columns: 1fr; }
  .project--flip .project-media { order: 0; }
  .project--wide .project-media { min-height: 0; aspect-ratio: 16 / 11; }
  .research-grid { grid-template-columns: 1fr; }
  .research-head { position: static; }
  .edu-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .now { font-size: 14.5px; }
  .hero h1 { font-size: clamp(2.2rem, 9.6vw, 2.8rem); }
  .hero-actions .button { flex: 1 1 auto; }
  .role { grid-template-columns: 1fr; gap: 8px; }
  .role-desc { grid-column: auto; }
  .role-when { flex-direction: row; gap: 12px; }
  .toolkit { grid-template-columns: 1fr; gap: 28px; }
  .degree { grid-template-columns: 48px minmax(0, 1fr); }
  .degree-years { grid-column: 2; }
  .pub { grid-template-columns: 1fr; gap: 6px; }
  .case-pair { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .project--wide .project-media { aspect-ratio: 1; }
  .plate--canopy { padding: 28px; }
  .footer-inner { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .section--ask, .project-open, .pubs-toggle, .contact-links, .site-footer, .compare-handle, .compare-range { display: none !important; }
  body { background: #fff; color: #000; }
  .contact { background: #fff; color: #000; margin-top: 32px; padding: 32px 0; border: 0; }
  .contact::before { display: none; }
  .contact .kicker, .contact h2 .hl, .contact-lede { color: #000; }
  .project, .ask-panel { box-shadow: none; break-inside: avoid; }
  .js .reveal { opacity: 1; transform: none; }
}
