/* Pauli site design system. Dark-first, instrument-like: thin borders, mono
   numerals, one violet accent, a phosphor green reserved for "live" signals.
   No frameworks, no build step: custom properties + modern CSS only. */

:root {
  --bg: #0a0d14;
  --bg-raised: #10141d;
  --bg-inset: #0d1018;
  --border: rgba(148, 163, 196, 0.16);
  --border-strong: rgba(148, 163, 196, 0.28);
  --text: #e7eaf2;
  --text-muted: #97a0b5;
  /* Faint is the floor of the type ramp, not decoration: it must clear WCAG AA
     (4.5:1) on the *lightest* dark surface, --bg-raised. 4.7:1 there; muted
     stays ~7:1 so the three-step hierarchy survives. */
  --text-faint: #788195;
  --accent: #8b7bff;
  --accent-strong: #a496ff;
  --accent-ink: #14102b;
  --live: #3ddc97;
  --warn: #f0b358;
  --bad: #ef6f6f;
  /* Form-control boundaries need 3:1 against the surface behind the control
     (WCAG 1.4.11); --border-strong composites to ~1.7:1. Inputs only; cards
     and hairlines keep the thin instrument look. */
  --border-input: rgba(148, 163, 196, 0.58);
  /* Code-window syntax colors. Dark values are the original literals; light
     mode overrides them; the pale green/amber were ~1.7:1 on a light inset. */
  --code-string: #7fc8a9;
  --code-number: #e3b75e;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --maxw: 1080px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #fafbfe;
    --bg-raised: #ffffff;
    --bg-inset: #f1f3f9;
    --border: rgba(34, 44, 74, 0.14);
    --border-strong: rgba(34, 44, 74, 0.26);
    --text: #181d2a;
    --text-muted: #4d5670;
    --text-faint: #666d82; /* 4.65:1 on --bg-inset, the darkest light surface */
    --accent: #5b48e0;
    --accent-strong: #4936c4;
    --accent-ink: #ffffff;
    /* Status colors need their own light values: the dark-theme live/warn/bad
       are tuned for near-black and land at 1.7 to 3.4:1 on white. Each must hold
       4.5:1 as text on its own 16 to 18% color-mix badge tint, not just on the
       plain surfaces (that tint is the binding case). warn is never text, so
       it clears the 3:1 non-text bar (dots, chart fills, notice edges). */
    --live: #096843;
    --warn: #bf7911;
    --bad: #ad2b2b;
    --border-input: rgba(34, 44, 74, 0.55);
    --code-string: #347a5c;
    --code-number: #8d6619;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

/* scroll-padding: the sticky .nav is ~58px tall, so without it every
   fragment jump (/#estimator, /docs#byok) and keyboard-focus scroll parks
   the target underneath the bar. Applies to focus-driven scrolls too. */
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); font-weight: 650; }
h3 { font-size: 1.12rem; font-weight: 600; }
p  { margin: 0 0 1em; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono  { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 0.875rem; }

/* UA placeholder gray is ~4.1:1 on our surfaces in both schemes; pin it to
   the faint token (opacity 1; Firefox dims via opacity, not color). */
::placeholder { color: var(--text-faint); opacity: 1; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.34em;
}
/* The chip treatment above is for prose code only. Shiki emits <pre><code>,
   where the code element is inline and spans the block: a border there
   re-draws on every wrapped line fragment, and the 0.86em shrink compounds
   with the pre's own size. */
pre code {
  font-size: 1em;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
}

/* ---------------------------------------------------------------- nav */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .sigil {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent) 0%, #5e8bff 100%);
  color: #0b0e16;
  font-size: 1rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  flex-wrap: wrap;
  min-width: 0; /* may shrink below the console workspace chip, which then truncates */
}
.nav-links a { color: var(--text-muted); font-size: 0.93rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--text); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  border-color: var(--border-strong);
  color: var(--text);
  background: transparent;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-small { padding: 7px 13px; font-size: 0.88rem; }
/* Adjacent buttons never sit in raw inline flow: wrapped inline-blocks
   stack with only line-height between them, so the buttons touch. Every
   multi-button group uses this row (site + console + JS-built groups). */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* The header CTA is an <a> inside .nav-links, and `.nav-links a` (0,1,1)
   outranks `.btn-primary` (0,1,0); without this the button paints muted
   gray on the accent fill (~1.3:1, unreadable). Kept below the .nav-links
   rules so it also wins the specificity tie with `.nav-links a:hover`. */
.nav-links a.btn-primary { color: var(--accent-ink); }

/* ---------------------------------------------------------------- hero */

