:root {
  --navy: #051E39;
  --navy-2: #0d2d52;
  --gold: #B39051;
  --gold-dark: #8F713D;
  --cream: #F9F6E5;
  --ink: #1d2430;
  --ink-2: #4a5462;
  --ink-3: #6f7886;
  --line: #e4e1d6;
  --bg: #ffffff;
  --panel: #f7f6f1;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: "Crimson Pro", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img, video, canvas { max-width: 100%; display: block; }
a { color: var(--navy-2); text-underline-offset: 2px; }
a:hover { color: var(--gold-dark); }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--panel); padding: 1px 5px; border-radius: 4px; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }

/* ---------- top bar ---------- */
#bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
#bar .wrap { display: flex; align-items: center; gap: 18px; height: 52px; overflow-x: auto; scrollbar-width: none; }
#bar .wrap::-webkit-scrollbar { display: none; }
#bar .mark { font: 600 18px var(--serif); color: var(--navy); text-decoration: none; white-space: nowrap; margin-right: auto; }
#bar a.sec { color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
#bar a.sec:hover, #bar a.sec.on { color: var(--navy); }
#bar a.sec.on { box-shadow: inset 0 -2px 0 var(--gold); }

/* ---------- header ---------- */
header.hero { padding: 56px 0 28px; text-align: center; }
header.hero h1 {
  font: 700 clamp(32px, 5.2vw, 52px)/1.08 var(--serif);
  color: var(--navy); margin: 0 auto 14px; max-width: 840px; letter-spacing: -0.01em;
}
header.hero .sub { font: 500 clamp(18px, 2.4vw, 22px)/1.4 var(--serif); color: var(--ink-2); margin: 0 auto 26px; max-width: 700px; font-style: italic; }
.authors { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 26px; font-size: 17px; }
.authors a, .authors span { color: var(--navy-2); text-decoration: none; }
.authors a:hover { text-decoration: underline; }
.affil { color: var(--ink-3); font-size: 15px; margin-top: 6px; }
.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: 999px;
  background: var(--navy); color: #fff; text-decoration: none; font-size: 15px; font-weight: 500;
  border: 1px solid var(--navy);
}
.btn:hover { background: var(--navy-2); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: var(--cream); color: var(--navy); }
.btn svg { width: 16px; height: 16px; }

