/* =====================================================================
   rapeepat.dev — shared design system ("blueprint / terminal" theme)
   Every migrated page loads this file + assets/site.js (after lang.js).

   ---------------------------------------------------------------------
   <head> boilerplate (copy into every page)
   ---------------------------------------------------------------------
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap" rel="stylesheet">
   <link rel="stylesheet" href="assets/site.css">
   <script>try{var t=localStorage.getItem("theme");if(t==="light"||t==="dark")document.documentElement.dataset.theme=t}catch(e){}</script>

   <body data-title="i18n.key">            ← lang.js sets <title> from it
     <a class="skip-link" href="#main" data-i18n="site.skip">…</a>
     <div data-site-nav="home|portfolio|achievements|downloads"></div>
     <main id="main" tabindex="-1"> … </main>
     <div data-site-footer></div>
     <script src="lang.js"></script>
     <script> addI18n({ th:{…}, en:{…} }) </script>   (page strings)
     <script src="assets/site.js"></script>
     <script src="lilith/lilith.js" defer></script>     (keep on every page)

   ---------------------------------------------------------------------
   TOKENS (use these, never raw colours)
   ---------------------------------------------------------------------
   --bg --surface --surface-2 --surface-3   page / panel / inset / hover fills
   --line --line-strong                     1px borders
   --text --text-muted --text-faint         body / secondary / decorative only
   --accent (cyan)  --accent-soft  --on-accent
   --amber          --amber-soft   --on-amber
   --ok --warn --danger                     status colours
   --font-mono (display/labels/code)  --font-body (Thai-capable text)
   --radius (4px)  --maxw (1120px)  --gutter (16px)  --ease

   ---------------------------------------------------------------------
   LAYOUT
   ---------------------------------------------------------------------
   .wrap                 centred container, max-width + 16px gutters
   .section              vertical rhythm for a page section (pad top/bottom)
   .stack / .stack--lg   vertical flow with gap
   .row                  inline flex row, wraps, gap 8px
   .grid                 auto-fill grid, min 260px columns
   .grid--2 / --3 / --4  fixed max columns (collapse to 1 col on phones)
   .grid--tight          smaller gap

   ---------------------------------------------------------------------
   TYPE
   ---------------------------------------------------------------------
   h1–h4                 mono display font (Thai falls back to body font)
   .eyebrow              small mono uppercase label, cyan, e.g. "// 01 · focus"
   .section-head         wrapper: .eyebrow + .section-title (+ optional p.lead)
   .section-title        h2 with trailing hairline rule; may start with an icon
   .lead                 larger muted intro paragraph
   .muted .faint .accent .amber .mono .center   text utilities
   .prompt               mono line prefixed by "$ " (terminal feel)
   code / kbd            inline code chips

   ---------------------------------------------------------------------
   COMPONENTS
   ---------------------------------------------------------------------
   .panel                window card: 1px border, surface bg, corner ticks
                         (uses ::before for the ticks — don't override it)
     .panel__bar         title bar row inside a panel (top, bordered)
       .panel__label     "// section" mono label in the bar
       .dots             three status dots (decorative) — <span class="dots"><i></i><i></i><i></i></span>
     .panel__body        padded content area
     .panel__foot        bottom row (border-top), e.g. actions/meta
   .panel--pad           panel with padding directly (no bar/body needed)
   .panel--accent        cyan top edge highlight
   .panel--amber         amber top edge highlight
   .panel--inset         flat inset surface (no ticks), for nested boxes
   a.panel / .panel--link   hover: cyan border + glow, lifts 2px
   .tile                 link row: icon box + .tile__text(strong+small) + .tile__arrow
   .icon-box             square bordered box holding an icon (.icon-box--lg)

   .btn                  default (outlined) button, 44px min height
   .btn--primary         solid cyan
   .btn--amber           solid amber
   .btn--ghost           borderless
   .btn--sm              compact (still 44px tall for touch)
   .btn--icon            square icon-only button (needs aria-label)
   .btn.is-active / [aria-pressed="true"]   selected state (filters)

   .tag                  small mono chip (tech names, categories)
   .tag--accent .tag--amber .tag--ok        coloured variants
   .status               dot + label ("online", "wip") — .status--ok/--warn/--off
   .dot                  standalone status dot (.dot--ok/--warn/--off/--accent)
   .stat                 big number + label  (.stat__num, .stat__label)
   .field                text input / select
   .divider              1px horizontal rule
   .hero                 page hero block (.hero__grid, .hero__title, .hero__lead,
                         .hero__actions, .hero__art)
   .fade-in              entrance animation (also .pop-in alias); no-op with reduced motion
   .sr-only .skip-link   accessibility helpers

   ICONS (assets/site.js) — <span data-icon="chip" data-size="20"></span>
   or Site.icon("chip", 20) → svg string. svg.icon inherits currentColor.
   ===================================================================== */

