/* Legatus site. Tokens bound from the brutalist-experimental direction.
   Accent is a dark red: it fails 4.5:1 as small text on --bg, so it is
   reserved for large display numerals and the route-trace packet.
   Primary actions use --fg on --surface, which clears 4.5:1. */
:root {
  --bg:      oklch(98% 0.004 240);
  --surface: oklch(100% 0 0);
  --fg:      oklch(15% 0.02 100);
  --muted:   oklch(40% 0.02 100);
  --border:  oklch(15% 0.02 100);
  --accent:  oklch(60% 0.22 25);

  --accent-soft: color-mix(in oklch, var(--accent) 14%, transparent);
  --fg-soft:     color-mix(in oklch, var(--fg) 6%, transparent);

  --font-display: 'Times New Roman', 'Iowan Old Style', Georgia, serif;
  --font-body:    ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    ui-monospace, "IBM Plex Mono", "JetBrains Mono", Menlo, monospace;

  --fs-h1: clamp(44px, 5.6vw, 84px);
  --fs-h2: clamp(32px, 3.4vw, 48px);
  --fs-h3: 22px;
  --fs-lead: 18px;
  --fs-body: 16px;
  --fs-meta: 13px;

  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: 56px;
  --gap-2xl: 96px;
  --container: 1120px;
  --gutter: 32px;

  --radius: 2px;
  --radius-lg: 2px;
}