.hero {
  position: relative;
  padding: 88px 0 56px;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(620px 300px at 50% -80px, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 72px);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 75%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 75%);
  pointer-events: none;
}
.hero > .container { position: relative; }

.hero .kicker {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 22px;
}

.hero .sub {
  max-width: 720px;
  margin: 0 auto 28px;
  color: var(--text-muted);
  font-size: 1.08rem;
}

.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 44px; }

/* ---------------------------------------------------------------- code window */

.code-window {
  text-align: left;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 860px;
  margin: 0 auto;
  box-shadow: 0 18px 50px -22px rgba(0, 0, 0, 0.6);
}
.code-window header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}
.code-window header .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.code-window header .title {
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.code-window header .copy {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px; /* keeps the tap target near the 24px floor */
  cursor: pointer;
}
.code-window header .copy:hover { color: var(--text); border-color: var(--border-strong); }
.code-window pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.55;
}
/* Shiki palette (CodeWindow renders <Code theme="css-variables">, which
   inlines color:var(--astro-code-*) per token). Every value aliases a
   scheme-flipping token above, so light mode needs no second set; a token
   variable left undefined falls back to the pre's inherited foreground. */
.astro-code {
  --astro-code-foreground: var(--text);
  --astro-code-background: transparent;
  --astro-code-token-comment: var(--text-faint);
  --astro-code-token-keyword: var(--accent-strong);
  --astro-code-token-string: var(--code-string);
  --astro-code-token-string-expression: var(--code-string);
  --astro-code-token-constant: var(--code-number);
  --astro-code-token-function: var(--text);
  --astro-code-token-parameter: var(--text);
  --astro-code-token-punctuation: var(--text-muted);
  --astro-code-token-link: var(--accent-strong);
}
/* Display-only response/output half: its own <pre> after the code (and
   outside the copy button's reach); collapse the doubled padding so the
   seam reads as the one blank line it used to be. */
.code-window .code-output pre { padding-top: 0; }

/* ---------------------------------------------------------------- sections */

section { padding: 56px 0; }
section.alt { background: var(--bg-raised); border-block: 1px solid var(--border); }

.section-head { max-width: 700px; margin-bottom: 32px; }
.section-head p { color: var(--text-muted); max-width: 64ch; }

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}
/* Grid items default to min-width:auto, so one wide child (a <pre> line, a
   nowrap table) grows the track past the container instead of engaging that
   child's own overflow-x:auto. Items must shrink; their scrollers scroll.
   Same rule for the console grids in console.css. */
.grid > * { min-width: 0; }

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
section.alt .card { background: var(--bg); }

.stat .big {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--accent-strong);
  display: block;
  margin-bottom: 6px;
}
.stat p { margin: 0; color: var(--text-muted); font-size: 0.93rem; }

/* ---------------------------------------------------------------- trust strip */

.trust {
  border-block: 1px solid var(--border);
  background: var(--bg-raised);
  padding: 14px 0;
}
.trust .container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px 28px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  margin-right: 7px;
  /* Two cycles (4.8s), then the dot settles solid: WCAG 2.2.2 allows
     auto-motion only under 5s without a pause control. The settled green
     still reads "live"; reduced-motion drops the pulse entirely. */
  animation: pulse 2.4s ease-in-out 2;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------------------------------------------------------------- estimator */

.controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 18px;
}
/* .field-hint: label-shaped text that is not a control's name (the slider's
   "1 to 100,000" range note; its accessible name is the aria-label). */
.controls label,
.controls .field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
/* min-width: 0 lets fields shrink below content size: a native select sizes
   to its WIDEST option (not the selected one), and the locale circuit labels
   exceed narrow viewports outright. */
