/* ---------- Tokens ---------- */
/* Dark is the default; light only when the visitor picks it. */
:root {
  --paper: #0f1318;
  --surface: #161b22;
  --ink: #e8ecf1;
  --muted: #a6afbc;
  --line: #2e3642;
  --accent: #8597ff;
  --accent-ink: #0f1318;
  --accent-soft: #1d2440;
  --wall: #4a5465;

  --font: "Schibsted Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --step--1: clamp(0.84rem, 0.82rem + 0.1vw, 0.9rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.4vw, 1.45rem);
  --step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2.2rem);
  --step-3: clamp(2.6rem, 1.8rem + 3.6vw, 5.2rem);

  --gutter: clamp(16px, 4.5vw, 4.5rem);
  --max: 100%;
  --radius: 0.625rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --paper: #f4f6f8;
  --surface: #ffffff;
  --ink: #15181d;
  --muted: #4a5161;
  --line: #cdd4dd;
  --accent: #2b46e0;
  --accent-ink: #ffffff;
  --accent-soft: #e4e8fd;
  --wall: #c7ced8;
  color-scheme: light;
}

/* ---------- Base ---------- */
/* Scale the whole page with the window on laptops and monitors: every size below is
   in rem, so the layout keeps the same proportions and fills the screen at any width
   or browser zoom. 1rem up to ~84rem wide, then 1.19vw (1.125rem at 1512, 1.4375rem at 1920). */
