/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #18202b;
  --muted: #5a6574;
  --border: #dce1e8;
  --accent: #1d5fc4;
  --accent-strong: #154a9b;
  --accent-soft: #e3ecfb;
  --on-accent: #ffffff;
  --ok: #17805f;
  --ok-soft: #e1f4ec;
  --warn: #a35d00;
  --warn-soft: #fdf1df;
  --danger: #b4232f;
  --danger-soft: #fbe5e7;

  /* flowchart */
  --fc-stroke: #2b3646;
  --fc-terminal: #dfe9fb;
  --fc-io: #e2f3ea;
  --fc-process: #ffffff;
  --fc-decision: #fdf0d9;
  --fc-call: #efe6fb;
  --fc-text: #18202b;
  --fc-label: #5a6574;
  --fc-hl: #ff9f1c;

  /* code */
  --code-bg: #fbfcfd;
  --code-kw: #1d4fb0;
  --code-op: #9b3b8f;
  --code-str: #157a3c;
  --code-num: #a3520a;
  --code-com: #8792a0;
  --code-fn: #0f7480;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 14px rgb(16 24 40 / 6%);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "DejaVu Sans Mono", "Noto Sans Mono", monospace;
  --maxw: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a; --surface: #161d26; --surface-2: #1d2631; --text: #e5eaf1; --muted: #98a4b3; --border: #2a3441;
    --accent: #6ea4ff; --accent-strong: #9cc0ff; --accent-soft: #1b2b45; --on-accent: #0b1220;
    --ok: #4cc59a; --ok-soft: #12302a; --warn: #f0b35c; --warn-soft: #33270f; --danger: #ff7b86; --danger-soft: #3a1a1f;
    --fc-stroke: #c3ccd8; --fc-terminal: #1f3150; --fc-io: #173326; --fc-process: #1a222c; --fc-decision: #3a2c12; --fc-call: #2c2140;
    --fc-text: #e5eaf1; --fc-label: #98a4b3;
    --code-bg: #121820; --code-kw: #8ab4ff; --code-op: #e29ad6; --code-str: #7fd49b; --code-num: #f0b072; --code-com: #6c7888; --code-fn: #6fd3dc;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131a; --surface: #161d26; --surface-2: #1d2631; --text: #e5eaf1; --muted: #98a4b3; --border: #2a3441;
  --accent: #6ea4ff; --accent-strong: #9cc0ff; --accent-soft: #1b2b45; --on-accent: #0b1220;
  --ok: #4cc59a; --ok-soft: #12302a; --warn: #f0b35c; --warn-soft: #33270f; --danger: #ff7b86; --danger-soft: #3a1a1f;
  --fc-stroke: #c3ccd8; --fc-terminal: #1f3150; --fc-io: #173326; --fc-process: #1a222c; --fc-decision: #3a2c12; --fc-call: #2c2140;
  --fc-text: #e5eaf1; --fc-label: #98a4b3;
  --code-bg: #121820; --code-kw: #8ab4ff; --code-op: #e29ad6; --code-str: #7fd49b; --code-num: #f0b072; --code-com: #6c7888; --code-fn: #6fd3dc;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

/* ── Reset & typography ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; text-wrap: balance; }
h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.6rem); letter-spacing: -.01em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
img { max-width: 100%; height: auto; }
code, pre { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
