/* Physical AI Systems Map — shared stylesheet
   Layout concept: engineering reference manual. Persistent left rail = the pipeline (ordered, numbered
   because stage order is real), working column for prose (~72ch), wide column for tables/diagrams.
   Tags use one consistent hue per technique across every page. */

:root {
  /* palette — light */
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #e9edf3;
  --fg: #141820;
  --muted: #566074;
  --line: #d4dae3;
  --line-strong: #aab3c2;
  --accent: #2346c4;
  --accent-ink: #1a3594;
  --accent-soft: #e3e9fb;
  --frontier: #a8226a;
  --frontier-soft: #f8e4ef;
  --ok: #1d7347;
  --warn: #9a5a00;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(20, 24, 32, .06), 0 4px 16px rgba(20, 24, 32, .05);

  /* technique / location tag hues (text on soft tint) */
  --t-cloud: #1c6db5;   --t-cloud-bg: #e2eef9;
  --t-onprem: #3b5b8c;  --t-onprem-bg: #e5ebf4;
  --t-sim: #6a43be;     --t-sim-bg: #eee8fa;
  --t-edge: #a35100;    --t-edge-bg: #fbeedd;
  --t-robot: #8a3a12;   --t-robot-bg: #f8e9e1;
  --t-rl: #b8233f;      --t-rl-bg: #fae4e8;
  --t-il: #157240;      --t-il-bg: #e0f3e8;
  --t-classical: #46536a; --t-classical-bg: #e7eaf0;
  --t-s2r: #0f6e66;     --t-s2r-bg: #ddf2ef;
  --t-r2s: #0c6a86;     --t-r2s-bg: #dcf0f6;
  --t-r2s2r: #155f9c;   --t-r2s2r-bg: #e0ecf7;
  --t-fm: #3a33a3;      --t-fm-bg: #e7e6f8;
  --t-wam: #7a1fb8;     --t-wam-bg: #f2e5fa;
  --t-icl: #557015;     --t-icl-bg: #eef3dc;

  /* type */
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-base: .9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.875rem;
  --fs-xxl: 2.5rem;

  --rail-w: 17.5rem;
  --radius: 6px;
  --measure: 72ch;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #151a22;
    --surface-2: #1c2230;
    --fg: #e4e8ef;
    --muted: #9aa5b8;
    --line: #283041;
    --line-strong: #3d4860;
    --accent: #8ea8ff;
    --accent-ink: #b4c5ff;
    --accent-soft: #1d2747;
    --frontier: #f07ab8;
    --frontier-soft: #3a1a2c;
    --ok: #5fcf93;
    --warn: #f0b04f;
    --bad: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
    --t-cloud: #7fb8ee;   --t-cloud-bg: #16283b;
    --t-onprem: #9fb5d8;  --t-onprem-bg: #1b2433;
    --t-sim: #b9a0f0;     --t-sim-bg: #241c3a;
    --t-edge: #f2b469;    --t-edge-bg: #33240f;
    --t-robot: #ec9e78;   --t-robot-bg: #331d13;
    --t-rl: #f28b9d;      --t-rl-bg: #3a1720;
    --t-il: #74d3a0;      --t-il-bg: #12301f;
    --t-classical: #b1bccd; --t-classical-bg: #232a36;
    --t-s2r: #6fd3c8;     --t-s2r-bg: #0f2e2b;
    --t-r2s: #6ccbe6;     --t-r2s-bg: #0f2a33;
    --t-r2s2r: #85b9ea;   --t-r2s2r-bg: #142738;
    --t-fm: #a9a4f2;      --t-fm-bg: #1f1d3d;
    --t-wam: #d29af5;     --t-wam-bg: #2c1840;
    --t-icl: #b8d779;     --t-icl-bg: #232e10;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #151a22;
  --surface-2: #1c2230;
  --fg: #e4e8ef;
  --muted: #9aa5b8;
  --line: #283041;
  --line-strong: #3d4860;
  --accent: #8ea8ff;
  --accent-ink: #b4c5ff;
  --accent-soft: #1d2747;
  --frontier: #f07ab8;
  --frontier-soft: #3a1a2c;
  --ok: #5fcf93;
  --warn: #f0b04f;
  --bad: #ff8a80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .25);
  --t-cloud: #7fb8ee;   --t-cloud-bg: #16283b;
  --t-onprem: #9fb5d8;  --t-onprem-bg: #1b2433;
  --t-sim: #b9a0f0;     --t-sim-bg: #241c3a;
  --t-edge: #f2b469;    --t-edge-bg: #33240f;
  --t-robot: #ec9e78;   --t-robot-bg: #331d13;
  --t-rl: #f28b9d;      --t-rl-bg: #3a1720;
  --t-il: #74d3a0;      --t-il-bg: #12301f;
  --t-classical: #b1bccd; --t-classical-bg: #232a36;
  --t-s2r: #6fd3c8;     --t-s2r-bg: #0f2e2b;
  --t-r2s: #6ccbe6;     --t-r2s-bg: #0f2a33;
  --t-r2s2r: #85b9ea;   --t-r2s2r-bg: #142738;
  --t-fm: #a9a4f2;      --t-fm-bg: #1f1d3d;
  --t-wam: #d29af5;     --t-wam-bg: #2c1840;
  --t-icl: #b8d779;     --t-icl-bg: #232e10;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
}
[hidden] { display: none !important; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--surface-2); padding: .08em .35em; border-radius: 3px; overflow-wrap: anywhere; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--fs-xxl); font-weight: 750; font-stretch: 112%; letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); font-weight: 700; font-stretch: 108%; }
h3 { font-size: var(--fs-md); font-weight: 650; }
h4 { font-size: var(--fs-base); font-weight: 650; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.25rem; }
li + li { margin-top: .3rem; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 100; background: var(--surface); padding: .5rem 1rem; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--surface);
  padding-block: 1rem 2rem; padding-inline: 0;
}
.rail .brand { display: block; padding: 0 1.1rem .9rem; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); }
.rail .brand b { font-family: var(--font-display); font-stretch: 115%; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; display: block; }
.rail .brand span { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }
.rail h2 { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 1rem 1.1rem .35rem; }
.rail ol, .rail ul { list-style: none; padding: 0; margin: 0; }
.rail li + li { margin-top: 0; }
.rail a.nav {
  display: grid; grid-template-columns: 2.1rem 1fr; align-items: baseline;
  padding: .28rem 1.1rem; color: var(--fg); text-decoration: none; font-size: var(--fs-sm); line-height: 1.35;
  border-left: 3px solid transparent;
}
.rail a.nav .n { font-family: var(--font-mono); color: var(--muted); font-size: var(--fs-xs); }
.rail a.nav:hover { background: var(--surface-2); }
.rail a.nav[aria-current="page"] { border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.rail a.nav.dim { opacity: .38; }
.rail .group-label { padding: .6rem 1.1rem .2rem; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }

.maincol { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center;
  padding-block: .55rem; padding-inline: 1.5rem;
}
.btn.menu-btn { display: none; }
.btn {
  font: inherit; font-size: var(--fs-sm); color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius); padding: .3rem .6rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn:hover { border-color: var(--accent); }
.search { position: relative; flex: 1 1 16rem; min-width: 0; max-width: 30rem; }
.search input {
  width: 100%; font: inherit; font-size: var(--fs-sm); padding: .4rem .7rem .4rem 2rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--fg);
}
.search svg { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--muted); fill: none; }
.search .results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 40; min-width: min(34rem, 92vw);
}
.search .results a { display: block; padding: .5rem .75rem; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); }
.search .results a:last-child { border-bottom: 0; }
.search .results a.active, .search .results a:hover { background: var(--accent-soft); }
.search .results .k { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-right: .4rem; }
.search .results .t { font-weight: 600; font-size: var(--fs-sm); }
.search .results .s { display: block; font-size: var(--fs-xs); color: var(--muted); margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search .results .empty { padding: .75rem; color: var(--muted); font-size: var(--fs-sm); }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chips .lbl { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); margin-right: .15rem; }
.chip {
  font: inherit; font-size: var(--fs-xs); font-weight: 500; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  padding: .18rem .55rem; border-radius: 999px; line-height: 1.4;
}
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip.clear { border-style: dashed; color: var(--muted); }

