/* AGV Simulation Studio documentation. Colours come from these tokens only;
   the light theme redefines every one of them. */
:root {
  --font-ui: system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
  --radius-s: 7px;
  --radius-m: 10px;
  --radius-l: 12px;
  --header-h: 56px;
  --sidebar-w: 268px;
  --toc-w: 220px;
  --content-w: 780px;

  --bg: #0a1624;
  --surface-1: #0d1c2d;
  --surface-2: #102235;
  --surface-3: #152c43;
  --surface-hover: #1b364c;
  --border-1: #1a2d3f;
  --border-2: #253a4e;
  --border-3: #31506a;
  --text: #dce8f3;
  --text-strong: #f2f8fc;
  --text-muted: #93b0ca;
  --text-faint: #7d93a8;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --accent-surface: #103a43;
  --on-accent: #04161d;
  --link: #5eead4;
  --info: #60a5fa;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --mark: #fde68a;
  --shadow-ink: #000000;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f8fb;
  --surface-1: #ffffff;
  --surface-2: #f0f4f8;
  --surface-3: #e6edf3;
  --surface-hover: #e1eaf1;
  --border-1: #dfe7ee;
  --border-2: #d0dbe5;
  --border-3: #b5c5d3;
  --text: #1b2a38;
  --text-strong: #0b1824;
  --text-muted: #4a6073;
  --text-faint: #5b7084;
  --accent: #0f766e;
  --accent-strong: #0d6961;
  --accent-surface: #e0f4f1;
  --on-accent: #ffffff;
  --link: #0b6b64;
  --info: #1d4ed8;
  --success: #047857;
  --warning: #92400e;
  --danger: #b91c1c;
  --mark: #fde68a;
  --shadow-ink: #0b1824;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 var(--font-ui);
}
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 12px; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); }
.skip-link:focus { top: 8px; }

/* Header */
.docs-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--header-h); padding: 0 16px;
  border-bottom: 1px solid var(--border-1);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--text-strong); text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: 15px; }