*, *::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-body);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; cursor: pointer; }
p { text-wrap: pretty; }
h1, h2, h3, h4 { text-wrap: balance; font-family: var(--font-display); }
html[lang="en"] .zh { display: none !important; }
html[lang="zh"] .en { display: none !important; }

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section { padding-block: clamp(48px, 8vw, var(--gap-2xl)); }
.section + .section { border-top: 2px solid var(--border); }
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-md); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-md); }
.grid-2-1 { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: var(--gap-xl); align-items: start; }
.grid-1-2 { display: grid; grid-template-columns: 0.8fr 1.4fr; gap: var(--gap-xl); align-items: start; }
@media (max-width: 920px) {
  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

.h1, h1 { font-size: var(--fs-h1); line-height: 0.96; letter-spacing: -0.03em; margin: 0; font-weight: 500; }
.h2, h2 { font-size: var(--fs-h2); line-height: 1.02; letter-spacing: -0.02em; margin: 0; font-weight: 500; }
.h3, h3 { font-size: var(--fs-h3); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; margin: 0; }
.lead { font-size: var(--fs-lead); line-height: 1.5; color: var(--muted); max-width: 60ch; margin: 0; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0 0 var(--gap-md);
}
.meta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.display-index {
  font-family: var(--font-display);
  font-size: clamp(72px, 10vw, 128px);
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: var(--accent);
  margin: 0;
}

.topnav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border);
}
.topnav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.logo { display: flex; align-items: center; text-decoration: none; flex: none; }
.logo img { height: 28px; width: auto; }
.topnav nav { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; justify-content: flex-end; }
.topnav nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.topnav nav a:hover { color: var(--fg); text-decoration: underline; }
.topnav nav a.is-current { color: var(--fg); text-decoration: underline; text-underline-offset: 6px; }
.nav-toggle {
  display: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg);
  border-radius: var(--radius);
}
.lang-switch { display: inline-flex; flex: none; border: 2px solid var(--fg); }
.lang-switch button {
  min-height: 44px;
  min-width: 40px;
  padding: 0 8px;
  background: transparent;
  color: var(--fg);
  border: 0;
}
.lang-switch button + button { border-left: 2px solid var(--fg); }
.lang-switch button[aria-pressed="true"] { background: var(--fg); color: var(--surface); }
.pagefoot { padding-block: var(--gap-xl); color: var(--muted); font-size: 13px; border-top: 2px solid var(--border); }
.pagefoot a { color: var(--fg); }
.pagefoot .row-between { flex-wrap: wrap; }
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; }
.skip-link {
  position: absolute;
  left: 16px;
  top: 8px;
  z-index: 30;
  transform: translateY(-160%);
  background: var(--fg);
  color: var(--surface);
  padding: 8px 12px;
  text-decoration: none;
}
.skip-link:focus { transform: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.btn-primary:hover { background: color-mix(in oklch, var(--fg) 82%, white); color: var(--surface); border-color: color-mix(in oklch, var(--fg) 82%, white); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn-secondary:hover { background: var(--fg); color: var(--surface); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; padding-inline: 0; text-decoration: underline; }
.btn-ghost:hover { color: var(--fg); background: transparent; }
.btn-arrow::after { content: ' →'; }

.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-flat { background: transparent; border: 0; padding: 0; }
.card-rule { background: transparent; border: 0; border-top: 2px solid var(--fg); padding: 20px 0 0; border-radius: 0; }

.feature h3 { margin-bottom: 8px; }
.feature p { margin: 0; color: var(--muted); font-size: 15px; }
.step-no {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.quote {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.32;
  letter-spacing: -0.01em;
  max-width: 28ch;
}
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.input, .textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
}
.textarea { min-height: 96px; resize: vertical; }

.ds-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ds-table th, .ds-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.ds-table th { color: var(--muted); font-weight: 500; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.ds-table tbody tr:hover { background: var(--fg-soft); }
.ds-table .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.table-wrap { overflow-x: auto; }

.content-img {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  justify-self: center;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface);
}
.figure { margin: 0; }
.figure figcaption { margin-top: 10px; }

.rule { border: 0; border-top: 2px solid var(--border); margin: 0; }

.hero { padding-block: clamp(56px, 8vw, 112px); }
.hero-center { text-align: left; max-width: 18ch; }
.hero h1 { margin-bottom: var(--gap-md); }
.hero .lead { margin-bottom: var(--gap-lg); }
.hero-cta { display: flex; gap: var(--gap-sm); flex-wrap: wrap; align-items: center; }
.hero-split { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: var(--gap-xl); align-items: end; }
@media (max-width: 920px) { .hero-split { grid-template-columns: 1fr; } }

.log-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: var(--gap-lg);
  padding: 22px 0;
  border-top: 2px solid var(--border);
  align-items: baseline;
  text-decoration: none;
  color: inherit;
}
.log-row h3 { font-size: 26px; }
.log-row:hover h3 { text-decoration: underline; }
.log-row .pull { text-align: right; }
@media (max-width: 920px) {
  .log-row { grid-template-columns: 56px 1fr; }
  .log-row .pull { display: none; }
}

.trace-frame {
  border: 2px solid var(--border);
  background: var(--surface);
  position: relative;
}
.trace-frame canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}
.seq { list-style: none; margin: 0; padding: 0; }
.seq-step {
  border-top: 2px solid var(--border);
  padding: 16px 12px;
  background: transparent;
  color: var(--fg);
}
.seq-step.is-live {
  background: var(--fg);
  color: var(--surface);
}
.seq-step.is-live p { color: color-mix(in oklch, var(--surface) 78%, transparent); }
.seq-step h3 { font-size: 22px; }
.seq-step p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.spec { margin: 0; }
.spec div {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.spec dt { margin: 0; }
.spec dd { margin: 0; font-family: var(--font-mono); text-align: right; }
@media (max-width: 920px) {
  .spec div { grid-template-columns: 1fr; }
  .spec dd { text-align: left; }
}

.note {
  border: 2px solid var(--border);
  padding: 16px 18px;
  font-size: 14px;
  color: var(--fg);
}

:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 3px;
}
.btn-primary:focus-visible { outline-color: var(--accent); }

@media (max-width: 920px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .topnav { position: sticky; }
  .topnav nav {
    display: none;
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    padding: 8px var(--gutter) 16px;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0;
  }
  .topnav nav.is-open { display: flex; }
  .lang-switch { margin-top: 8px; }
}

