*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f3ef;
  --panel: #e7e6e1;
  --screen: #fafaf7;
  --ink: #1c1c1a;
  --ink-2: #464641;
  --mid: #706f6a;
  --line: rgba(28, 28, 26, 0.14);
  --line-2: rgba(28, 28, 26, 0.08);
  --accent: #e0592a;
  --accent-ink: #ad4119; /* orange for small text: 4.7:1 on the panel */
  --green: #46843c;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --wrap: 1240px;
  --gutter: 40px;
}

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  font-family: var(--sans);
  font-optical-sizing: auto;
  font-feature-settings: "ss01", "cv11";
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
code, pre { font-family: var(--mono); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* Local review bar */
.review { display: flex; justify-content: center; gap: 16px; padding: 6px var(--gutter); font-size: 12px; background: var(--ink); color: #bdbcb6; }

/* Header */
.head { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid transparent; transition: border-color 0.2s; }
.head.scrolled { border-bottom-color: var(--line); }
.head-in { display: flex; align-items: center; gap: 36px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.logo img { width: 28px; height: 28px; }
.nav { display: flex; gap: 28px; margin-left: auto; }
.nav a { font-size: 14px; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.nav a:hover { color: var(--ink); }

/* Type scale */
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--mid); }
h1 { font-size: clamp(40px, 5vw, 68px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.02; }
h2 { font-size: clamp(28px, 2.7vw, 38px); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; }
h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.sub { font-size: clamp(20px, 2vw, 26px); font-weight: 400; letter-spacing: -0.02em; line-height: 1.25; color: var(--ink-2); }
.lede { font-size: 17px; line-height: 1.6; color: var(--ink-2); }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.btn { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; text-decoration: none; padding: 12px 18px; border-radius: 6px; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--ink-2); }
.btn-ghost { border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }

/* Hero */
.hero { padding: 56px 0 64px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; align-items: start; }
.hero-copy { padding-top: 12px; }
.hero-copy h1 { margin: 18px 0 18px; font-size: clamp(34px, 4.1vw, 56px); letter-spacing: -0.03em; line-height: 1.04; white-space: pre-line; text-wrap: balance; }
.hero-copy .sub { margin-bottom: 26px; max-width: 520px; white-space: pre-line; text-wrap: balance; }
.hero-copy .lede { max-width: 500px; }

/* Instrument: a device-like panel around a canvas */
.instrument { --mid: #5f5e59; background: var(--panel); border-radius: 22px; padding: 12px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 1px 0 rgba(28,28,26,0.04); }
.screen { position: relative; background: var(--screen); border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-2); }
.screen > canvas, .stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage { position: absolute; inset: 0; }
.screen.r-hero { aspect-ratio: 16 / 11; }
.screen.r-wide { aspect-ratio: 16 / 10; }
.screen.r-big { aspect-ratio: 16 / 9; }
/* Who is asking: the split screen (who.js lays itself out to the size it gets). */
.screen.r-who { aspect-ratio: 16 / 9; }
.readout { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 14px 8px 4px; min-height: 70px; }
.readout .moment { max-width: 560px; }
[data-system] .readout { min-height: 104px; }
.readout .moment b { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 4px; min-height: 14px; }
.readout .moment span { display: block; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.clock { display: flex; align-items: center; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.clock svg { width: 30px; height: 30px; }
.clock[hidden] { display: none; }

.controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; align-items: start; }
.keys { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.controls .keys { margin-top: 0; }
.key { appearance: none; border: 0; background: transparent; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 4px 4px; color: var(--mid); }
.key .cap { width: 100%; height: 34px; border-radius: 7px; background: var(--screen); box-shadow: 0 1px 0 rgba(28,28,26,0.12), inset 0 -2px 0 rgba(28,28,26,0.05); position: relative; transition: transform 0.08s, box-shadow 0.08s; }
.key .cap::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--line); transition: background 0.2s; }
.key span { font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.key[hidden] { display: none; }
.key[aria-selected="true"] { color: var(--ink); }
.key[aria-selected="true"] .cap { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(28,28,26,0.12); }
.key[aria-selected="true"] .cap::after { background: var(--accent); }
.key:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 8px; }
.instrument.is-paused .key[aria-selected="true"] .cap::after { background: var(--ink-2); }
.key-pause { width: 56px; }
.key-pause[hidden] { display: none; }
.key-pause .cap { display: grid; place-items: center; }
.key-pause .cap::after { display: none; }
.key-pause svg { width: 12px; height: 12px; fill: var(--ink-2); }
.instrument.is-paused .key-pause { color: var(--ink); }
.instrument.is-paused .key-pause .cap { transform: translateY(1px); box-shadow: inset 0 1px 2px rgba(28,28,26,0.12); }
.key-progress { height: 2px; background: var(--line-2); margin: 10px 68px 0 4px; border-radius: 2px; overflow: hidden; }
.key-progress i { display: block; height: 100%; width: 0; background: var(--ink-2); }
/* An instrument without keys: a progress line through its one scene, then the pause key. */
.controls.solo { align-items: center; }
.controls.solo .key-progress { margin: 0 8px 12px 4px; }
.controls[hidden] { display: none; }
.scene-note { padding: 14px 6px 4px; display: grid; }
.scene-note > div { display: grid; gap: 6px; align-content: start; }
.js .scene-note > div { grid-area: 1 / 1; }
html:not(.js) .scene-note { gap: 16px; }
/* Without scripts the screens stay empty: the keys and the progress line are not shown. */
html:not(.js) .instrument:not(.start-inst) .keys, html:not(.js) .key-progress { display: none; }
.scene-note > div[aria-hidden="true"] { visibility: hidden; }
.scene-note b { font-size: 15px; font-weight: 600; }
.scene-note span { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.scene-note .note-link { justify-self: start; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.scene-note .note-link:hover { text-decoration-color: var(--ink); }
.scene-note .note-link:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 2px; }

/* Sections */
.section { padding: 64px 0; border-top: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; margin-bottom: 40px; align-items: end; }
.section-head p { font-size: 17px; line-height: 1.6; color: var(--ink-2); max-width: 620px; }

.what-head .label, .who-head .label, .use-head .label, .how-head .label, .start .label { display: block; margin-bottom: 12px; }
.section-head h2 { text-wrap: balance; }
.section-head p { text-wrap: pretty; }

/* What it is: the label and one factual lede over the drawing (what.css). */
.what-head { max-width: 720px; margin-bottom: 32px; }
.what-lede { font-size: 20px; line-height: 1.45; letter-spacing: -0.014em; color: var(--ink); text-wrap: pretty; }

/* In use: the household at full size, its instrument with its text beside it. */
.system { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 40px; align-items: start; }
.system-copy .label { display: block; margin-bottom: 10px; }
.system-copy h3 { font-size: 24px; letter-spacing: -0.02em; margin-bottom: 12px; }
.system-copy p { color: var(--ink-2); margin-bottom: 18px; text-wrap: pretty; }
.list { list-style: none; border-top: 1px solid var(--line); }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; color: var(--ink-2); }
.facts { margin-top: 18px; display: grid; gap: 4px; }
.facts li { list-style: none; font-size: 13px; color: var(--mid); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 6px 2px; font-size: 12px; color: var(--mid); }
.legend[hidden] { display: none; }
/* All of a figure's legends share one cell, so switching views does not change its height. */
.legends { display: grid; }
.legends > .legend { grid-area: 1 / 1; align-content: start; }
.legends > .legend[hidden] { display: flex; visibility: hidden; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span.items { flex-wrap: wrap; row-gap: 4px; }
.legend i { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.legend i.coord { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px var(--ink); }
.legend i.helper { background: var(--screen); border: 1.3px solid var(--ink); }
.legend i.person { background: radial-gradient(circle, #706f6a 0 1.6px, transparent 2px); border: 1.4px solid #706f6a; }
.legend i.src { border-radius: 0; background: transparent; border: 1.2px solid #706f6a; }
.legend i.hot { background: var(--accent); }
.legend i.tone-mid { background: #706f6a; }
.legend i.msg { width: 14px; height: 3px; border-radius: 2px; background: var(--ink); }
.legend i.msg.green { background: var(--green); }
.legend i.msg.mid { background: #706f6a; }
.legend i.box { width: 14px; height: 9px; border-radius: 0; background: var(--screen); border: 1px solid rgba(28, 28, 26, 0.55); }
.legend i.kb { width: 14px; height: 9px; border-radius: 0; background: linear-gradient(rgba(28, 28, 26, 0.06), rgba(28, 28, 26, 0.06)), var(--screen); border: 1px solid rgba(28, 28, 26, 0.3); }
.legend i.frame { width: 11px; height: 11px; border-radius: 0; background: transparent; border: 1px dashed rgba(28, 28, 26, 0.45); }
.legend i.item { border-radius: 0; background: var(--accent); }
.legend i.item.open { background: transparent; border: 1px solid rgba(28, 28, 26, 0.6); }
.legend i.item.done { background: var(--ink); }
.legend i.item.skip { background: rgba(196, 194, 188, 0.6); }
.legend i.helper.sm { width: 7px; height: 7px; }
.legend i.rel { width: 14px; height: 1.5px; border-radius: 0; background: #8d8c86; }
.legend i.msg.acc { background: var(--accent); }
.legend i.dormant { background: rgba(28, 28, 26, 0.22); }
.legend i.ev { background: radial-gradient(circle, var(--ink) 0 1.2px, var(--screen) 1.6px); border: 1.4px solid var(--ink); }
.legend i.cand { background: var(--screen); border: 1.2px dashed var(--accent); }
.legend i.evid { width: 14px; height: 0; border-radius: 0; background: transparent; border-top: 1.5px dotted var(--accent); }
.legend i.srcs { width: 10px; height: 4px; border-radius: 0; background: linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 6px, var(--ink) 6px); }
.legend i.conf { width: 16px; height: 9px; border-radius: 0; background: transparent; border: 1.1px solid var(--accent); }
.legend .g { flex: none; width: 14px; height: 14px; overflow: visible; }
.legend .g .d { fill: var(--ink); }
.legend .g .d.faint { fill: rgba(28, 28, 26, 0.22); }
.legend .g .a { fill: none; stroke-width: 1.7; stroke-linecap: round; }
.legend .g .a.idle { stroke: #706f6a; stroke-opacity: 0.55; stroke-width: 1.5; }
.legend .g .a.w { stroke: var(--ink); }
.legend .g .a.r { stroke: #706f6a; }
.legend .g .a.q { stroke: var(--accent); }
.legend .g.kb path, .legend .g.kb ellipse { fill: var(--screen); stroke: var(--ink); stroke-width: 1.1; }
.legend span.items .g { margin-left: 4px; }

/* Transcript: what the zoomed-in agent is doing, line by line, beside the canvas */
.screen { --pane: clamp(272px, 40%, 400px); }
.transcript { position: absolute; top: 0; right: 0; bottom: 0; width: var(--pane); display: flex; flex-direction: column; background: var(--screen); border-left: 1px solid var(--line); }
.transcript[hidden] { display: none; }
.screen.split .stage { right: var(--pane); }
.tx-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 10px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--mid); border-bottom: 1px solid var(--line-2); }
.tx-live { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.instrument.is-paused .tx-live { background: var(--line); }
.tx-lines { flex: 1; min-height: 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 10px 16px 16px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tx-lines li { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 10px; padding: 4px 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-2); animation: tx-in 0.35s ease-out; }
.tx-lines .k { padding-top: 2.5px; font-size: 9px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mid); white-space: nowrap; }
.tx-lines .x { overflow-wrap: anywhere; }
.tx-lines code { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.tx-lines li.tx-think .x, .tx-lines li.tx-note .x { color: var(--mid); }
.tx-lines li.tx-input .x, .tx-lines li.tx-peer .x { color: var(--ink); }
.tx-lines li.sub { padding-top: 0; }
.tx-lines li.sub .x { padding-left: 10px; border-left: 1px solid var(--line); }
.tx-lines li.now .k { color: var(--accent-ink); }
.tx-lines li.now .k:empty::before { content: ""; display: block; width: 5px; height: 5px; margin-top: 4px; border-radius: 50%; background: var(--accent); }
@keyframes tx-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Reach it: the hero's keys over a dark screen; one pane per interface, all in one cell so
   switching keeps the height. Without scripts the panes stack and the keys stay hidden. */
.start { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; align-items: center; }
.start .lede { margin-top: 16px; }
.reach-note { margin-top: 22px; font-size: 14px; color: var(--mid); }
.term { font-family: var(--mono); background: var(--ink); color: #e7e6e1; border-radius: 14px; padding: 22px 24px; font-size: 13px; line-height: 1.65; overflow-x: auto; }
.term .c { color: #8d8c86; }
.term .p { color: #8d8c86; }
.start-inst .screen.term-screen { background: #1d1d1b; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04); }
.start-inst .term { background: transparent; border-radius: 0; margin: 0; scrollbar-width: thin; scrollbar-color: #3a3a37 transparent; }
.start-inst:not(.is-keyed) .term + .term { border-top: 1px solid rgba(255, 255, 255, 0.08); }
.start-inst .term .ln { display: block; white-space: pre-wrap; overflow-wrap: anywhere; padding-left: calc((var(--i, 0) + 4) * 1ch); text-indent: calc((var(--i, 0) + 4) * -1ch); }
.start-inst:not(.is-keyed) .keys { display: none; }
.start-inst.is-keyed .term-screen { display: grid; }
.start-inst.is-keyed .term-screen > [data-pane] { grid-area: 1 / 1; min-width: 0; }
.start-inst.is-keyed .term-screen > [aria-hidden="true"] { visibility: hidden; }
.start-inst .keys { margin-top: 12px; }

/* Footer */
.foot { border-top: 1px solid var(--line); padding: 28px 0 40px; }
.foot-in { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; font-size: 14px; }
.foot nav { display: flex; gap: 22px; }
.foot nav a { text-decoration: none; color: var(--ink-2); }
.foot .note { margin-left: auto; color: var(--mid); font-size: 13px; }

/* Responsive */
/* The systems stack earlier than the rest, so a split screen keeps room for its transcript. */
@media (max-width: 1200px) {
  .system { grid-template-columns: 1fr; }
  .system-copy { max-width: 640px; }
}
@media (max-width: 1080px) {
  .hero-grid, .section-head, .start { grid-template-columns: 1fr; }
  /* one column: the headline has the full width, so it may stay larger */
  .hero-copy h1 { font-size: clamp(34px, 6vw, 56px); max-width: 760px; }
  .start { grid-template-columns: minmax(0, 1fr); }
  .section-head { gap: 16px; }
  .section-head p, .system-copy { max-width: 640px; }
  .what-head { margin-bottom: 28px; }
  .section-head { margin-bottom: 24px; }
}
/* The large instrument (How it works) puts the transcript under the canvas
   below 1080px, so the drawing keeps the full width. */
@media (max-width: 1080px) {
  .screen.r-who { aspect-ratio: 3 / 2; }
  .screen.r-big.split { aspect-ratio: auto; }
  .screen.r-big.split .stage { position: relative; inset: auto; aspect-ratio: 16 / 11; }
  .screen.r-big .transcript { position: relative; width: auto; height: 240px; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 940px) {
  html { scroll-padding-top: 108px; }
  .head-in { flex-wrap: wrap; height: auto; gap: 0 20px; padding-top: 12px; }
  .nav { order: 3; flex: 0 0 calc(100% + 2 * var(--gutter)); margin: 0 calc(-1 * var(--gutter)); padding: 10px var(--gutter); gap: 20px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { font-size: 13.5px; }
}
@media (max-width: 720px) {
  :root { --gutter: 20px; }
  .what-lede { font-size: 18px; line-height: 1.45; }
  .hero { padding: 32px 0 56px; }
  .section { padding: 48px 0; }
  .section-head { margin-bottom: 20px; }
  .what-head { margin-bottom: 24px; }
  .instrument { padding: 8px; border-radius: 18px; margin: 0 -6px; }
  .screen.r-hero, .screen.r-wide, .screen.r-big { aspect-ratio: 4 / 5; }
  .screen.r-who { aspect-ratio: 1 / 1; }
  .screen.split { aspect-ratio: auto; }
  .screen.split .stage { position: relative; inset: auto; aspect-ratio: 1 / 1; }
  /* The large instruments keep a taller canvas above their transcript on phones. */
  .screen.r-big.split .stage { aspect-ratio: 4 / 5; }
  .screen.r-big .transcript { height: 216px; }
  .transcript { position: relative; width: auto; height: 216px; border-left: 0; border-top: 1px solid var(--line); }
  .tx-head { padding: 10px 14px 8px; }
  .tx-lines { padding: 8px 14px 12px; }
  .tx-lines li { grid-template-columns: 46px minmax(0, 1fr); gap: 8px; font-size: 12px; }
  .key span { white-space: normal; text-wrap: balance; text-align: center; line-height: 1.2; }
  .readout .moment span { font-size: 13px; }
  /* Clock beside the moment title, body at full width, so long captions do not push the legend. */
  [data-system] .readout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; align-items: center; align-content: start; min-height: 132px; }
  [data-system] .readout .moment { display: contents; }
  [data-system] .readout .moment b { grid-column: 1; grid-row: 1; margin: 0; }
  [data-system] .readout .clock { grid-column: 2; grid-row: 1; }
  [data-system] .readout .moment span { grid-column: 1 / -1; grid-row: 2; margin-top: 4px; }
  .controls, .keys { gap: 4px; }
  .key { padding-left: 0; padding-right: 0; }
  .key span { font-size: 10.5px; letter-spacing: -0.01em; }
  .key-pause { width: 28px; }
  .key-pause span { visibility: hidden; }
  .legend .wide-only { display: none; }
  .key-progress { margin-right: 32px; }
  .term { font-size: 11.5px; padding: 18px; }
  .start-inst .term { padding: 18px 16px; }
  .foot .note { margin-left: 0; }
}
/* Five sections in the nav: phones keep them on one line down to 360px (below that it scrolls). */
@media (max-width: 440px) {
  .nav { gap: 14px; }
  .nav a { font-size: 13px; }
}
@media (max-width: 380px) {
  .nav { gap: 10px; }
  .nav a { font-size: 12.5px; }
}
/* Phones: the split screen stands taller, so both columns keep their words. */
@media (max-width: 540px) {
  .screen.r-who { aspect-ratio: 2 / 3; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tx-lines li { animation: none; }
  * { transition: none !important; }
  .key-progress { display: none; }
}

.section-head p:empty { display: none; }