@media (min-width: 1100px) {
  html { font-size: max(100%, 1.19vw) !important; }
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; scrollbar-gutter: stable; scroll-behavior: smooth; scroll-padding-top: 4.75rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
svg { display: block; }
code { font-size: 0.92em; background: var(--accent-soft); padding: 0.05em 0.35em; border-radius: 0.25rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 0.25rem; }
::selection { background: var(--accent); color: var(--accent-ink); }

.skip {
  position: absolute; left: 0.75rem; top: 0; transform: translateY(-120%); z-index: 100;
  background: var(--ink); color: var(--paper); padding: 0.5rem 0.875rem; border-radius: 0.375rem; text-decoration: none;
}
.skip:focus { transform: translateY(0.75rem); }

/* ---------- Buttons and links ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.75rem; padding: 0 1.25rem;
  font: inherit; font-weight: 600; font-size: var(--step--1);
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 62.4375rem;
  text-decoration: none; cursor: pointer;
  transition: transform 0.2s var(--ease), background-color 0.2s, color 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--ghost { background: transparent; color: var(--ink); border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--small { min-height: 2.5rem; padding: 0 1rem; }
@media (pointer: coarse) { .btn--small { min-height: 44px; } .text-link { padding: 10px 0; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.text-link {
  color: var(--accent); font-weight: 600; text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 0.2s;
}
.text-link:hover { text-decoration-color: currentColor; }
.muted-note { color: var(--muted); font-size: var(--step--1); }

.icon-btn, .icon-link {
  display: inline-grid; place-items: center;
  width: 2.75rem; height: 2.75rem; padding: 0;
  background: transparent; color: var(--ink);
  border: 1px solid transparent; border-radius: 62.4375rem; cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.icon-btn:hover, .icon-link:hover { border-color: var(--line); background: var(--surface); }
.icon-btn svg, .icon-link svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(0.75rem);
  -webkit-backdrop-filter: saturate(1.4) blur(0.75rem);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav__inner {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter);
  height: 4rem; display: flex; align-items: center; gap: 1.5rem;
}
.nav__name { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.nav__links { display: flex; gap: 0.25rem; margin-left: auto; order: 1; }
.nav__links a {
  position: relative; padding: 0.5rem 0.75rem; border-radius: 62.4375rem;
  color: var(--muted); text-decoration: none; font-size: var(--step--1); font-weight: 500;
  transition: color 0.2s, background-color 0.2s;
}
.nav__links a:hover { color: var(--ink); }
.nav__links a.is-active { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.nav__actions { display: flex; align-items: center; gap: 0.375rem; order: 2; }
.nav__menu { display: none; }

.i-sun { display: none !important; }
:root[data-theme="light"] .i-sun { display: block !important; }
:root[data-theme="light"] .i-moon { display: none !important; }

@media (max-width: 720px) {
  .nav__links {
    position: absolute; top: 4rem; left: 0; right: 0;
    flex-direction: column; gap: 0; margin: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: var(--paper); border-bottom: 1px solid var(--line);
    opacity: 0; visibility: hidden; transform: translateY(-0.5rem);
    transition: opacity 0.2s, transform 0.25s var(--ease), visibility 0.2s;
  }
  .nav__links.is-open { opacity: 1; visibility: visible; transform: none; }
  .nav__links a { padding: 0.875rem 0.25rem; border-radius: 0; font-size: var(--step-0); color: var(--ink); border-bottom: 1px solid var(--line); }
  .nav__links a:last-child { border-bottom: 0; }
  .nav__links a.is-active { background: none; box-shadow: none; color: var(--accent); }
  .nav__actions { margin-left: auto; }
  .nav__menu { display: inline-grid; }
}

/* ---------- Layout ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: clamp(3.5rem, 8vw, 6.5rem) 0 0; }
.section--tight { padding-top: clamp(3.5rem, 7vw, 5.5rem); }
.section__head { margin-bottom: 1.75rem; }
.section__head h2 { font-size: var(--step-2); }
.section__sub { margin-top: 0.5rem; color: var(--muted); max-width: 52ch; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(2rem, 6vw, 5rem); align-items: center;
  padding: clamp(2rem, 6vw, 5rem) 0 clamp(0.5rem, 2vw, 1rem);
}
.hero__title { font-size: var(--step-3); font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; }
.hero__lede { margin-top: 1.25rem; font-size: var(--step-1); line-height: 1.4; max-width: 30ch; font-weight: 500; }
.hero__bio { margin-top: 1rem; color: var(--muted); max-width: 54ch; }
.facts { margin: 1.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; }
.facts div { min-width: 0; }
.facts dt { font-size: var(--step--1); color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: var(--step--1); }
.hero__cta { margin-top: 2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.hero__socials { display: inline-flex; gap: 0.25rem; margin-left: 0.25rem; }

/* Page-load sequence: the single orchestrated moment */
.reveal { animation: rise 0.9s var(--ease) both; animation-delay: calc(var(--d, 0) * 90ms + 80ms); }
@keyframes rise { from { opacity: 0; transform: translateY(0.875rem); } to { opacity: 1; transform: none; } }

/* Gridworld */
.grid-demo { margin: 0; justify-self: end; width: 100%; max-width: 28rem; }
.grid-demo__board {
  --n: 9;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px;
  aspect-ratio: 1; padding: 0.625rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 0.875rem;
  touch-action: manipulation;
}
.cell {
  position: relative; border: 0; padding: 0; margin: 0;
  border-radius: 0.25rem; cursor: pointer;
  background: color-mix(in oklab, var(--accent) calc(var(--v, 0) * 100%), var(--paper));
  transition: background-color 0.35s ease-out, transform 0.2s var(--ease);
}
.cell:hover { transform: scale(0.9); }
.cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 2px var(--paper); z-index: 1; }
.cell--wall { background: var(--wall); cursor: default; }
.cell--wall:hover { transform: none; }
.cell--goal { background: var(--accent); }
.cell--goal::after {
  content: ""; position: absolute; inset: 28%; border-radius: 50%;
  background: var(--accent-ink);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(0.7); opacity: 0.7; } }
.cell .arrow {
  position: absolute; inset: 0; margin: auto; width: 46%; height: 46%;
  opacity: 0; transition: opacity 0.4s;
  stroke: var(--ink); stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round;
}
.grid-demo.is-settled .cell .arrow { opacity: 0.4; }
.grid-demo.is-settled .cell.on-path .arrow { opacity: 1; }
.cell.on-path { box-shadow: inset 0 0 0 2px var(--ink); }
.agent {
  position: absolute; top: 0; left: 0; z-index: 2; pointer-events: none;
  width: var(--cs); height: var(--cs); display: grid; place-items: center;
  transition: transform 0.22s var(--ease), opacity 0.3s;
}
.agent::before { content: ""; width: 46%; height: 46%; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--paper); }
.grid-demo__board { position: relative; }
.cell.is-hi .arrow { stroke: var(--accent-ink); }
.grid-demo__caption { margin-top: 0.875rem; display: flex; flex-direction: column; gap: 0.25rem; max-width: 46ch; font-size: var(--step--1); color: var(--muted); }
.grid-demo__hint { color: var(--ink); font-weight: 500; }