.measure-18 { max-width: 18ch; margin-bottom: 16px; }
.measure-20 { max-width: 20ch; }
.measure-22 { max-width: 22ch; margin-bottom: 20px; }
.measure-36 { max-width: 36ch; }
.section-intro { margin-bottom: 8px; max-width: 36ch; }
.section-intro-wide { max-width: 40ch; margin-bottom: 28px; }
.section-head { margin-bottom: 8px; align-items: flex-end; }
.heading-tight { margin-bottom: 8px; }
.heading-gap-sm { margin-bottom: 20px; }
.heading-block,
.space-below { margin-bottom: 28px; }
.heading-band { margin: 20px 0 28px; }
.space-top { margin-top: 28px; }
.space-top-xs { margin-top: 20px; }
.space-top-sm { margin-top: 24px; }
.space-top-md { margin-top: 32px; }
.space-top-lg { margin-top: 36px; }
.align-start { align-items: start; }
.stack-roomy { gap: 48px; }
.stack-loose { gap: 28px; }
.stack-close { gap: 20px; }
.lead-tight { margin-top: 8px; }
.lead-snug { margin-top: 10px; }
.lead-block { margin-top: 16px; }
.lead-cta { margin: 16px 0 28px; }
.lead-address { margin: 16px 0 8px; }
.meta-gap { margin-bottom: 24px; }
.cta-band { max-width: 640px; }
.cta-wide { max-width: 720px; }
.list-follow { margin: 20px 0 0; padding-left: 18px; }
[id] { scroll-margin-top: 88px; }

.route-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: var(--gap-xl); align-items: start; }
.route-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.route-toolbar .btn { min-width: 88px; }
.route { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.route-rail { position: relative; }
.route-rail::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 26px;
  bottom: 26px;
  width: 2px;
  background: var(--fg);
  opacity: 0.28;
}
.route-packet {
  position: absolute;
  left: 5px;
  top: 0;
  width: 18px;
  height: 18px;
  background: var(--accent);
  transform: translateY(8px);
  transition: transform 0.55s cubic-bezier(0.2, 0.75, 0.2, 1);
}
.route-steps { list-style: none; margin: 0; padding: 0; }
.route-step { border-bottom: 2px solid var(--border); color: var(--fg); background: transparent; }
.route-step button {
  display: flex;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 14px 12px 8px;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
}
.route-step .step-no { margin: 0; color: inherit; }
.route-note { display: none; margin: 0; padding: 0 12px 14px 58px; font-size: 14px; }
.route-step.is-live { background: var(--fg); color: var(--surface); }
.route-step.is-live .route-note { display: block; color: color-mix(in oklch, var(--surface) 84%, transparent); }
.route-step:hover { border-bottom-color: var(--fg); }
.route-step.is-live:hover { background: color-mix(in oklch, var(--fg) 86%, white); color: var(--surface); }
.route-step.is-live button:focus-visible { outline-color: var(--surface); }
.route-toolbar button[aria-pressed="false"] .when-paused { display: none !important; }
.route-toolbar button[aria-pressed="true"] .when-run { display: none !important; }
.sheet-note { margin-top: 16px; }

@media (max-width: 920px) {
  .route-layout { grid-template-columns: 1fr; }
  .route-note { padding-left: 12px; }
}
body.is-floor {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.is-floor .floor-app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.floor-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg);
}
.floor-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.floor-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px var(--gutter);
  border-top: 2px solid var(--border);
  background: var(--surface);
}
.floor-status { margin: 0; max-width: 68ch; color: var(--fg); }
.floor-dwell { margin: 4px 0 0; color: var(--fg); }
.floor-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body.is-floor .pagefoot { padding-block: 14px 16px; }
@media (max-width: 920px) {
  body.is-floor { height: auto; min-height: 100dvh; overflow: auto; }
  body.is-floor .floor-stage { flex: none; min-height: 70vh; }
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .route-packet { transition: none; }
}