.page { padding-block: 1.75rem 4rem; padding-inline: 1.5rem; max-width: 76rem; width: 100%; }
.crumbs { font-size: var(--fs-xs); font-family: var(--font-mono); color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }
.crumbs span + span::before { content: " / "; padding: 0 .2rem; }

/* ---------- page header ---------- */
.phead { display: grid; gap: .6rem; margin-bottom: 1.5rem; max-width: 60rem; }
.phead .lede { font-size: var(--fs-md); color: var(--muted); max-width: var(--measure); }
.metaline { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }
.metaline b { color: var(--fg); font-weight: 500; }
.toc { display: flex; flex-wrap: wrap; gap: .25rem .35rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.toc li + li { margin-top: 0; }
.toc a { font-size: var(--fs-xs); font-family: var(--font-mono); text-decoration: none; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: .1rem .4rem; display: inline-block; }
.toc a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- sections ---------- */
.sec { padding-top: 2rem; margin-top: 2rem; border-top: 1px solid var(--line); scroll-margin-top: 4.5rem; }
.sec > header { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.sec > header .num { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); min-width: 1.6rem; }
.prose { max-width: var(--measure); display: grid; gap: .75rem; }
.prose p, .prose li { overflow-wrap: break-word; }
.callout {
  max-width: var(--measure); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); padding: .9rem 1rem; border-radius: var(--radius);
}
.callout.big p { font-size: var(--fs-md); font-family: var(--font-display); font-weight: 500; line-height: 1.45; }
.callout.frontier { border-left-color: var(--frontier); }
.callout h4 { margin-bottom: .35rem; }
.twocol { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.twocol > * { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.panel h3 { margin-bottom: .5rem; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
th, td { text-align: left; vertical-align: top; padding: .5rem .65rem; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ↕"; opacity: .45; }
th.sortable[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }
td .what { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: .15rem; max-width: 22rem; }
td.name { min-width: 10rem; }
td.name b { font-weight: 600; }
td.wide { min-width: 11rem; }
td.date { white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-xs); }
tr.superseded td { opacity: .6; }
tr.superseded td.name b { text-decoration: line-through; }
table.tools tbody tr:target, tr.flash { background: var(--accent-soft); }
.filternote { font-size: var(--fs-xs); color: var(--muted); padding: .4rem .2rem; }
.filternote button { font: inherit; color: var(--accent); background: none; border: 0; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---------- tags / badges ---------- */
.tag {
  display: inline-block; font-family: var(--font-mono); font-size: .6875rem; font-weight: 500; line-height: 1.5;
  padding: 0 .4rem; border-radius: 3px; white-space: nowrap; letter-spacing: .02em;
}
.tags { display: inline-flex; flex-wrap: wrap; gap: .25rem; vertical-align: middle; }
.tag-cloud { color: var(--t-cloud); background: var(--t-cloud-bg); }
.tag-onprem { color: var(--t-onprem); background: var(--t-onprem-bg); }
.tag-sim { color: var(--t-sim); background: var(--t-sim-bg); }
.tag-edge { color: var(--t-edge); background: var(--t-edge-bg); }
.tag-robot { color: var(--t-robot); background: var(--t-robot-bg); }
.tag-rl { color: var(--t-rl); background: var(--t-rl-bg); }
.tag-il { color: var(--t-il); background: var(--t-il-bg); }
.tag-classical { color: var(--t-classical); background: var(--t-classical-bg); }
.tag-sim2real { color: var(--t-s2r); background: var(--t-s2r-bg); }
.tag-real2sim { color: var(--t-r2s); background: var(--t-r2s-bg); }
.tag-real2sim2real { color: var(--t-r2s2r); background: var(--t-r2s2r-bg); }
.tag-fm { color: var(--t-fm); background: var(--t-fm-bg); }
.tag-wam { color: var(--t-wam); background: var(--t-wam-bg); }
.tag-icl { color: var(--t-icl); background: var(--t-icl-bg); }
.tag-frontier { color: var(--frontier); background: var(--frontier-soft); font-weight: 600; }
.tag-open { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tag-closed { color: var(--muted); background: var(--surface-2); }
.tag-mixed { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.mat { font-family: var(--font-mono); font-size: var(--fs-xs); white-space: nowrap; }
.mat::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .3rem; vertical-align: 0; border: 1.5px solid currentColor; }
.mat-research { color: var(--warn); }
.mat-pilot { color: var(--accent); }
.mat-pilot::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.mat-production { color: var(--ok); }
.mat-production::before { background: currentColor; }
.verdict { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.verdict-breakthrough { color: var(--frontier); }
.verdict-important { color: var(--accent); }
.verdict-incremental { color: var(--muted); }

/* ---------- level meters (where / technique) ---------- */
.meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: .5rem; }
.meter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; display: grid; gap: .2rem; min-width: 0; }
.meter .top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 9px; height: 9px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line-strong); display: inline-block; }
.dots i.on { background: var(--fg); border-color: var(--fg); }
.meter .note { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.meter.l0 { opacity: .55; }

/* ---------- methods ---------- */
.methods { display: grid; gap: 0; border-top: 1px solid var(--line); }
.method { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: .4rem 1.25rem; padding: .9rem 0; border-bottom: 1px solid var(--line); scroll-margin-top: 4.5rem; }
.method h3 { font-size: var(--fs-base); }
.method .side { display: grid; gap: .35rem; align-content: start; }
.method .body { display: grid; gap: .45rem; max-width: var(--measure); }
.method .tradeoffs { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .3rem 1rem; font-size: var(--fs-sm); }
.method .tradeoffs div { min-width: 0; }
.method .tradeoffs b { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; }
.method.is-frontier h3::after { content: "FRONTIER"; margin-left: .5rem; font-family: var(--font-mono); font-size: .625rem; letter-spacing: .08em; color: var(--frontier); vertical-align: middle; }

/* ---------- lists ---------- */
.pitfalls { list-style: none; padding: 0; display: grid; gap: .65rem; max-width: var(--measure); }
.pitfalls li + li { margin-top: 0; }
.pitfalls li { padding-left: 1rem; border-left: 2px solid var(--bad); }
.pitfalls b { display: block; }
.papers { list-style: none; padding: 0; display: grid; gap: .55rem; max-width: var(--measure); }
.papers li + li { margin-top: 0; }
.papers .yr { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); margin-right: .4rem; }
.papers .why { display: block; font-size: var(--fs-sm); color: var(--muted); }

details.qa { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-width: 60rem; }
details.qa + details.qa { margin-top: .5rem; }
details.qa summary { cursor: pointer; padding: .7rem .9rem; font-weight: 600; list-style: none; display: grid; grid-template-columns: 1.8rem 1fr; }
details.qa summary::-webkit-details-marker { display: none; }
details.qa summary .q { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); padding-top: .15rem; }
details.qa[open] summary { border-bottom: 1px solid var(--line); }
details.qa .a { padding: .75rem .9rem .9rem 2.7rem; display: grid; gap: .5rem; max-width: var(--measure); }

/* ---------- pipeline diagrams ---------- */
.diagram { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
.diagram svg { display: block; min-width: 56rem; width: 100%; height: auto; }
.diagram.mini svg { min-width: 46rem; }
.d-lane { fill: var(--surface-2); }
.d-lane-label { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; }
.d-node rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.2; }
.d-node text { fill: var(--fg); font-family: var(--font-body); font-size: 12px; }
.d-node .d-num { fill: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.d-node:hover rect, .d-node:focus rect { stroke: var(--accent); stroke-width: 2; }
.d-node.cur rect { fill: var(--accent); stroke: var(--accent); }
.d-node.cur text, .d-node.cur .d-num { fill: var(--surface); }
.d-node.up rect { stroke: var(--accent); stroke-dasharray: 4 3; }
.d-node.down rect { stroke: var(--accent); stroke-width: 2; }
.d-node.dim { opacity: .25; }
.d-node.hit rect { stroke: var(--frontier); stroke-width: 2.2; }
.d-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.4; }
.d-edge.fb { stroke: var(--frontier); stroke-dasharray: 5 4; }
.d-edge.hot { stroke: var(--accent); stroke-width: 2; }
.d-arrow { fill: var(--line-strong); }
.d-arrow.fb { fill: var(--frontier); }
.d-arrow.hot { fill: var(--accent); }
.d-elabel { fill: var(--muted); font-family: var(--font-mono); font-size: 10px; }
.d-elabel.fb { fill: var(--frontier); }
.d-band rect { fill: var(--bad); opacity: .09; }
.d-band text { fill: var(--bad); font-family: var(--font-mono); font-size: 11px; }
.d-band:hover rect { opacity: .16; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: var(--fs-xs); color: var(--muted); margin-top: .5rem; }
.legend .sw { display: inline-block; width: 1.6rem; height: 0; border-top: 2px solid var(--line-strong); vertical-align: middle; margin-right: .35rem; }
.legend .sw.fb { border-top: 2px dashed var(--frontier); }
.legend .sw.box { width: .8rem; height: .8rem; border: 1px solid var(--line-strong); border-radius: 2px; }

/* runtime diagram */
.rt-group rect.grp { fill: var(--surface-2); stroke: var(--line); }
.rt-group text.gl { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; }
.rt-proc rect { stroke-width: 1.3; }
.rt-proc.learned rect { fill: var(--t-fm-bg); stroke: var(--t-fm); }
.rt-proc.classical rect { fill: var(--t-classical-bg); stroke: var(--t-classical); }
.rt-proc.safety rect { fill: color-mix(in srgb, var(--bad) 12%, var(--surface)); stroke: var(--bad); }
.rt-proc.infra rect { fill: var(--surface); stroke: var(--line-strong); }
.rt-proc text { fill: var(--fg); font-family: var(--font-body); font-size: 11.5px; }
.rt-proc text.hz { fill: var(--muted); font-family: var(--font-mono); font-size: 10.5px; }
.rt-flow { fill: none; stroke: var(--line-strong); stroke-width: 1.3; }
.rt-flow.safety { stroke: var(--bad); }

/* matrix */
table.matrix td.cell { text-align: center; white-space: nowrap; }
table.matrix td.cell .dots { justify-content: center; }
table.matrix td.cell .cn { display: block; font-size: .6875rem; color: var(--muted); white-space: normal; min-width: 7rem; max-width: 10rem; margin: .15rem auto 0; line-height: 1.3; }
table.matrix td.cell.l0 { opacity: .5; }
table.matrix th.rowh { position: sticky; left: 0; background: var(--surface); z-index: 1; text-transform: none; font-family: var(--font-body); font-size: var(--fs-sm); color: var(--fg); letter-spacing: 0; white-space: normal; min-width: 11rem; }

/* frontier cards */
.fgrid { display: grid; gap: 0; border-top: 1px solid var(--line); }
.fitem { padding: 1.1rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 16rem) minmax(0, 1fr); gap: .5rem 1.5rem; scroll-margin-top: 4.5rem; }
.fitem .side { display: grid; gap: .4rem; align-content: start; }
.fitem .body { display: grid; gap: .55rem; max-width: var(--measure); }
.fitem dl { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .3rem .9rem; margin: 0; font-size: var(--fs-sm); }
.fitem dt { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding-top: .15rem; }
.fitem dd { margin: 0; min-width: 0; }