/* ---------- Featured projects ---------- */
.featured { display: grid; gap: 1.25rem; }
.feature {
  display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem;
  overflow: hidden;
  transition: border-color 0.25s;
}
.feature:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.feature__art {
  display: grid; place-items: center; padding: clamp(1.25rem, 3vw, 2.25rem);
  background: var(--accent-soft);
  border-right: 1px solid var(--line);
}
.feature__art svg { width: 100%; max-width: 23.75rem; height: auto; }
.feature__body { padding: clamp(1.375rem, 3vw, 2.25rem); display: flex; flex-direction: column; }
.badge {
  align-self: flex-start;
  font-size: var(--step--1); font-weight: 600; color: var(--accent);
}
.feature__title { margin-top: 0.375rem; font-size: var(--step-2); letter-spacing: -0.02em; }
.feature__line { margin-top: 0.625rem; color: var(--muted); max-width: 52ch; }
.feature__points { margin-top: 1rem; display: grid; gap: 0.5rem; }
.feature__points li { position: relative; padding-left: 1.125rem; font-size: var(--step--1); line-height: 1.5; }
.feature__points li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 0.375rem; height: 0.375rem; border-radius: 2px; background: var(--accent); }
.feature__actions { margin-top: auto; padding-top: 1.375rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }

.tags { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.tags li {
  font-size: 0.78rem; font-weight: 500; color: var(--muted);
  padding: 3px 0.625rem; border: 1px solid var(--line); border-radius: 62.4375rem; background: var(--paper);
}

/* Illustration strokes, themed */
.a-panel { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.a-field { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.a-faint { stroke: var(--wall); stroke-width: 4; stroke-linecap: round; }
.a-hl { fill: color-mix(in srgb, var(--accent) 22%, transparent); }
.a-chip { fill: var(--accent); }
.a-chip-t { fill: var(--accent-ink); font: 600 10px var(--font); }
.a-link { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.a-grad { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 4; opacity: 0.6; }
.a-grad-t { fill: var(--accent); font: 600 12px var(--font); }
.a-dot { fill: var(--accent); }
.a-core { fill: var(--accent); }
.a-core-t { fill: var(--accent-ink); font: 700 11px var(--font); }
.a-label { fill: var(--ink); font: 500 11px var(--font); }
.a-node { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.a-zone { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
.a-bag { fill: var(--ink); opacity: 0.75; }
.a-box { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.a-path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 2 5; stroke-linecap: round; }
.a-rotor { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }

/* ---------- More work ---------- */
.subhead { margin: 3.5rem 0 0.5rem; font-size: var(--step-1); }
.more { border-top: 1px solid var(--line); }
.more__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.5rem 2rem; align-items: center;
  padding: 1.375rem 0; border-bottom: 1px solid var(--line);
}
.more__main h4 { font-size: var(--step-0); font-weight: 700; }
.more__main p { margin-top: 0.25rem; color: var(--muted); font-size: var(--step--1); max-width: 70ch; }
.more__row .tags { margin: 0; justify-content: flex-end; }
.more__link { display: flex; gap: 1rem; white-space: nowrap; font-size: var(--step--1); justify-self: end; min-width: 8.75rem; justify-content: flex-end; }
.more__foot { margin-top: 1.125rem; color: var(--muted); font-size: var(--step--1); }

/* ---------- Experience ---------- */
.jobs { display: grid; }
.job {
  display: grid; grid-template-columns: 10.625rem minmax(0, 1fr); gap: 0.5rem 2rem;
  padding: 1.625rem 0; border-top: 1px solid var(--line);
}
.job:last-child { border-bottom: 1px solid var(--line); }
.job__when { color: var(--muted); font-size: var(--step--1); padding-top: 3px; font-variant-numeric: tabular-nums; }
.job__role { font-size: var(--step-1); }
.job__role span { color: var(--ink); font-weight: 700; }
.job__where { margin-top: 0.25rem; color: var(--muted); font-size: var(--step--1); }
.job ul { margin-top: 0.75rem; display: grid; gap: 0.5rem; max-width: 72ch; }
.job li { position: relative; padding-left: 1.125rem; }
.job li::before { content: ""; position: absolute; left: 2px; top: 0.66em; width: 0.375rem; height: 0.375rem; border-radius: 2px; background: var(--wall); }
.involve { margin-top: 1.25rem; color: var(--muted); font-size: var(--step--1); }
.involve span { color: var(--ink); font-weight: 600; margin-right: 0.375rem; }

/* ---------- Research ---------- */
.paper {
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(1.5rem, 4vw, 3.5rem);
  padding: clamp(1.375rem, 3vw, 2.25rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem;
}
.paper__text h3 { font-size: var(--step-1); }
.paper__cite { margin-top: 0.375rem; color: var(--muted); font-size: var(--step--1); font-style: italic; }
.paper__text p + p { margin-top: 0.875rem; }
.paper__text > p:nth-of-type(2) { max-width: 64ch; }
.bars { display: grid; gap: 0.875rem; }
.bar { display: grid; grid-template-columns: 1fr; gap: 0.25rem; font-size: var(--step--1); }
.bar em { order: -1; font-style: normal; color: var(--muted); }
.bar span {
  display: block; position: relative; height: 1.875rem; line-height: 1.875rem; padding-left: 0.625rem;
  font-weight: 600; color: var(--ink); z-index: 0;
  width: calc(var(--v) * 1%); min-width: 4.5em;
}
.bar span::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--accent-soft); border-radius: 0.375rem;
  transform-origin: left; transition: transform 1.1s var(--ease);
}
.bar--hi span { color: var(--accent-ink); }
.bar--hi span::before { background: var(--accent); }
.paper.is-pending .bar span::before { transform: scaleX(0.06); }
.paper.is-pending .bar--hi span { color: var(--ink); }
.bar--hi span { transition: color 0.4s 0.5s; }
.paper__figcap { margin-top: 0.75rem; font-size: 0.78rem; color: var(--muted); }

/* ---------- Skills ---------- */
.skills { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 3rem; }
.skills dt { font-weight: 700; font-size: var(--step--1); }
.skills dd { margin: 0.25rem 0 0; color: var(--muted); }

/* ---------- Contact ---------- */
.contact { margin: clamp(4.5rem, 10vw, 8rem) 0 0; padding: clamp(2.25rem, 6vw, 4.5rem) 0; border-top: 1px solid var(--line); }
.contact h2 { font-size: var(--step-2); }
.contact p { margin-top: 0.625rem; color: var(--muted); max-width: 48ch; }
.contact__email {
  display: inline-block; margin-top: 1.25rem;
  font-size: clamp(1.6rem, 1rem + 3.4vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
  color: var(--ink); text-decoration: none; overflow-wrap: anywhere;
  background: linear-gradient(var(--accent), var(--accent)) left bottom / 0% 3px no-repeat;
  transition: background-size 0.45s var(--ease), color 0.2s;
}
.contact__email:hover { background-size: 100% 3px; color: var(--accent); }
.contact__links { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1.75rem; }
.foot { max-width: var(--max); margin: 0 auto; padding: 1.5rem var(--gutter) 2.5rem; color: var(--muted); font-size: 0.8rem; }

/* ---------- Case study dialog ---------- */
.study {
  width: min(45rem, 100vw - 2rem); max-height: min(86vh, 56.25rem);
  padding: 0; border: 1px solid var(--line); border-radius: 1.125rem;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 1.875rem 5rem -1.25rem rgb(0 0 0 / 0.35);
}
.study::backdrop { background: rgb(10 14 20 / 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.study[open] { animation: study-in 0.35s var(--ease); }
.study[open]::backdrop { animation: fade 0.3s ease; }
.study.is-closing { animation: study-out 0.2s ease forwards; }
.study.is-closing::backdrop { animation: fade 0.2s ease reverse forwards; }
@keyframes study-in { from { opacity: 0; transform: translateY(1.125rem) scale(0.985); } }
@keyframes study-out { to { opacity: 0; transform: translateY(0.625rem) scale(0.99); } }
@keyframes fade { from { opacity: 0; } }
.study__bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 0.875rem 0.75rem clamp(1.25rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(0.5rem); -webkit-backdrop-filter: blur(0.5rem);
  border-bottom: 1px solid var(--line);
}
.study__kicker { font-size: var(--step--1); font-weight: 600; color: var(--accent); }
.study__body { padding: clamp(1.25rem, 4vw, 2.5rem); padding-top: 1.5rem; }
.study__body h2 { font-size: var(--step-2); letter-spacing: -0.02em; }
.study__lede { margin-top: 0.625rem; font-size: var(--step-1); line-height: 1.45; color: var(--muted); max-width: 52ch; }
.study__body h3 { margin-top: 2rem; font-size: var(--step-0); }
.study__body h3 + p, .study__body h3 + ul { margin-top: 0.5rem; }
.study__body p { max-width: 64ch; }
.study__body ul { display: grid; gap: 0.625rem; max-width: 64ch; }
.study__body ul li { position: relative; padding-left: 1.125rem; }
.study__body ul li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 0.375rem; height: 0.375rem; border-radius: 2px; background: var(--accent); }
.stats { margin-top: 0.75rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.625rem; }
.stats div { padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stats strong { display: block; font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.75rem); letter-spacing: -0.02em; line-height: 1.1; color: var(--accent); white-space: nowrap; }
.stats span { display: block; margin-top: 0.375rem; font-size: var(--step--1); color: var(--muted); line-height: 1.4; }
.study__body .muted-note { margin-top: 0.75rem; }
.study__links { margin-top: 1.75rem; }
body.has-modal { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .feature { grid-template-columns: 1fr; }
  .feature__art { border-right: 0; border-bottom: 1px solid var(--line); aspect-ratio: 16 / 7; padding: 1rem; }
  .feature__art svg { max-height: 100%; width: auto; }
  .more__row { grid-template-columns: minmax(0, 1fr) auto; }
  .more__row .tags { display: none; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: 2rem; }
}
@media (max-width: 680px) {
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .grid-demo { justify-self: start; max-width: 21.25rem; }
}
@media (max-width: 820px) {
  .paper { grid-template-columns: 1fr; }
  .paper__figure { order: 2; }
}
@media (max-width: 640px) {
  .job { grid-template-columns: 1fr; gap: 0.25rem; }
  .skills { grid-template-columns: 1fr; gap: 1.125rem; }
  .more__row { grid-template-columns: 1fr; gap: 0.625rem; }
  .more__link { justify-self: start; justify-content: flex-start; min-width: 0; }
  .feature__art { display: none; }
  .study { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 1.125rem 1.125rem 0 0; border-bottom: 0; }
  @keyframes study-in { from { transform: translateY(2.5rem); opacity: 0; } }
}
@media (max-width: 380px) {
  .hero__socials { margin-left: 0; }
  .btn { padding: 0 1rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 360px) {
  .nav__inner { gap: 0.5rem; }
  .nav__actions { gap: 2px; }
  .nav__name { font-size: 0.95rem; }
}

/* Desktop: the intro fills the first screen. */
@media (min-width: 900px) {
  .hero { min-height: calc(100svh - 4rem); padding-top: 0; padding-bottom: 2rem; }
}

/* ---------- Tactile FLORA flagship ---------- */
:root { --tf-warn: #ff8a70; --tf-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
:root[data-theme="light"] { --tf-warn: #c2410c; }
.feature--flagship { grid-template-columns: minmax(0, 1fr); }
.feature--flagship .feature__art { display: block; place-items: normal; margin: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: clamp(1rem, 2.5vw, 1.75rem); }
.feature--flagship .feature__art svg { max-width: none; }
.feature--flagship .feature__body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(1.5rem, 4vw, 3.5rem); }
.tf__copy { display: flex; flex-direction: column; }

.tf__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.tf__kicker { font-size: var(--step--1); font-weight: 600; color: var(--ink); }
.tf__kicker span { font-weight: 400; color: var(--muted); }
.tf__seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.tf__seg button {
  font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--muted); cursor: pointer;
  padding: 0.375rem 0.875rem; border: 0; border-radius: 999px; background: none; transition: background 0.2s, color 0.2s;
}
.tf__seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
@media (pointer: coarse) { .tf__seg button { min-height: 40px; } }

.tf__stage { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 0.75rem; }
.tf__panel {
  position: relative; display: flex; flex-direction: column; gap: 0.5rem; min-width: 0;
  padding: 0.875rem; border: 1px solid var(--line); border-radius: 0.75rem;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}
.tf__label { font-size: 0.78rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 0.5rem; }
.tf__label span { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 0.7rem; }
.tf__note { font-size: 0.75rem; color: var(--muted); }
.tf__cam, .tf__plot { width: 100%; height: auto; max-height: 12.5rem; display: block; overflow: hidden; margin-inline: auto; }

.tf-table { stroke: var(--wall); stroke-width: 2; }
.tf-cube { fill: color-mix(in srgb, var(--accent) 30%, var(--surface)); stroke: var(--accent); stroke-width: 1.5; }
.tf-wrist, .tf-finger { fill: var(--surface); stroke: var(--wall); stroke-width: 1.5; }
.tf-pad { fill: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); }
.is-bad .tf-pad { fill: var(--tf-warn); filter: drop-shadow(0 0 4px var(--tf-warn)); }
.tf-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
.tf-thresh { stroke: none; }
.tf-axis { font-size: 9px; fill: var(--muted); font-family: var(--tf-mono); }
.tf-line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
.tf-area { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.tf-head { fill: var(--ink); stroke: var(--accent); stroke-width: 2; }
.is-bad .tf-line { stroke: var(--tf-warn); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--tf-warn) 60%, transparent)); }
.is-bad .tf-area { fill: color-mix(in srgb, var(--tf-warn) 14%, transparent); }
.is-bad .tf-head { stroke: var(--tf-warn); }
.tf-flag { opacity: 0; transition: opacity 0.3s; }
.tf-flag.is-on { opacity: 1; }
.tf-flag path { stroke: var(--tf-warn); stroke-width: 1.25; stroke-dasharray: 2 2; }
.tf-flag rect { fill: var(--tf-warn); }
.tf-flag text { font-size: 9.5px; font-weight: 700; fill: var(--paper); }

.tf__prompt {
  margin: 0; flex: 1; min-height: 8.5rem; overflow: hidden; white-space: pre;
  font-family: var(--tf-mono); font-size: clamp(0.62rem, 0.55rem + 0.25vw, 0.74rem); line-height: 1.6; color: var(--muted);
  padding: 0.625rem 0.75rem; border-radius: 0.5rem; background: var(--paper); border: 1px solid var(--line);
}
.tf__prompt::first-line { color: var(--accent); }
.tf__scores { display: grid; gap: 0.375rem; }
.tf__score { display: grid; grid-template-columns: 6.5rem 1fr 3.25rem; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); }
.tf__score i { height: 0.5rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.tf__score b { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--wall); transition: width 0.25s linear; }
.tf__score strong { white-space: nowrap; font-family: var(--tf-mono); font-size: 0.72rem; color: var(--ink); text-align: right; }
.tf__score--hi span { color: var(--ink); font-weight: 600; }
.tf__score--hi b { background: var(--accent); }
.is-bad .tf__score--hi b { background: var(--tf-warn); }

.tf__results { display: flex; flex-direction: column; gap: 1.25rem; align-self: center; }
.tf__rhead { font-size: var(--step--1); font-weight: 700; }
.tf__rhead span { font-weight: 400; color: var(--muted); }
.tf__rgroup { display: grid; gap: 0.5rem; }
.tf__rgroup > p { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.tf__rbar { display: grid; grid-template-columns: 9.5rem 1fr 2.75rem; align-items: center; gap: 0.625rem; font-size: 0.8rem; }
.tf__rbar em { font-style: normal; color: var(--muted); }
.tf__rbar i { position: relative; height: 0.625rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.tf__rbar i::before { content: ""; position: absolute; inset: 0 auto 0 0; width: calc(var(--v) * 100%); border-radius: inherit; background: var(--wall); transform-origin: left; animation: tf-grow 1.2s var(--ease) both; }
.tf__rbar i::after { content: ""; position: absolute; top: -2px; bottom: -2px; left: 50%; border-left: 1px dashed var(--muted); opacity: 0.6; }
.tf__rbar strong { font-family: var(--tf-mono); font-size: 0.78rem; text-align: right; color: var(--muted); }
.tf__rbar--hi em, .tf__rbar--hi strong { color: var(--ink); font-weight: 700; }
.tf__rbar--hi i::before { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent)); box-shadow: 0 0 12px var(--accent); }
@keyframes tf-grow { from { transform: scaleX(0); } }

@media (max-width: 960px) {
  .tf__stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tf__panel--wide { grid-column: 1 / -1; }
  .feature--flagship .feature__body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .tf__stage { gap: 0.5rem; } .tf__panel { padding: 0.625rem; }
  .tf__rbar { grid-template-columns: 7.5rem 1fr 2.5rem; font-size: 0.75rem; }
  .tf__score { grid-template-columns: 5.75rem 1fr 3rem; }
}
@media (prefers-reduced-motion: reduce) { .tf__rbar i::before { animation: none; } .tf__score b { transition: none; } }