/* ---------- teaser ---------- */
.teaser { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 40px; align-items: center; padding: 18px 0 8px; }
.teaser .vid { border-radius: 14px; overflow: hidden; background: #000; position: relative; aspect-ratio: 4 / 5; }
.teaser .vid video { width: 100%; height: 100%; object-fit: cover; }
.teaser.robot { align-items: start; padding-top: 4px; }
.teaser.robot .lead, .teaser.robot p { font-size: 16px; }
.tag {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  background: rgba(5, 30, 57, 0.82); color: #fff; font: 500 12px var(--sans);
  padding: 3px 9px; border-radius: 999px; letter-spacing: 0.02em;
}
.teaser .lead { font-size: 18px; line-height: 1.6; color: var(--ink); margin: 0 0 22px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 12px; background: var(--bg); }
.tile .n { font: 700 30px/1 var(--serif); color: var(--navy); }
.tile .n small { font-size: 0.55em; font-weight: 600; color: var(--ink-2); }
.tile .l { font-size: 13px; line-height: 1.4; color: var(--ink-2); margin-top: 6px; }

/* ---------- sections ---------- */
section { padding: 52px 0 12px; }
section + section { border-top: 1px solid var(--line); margin-top: 32px; }
h2 { font: 700 34px/1.15 var(--serif); color: var(--navy); margin: 0 0 6px; }
h2 + .kicker { color: var(--ink-3); margin: 0 0 22px; font-size: 15px; }
h3 { font: 600 23px/1.25 var(--serif); color: var(--navy); margin: 36px 0 10px; }
p { margin: 0 0 14px; }
.muted { color: var(--ink-3); }
figure { margin: 22px 0; }
figcaption { font-size: 14px; color: var(--ink-2); line-height: 1.55; margin-top: 10px; }
figcaption b { color: var(--ink); font-weight: 600; }
.rounded { border-radius: 12px; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid2 figure, .grid3 figure { margin: 0; }
.media-frame { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); position: relative; }
.media-frame img, .media-frame video { width: 100%; }
.media-frame.mech img { aspect-ratio: 4 / 3; object-fit: cover; object-position: center 62%; }
.portrait video { aspect-ratio: 4 / 5; object-fit: cover; background: #000; }

/* ---------- pipeline ---------- */
.pipeline { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; margin: 24px 0 8px; }
.zone { border: 1.5px dashed #c9c3ae; border-radius: 14px; padding: 14px; position: relative; }
.zone > .zl { position: absolute; top: -11px; left: 14px; background: var(--bg); padding: 0 8px; font: 600 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold-dark); }
.chain { display: flex; flex-direction: column; gap: 8px; }
.node { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 12px; }
.node b { display: block; color: var(--navy); font-size: 14.5px; }
.node span { color: var(--ink-2); font-size: 13px; line-height: 1.4; display: block; }
.node.key { background: var(--cream); border-color: #e5dcb8; }
.flow { color: var(--gold); text-align: center; font-size: 13px; line-height: 1; }
.wire { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; min-width: 120px; color: var(--ink-2); font-size: 12.5px; text-align: center; }
.wire .line { width: 100%; height: 2px; background: var(--gold); position: relative; }
.wire .line::after { content: ""; position: absolute; right: -2px; top: -5px; border: 6px solid transparent; border-left: 8px solid var(--gold); }
.wire code { font-size: 11.5px; white-space: nowrap; }

/* ---------- tables ---------- */
table.ops { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 10px 0 6px; }
table.ops th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; border-bottom: 1px solid var(--ink-3); padding: 6px 10px 6px 0; }
table.ops td { border-bottom: 1px solid var(--line); padding: 8px 10px 8px 0; vertical-align: top; }
table.ops td:first-child { font-family: var(--mono); font-size: 13px; color: var(--navy); white-space: nowrap; }
pre.wirefmt { background: var(--navy); color: #e8e4d0; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 12.5px/1.6 var(--mono); margin: 12px 0; }
pre.wirefmt .c { color: #9aa6b5; }

ol.fsm { counter-reset: s; list-style: none; padding: 0; margin: 14px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
ol.fsm li { counter-increment: s; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 10px 40px; position: relative; font-size: 14px; line-height: 1.45; }
ol.fsm li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 20px; height: 20px; border-radius: 50%; background: var(--navy); color: #fff; font: 600 11.5px/20px var(--sans); text-align: center; }
ol.fsm li b { color: var(--navy); display: block; }

/* ---------- replay viewer ---------- */
.viewer { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg); margin: 20px 0 8px; }
.viewer-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.seg { display: inline-flex; border: 1px solid #cfcab8; border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 13px; font: 500 13px var(--sans); color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button + button { border-left: 1px solid #e6e2d4; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; }
.stage { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(#fbfaf6, #efede4); }
.stage canvas { width: 100% !important; height: 100% !important; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.stage .status { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.pill { background: rgba(255, 255, 255, 0.92); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; font: 500 12.5px var(--sans); color: var(--ink); width: fit-content; }
.pill.phase { background: var(--navy); border-color: var(--navy); color: #fff; }
.stage .hint { position: absolute; right: 12px; bottom: 10px; font-size: 12px; color: var(--ink-3); pointer-events: none; }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; }
.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; contain: size; }
.side h4 { margin: 0; padding: 12px 14px 8px; font: 600 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); display: flex; justify-content: space-between; }
.log { position: relative; list-style: none; margin: 0; padding: 0 6px 8px; overflow-y: auto; flex: 1; min-height: 0; font: 12.5px/1.35 var(--mono); }
.log li { display: grid; grid-template-columns: 44px 84px 1fr; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--ink-3); }
.log li.past { color: var(--ink-2); }
.log li.now { background: var(--cream); color: var(--navy); }
.log li .op { font-weight: 600; }
.op-CLAMP { color: #1f5f9e; } .op-RELEASE { color: #9c5d12; } .op-ROTATE { color: #6b3fa0; } .op-DUAL_HOLD { color: #2e6b47; }
.log li:not(.past):not(.now) .op { color: inherit; }
.moves { display: flex; flex-wrap: wrap; gap: 5px; padding: 12px 14px 4px; border-top: 1px solid var(--line); }
.moves .mv { font: 600 13px var(--mono); padding: 3px 7px; border-radius: 6px; background: var(--panel); color: var(--ink-3); border: 1px solid transparent; }
.moves .mv.done { color: var(--ink); }
.moves .mv.now { background: var(--gold); color: #fff; }
.controls { display: flex; align-items: center; gap: 12px; padding: 10px 14px 12px; }
.play { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.play svg { width: 16px; height: 16px; }
.scrub { flex: 1; position: relative; height: 26px; }
.scrub input { position: absolute; inset: 0; width: 100%; margin: 0; z-index: 2; opacity: 0; cursor: pointer; }
.scrub .track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; border-radius: 2px; background: #e6e2d4; overflow: hidden; }
.scrub .scan { position: absolute; top: 0; bottom: 0; background: #d9cfae; }
.scrub .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--navy); }
.scrub .knob { position: absolute; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); transform: translateX(-7px); }
.time { font: 12.5px var(--mono); color: var(--ink-3); min-width: 92px; text-align: right; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-3); padding: 0 14px 12px; }
.legend-row i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; margin: 18px 0; }
.chart h5 { margin: 0 0 2px; font: 600 15px var(--sans); color: var(--ink); }
.chart .note { font-size: 13px; color: var(--ink-3); margin: 0 0 6px; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .ax { font: 11.5px var(--sans); fill: var(--ink-3); }
.chart .axl { stroke: #c9c4b4; stroke-width: 1; }
.chart .grid { stroke: #eeebe2; stroke-width: 1; }
.chart .bar { fill: var(--navy); }
.chart .bar.hl { fill: var(--gold-dark); }
.chart .hit { fill: transparent; cursor: default; }
.chart .med { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 4 3; }
.chart .medl { font: 600 11.5px var(--sans); fill: var(--gold-dark); }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--navy); color: #fff; font: 12.5px/1.4 var(--sans); padding: 6px 9px; border-radius: 6px; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 0.08s; white-space: nowrap; }
.tip b { font-weight: 600; }
details.table { margin: 4px 0 0; font-size: 14px; }
details.table summary { cursor: pointer; color: var(--navy-2); }
details.table table { border-collapse: collapse; margin-top: 10px; font-size: 13.5px; }
details.table th, details.table td { padding: 4px 14px 4px 0; border-bottom: 1px solid var(--line); text-align: right; }
details.table th:first-child, details.table td:first-child { text-align: left; }

/* ---------- misc ---------- */
.callout { border-left: 3px solid var(--gold); background: var(--cream); padding: 12px 16px; border-radius: 0 10px 10px 0; font-size: 15px; margin: 18px 0; }
.team { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.member { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.member .nm { font: 600 18px var(--serif); color: var(--navy); }
.member .rl { font-size: 13.5px; color: var(--ink-2); line-height: 1.45; margin-top: 4px; }
.bib { position: relative; }
.bib pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; font: 13px/1.55 var(--mono); margin: 0; }
.bib button { position: absolute; top: 10px; right: 10px; border: 1px solid #cfcab8; background: #fff; border-radius: 6px; padding: 4px 10px; font: 500 12.5px var(--sans); cursor: pointer; color: var(--ink-2); }
footer { margin-top: 56px; background: var(--navy); color: #cfd6df; padding: 30px 0 34px; font-size: 14px; }
footer a { color: #fff; }
footer p { margin: 0 0 6px; }

@media (max-width: 860px) {
  .teaser { grid-template-columns: 1fr; gap: 22px; }
  .teaser .vid { max-width: 420px; margin: 0 auto; width: 100%; }
  .pipeline { grid-template-columns: 1fr; }
  .wire { min-width: 0; flex-direction: row; padding: 4px 0; }
  .wire .line { width: 2px; height: 26px; flex: none; }
  .wire .line::after { right: -5px; top: auto; bottom: -4px; border: 6px solid transparent; border-top: 8px solid var(--gold); }
  .viewer-body { grid-template-columns: 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); height: 240px; }
  ol.fsm { grid-template-columns: 1fr 1fr; }
  .team { grid-template-columns: 1fr 1fr; }
  .tiles.four { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  header.hero { padding-top: 36px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles:not(.four) .tile:last-child { grid-column: span 2; }
  .grid2, .grid3, .charts, ol.fsm, .team { grid-template-columns: 1fr; }
  .grid3 .portrait { max-width: 300px; margin: 0 auto; width: 100%; }
  h2 { font-size: 29px; }
  .stage { aspect-ratio: 1 / 1; }
  .time { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