.brand-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { padding: 1px 7px; border: 1px solid var(--border-3); border-radius: 999px; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.header-spacer { flex: 1; }
.menu-button, .icon-button {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
  padding: 0; border: 1px solid var(--border-2); border-radius: var(--radius-s);
  background: var(--surface-1); color: var(--text); cursor: pointer;
}
.menu-button:hover, .icon-button:hover { background: var(--surface-hover); }
.menu-button { display: none; }
.lang-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--surface-1); }
.lang-switch a { min-width: 34px; padding: 3px 8px; border-radius: 6px; color: var(--text-muted); font-size: 12px; font-weight: 650; text-align: center; text-decoration: none; }
.lang-switch a:hover { color: var(--text-strong); background: var(--surface-2); }
.lang-switch a[aria-current="true"] { color: var(--text-strong); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-3); }
.open-app { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; flex-shrink: 0; border-radius: var(--radius-s); background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.open-app:hover { background: var(--accent-strong); text-decoration: none; }

/* Search */
.search { position: relative; width: min(420px, 38vw); }
.search input {
  width: 100%; height: 34px; padding: 0 44px 0 34px;
  border: 1px solid var(--border-2); border-radius: var(--radius-s);
  background: var(--surface-1); color: var(--text); font: inherit; font-size: 13px;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search > svg { position: absolute; left: 10px; top: 9px; color: var(--text-faint); pointer-events: none; }
.search kbd.search-hint { position: absolute; right: 8px; top: 7px; pointer-events: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  max-height: min(70vh, 520px); overflow: auto; margin: 0; padding: 6px; list-style: none;
  border: 1px solid var(--border-3); border-radius: var(--radius-m); background: var(--surface-2);
  box-shadow: 0 18px 50px color-mix(in srgb, var(--shadow-ink) 45%, transparent);
}
.search-results[hidden] { display: none; }
.search-results a { display: block; padding: 8px 10px; border-radius: var(--radius-s); color: var(--text); text-decoration: none; }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--surface-hover); }
.search-results .result-title { display: block; color: var(--text-strong); font-weight: 600; font-size: 13px; }
.search-results .result-page { color: var(--text-faint); font-size: 11px; }
.search-results .result-snippet { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.search-results mark { background: color-mix(in srgb, var(--mark) 55%, transparent); color: inherit; border-radius: 2px; }
.search-empty { padding: 10px; color: var(--text-muted); font-size: 13px; }

/* Shell */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px; margin: 0 auto;
}
.docs-sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 24px 12px 40px 16px; border-right: 1px solid var(--border-1);
}
.nav-group + .nav-group { margin-top: 20px; }
.nav-group-title { margin: 0 0 6px 10px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.nav-group ul { margin: 0; padding: 0; list-style: none; }
.nav-group a {
  display: block; padding: 6px 10px; border-radius: var(--radius-s);
  color: var(--text-muted); font-size: 14px; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-group a:hover { color: var(--text-strong); background: var(--surface-2); }
.nav-group a[aria-current="page"] { color: var(--accent); background: var(--accent-surface); font-weight: 600; }

main { min-width: 0; padding: 36px 48px 80px; }
.doc { max-width: var(--content-w); margin: 0 auto; }
.docs-toc {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 36px 16px 40px 8px;
}
.toc-title { margin: 0 0 8px; color: var(--text-faint); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.docs-toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border-2); }
.docs-toc a { display: block; margin-left: -1px; padding: 4px 0 4px 12px; border-left: 2px solid transparent; color: var(--text-muted); font-size: 13px; line-height: 1.4; text-decoration: none; }
.docs-toc a.depth-3 { padding-left: 24px; font-size: 12px; }
.docs-toc a:hover { color: var(--text-strong); }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* Article typography */
.breadcrumb { margin: 0 0 8px; color: var(--text-faint); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.doc h1 { margin: 0 0 12px; color: var(--text-strong); font-size: 32px; line-height: 1.2; letter-spacing: -.01em; }
.doc .lead { margin: 0 0 28px; color: var(--text-muted); font-size: 17px; line-height: 1.6; }
.doc h2 { position: relative; margin: 44px 0 12px; padding-top: 24px; border-top: 1px solid var(--border-1); color: var(--text-strong); font-size: 22px; line-height: 1.3; }
.doc h3 { position: relative; margin: 28px 0 8px; color: var(--text-strong); font-size: 17px; line-height: 1.35; }
.doc h4 { margin: 20px 0 6px; color: var(--text-strong); font-size: 15px; }
.doc p, .doc ul, .doc ol, .doc dl { margin: 0 0 14px; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li + li { margin-top: 4px; }
.doc li > ul, .doc li > ol { margin: 6px 0 0; }
.doc strong { color: var(--text-strong); }
.doc hr { margin: 32px 0; border: 0; border-top: 1px solid var(--border-1); }
.anchor { margin-left: 8px; color: var(--text-faint); font-weight: 400; text-decoration: none; opacity: 0; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.doc code { padding: 1px 5px; border: 1px solid var(--border-2); border-radius: 5px; background: var(--surface-2); color: var(--text-strong); font: 0.88em var(--font-mono); }
.doc pre { position: relative; margin: 0 0 16px; padding: 14px 16px; overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius-m); background: var(--surface-1); }
.doc pre code { padding: 0; border: 0; background: none; font-size: 13px; line-height: 1.6; }
.copy-button { position: absolute; top: 8px; right: 8px; height: 26px; padding: 0 9px; border: 1px solid var(--border-2); border-radius: 6px; background: var(--surface-2); color: var(--text-muted); font: 600 11px var(--font-ui); cursor: pointer; }
.copy-button:hover { color: var(--text-strong); background: var(--surface-hover); }
kbd {
  display: inline-block; min-width: 22px; padding: 0 6px;
  border: 1px solid var(--border-3); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-strong);
  font: 600 12px/20px var(--font-mono); text-align: center; white-space: nowrap;
}
/* A UI label: what the user reads on screen, exactly. */
.ui { color: var(--text-strong); font-weight: 600; white-space: nowrap; }
.path-ui { color: var(--text-strong); font-weight: 600; }
.path-ui .sep { margin: 0 4px; color: var(--text-faint); font-weight: 400; }

/* Tables */
.table-wrap { margin: 0 0 18px; overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius-m); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc th, .doc td { padding: 9px 12px; border-bottom: 1px solid var(--border-1); text-align: left; vertical-align: top; }
.doc th { background: var(--surface-2); color: var(--text-strong); font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc td.num, .doc th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc td:first-child { color: var(--text-strong); }

/* Callouts */
.callout { margin: 0 0 18px; padding: 12px 16px; border: 1px solid var(--border-2); border-left: 3px solid var(--info); border-radius: var(--radius-m); background: color-mix(in srgb, var(--info) 7%, var(--surface-1)); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { display: block; margin-bottom: 4px; color: var(--info); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.callout.tip { border-left-color: var(--success); background: color-mix(in srgb, var(--success) 7%, var(--surface-1)); }
.callout.tip .callout-title { color: var(--success); }
.callout.warning { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 8%, var(--surface-1)); }
.callout.warning .callout-title { color: var(--warning); }
.callout.danger { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface-1)); }
.callout.danger .callout-title { color: var(--danger); }

/* Numbered steps */
.doc ol.steps { counter-reset: step; padding-left: 0; list-style: none; }
.doc ol.steps > li { position: relative; margin: 0; padding: 0 0 18px 44px; counter-increment: step; }
.doc ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--border-3); border-radius: 50%;
  background: var(--surface-2); color: var(--accent); font-weight: 700; font-size: 13px;
}
.doc ol.steps > li::after { content: ""; position: absolute; left: 14px; top: 32px; bottom: 4px; border-left: 1px solid var(--border-2); }
.doc ol.steps > li:last-child::after { display: none; }
.doc ol.steps > li > strong:first-child { display: block; margin-bottom: 2px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 24px; }
.card { display: block; padding: 16px; border: 1px solid var(--border-2); border-radius: var(--radius-l); background: var(--surface-1); color: var(--text); text-decoration: none; transition: border-color .15s, background .15s; }
.card:hover { border-color: var(--accent); background: var(--surface-2); text-decoration: none; }
.card strong { display: block; margin-bottom: 4px; color: var(--text-strong); font-size: 15px; }
.card span { display: block; color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* Workflow chains: block names joined by arrows */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0; margin: 0 0 16px; padding: 12px; border: 1px dashed var(--border-3); border-radius: var(--radius-m); background: var(--surface-1); }
.flow span { padding: 4px 10px; border: 1px solid var(--border-3); border-radius: var(--radius-s); background: var(--surface-2); color: var(--text-strong); font-size: 13px; font-weight: 600; white-space: nowrap; }
.flow span small { margin-left: 6px; color: var(--text-muted); font-weight: 400; }
.flow span + span::before { content: "→"; margin: 0 8px 0 -2px; color: var(--accent); font-weight: 700; position: relative; left: -12px; }
.flow span + span { margin-left: 22px; }
.flow span.branch { border-style: dashed; }