.controls .field { min-width: 0; }
.controls select,
.controls input[type="number"] {
  background: var(--bg-inset);
  border: 1px solid var(--border-input);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92rem;
  border-radius: 8px;
  padding: 9px 12px;
  min-width: 120px;
  max-width: 100%;
  text-overflow: ellipsis;
}
.controls .field.grow { flex: 1; min-width: 220px; }
.controls input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); } /* UA side margins overflow the 100%-width field */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg-raised);
}
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
th {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
td { font-size: 0.9rem; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td .device-name { font-family: var(--mono); font-size: 0.85rem; }
td .device-sub { display: block; font-size: 0.74rem; color: var(--text-faint); }
tr.infeasible td { color: var(--text-faint); }

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: 8px;
  vertical-align: 1px;
}
.badge.cheapest { background: color-mix(in srgb, var(--live) 18%, transparent); color: var(--live); }
.badge.fastest  { background: color-mix(in srgb, #5e8bff 20%, transparent); color: #8db0ff; }
.badge.fidelity { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent-strong); }
@media (prefers-color-scheme: light) {
  .badge.fastest { color: #2f5fd0; }
}

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.status-dot.online { background: var(--live); }
.status-dot.degraded { background: var(--warn); }
.status-dot.offline, .status-dot.retired { background: var(--bad); }

.estimator-note { margin-top: 12px; font-size: 0.82rem; color: var(--text-faint); }
.estimator-status { font-family: var(--mono); font-size: 0.82rem; color: var(--text-muted); margin: 6px 0 0; min-height: 1.4em; }

/* ---------------------------------------------------------------- prose pages */

.page { padding: 56px 0 72px; }
.page .lede { font-size: 1.08rem; color: var(--text-muted); max-width: 64ch; }
.prose { max-width: 760px; }
/* Reading measure: running text caps near 70 characters (the 45 to 75
   range), in ch so it tracks the font. Direct children only: code windows,
   tables, and callouts keep the full 760px column, so snippets and rows
   don't pay for the narrower prose. */
.prose > p, .prose > ul, .prose > ol { max-width: 70ch; }
.prose h2 { margin-top: 2.2em; }
.prose h3 { margin-top: 1.6em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.45em; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.2em 0; }
.prose .code-window { margin: 18px 0; max-width: none; }
.prose table { min-width: 0; }
.prose td { white-space: normal; } /* prose cells are sentences; wrap, don't force a sideways scroll */

.callout {
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--bg-raised);
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.93rem;
}

/* ---------------------------------------------------------------- footer */

footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 48px;
  margin-top: 40px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.footer-grid { display: flex; gap: 28px; flex-wrap: wrap; justify-content: space-between; }
.footer-grid nav { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-grid nav a { color: var(--text-muted); }
.footer-grid nav a:hover { color: var(--text); }
.lang-switcher { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
/* CJK labels (日本語, 中文) break between any two characters when the row
   shrinks; wrap whole labels to the next line instead. */
.lang-switcher a { color: var(--text-faint); white-space: nowrap; }
.lang-switcher a:hover { color: var(--text); }
.lang-switcher a[aria-current] { color: var(--text-muted); }
.disclaimer { font-size: 0.76rem; color: var(--text-faint); margin-top: 14px; max-width: 860px; }

/* ---------------------------------------------------------------- misc */

.error-page { text-align: center; padding: 120px 24px; }
.error-page .big { font-family: var(--mono); font-size: 5rem; color: var(--accent-strong); margin: 0; }
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 50;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- print */

/* Docs and pricing get printed; near-black pages should not. Remap the
   tokens to grayscale-on-white (a print palette, not a copy of the light
   theme) and drop the interactive chrome. */
@media print {
  :root {
    --bg: #ffffff;
    --bg-raised: #ffffff;
    --bg-inset: #ffffff;
    --border: rgba(0, 0, 0, 0.25);
    --border-strong: rgba(0, 0, 0, 0.45);
    --text: #000000;
    --text-muted: #222222;
    --text-faint: #444444;
    --accent: #000000;
    --accent-strong: #000000;
    --accent-ink: #ffffff;
    --live: #222222;
    --warn: #222222;
    --bad: #222222;
    --border-input: rgba(0, 0, 0, 0.55);
    --code-string: #222222;
    --code-number: #222222;
    color-scheme: light;
  }
  .nav, .skip-link, .cta-row, .btn-row,
  .code-window header .copy, footer nav { display: none; }
  a { text-decoration: underline; }
  .hero::before { display: none; }
}

/* /data landscape page: paired single-series charts. */
.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 720px) { .chart-pair { grid-template-columns: 1fr; } }
.chart-pair figure {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 14px 16px 10px;
}
.chart-pair figcaption { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 8px; }
.chart-mount { position: relative; }
.chart-tip {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* /data: current-value stat above each history chart, and the per-device
   benchmark results (decision 079). Text pairings reuse the documented
   token floors; no new colors. */
.stat-now {
  font-family: var(--mono);
  font-size: 1.45rem;
  line-height: 1.3;
  margin-bottom: 6px;
  min-height: 1.9rem; /* steady card height while a selection loads */
}
.stat-now .stat-sub {
  margin-left: 10px;
  font-size: 0.75rem;
  color: var(--text-faint);
}
.stat-now .stat-dim {
  font-size: 0.95rem;
  color: var(--text-muted);
}
.bench-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 14px 16px;
  margin-top: 16px;
  max-width: 640px;
}
.bench-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.bench-annotation {
  display: inline-block;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.bench-value {
  font-family: var(--mono);
  font-size: 1.6rem;
  line-height: 1.2;
}
.bench-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.bench-facts {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin: 2px 0 0;
}
.bench-subcap {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 14px 0 4px;
}
