/* =========================================================================
   CANDO · project page
   ========================================================================= */
:root {
  --bg: #f7f6f2;
  --bg-tint: #efede6;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #2b2f36;
  --muted: #646a74;
  --line: #e2dfd6;
  --line-2: #d4d0c4;
  --accent: #3f6c8a;
  --accent-soft: #e3ecf2;
  --terra: #c97b4a;
  --gold: #d9ae58;
  --green: #5b8c5a;
  --red: #b5654a;
  --bad: #c2423a;
  --dark: #37342f;
  --dark-2: #423e38;
  --dark-line: #57524a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 28px -12px rgba(20, 22, 26, .18);
  --shadow-lg: 0 30px 80px -30px rgba(20, 22, 26, .35);
  --serif: "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
b, strong { font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .75rem; line-height: 1.5; }
kbd {
  font: 500 .72rem var(--mono); padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--line-2); background: var(--surface); box-shadow: 0 1px 0 var(--line-2);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { width: min(1180px, 100% - 48px); margin-inline: auto; }
.container.narrow { width: min(820px, 100% - 48px); }
.section { padding: 112px 0; position: relative; }
.section-tint { background: var(--bg-tint); }
.section-dark { background: var(--dark); color: #eeeae3; }
.section-dark .muted { color: #b0a99d; }
.section-head { margin-bottom: 48px; }
.eyebrow {
  font: 600 .75rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 14px;
}
.section-dark .eyebrow { color: #8fb3cf; }
.section-title { font: 400 clamp(2.1rem, 4vw, 3.3rem)/1.06 var(--serif); letter-spacing: -.01em; margin: 0 0 18px; }
.section-title em { font-style: italic; color: var(--accent); }
.section-dark .section-title em { color: #8fb3cf; }
.section-lede { font-size: 1.125rem; color: var(--muted); margin: 0; }
.section-dark .section-lede { color: #c2bbaf; }
.sub-title { font: 400 1.9rem/1.2 var(--serif); margin: 72px 0 24px; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- nav ---------- */
.scroll-progress {
  position: fixed; inset: 0 auto auto 0; height: 2px; width: 0; z-index: 60;
  background: linear-gradient(90deg, var(--accent), var(--terra));
}
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100% - 1180px) / 2));
  background: rgba(247, 246, 242, .72); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .3s, background .3s;
}
.nav.is-scrolled { border-bottom-color: var(--line); }
.nav.is-dark { background: rgba(55, 52, 47, .85); border-bottom-color: var(--dark-line); }
.nav.is-dark .nav-brand, .nav.is-dark .nav-links a { color: #eeeae3; }
.nav.is-dark .nav-links a:hover { background: rgba(255, 255, 255, .08); }
.nav.is-dark .nav-links a.is-active { color: #8fb3cf; }
.nav.is-dark .nav-links .nav-cta { background: #fff; color: var(--ink); }
.nav.is-dark .nav-toggle span { background: #fff; }
.nav-brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1rem var(--sans); letter-spacing: .08em; color: var(--ink); }
.nav-brand:hover { text-decoration: none; }
.brand-logo { display: block; height: 30px; width: auto; }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: var(--ink-2); font-size: .9rem; font-weight: 500; padding: 8px 12px; border-radius: 999px; transition: background .2s, color .2s;
}
.nav-links a:hover { background: rgba(0, 0, 0, .05); text-decoration: none; }
.nav-links a.is-active { color: var(--accent); }
.nav-links .nav-cta { background: var(--ink); color: #fff; margin-left: 6px; }
.nav-links .nav-cta:hover { background: #000; }
.nav-toggle { display: none; background: none; border: 0; width: 40px; height: 40px; cursor: pointer; }
.nav-toggle span { display: block; height: 2px; width: 22px; background: var(--ink); margin: 5px auto; transition: transform .3s; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--line-2);
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px;
  font: 500 .92rem var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--b);
  cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s, background .2s, border-color .2s; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--ink-2); }
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-dark:hover { background: #000; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #335a74; border-color: #335a74; }
.btn-small { padding: 7px 14px; font-size: .84rem; }
.btn-ghost { background: transparent; }
.section-dark .btn-ghost { color: #eeeae3; border-color: var(--dark-line); }
.section-dark .btn-ghost:hover { border-color: #8fb3cf; }
.btn-block { width: 100%; justify-content: center; padding: 13px 18px; font-size: 1rem; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 14px; }
.link-arrow { font-weight: 500; font-size: .92rem; }
.link-arrow::after { content: " →"; transition: margin .2s; }
.link-arrow:hover::after { margin-left: 4px; }

/* ---------- segmented control / toggles / selects ---------- */
.seg-control { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, .05); gap: 2px; }
.section-dark .seg-control { background: rgba(255, 255, 255, .06); }
.seg-control button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  font: 500 .82rem var(--sans); color: var(--muted); transition: background .25s, color .25s, box-shadow .25s;
}
.seg-control button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.select { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); }
.select select {
  appearance: none; font: 500 .86rem var(--sans); color: var(--ink); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 7px 34px 7px 14px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23555' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 14px center;
  cursor: pointer; max-width: 260px;
}
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 30px; height: 18px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(12px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- hero ---------- */
.hero { position: relative; min-height: calc(100vh - var(--nav-h)); display: grid; align-items: center; padding: 48px 0 96px; overflow: hidden; }
.hero-grid-bg {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(63, 108, 138, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(63, 108, 138, .07) 1px, transparent 1px);
  background-size: 32px 32px; mask-image: radial-gradient(ellipse 80% 70% at 60% 40%, #000 30%, transparent 75%);
}
.hero-inner { width: min(1240px, 100% - 48px); margin: auto; display: grid; grid-template-columns: 1.1fr 1fr; gap: 56px; align-items: center; position: relative; }
.venue-badge {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 22px; padding: 6px 14px 6px 10px; border-radius: 999px;
  font: 600 .78rem var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.venue-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--terra); box-shadow: 0 0 0 4px rgba(201, 123, 74, .18); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(201, 123, 74, 0); } }
.hero-title { margin: 0 0 22px; }
.hero-word { display: block; font: 400 clamp(4.4rem, 10vw, 8.4rem)/.9 var(--serif); letter-spacing: -.02em; }
.hero-word::after { content: "."; color: var(--terra); }
.hero-sub { display: block; margin-top: 14px; font: 500 clamp(1rem, 1.45vw, 1.22rem)/1.35 var(--sans); color: var(--ink-2); letter-spacing: -.005em; }
.hero-sub u { text-decoration: none; color: var(--accent); font-weight: 700; }
.hero-sub .nb { white-space: nowrap; }
.hero-lede { font-size: 1.08rem; color: var(--muted); max-width: 580px; margin: 0 0 26px; }
.hero-lede strong { color: var(--ink); }
.authors { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 0; margin: 0 0 6px; font-weight: 500; }
.authors sup { color: var(--accent); margin-left: 1px; }
.affiliations { margin: 0 0 28px; font-size: .84rem; color: var(--muted); }
.affiliations sup { color: var(--accent); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.hero-stage { margin: 0; }
.stage-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
  padding: 18px 18px 16px; position: relative;
}
.stage-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.stage-title { font: 600 .78rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stage-iter { font: 500 .82rem var(--mono); color: var(--muted); }
.stage-iter b { color: var(--ink); }
.stage-canvas { aspect-ratio: 1.18; border-radius: 14px; background: #fff; position: relative; }
.stage-canvas svg { width: 100%; height: 100%; display: block; overflow: visible; }
.stage-agents { display: flex; gap: 6px; margin: 12px 0 10px; }
.stage-agents span {
  flex: 1; text-align: center; font: 600 .74rem var(--sans); letter-spacing: .02em; padding: 7px 4px; border-radius: 8px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); transition: all .35s var(--ease);
}
.stage-agents span.is-on { background: var(--ink); color: #fff; border-color: var(--ink); transform: translateY(-2px); }
.meter-row { display: grid; grid-template-columns: 170px 1fr 42px; gap: 10px; align-items: center; font-size: .78rem; color: var(--muted); margin-top: 6px; }
.meter-row b { font: 500 .8rem var(--mono); color: var(--ink); text-align: right; }
.meter { height: 6px; border-radius: 99px; background: var(--bg-tint); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--terra), var(--gold), var(--green)); background-size: 300% 100%; transition: width .7s var(--ease); }
.hero-stage figcaption { font-size: .78rem; color: var(--muted); margin-top: 12px; text-align: center; }
.scroll-cue { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); width: 24px; height: 38px; border: 1.5px solid var(--line-2); border-radius: 14px; }
.scroll-cue span { position: absolute; left: 50%; top: 8px; width: 3px; height: 7px; margin-left: -1.5px; border-radius: 2px; background: var(--muted); animation: cue 1.8s infinite; }
@keyframes cue { 0% { opacity: 0; transform: translateY(0); } 40% { opacity: 1; } 80% { opacity: 0; transform: translateY(12px); } }

/* hero svg effects */
#hero-svg .elem polygon { transition: stroke .3s; }
#hero-svg .elem.is-bad polygon:first-child { stroke: var(--bad) !important; stroke-width: 2px; }
.ghost-poly { fill: none; stroke: #9aa3b2; stroke-dasharray: 2 2; opacity: .6; }

/* ---------- stats & contributions ---------- */
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 96px; overflow: hidden; }
.stat { padding: 28px 26px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font: 400 3rem/1 var(--serif); letter-spacing: -.01em; margin-bottom: 10px; color: var(--ink); }
.stat span { font-size: .88rem; color: var(--muted); display: block; line-height: 1.45; }
.split { display: grid; grid-template-columns: 1fr 1.25fr; gap: 64px; align-items: start; margin-bottom: 72px; }
.prose p { margin: 0 0 16px; color: var(--ink-2); font-size: 1.06rem; }
.contrib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.contrib { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; position: relative; transition: transform .35s var(--ease), box-shadow .35s; }
.contrib:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.contrib-num { font: italic 400 2.4rem/1 var(--serif); color: var(--terra); }
.contrib h3 { margin: 12px 0 8px; font-size: 1.2rem; }
.contrib p { color: var(--muted); margin: 0 0 16px; font-size: .95rem; }

/* ---------- anatomy ---------- */
.anatomy { display: grid; grid-template-columns: 1.5fr 1fr; gap: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.anatomy-figure { position: relative; min-height: 380px; }
.anatomy-figure svg { width: 100%; height: 100%; max-height: 560px; display: block; }
.anatomy-figure .elem { transition: opacity .3s; cursor: pointer; }
.anatomy-figure.is-focus .elem:not(.is-hl) { opacity: .12 !important; }
.anatomy-figure.is-focus .elem-label { opacity: .15; }
.anatomy-side h3 { margin: 0 0 4px; font: 400 1.7rem var(--serif); }
.class-groups { display: grid; gap: 16px; margin-top: 18px; }
.class-group h4 { margin: 0 0 8px; font: 600 .72rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.class-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.class-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 7px; border-radius: 999px; font-size: .8rem;
  border: 1px solid var(--line); background: var(--bg); cursor: default; transition: all .2s;
}
.class-chip:hover, .class-chip.is-hl { border-color: var(--ink-2); background: var(--surface); box-shadow: var(--shadow); }
.class-chip .abbr { font: 600 .68rem var(--mono); color: var(--muted); }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid; flex: none; display: inline-block; }
.swatch-line { width: 16px; height: 0; border-top: 2px solid #2b2b2b; display: inline-block; flex: none; }
.anatomy-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: .78rem; padding: 6px 10px; border-radius: 8px;
  transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap; z-index: 3;
}

/* ---------- cards & charts ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); margin-bottom: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.card-title { margin: 0 0 14px; font-size: 1.05rem; font-weight: 600; }
.card-head .card-title { margin: 0; }
.bench-stats { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; margin-top: 22px; }
.bench-stats .card { margin: 0; }
.hbar-chart { margin-top: 16px; display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: 220px 1fr 54px; align-items: center; gap: 12px; font-size: .82rem; }
.hbar-label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 1s var(--ease); }
.hbar-val { font: 500 .78rem var(--mono); text-align: right; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; margin: 0 0 22px; }
.facts div { border-top: 1px solid var(--line); padding-top: 10px; }
.facts dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.facts dd { margin: 4px 0 0; font: 400 1.55rem/1.1 var(--serif); }
.facts.compact { grid-template-columns: 1fr 1fr; gap: 12px; }
.facts.compact dd { font-size: 1.2rem; }
.split-bar { display: flex; gap: 2px; border-radius: 10px; overflow: hidden; font-size: .78rem; font-weight: 500; }
.split-bar span { padding: 10px 12px; white-space: nowrap; color: #fff; text-align: center; }
.split-bar .seg-train { background: var(--accent); text-align: left; }
.split-bar .seg-val { background: #6c93b8; }
.split-bar .seg-test { background: var(--terra); }
.split-brace { display: flex; gap: 4px; margin: 6px 0 10px; font-size: .74rem; color: var(--muted); }
.split-brace span { border-top: 2px solid var(--line-2); padding-top: 4px; text-align: center; white-space: nowrap; }

/* ---------- design manual ---------- */
.manual-tabs { margin-bottom: 20px; }
.manual-panel { display: none; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.manual-panel.is-active { display: grid; animation: fadeUp .5s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }
.rule-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.rule-card h4 { margin: 14px 0 6px; font-size: 1.02rem; }
.rule-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.rule-visual { height: 130px; border-radius: 12px; background: var(--bg); overflow: hidden; }
.rule-visual svg { width: 100%; height: 100%; }

/* ---------- vehicles ---------- */
.vehicles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.vehicle { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.vehicle-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.vehicle-head h4 { margin: 0; font-size: 1.05rem; }
.vehicle-dims { font: 500 .76rem var(--mono); color: var(--muted); }
.vehicle-icon { height: 34px; margin-bottom: 12px; }
.route-seq { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: .74rem; margin: 6px 0; }
.route-seq .node { padding: 3px 8px; border-radius: 6px; font-weight: 600; font-family: var(--mono); font-size: .7rem; color: #1a1a1a; }
.route-seq .arrow { color: var(--muted); }

/* ---------- voronoi ---------- */
.voronoi { display: grid; grid-template-columns: .8fr 1.2fr; gap: 40px; align-items: center; margin-top: 72px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 32px; box-shadow: var(--shadow); }
.voronoi h3 { font: 400 1.8rem var(--serif); margin: 0 0 12px; }
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: .94rem; }
.steps li { margin-bottom: 8px; }
.voronoi-figure { margin: 0; }
.voronoi-figure img { border-radius: 12px; }

/* ---------- metrics ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.metric-card p { color: var(--muted); font-size: .9rem; margin: 0; }
.metric-card .math-block { color: var(--ink); margin: 12px 0; overflow-x: auto; }
.metric-card-wide { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr 1fr; gap: 24px; align-items: center; }
.metric-card-wide .math-block { margin: 0; }
.metric-tag { display: inline-block; font: 600 .72rem var(--mono); letter-spacing: .06em; padding: 4px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }

/* ---------- explorer ---------- */
.explorer-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.chip-filter { display: flex; flex-wrap: wrap; gap: 6px; max-width: 820px; }
.chip-filter button {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px 5px 7px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font: 500 .78rem var(--sans); color: var(--ink-2); cursor: pointer; transition: all .2s;
}
.chip-filter button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-filter button .swatch { width: 11px; height: 11px; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.count-pill { font: 500 .78rem var(--mono); padding: 5px 10px; border-radius: 999px; background: var(--bg-tint); color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; text-align: left;
  transition: transform .3s var(--ease), box-shadow .3s, border-color .3s; font: inherit; color: inherit; display: flex; flex-direction: column;
  animation: fadeUp .45s var(--ease) both;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-2); }
.tile-figure { aspect-ratio: 1.15; background: #fff; border-radius: 8px; position: relative; overflow: hidden; }
.tile-figure svg { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
.tile-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: .76rem; color: var(--muted); }
.tile-meta .mono { color: var(--ink-2); font-size: .74rem; }
.cx-bar { width: 54px; height: 5px; border-radius: 99px; background: var(--bg-tint); overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 6px; }
.cx-bar i { display: block; height: 100%; background: linear-gradient(90deg, #93c0d9, #3f6c8a); }
.gallery-more { text-align: center; margin-top: 28px; }

/* viewer dialog */
.viewer { width: min(1180px, 96vw); max-height: 94vh; border: 0; border-radius: 22px; padding: 0; box-shadow: var(--shadow-lg); background: var(--surface); color: var(--ink); }
.viewer::backdrop { background: rgba(18, 21, 27, .55); backdrop-filter: blur(4px); }
.viewer[open] { animation: pop .35s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(10px); } }
.viewer-inner { display: flex; flex-direction: column; max-height: 94vh; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.viewer-head h3 { margin: 0; font-size: .95rem; font-weight: 500; }
.viewer-head .eyebrow { margin-bottom: 4px; }
.viewer-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.viewer-body { display: grid; grid-template-columns: 1fr 280px; overflow: auto; }
.viewer-figure { position: relative; padding: 18px; min-height: 60vh; }
.viewer-figure svg { width: 100%; height: 70vh; display: block; }
.viewer-figure .elem { cursor: crosshair; transition: opacity .25s; }
.viewer-figure .elem.is-hidden, .viewer-figure .elem-label.is-hidden { opacity: 0 !important; pointer-events: none; }
.viewer-figure .elem:hover polygon:first-child { stroke: #000; stroke-width: 2px; }
.viewer-side { border-left: 1px solid var(--line); padding: 20px; overflow: auto; }
.legend { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; font-size: .8rem; }
.legend-row { display: flex; align-items: center; gap: 9px; padding: 3px 6px; border-radius: 6px; }
.legend-row.is-toggle { cursor: pointer; user-select: none; }
.legend-row.is-toggle:hover { background: var(--bg); }
.legend-row.is-off { opacity: .35; text-decoration: line-through; }
.hover-card { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: .76rem; line-height: 1.45; padding: 8px 11px; border-radius: 9px; z-index: 4; transform: translate(14px, 14px); }
.hover-card b { color: #fff; }
.inventory { margin-top: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.inv-item { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; padding: 4px 8px; border-radius: 8px; background: var(--surface); }
.inv-item .mono { color: var(--muted); font-size: .7rem; }

/* ---------- method (dark) ---------- */
.agent-lab { display: grid; grid-template-columns: 1.45fr 1fr; gap: 28px; background: var(--dark-2); border: 1px solid var(--dark-line); border-radius: 22px; padding: 24px; }
.agent-diagram svg { width: 100%; height: auto; display: block; }
.agent-controls { display: flex; gap: 14px; align-items: center; margin-top: 8px; }
.agent-node { cursor: pointer; }
.agent-node rect { fill: #4a4640; stroke: #67615a; stroke-width: 1.2; transition: fill .3s, stroke .3s; }
.agent-node text { fill: #eeeae3; font: 600 13px var(--sans); pointer-events: none; }
.agent-node .sub { fill: #b0a99d; font: 400 10.5px var(--sans); }
.agent-node.is-active rect { stroke: #8fb3cf; fill: #4a525a; }
.agent-node.is-selected rect { stroke: #d9ae58; stroke-width: 2; }
.agent-node:hover rect { stroke: #8fb3cf; }
.agent-edge { fill: none; stroke: #67615a; stroke-width: 1.5; }
.agent-edge.is-active { stroke: #8fb3cf; }
.agent-packet { fill: #d9ae58; filter: drop-shadow(0 0 6px rgba(217, 174, 88, .8)); }
.agent-panel { background: #3a3732; border: 1px solid var(--dark-line); border-radius: 16px; padding: 22px; }
.agent-panel h4 { margin: 0 0 4px; font: 400 1.7rem var(--serif); color: #fff; }
.agent-panel .role { font: 600 .72rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: #d9ae58; }
.agent-panel p { color: #cbc5ba; font-size: .93rem; }
.agent-panel ul { padding-left: 18px; color: #cbc5ba; font-size: .88rem; margin: 0; }
.agent-panel li { margin-bottom: 5px; }
.agent-io { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.agent-io div { background: #4a4640; border-radius: 10px; padding: 10px 12px; font-size: .8rem; color: #dcd6cc; }
.agent-io span { display: block; font: 600 .66rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: #8fb3cf; margin-bottom: 4px; }

.code-lab { display: grid; grid-template-columns: .9fr 1.1fr; gap: 36px; align-items: center; margin-top: 64px; }
.code-lab h3, .strategies h3 { font: 400 1.9rem/1.15 var(--serif); margin: 0 0 12px; color: #fff; }
.code-lab p { color: #cbc5ba; }
.code-chart { background: var(--dark-2); border: 1px solid var(--dark-line); border-radius: 18px; padding: 16px; position: relative; }
.code-chart svg { width: 100%; height: auto; display: block; }
.code-chart .btn { position: absolute; bottom: 14px; right: 14px; }
.sliders { display: grid; gap: 12px; margin: 18px 0; }
.sliders label { display: grid; grid-template-columns: 130px 1fr 28px; align-items: center; gap: 12px; font-size: .88rem; color: #dcd6cc; }
.sliders output { font: 500 .88rem var(--mono); color: #d9ae58; text-align: right; }
input[type="range"] { accent-color: #d9ae58; width: 100%; }

.strategies { display: grid; grid-template-columns: .8fr 1.2fr; gap: 36px; margin-top: 64px; align-items: start; }
.strategy-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.strategy {
  background: var(--dark-2); border: 1px solid var(--dark-line); border-radius: 12px; padding: 14px; transition: transform .3s var(--ease), border-color .3s;
}
.strategy:hover { transform: translateY(-3px); border-color: #8fb3cf; }
.strategy b { display: block; color: #fff; font-size: .88rem; margin-bottom: 6px; }
.strategy span { font-size: .76rem; color: #b0a99d; line-height: 1.4; display: block; }
.strategy .guid { display: inline-block; margin-top: 8px; font: 600 .62rem var(--sans); letter-spacing: .08em; text-transform: uppercase; padding: 3px 7px; border-radius: 5px; }
.guid.full { background: rgba(143, 179, 207, .15); color: #8fb3cf; }
.guid.focus { background: rgba(217, 174, 88, .15); color: #d9ae58; }
.guid.none { background: rgba(201, 123, 74, .15); color: #e19a6d; }

.algo { margin-top: 56px; border: 1px solid var(--dark-line); border-radius: 14px; background: var(--dark-2); }
.algo summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: #eeeae3; list-style: none; }
.algo summary::-webkit-details-marker { display: none; }
.algo summary::before { content: "+"; display: inline-block; width: 18px; color: #d9ae58; transition: transform .3s; }
.algo[open] summary::before { transform: rotate(45deg); }
.algo pre { margin: 0; padding: 4px 22px 22px; font-size: .86rem; line-height: 1.8; color: #dcd6cc; overflow-x: auto; }
.algo .kw { color: #d9ae58; font-weight: 500; }
.algo .fn { color: #8fb3cf; }
.algo .cm { color: #a59e92; }
.algo .ss { display: inline-block; vertical-align: middle; line-height: 1; font-size: .72em; text-align: left; }
.algo .ss sup, .algo .ss sub { display: block; vertical-align: baseline; font-size: inherit; line-height: 1.05; }

/* ---------- results ---------- */
.results-main { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
.bar-race { display: grid; gap: 10px; }
.race-row { display: grid; grid-template-columns: 230px 1fr; gap: 14px; align-items: center; font-size: .86rem; }
.race-name { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-name .sym { width: 14px; text-align: center; color: var(--muted); flex: none; }
.race-row.is-ours .race-name { font-weight: 600; }
.race-track { position: relative; height: 26px; background: var(--bg); border-radius: 7px; overflow: hidden; }
.race-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 7px; background: #c9cdd4; transition: width 1s var(--ease); display: flex; align-items: center; justify-content: flex-end; }
.race-row.is-ours .race-fill { background: linear-gradient(90deg, #6c93b8, #3f6c8a); }
.race-val { position: absolute; top: 50%; transform: translateY(-50%); font: 500 .78rem var(--mono); color: var(--ink-2); transition: left 1s var(--ease); padding-left: 8px; white-space: nowrap; }
.race-row.is-ours .race-val.is-inside { color: #fff; }
.race-err { position: absolute; top: 50%; height: 2px; background: rgba(0, 0, 0, .25); transform: translateY(-50%); transition: all 1s var(--ease); }
.legend-inline { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 0; }
.effort { display: grid; gap: 14px; margin: 8px 0 18px; }
.effort-row { display: grid; grid-template-columns: 140px 1fr 70px; gap: 12px; align-items: center; font-size: .84rem; }
.effort-bar { height: 16px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.effort-bar i { display: block; height: 100%; width: 0; background: #c9cdd4; transition: width 1.1s var(--ease); }
.effort-row.is-ours .effort-bar i { background: var(--terra); }
.effort-row b { font: 500 .8rem var(--mono); text-align: right; }
.traj { margin: 0; }
.traj img { border-radius: 10px; border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table.results { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.results th, table.results td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.results th:first-child, table.results td:first-child, table.results th:nth-child(2), table.results td:nth-child(2) { text-align: left; }
table.results thead th { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.results tr.is-ours td { background: var(--accent-soft); font-weight: 600; }
table.results td.best { color: var(--accent); font-weight: 700; }
table.results td.second { text-decoration: underline; text-underline-offset: 3px; }
table.results tbody tr { transition: background .2s; }
table.results tbody tr:hover td { background: var(--bg); }
table.results tr.group-start td { border-top: 2px solid var(--line-2); }
.ablation { display: grid; gap: 8px; }
.abl-row { display: grid; grid-template-columns: 220px 1fr 70px; gap: 14px; align-items: center; font-size: .86rem; }
.abl-row.is-full { font-weight: 600; }
.abl-track { position: relative; height: 18px; background: var(--bg); border-radius: 5px; }
.abl-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 5px; background: #c9cdd4; transition: width .9s var(--ease), background .4s; }
.abl-row.is-full .abl-fill { background: var(--accent); }
.abl-row.is-worse .abl-fill { background: #e3a58a; }
.abl-ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); transition: left .9s var(--ease); }
.abl-row b { font: 500 .8rem var(--mono); text-align: right; }

/* ---------- playground ---------- */
.studio { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; }
.studio-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.toolbar-sep { flex: 1; }
.studio-body { display: grid; grid-template-columns: 1fr 360px; height: min(80vh, 780px); min-height: 560px; }
.studio-canvas { position: relative; min-height: 0; background: #fff; background-image: radial-gradient(circle, #e7e4db 1px, transparent 1px); background-size: 22px 22px; }
.studio-canvas svg { width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.studio-canvas .elem.is-movable { cursor: grab; }
.studio-canvas .elem.is-dragging { cursor: grabbing; }
.studio-canvas .elem.is-selected polygon:first-child { stroke: #111 !important; stroke-width: 2.2px; }
.studio-canvas .elem.is-flagged polygon:first-child { stroke: var(--bad) !important; stroke-width: 2px; }
.studio-canvas .elem.is-focus polygon:first-child { stroke: #111 !important; stroke-width: 2.6px; }
.studio-canvas .elem.is-dim { opacity: .25; }
.overlap-shape { fill: rgba(194, 66, 58, .45); stroke: var(--bad); stroke-width: 1px; pointer-events: none; }
.rot-handle { cursor: grab; }
.rot-handle circle { fill: #fff; stroke: #111; stroke-width: 1.5px; }
.rot-handle line { stroke: #111; stroke-width: 1px; stroke-dasharray: 3 2; }
.route-path { fill: none; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; opacity: .75; }
.route-path.car { stroke: #3f6c8a; }
.route-path.bike { stroke: #5b8c5a; }
.route-path.hgv { stroke: #c97b4a; }
.egress-zone { fill: rgba(91, 140, 90, .14); stroke: rgba(91, 140, 90, .7); stroke-dasharray: 3 2; pointer-events: none; }
.egress-zone.bad { fill: rgba(194, 66, 58, .16); stroke: rgba(194, 66, 58, .8); }
.studio-hint { position: absolute; left: 14px; bottom: 12px; font-size: .74rem; color: var(--muted); background: rgba(255, 255, 255, .9); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; max-width: calc(100% - 28px); }
.studio-legend { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; font: 500 .7rem var(--mono); color: var(--ink-2); pointer-events: none; }
.studio-legend > span { display: inline-flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, .85); padding: 2px 6px; border-radius: 6px; }
.studio-legend .swatch { width: 10px; height: 10px; }
.route-key { gap: 5px; }
.route-key i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; margin-left: 4px; }
.studio-panel { border-left: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 16px; background: #fcfbf8; min-height: 0; overflow: auto; }
.spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite; }
.is-busy .spinner { display: inline-block; }
.is-busy .btn-label::after { content: "…"; }
@keyframes spin { to { transform: rotate(360deg); } }
.score-hero { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-tint); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 1s var(--ease), stroke .4s; }
.ring > div { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring b { font: 400 2.1rem/1 var(--serif); }
.ring span { font: 600 .66rem var(--sans); letter-spacing: .12em; color: var(--muted); }
.score-pair { display: grid; gap: 10px; flex: 1; }
.score-pair div { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.score-pair span { font-size: .8rem; color: var(--muted); font-weight: 600; letter-spacing: .06em; }
.score-pair b { font: 400 1.6rem/1 var(--serif); }
.score-bars { display: grid; gap: 7px; }
.sbar { display: grid; grid-template-columns: 58px 1fr 44px; gap: 10px; align-items: center; font-size: .78rem; }
.sbar.sub { padding-left: 12px; grid-template-columns: 46px 1fr 44px; }
.sbar span { font-weight: 600; color: var(--ink-2); }
.sbar.sub span { font-weight: 500; color: var(--muted); }
.sbar-track { height: 7px; border-radius: 99px; background: var(--bg-tint); overflow: hidden; }
.sbar-track i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .8s var(--ease), background .4s; }
.sbar b { font: 500 .78rem var(--mono); text-align: right; }
.sbar.is-group { margin-top: 6px; }
.feedback { display: grid; gap: 10px; }
.fb-group h5 { margin: 0 0 6px; font: 600 .72rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.fb-group h5 .ok { color: var(--green); }
.fb-item {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .8rem; line-height: 1.45; color: var(--ink-2);
  padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; margin-bottom: 5px;
  border-left: 3px solid var(--bad); transition: background .2s, transform .2s;
}
.fb-item:hover { background: #fff6f3; transform: translateX(2px); }
.fb-item small { display: block; color: var(--muted); font-size: .72rem; margin-top: 2px; }
.fb-ok { font-size: .8rem; color: var(--green); padding: 6px 10px; border-radius: 9px; background: rgba(91, 140, 90, .1); }
.fb-banner { padding: 10px 12px; border-radius: 10px; font-size: .84rem; font-weight: 500; }
.fb-banner.good { background: rgba(91, 140, 90, .12); color: #3e6a3d; }
.fb-banner.warn { background: rgba(217, 174, 88, .18); color: #7a5a17; }
.fb-banner.bad { background: rgba(194, 66, 58, .1); color: #8b2f28; }

/* ---------- bibtex / footer ---------- */
.bibtex { position: relative; background: var(--dark); color: #e6e1d8; border-radius: var(--radius); padding: 24px 26px; }
.bibtex pre { margin: 0; font-size: .86rem; overflow-x: auto; line-height: 1.7; }
.copy-btn { position: absolute; top: 14px; right: 14px; background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .15); }
.footer { border-top: 1px solid var(--line); padding: 36px 0; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .86rem; transition: all .35s var(--ease); pointer-events: none; z-index: 100; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-stage { max-width: 620px; }
  .anatomy, .results-main, .agent-lab, .code-lab, .strategies, .voronoi, .bench-stats { grid-template-columns: 1fr; }
  .studio-body { grid-template-columns: 1fr; height: auto; }
  .studio-canvas { height: 70vh; }
  .studio-panel { border-left: 0; border-top: 1px solid var(--line); }
  .strategy-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .nav-links { position: fixed; inset: var(--nav-h) 0 auto 0; flex-direction: column; align-items: stretch; background: var(--bg); padding: 12px 24px 20px; border-bottom: 1px solid var(--line); transform: translateY(-120%); transition: transform .35s var(--ease); }
  .nav-links.is-open { transform: none; }
  .nav-toggle { display: block; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat { border-top: 1px solid var(--line); }
  .split, .contrib-grid, .manual-panel.is-active, .vehicles, .metric-grid { grid-template-columns: 1fr; }
  .metric-card-wide { grid-template-columns: 1fr; }
  .viewer-body { grid-template-columns: 1fr; }
  .viewer-side { border-left: 0; border-top: 1px solid var(--line); }
  .race-row { grid-template-columns: 1fr; gap: 4px; }
  .abl-row { grid-template-columns: 1fr 60px; }
  .abl-row .abl-track { grid-column: 1 / -1; grid-row: 2; }
  .section { padding: 80px 0; }
  .hbar { grid-template-columns: 120px 1fr 44px; }
}