/* Scenario recipe boxes */
.recipe { margin: 0 0 24px; padding: 18px 20px; border: 1px solid var(--border-2); border-radius: var(--radius-l); background: var(--surface-1); }
.recipe > :last-child { margin-bottom: 0; }
.recipe dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 16px; }
.recipe dt { color: var(--text-faint); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding-top: 2px; }
.recipe dd { margin: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.badge { padding: 1px 8px; border: 1px solid var(--border-3); border-radius: 999px; color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Definition list for glossary */
.glossary dt { margin-top: 12px; color: var(--text-strong); font-weight: 650; }
.glossary dd { margin: 2px 0 0 0; color: var(--text); }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: var(--content-w); margin: 56px auto 0; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border-2); border-radius: var(--radius-l); color: var(--text-strong); font-weight: 600; text-decoration: none; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--text-faint); font-size: 12px; font-weight: 500; }
.pager .next { grid-column: 2; text-align: right; }
.docs-footer { max-width: var(--content-w); margin: 40px auto 0; padding-top: 16px; border-top: 1px solid var(--border-1); color: var(--text-faint); font-size: 12px; }
.docs-footer-button { padding: 0; border: 0; background: none; color: var(--link); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.docs-footer-button[hidden] { display: none; }

/* Backdrop for the mobile navigation drawer */
.nav-backdrop { display: none; }

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
  main { padding: 32px 36px 72px; }
}
@media (max-width: 900px) {
  .menu-button { display: inline-grid; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar {
    position: fixed; z-index: 35; top: var(--header-h); left: 0; bottom: 0; height: auto;
    width: min(300px, 86vw); background: var(--bg); transform: translateX(-102%); transition: transform .2s ease;
  }
  body.nav-open .docs-sidebar { transform: none; box-shadow: 0 0 60px color-mix(in srgb, var(--shadow-ink) 50%, transparent); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 34; background: color-mix(in srgb, var(--shadow-ink) 35%, transparent); }
  .brand-name, .header-spacer { display: none; }
  .search { width: auto; flex: 1 1 auto; min-width: 0; }
  /* The results list spans the viewport under the header instead of the narrow field. */
  .search-results { position: fixed; top: calc(var(--header-h) + 4px); left: 12px; right: 12px; }
  main { padding: 28px 16px 64px; }
}
@media (max-width: 560px) {
  .docs-header { gap: 8px; padding: 0 12px; }
  .brand-tag, .open-app span, .search kbd.search-hint { display: none; }
  .open-app { width: 34px; padding: 0; justify-content: center; }
  .doc h1 { font-size: 26px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .recipe dl { grid-template-columns: minmax(0, 1fr); }
  .recipe dt { padding-top: 6px; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .docs-header, .docs-sidebar, .docs-toc, .pager, .copy-button { display: none !important; }
  .docs-shell { display: block; }
  main { padding: 0; }
}