:root {
  /* ---- light theme (default tokens) ---- */
  --bg: #f3f6fa;
  --grid-minor: rgba(14, 116, 144, .07);
  --grid-major: rgba(14, 116, 144, .12);
  --glow-top: rgba(14, 116, 144, .10);
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #e9eff6;
  --line: #d3dce8;
  --line-strong: #9eb0c6;
  --text: #0b1526;
  --text-muted: #44566f;
  --text-faint: #7d8ea6;
  --accent: #0e7490;          /* 5.4:1 on white */
  --accent-strong: #0b5f76;
  --accent-soft: rgba(14, 116, 144, .12);
  --on-accent: #ffffff;
  --amber: #a85a06;           /* 5.1:1 on white */
  --amber-fill: #f59e0b;
  --amber-soft: rgba(217, 119, 6, .14);
  --on-amber: #1a1204;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --off: #8794a6;
  --tick: var(--accent);
  --focus: #0e7490;
  --shadow: 0 1px 2px rgba(11, 21, 38, .06), 0 8px 24px rgba(11, 21, 38, .06);
  --glow: 0 0 0 1px var(--accent-soft), 0 10px 30px rgba(14, 116, 144, .16);

  --font-mono: "JetBrains Mono", "IBM Plex Sans Thai", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-body: "IBM Plex Sans Thai", "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* legacy names some page code / lilith may read */
  --font-display: var(--font-mono);

  --radius: 4px;
  --maxw: 1120px;
  --gutter: 16px;
  --nav-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

/* ---- dark theme: system preference unless user forced light ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070c18;
    --grid-minor: rgba(56, 189, 248, .045);
    --grid-major: rgba(56, 189, 248, .085);
    --glow-top: rgba(34, 211, 238, .10);
    --surface: #0c1426;
    --surface-2: #0a1120;
    --surface-3: #142038;
    --line: #1f2d4a;
    --line-strong: #34486e;
    --text: #dce6f4;
    --text-muted: #93a6c2;
    --text-faint: #5d7294;
    --accent: #22d3ee;
    --accent-strong: #67e8f9;
    --accent-soft: rgba(34, 211, 238, .14);
    --on-accent: #03141a;
    --amber: #fbbf24;
    --amber-fill: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .14);
    --on-amber: #1a1204;
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --off: #5d7294;
    --focus: #67e8f9;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 10px 30px rgba(0, 0, 0, .35);
    --glow: 0 0 0 1px rgba(34, 211, 238, .25), 0 0 28px rgba(34, 211, 238, .18);
    color-scheme: dark;
  }
}
/* ---- dark theme: forced by the toggle ---- */
:root[data-theme="dark"] {
  --bg: #070c18;
  --grid-minor: rgba(56, 189, 248, .045);
  --grid-major: rgba(56, 189, 248, .085);
  --glow-top: rgba(34, 211, 238, .10);
  --surface: #0c1426;
  --surface-2: #0a1120;
  --surface-3: #142038;
  --line: #1f2d4a;
  --line-strong: #34486e;
  --text: #dce6f4;
  --text-muted: #93a6c2;
  --text-faint: #5d7294;
  --accent: #22d3ee;
  --accent-strong: #67e8f9;
  --accent-soft: rgba(34, 211, 238, .14);
  --on-accent: #03141a;
  --amber: #fbbf24;
  --amber-fill: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .14);
  --on-amber: #1a1204;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --off: #5d7294;
  --focus: #67e8f9;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02) inset, 0 10px 30px rgba(0, 0, 0, .35);
  --glow: 0 0 0 1px rgba(34, 211, 238, .25), 0 0 28px rgba(34, 211, 238, .18);
  color-scheme: dark;
}