/* timeline */
.tl text { font-family: var(--font-mono); font-size: 10.5px; fill: var(--muted); }
.tl text.ev { fill: var(--fg); font-family: var(--font-body); font-size: 11px; }
.tl line.axis { stroke: var(--line-strong); }
.tl line.tick { stroke: var(--line); }
.tl circle { stroke: var(--surface); stroke-width: 1.5; }
.tl circle.breakthrough { fill: var(--frontier); }
.tl circle.important { fill: var(--accent); }
.tl circle.incremental { fill: var(--muted); }
.tl circle.infra { fill: var(--line-strong); }
.tl line.stem { stroke: var(--line-strong); stroke-width: 1; }

/* prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.pager a { display: grid; gap: .15rem; text-decoration: none; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); }
.pager a:hover { border-color: var(--accent); }
.pager a.next { text-align: right; }
.pager .eyebrow { font-size: .6875rem; }
.foot { padding-block: 1.25rem 2rem; padding-inline: 1.5rem; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }

/* landing */
.hero { display: grid; gap: .9rem; margin-bottom: 1.5rem; max-width: 62rem; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.1rem); font-stretch: 118%; }
.hero p { max-width: 68ch; font-size: var(--fs-md); color: var(--muted); }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem; }
.cards3 > * { min-width: 0; }
.linkcard { display: grid; gap: .3rem; padding: .85rem 1rem; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.linkcard:hover { border-color: var(--accent); }
.linkcard b { font-family: var(--font-display); font-weight: 650; }
.linkcard span { color: var(--muted); font-size: var(--fs-sm); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; font-size: var(--fs-sm); }
.kv dt { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); padding-top: .1rem; }
.kv dd { margin: 0; }

/* responsive */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(19rem, 86vw); z-index: 60; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); padding-top: calc(1rem + env(safe-area-inset-top, 0px)); }
  .rail.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .page, .foot { padding-inline: 1rem; }
  .topbar { position: static; }
  .sec, .method, .fitem { scroll-margin-top: 1rem; }
  .method, .fitem { grid-template-columns: minmax(0, 1fr); }
  .fitem dl { grid-template-columns: minmax(0, 1fr); }
  .fitem dt { padding-top: .4rem; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: var(--fs-xl); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .rail, .topbar, .pager { display: none; }
  .app { display: block; }
}