/* ============================ base ============================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 12px); }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: 16px; line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  /* blueprint grid: 24px minor, 120px major, soft glow at the top */
  background-image:
    radial-gradient(ellipse 80% 420px at 50% -120px, var(--glow-top), transparent 70%),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 100% 100%, 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
main { flex: 1 0 auto; }
main:focus { outline: none; }
img, svg, video { max-width: 100%; }
img { height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
h1, h2, h3, h4 {
  font-family: var(--font-mono); font-weight: 700; line-height: 1.2;
  margin: 0 0 .5em; letter-spacing: -.01em; color: var(--text);
}
h1 { font-size: clamp(2rem, 7vw, 3.4rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.35rem, 4vw, 1.9rem); }
h3 { font-size: 1.12rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.2em; }
hr, .divider { border: 0; height: 1px; background: var(--line); margin: 24px 0; }
code, kbd {
  font-family: var(--font-mono); font-size: .88em;
  padding: .1em .4em; border-radius: 3px;
  background: var(--surface-3); border: 1px solid var(--line); color: var(--text);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }

/* ============================ utilities ============================ */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding-top: 48px; padding-bottom: 48px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack--lg { gap: 24px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.accent { color: var(--accent); }
.amber { color: var(--amber); }
.sr-only { position: absolute !important; 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: 8px; top: -80px; z-index: 200;
  padding: 10px 14px; font-family: var(--font-mono); font-size: .9rem;
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius); text-decoration: none;
}
.skip-link:focus { top: 8px; color: var(--on-accent); }

/* ============================ grid ============================ */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.grid--tight { gap: 10px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* ============================ type helpers ============================ */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .78rem; font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 10px;
}
.section-head { margin-bottom: 24px; }
.section-title {
  display: flex; align-items: center; gap: 12px; margin: 0;
}
.section-title::after { content: ""; flex: 1 1 24px; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.section-title .icon { color: var(--accent); flex: none; }
.section-head .lead { margin-top: 10px; }
.lead { font-size: 1.08rem; color: var(--text-muted); max-width: 62ch; }
.prompt { font-family: var(--font-mono); font-size: .9rem; color: var(--text-muted); }
.prompt::before { content: "$ "; color: var(--accent); }

/* ============================ icons ============================ */
.icon { display: inline-block; flex: none; vertical-align: -0.18em; stroke: currentColor; fill: none; }
.icon-wrap { display: inline-flex; line-height: 0; }
.icon-box {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: var(--radius);
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--line);
}
.icon-box--lg { width: 56px; height: 56px; }
.icon-box--amber { color: var(--amber); background: var(--amber-soft); }

/* ============================ panel ============================ */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
/* corner tick marks (8 tiny segments) */
.panel::before {
  content: ""; position: absolute; inset: -1px; pointer-events: none; border-radius: inherit;
  --t: 10px;
  background:
    linear-gradient(var(--tick), var(--tick)) top left / var(--t) 1px,
    linear-gradient(var(--tick), var(--tick)) top left / 1px var(--t),
    linear-gradient(var(--tick), var(--tick)) top right / var(--t) 1px,
    linear-gradient(var(--tick), var(--tick)) top right / 1px var(--t),
    linear-gradient(var(--tick), var(--tick)) bottom left / var(--t) 1px,
    linear-gradient(var(--tick), var(--tick)) bottom left / 1px var(--t),
    linear-gradient(var(--tick), var(--tick)) bottom right / var(--t) 1px,
    linear-gradient(var(--tick), var(--tick)) bottom right / 1px var(--t);
  background-repeat: no-repeat;
  opacity: .7;
}
.panel--pad { padding: 20px; }
.panel--inset { background: var(--surface-2); box-shadow: none; }
.panel--inset::before { display: none; }
.panel--accent { border-top: 2px solid var(--accent); }
.panel--amber { border-top: 2px solid var(--amber); --tick: var(--amber); }
.panel__bar {
  display: flex; align-items: center; gap: 10px; min-height: 36px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted);
}
.panel__label { margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.panel__label::before { content: "// "; color: var(--accent); }
.panel__body { padding: 20px; }
.panel__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--line);
}
.dots { display: inline-flex; gap: 6px; flex: none; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.dots i:nth-child(1) { background: var(--danger); opacity: .75; }
.dots i:nth-child(2) { background: var(--amber); opacity: .75; }
.dots i:nth-child(3) { background: var(--ok); opacity: .75; }
@media (max-width: 400px) { .panel__body, .panel--pad { padding: 16px; } .panel__foot { padding: 12px 16px; } }

a.panel, .panel--link { display: block; text-decoration: none; color: var(--text); }
.panel.tile { display: flex; }
a.panel:hover, .panel--link:hover, a.panel:focus-visible, .panel--link:focus-visible {
  border-color: var(--accent); box-shadow: var(--glow); transform: translateY(-2px); color: var(--text);
}

/* tile: icon + text + arrow (nav cards, contact links, file rows) */
.tile { display: flex; align-items: center; gap: 14px; padding: 16px; min-height: 76px; }
.tile__text { min-width: 0; flex: 1; }
.tile__text strong { display: block; font-family: var(--font-mono); font-size: 1rem; line-height: 1.3; color: var(--text); }
.tile__text small { display: block; font-size: .86rem; line-height: 1.45; color: var(--text-muted); overflow-wrap: anywhere; }
.tile__arrow { flex: none; color: var(--text-faint); transition: transform .2s var(--ease), color .2s var(--ease); }
a.tile:hover .tile__arrow, a.tile:focus-visible .tile__arrow { color: var(--accent); transform: translateX(3px); }
.tile.is-disabled { opacity: .62; cursor: not-allowed; }

/* ============================ buttons ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px;
  font-family: var(--font-mono); font-size: .92rem; font-weight: 500; line-height: 1.2;
  color: var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: background .15s, border-color .15s, color .15s, box-shadow .2s var(--ease), transform .1s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); box-shadow: var(--glow); }
.btn--amber { background: var(--amber-fill); border-color: var(--amber-fill); color: var(--on-amber); }
.btn--amber:hover { filter: brightness(1.06); color: var(--on-amber); border-color: var(--amber-fill); box-shadow: 0 0 0 3px var(--amber-soft); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.btn--sm { padding: 6px 12px; font-size: .84rem; }
.btn--icon { width: 44px; padding: 0; }
.btn.is-active, .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ============================ tags / status ============================ */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; min-height: 24px;
  font-family: var(--font-mono); font-size: .74rem; font-weight: 500; line-height: 1.4;
  color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 3px; white-space: nowrap;
}
.tag--accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tag--amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.tag--ok { color: var(--ok); border-color: currentColor; background: transparent; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }

.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot--ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot--warn { background: var(--warn); }
.dot--off { background: var(--off); }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .8rem; color: var(--text-muted);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.status--ok::before { background: var(--ok); animation: pulse 2.4s var(--ease) infinite; }
.status--warn::before { background: var(--warn); }
.status--off::before { background: var(--off); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

/* ============================ stats ============================ */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__num { font-family: var(--font-mono); font-size: clamp(1.6rem, 5vw, 2.2rem); font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat__label { font-family: var(--font-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

/* ============================ forms ============================ */
.field {
  width: 100%; min-height: 44px; padding: 8px 12px;
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--text-faint); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================ hero ============================ */
.hero { padding-top: 56px; padding-bottom: 40px; }
.hero__grid { display: grid; gap: 32px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; }
.hero__title { margin: 0 0 8px; }
.hero__title .cursor { display: inline-block; width: .55em; height: .9em; margin-left: .08em; vertical-align: -.06em; background: var(--accent); animation: blink 1.1s steps(1) infinite; }
.hero__lead { font-size: 1.1rem; color: var(--text-muted); max-width: 58ch; margin: 16px 0 0; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero__art { min-width: 0; }
@media (max-width: 860px) {
  .hero { padding-top: 32px; }
  .hero__grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 400px) { .hero__actions .btn { flex: 1 1 100%; } }
@keyframes blink { 50% { opacity: 0; } }

/* ============================ site nav (injected by site.js) ============================ */
.site-nav {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav__bar { display: flex; align-items: center; gap: 12px; min-height: var(--nav-h); }
.site-nav__brand {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; flex: none;
  font-family: var(--font-mono); font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none;
}
.site-nav__brand:hover { color: var(--text); }
.site-nav__brand .icon-box { width: 32px; height: 32px; }
.site-nav__brand .accent { color: var(--accent); font-weight: 500; }
.site-nav__links { display: flex; gap: 4px; margin-left: auto; }
.site-nav__links a {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 12px;
  font-family: var(--font-mono); font-size: .86rem; color: var(--text-muted); text-decoration: none;
  border-radius: var(--radius);
}
.site-nav__links a:hover { color: var(--text); background: var(--surface-3); }
.site-nav__links a[aria-current="page"] { color: var(--accent); }
.site-nav__links a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 6px; height: 2px; background: var(--accent); border-radius: 1px;
}
.site-nav__tools { display: flex; align-items: center; gap: 6px; flex: none; }
.theme-toggle .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: inline-block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .i-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* language toggle (click handling + .on state come from lang.js) */
.lang-toggle {
  display: inline-flex; align-items: stretch; padding: 3px; gap: 2px; cursor: pointer;
  min-height: 44px; min-width: 44px;
  font-family: var(--font-mono); font-size: .76rem; font-weight: 700;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.lang-toggle:hover { border-color: var(--accent); }
.lang-toggle span { display: grid; place-items: center; padding: 0 8px; border-radius: 2px; }
.lang-toggle span.on { background: var(--accent); color: var(--on-accent); }

@media (max-width: 720px) {
  .site-nav__bar { flex-wrap: wrap; gap: 0 8px; padding-top: 6px; }
  .site-nav__tools { margin-left: auto; }
  .site-nav__links {
    order: 3; width: calc(100% + 2 * var(--gutter)); margin: 6px calc(-1 * var(--gutter)) 0;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    border-top: 1px solid var(--line);
  }
  .site-nav__links a { justify-content: center; padding: 0 2px; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .site-nav__links a .icon { display: none; }
  .site-nav__links a[aria-current="page"]::after { left: 20%; right: 20%; bottom: 4px; }
}

/* ============================ footer (injected by site.js) ============================ */
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 85%, transparent); }
.site-footer__inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px;
  padding-top: 20px; padding-bottom: 24px;
  font-family: var(--font-mono); font-size: .78rem; color: var(--text-muted);
}
.site-footer__inner a { color: var(--text-muted); }
.site-footer__inner a:hover { color: var(--accent); }
/* room for the fixed chat launcher (bottom-right) so it never covers the footer text */
.site-footer__inner { padding-bottom: 88px; }

/* ============================ motion ============================ */
.fade-in, .pop-in { animation: fade-up .5s var(--ease) both; }
.fade-in.d1 { animation-delay: .06s; } .fade-in.d2 { animation-delay: .12s; } .fade-in.d3 { animation-delay: .18s; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .hero__title .cursor { animation: none; }
}

/* ============================ Lilith chat widget ============================
   lilith/lilith.css (injected by lilith/lilith.js) styles .lil-launcher / .lil-panel
   straight from the tokens above (--surface, --line, --accent, --font-mono …), so it
   follows dark + light automatically. Its only private tokens are --lil-vp-* (the
   always-dark character viewport), defined in lilith.css. Nothing to remap here.
   The footer's extra bottom padding above keeps the launcher off the footer text. */
