/* ===========================================================================
   Bindex — design system (W0-2). Single source of truth for tokens.
   Five modes: System · Light · Dark · Rainbow · Rainbow Dark. Values from
   plan/08 §2 (canonical namespace), §3 (palettes), §4.4 (WCAG-corrected
   values — AWAIT HUMAN SIGN-OFF), plus §2.4 structural + plan/10 §3 motion.
   <html> carries the server-injected data-theme ({{theme_class}}); :root = Light
   is the defensive default. Print forces Light. All component colours resolve
   through var(--…); only this file's token table holds literal colours.
   =========================================================================== */
@import url("./fonts/fonts.css");

/* ===== §3 TOKEN TABLE (single source of truth) — BEGIN ===== */

/* BEGIN STRUCTURAL TOKENS */
:root {
  /* --- typography (self-hosted geometric sans + mono; no external requests) --- */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* --- radii (cards 12 / panels 16 / pills 999) --- */
  --radius-card: 12px; --radius-panel: 16px; --radius-pill: 999px;
  --radius-md: 12px; --radius-sheet: 16px;
  /* --- spacing scale 4/8/12/16/24/32/48/64 --- */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;
  --space-3xs: 2px; --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px;
  --space-md: 16px; --space-lg: 24px; --space-xl: 32px; --space-2xl: 48px; --space-3xl: 64px;
  /* --- motion (plan/10 §3, frozen shared contract; wiring is a later wave) --- */
  --dur-fast: 150ms; --dur-base: 200ms; --dur-slow: 240ms; --dur-exit: 180ms;
  --theme-dur: 200ms; --ease-out: cubic-bezier(0.16, 1, 0.30, 1);
  --ease-in-out: cubic-bezier(0.40, 0, 0.20, 1); --stagger: 60ms;
  /* --- layout dimensions & breakpoints --- */
  --container-max: 1200px; --measure-lookup: 800px; --touch-min: 44px;
  --bp-mobile: 390px; --bp-md: 768px; --bp-lg: 1024px;
  /* --- focus --- */
  --focus-ring: 2px; --focus-offset: 2px;
  /* --- type scale --- */
  --type-display: 3rem; --type-h1: 2.25rem; --type-h2: 1.75rem; --type-h3: 1.375rem;
  --type-body: 1rem; --type-label: 0.875rem; --type-micro: 0.75rem;
  --type-mono: 0.9375rem; --type-stat: 2.5rem;
  /* --- z-index --- */
  --z-sticky: 100; --z-drawer: 200; --z-sheet: 300; --z-toast: 400; --z-modal: 500;
  /* --- deprecated aliases (§0.2): old names resolve through var() for one
     release window so the page-level <style> blocks do not break; they follow
     the active data-theme automatically. No literal colours here. --- */
  --panel: var(--surface); --panel-2: var(--surface-2); --panel-3: var(--surface-3);
  --line: var(--border); --line-strong: var(--border-strong);
  --text-muted: var(--muted); --text-dim: color-mix(in srgb, var(--muted) 75%, var(--surface));
  --accent-2: var(--rainbow-6); --accent-line: var(--border-strong);
  --ok: var(--success); --warn: var(--warning); --err: var(--danger);
  --ok-soft: color-mix(in srgb, var(--success) 14%, var(--surface));
  --warn-soft: color-mix(in srgb, var(--warning) 14%, var(--surface));
  --err-soft: color-mix(in srgb, var(--danger) 14%, var(--surface));
  --grad: var(--primary-gradient); --grad-text: var(--text-gradient);
  --glow: var(--hero-gradient); --shadow-lit: var(--shadow);
  --radius: var(--radius-card); --radius-sm: var(--radius-card); --radius-lg: var(--radius-panel);
  --sans: var(--font-sans); --mono: var(--font-mono);
  /* Button helpers — per-theme via var()/color-mix (token layer). ADDENDUM:
     centred, small 12.5–14px type, calm weight 600, near-zero tracking, tight
     padding rhythm and SUBTLE elevation (crisp, calm controls — not chunky). */
  --btn-fs-sm: 12.5px; --btn-fs-md: 13px; --btn-fs-lg: 14px;
  --btn-fw: 600; --btn-ls: 0.01em;
  --btn-pad-y: 7px; --btn-pad-x: 14px;
  --btn-pad-y-sm: 5px; --btn-pad-x-sm: 10px;
  --btn-pad-y-lg: 10px; --btn-pad-x-lg: 20px;
  --btn-depth: 0 1px 2px color-mix(in srgb, var(--text) 8%, transparent);
  --btn-depth-hover: 0 2px 8px color-mix(in srgb, var(--accent) 22%, transparent);
  --btn-depth-active: 0 1px 1px color-mix(in srgb, var(--text) 10%, transparent);
  --btn-focus-halo: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent);
}
/* END STRUCTURAL TOKENS */

/* BEGIN MODE light */
:root, [data-theme="light"] {
  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E8EEF7;
  --text: #0F172A;
  --muted: #5E6B80;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-ui: #7C8AA0;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #DBEAFE;
  --success: #047857;
  --warning: #B45309;
  --danger: #B91C1C;
  --shadow: 0 8px 24px rgba(15,23,42,0.06);
  --rainbow-1: var(--chart-1);
  --rainbow-2: var(--chart-2);
  --rainbow-3: var(--chart-3);
  --rainbow-4: var(--chart-4);
  --rainbow-5: var(--chart-5);
  --rainbow-6: var(--chart-6);
  --primary-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --hero-gradient: radial-gradient(58% 58% at 50% 0%, var(--accent-soft) 0%, transparent 72%);
  --text-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --accent-ink: #FFFFFF;
  --gradient-ink: #FFFFFF;
  --chart-1: #0072B2;
  --chart-2: #C05300;
  --chart-3: #007A59;
  --chart-4: #A64B8C;
  --chart-5: #8A6100;
  --chart-6: #1D6FA5;
}
/* END MODE light */

/* BEGIN MODE dark */
/* V2 premium Dark rework: cool-cast layered surfaces, refined accent, layered
   elevation; values re-verified within WCAG 2.2 AA. */
[data-theme="dark"] {
  --bg: #0A0E1A;
  --surface: #121A2B;
  --surface-2: #1B2739;
  --surface-3: #243249;
  --text: #EDF2FC;
  --muted: #9DAAC2;
  --border: #26334A;
  --border-strong: #3C4C69;
  --border-ui: #7186A8;
  --accent: #6EA8FE;
  --accent-hover: #9CC8FF;
  --accent-soft: #162034;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --shadow: 0 8px 24px rgba(0,0,0,0.50), 0 1px 3px rgba(0,0,0,0.40), inset 0 1px 0 rgba(255,255,255,0.05);
  --rainbow-1: var(--chart-1);
  --rainbow-2: var(--chart-2);
  --rainbow-3: var(--chart-3);
  --rainbow-4: var(--chart-4);
  --rainbow-5: var(--chart-5);
  --rainbow-6: var(--chart-6);
  --primary-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --hero-gradient: radial-gradient(58% 58% at 50% 0%, var(--accent-soft) 0%, transparent 72%);
  --text-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --accent-ink: #0B1020;
  --gradient-ink: #0B1020;
  --chart-1: #56B4E9;
  --chart-2: #FF8A4C;
  --chart-3: #4ADEA8;
  --chart-4: #E39AD0;
  --chart-5: #F0C24A;
  --chart-6: #8FD3FF;
}
/* END MODE dark */

/* BEGIN MODE rainbow */
[data-theme="rainbow"] {
  --bg: #FBFCFF;
  --surface: #FFFFFF;
  --surface-2: #F5F7FF;
  --surface-3: #EEF2FF;
  --text: #161B33;
  --muted: #5E6B80;
  --border: rgba(99,102,241,0.16);
  --border-strong: rgba(99,102,241,0.28);
  --border-ui: #7C8AA0;
  --accent: #6D4AE0;
  --accent-hover: #5A38C4;
  --accent-soft: #EEE9FF;
  --success: #0B7A52;
  --warning: #9A5A00;
  --danger: #C2185B;
  --shadow: 0 12px 30px rgba(99,102,241,0.10);
  --rainbow-1: #FF5D8F;
  --rainbow-2: #FF9F45;
  --rainbow-3: #FFD166;
  --rainbow-4: #34D399;
  --rainbow-5: #38BDF8;
  --rainbow-6: #A78BFA;
  --primary-gradient: linear-gradient(110deg,#A78BFA,#38BDF8,#34D399);
  --hero-gradient: radial-gradient(60% 55% at 18% 0%, rgba(167,139,250,0.20) 0%, transparent 60%), radial-gradient(55% 50% at 82% 4%, rgba(56,189,248,0.18) 0%, transparent 60%), radial-gradient(50% 45% at 50% 0%, rgba(255,93,143,0.12) 0%, transparent 62%), radial-gradient(45% 40% at 30% 20%, rgba(52,211,153,0.10) 0%, transparent 60%);
  --text-gradient: linear-gradient(110deg,#5A38C4,#1D6FA5,#0B7A52);
  --accent-ink: #FFFFFF;
  --gradient-ink: #161B33;
  --chart-1: #0072B2;
  --chart-2: #C05300;
  --chart-3: #007A59;
  --chart-4: #A64B8C;
  --chart-5: #8A6100;
  --chart-6: #1D6FA5;
}
/* END MODE rainbow */

/* BEGIN MODE rainbow-dark */
[data-theme="rainbow-dark"] {
  --bg: #0A0B16;
  --surface: #121426;
  --surface-2: #1A1D33;
  --surface-3: #232743;
  --text: #F2F4FF;
  --muted: #A5A9C5;
  --border: rgba(167,139,250,0.20);
  --border-strong: rgba(167,139,250,0.34);
  --border-ui: rgba(167,139,250,0.60);
  --accent: #B39BFF;
  --accent-hover: #C9B8FF;
  --accent-soft: rgba(167,139,250,0.14);
  --success: #4ADEA8;
  --warning: #FFD978;
  --danger: #FF8FA3;
  --shadow: 0 14px 38px rgba(0,0,0,0.45);
  --rainbow-1: #FF6FA5;
  --rainbow-2: #FFB15C;
  --rainbow-3: #FFD978;
  --rainbow-4: #4ADEA8;
  --rainbow-5: #5CC8FF;
  --rainbow-6: #B39BFF;
  --primary-gradient: linear-gradient(110deg,#B39BFF,#5CC8FF,#4ADEA8);
  --hero-gradient: radial-gradient(60% 55% at 18% 0%, rgba(179,155,255,0.22) 0%, transparent 60%), radial-gradient(55% 50% at 82% 4%, rgba(92,200,255,0.18) 0%, transparent 60%), radial-gradient(50% 45% at 50% 0%, rgba(255,111,165,0.14) 0%, transparent 62%), radial-gradient(45% 40% at 30% 20%, rgba(74,222,168,0.12) 0%, transparent 60%);
  --text-gradient: linear-gradient(110deg,#C9B8FF,#8FD3FF,#8FE9C4);
  --accent-ink: #0A0B16;
  --gradient-ink: #0A0B16;
  --chart-1: #56B4E9;
  --chart-2: #FF8A4C;
  --chart-3: #4ADEA8;
  --chart-4: #E39AD0;
  --chart-5: #F0C24A;
  --chart-6: #8FD3FF;
}
/* END MODE rainbow-dark */

/* BEGIN MODE system */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
  /* System-dark mirrors the V2 premium Dark palette. */
  --bg: #0A0E1A;
  --surface: #121A2B;
  --surface-2: #1B2739;
  --surface-3: #243249;
  --text: #EDF2FC;
  --muted: #9DAAC2;
  --border: #26334A;
  --border-strong: #3C4C69;
  --border-ui: #7186A8;
  --accent: #6EA8FE;
  --accent-hover: #9CC8FF;
  --accent-soft: #162034;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
  --shadow: 0 8px 24px rgba(0,0,0,0.50), 0 1px 3px rgba(0,0,0,0.40), inset 0 1px 0 rgba(255,255,255,0.05);
  --rainbow-1: var(--chart-1);
  --rainbow-2: var(--chart-2);
  --rainbow-3: var(--chart-3);
  --rainbow-4: var(--chart-4);
  --rainbow-5: var(--chart-5);
  --rainbow-6: var(--chart-6);
  --primary-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --hero-gradient: radial-gradient(58% 58% at 50% 0%, var(--accent-soft) 0%, transparent 72%);
  --text-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --accent-ink: #0B1020;
  --gradient-ink: #0B1020;
  --chart-1: #56B4E9;
  --chart-2: #FF8A4C;
  --chart-3: #4ADEA8;
  --chart-4: #E39AD0;
  --chart-5: #F0C24A;
  --chart-6: #8FD3FF;
  }
}
/* END MODE system */

@media print {
  :root, [data-theme] {
  --bg: #F7F9FC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E8EEF7;
  --text: #0F172A;
  --muted: #5E6B80;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --border-ui: #7C8AA0;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #DBEAFE;
  --success: #047857;
  --warning: #B45309;
  --danger: #B91C1C;
  --shadow: 0 8px 24px rgba(15,23,42,0.06);
  --rainbow-1: var(--chart-1);
  --rainbow-2: var(--chart-2);
  --rainbow-3: var(--chart-3);
  --rainbow-4: var(--chart-4);
  --rainbow-5: var(--chart-5);
  --rainbow-6: var(--chart-6);
  --primary-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --hero-gradient: radial-gradient(58% 58% at 50% 0%, var(--accent-soft) 0%, transparent 72%);
  --text-gradient: linear-gradient(110deg, var(--accent), var(--accent-hover));
  --accent-ink: #FFFFFF;
  --gradient-ink: #FFFFFF;
  --chart-1: #0072B2;
  --chart-2: #C05300;
  --chart-3: #007A59;
  --chart-4: #A64B8C;
  --chart-5: #8A6100;
  --chart-6: #1D6FA5;
  }
  .theme-switcher, .theme-popover, .theme-sheet, .toast, .glow-field::before { display: none !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  body { background: #FFFFFF; color: var(--text); }
}

/* ===== §3 TOKEN TABLE — END ===== */

/* ===== COMPONENTS — token vars only, no literal colours below this line ===== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "tnum";
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: var(--focus-ring) solid var(--accent); outline-offset: var(--focus-offset); border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }

.grad-text { background: var(--text-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.grad-fill { background: var(--primary-gradient); color: var(--gradient-ink); }
.grad-panel { position: relative; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--primary-gradient) border-box; border: 1px solid transparent; }
.grad-rule { height: 2px; border: 0; border-radius: 2px; background: var(--primary-gradient); margin: 0; }
/* F3 (plan/09 §10): the decorative radial glow deliberately bleeds -10% on
   each side; clip only the horizontal bleed so its ::before box can never
   inflate documentElement.scrollWidth at --bp-mobile. Vertical bleed stays. */
.glow-field { position: relative; isolation: isolate; overflow-x: clip; }
.glow-field::before { content: ""; position: absolute; z-index: -1; inset: -30% -10% auto -10%; height: 130%; background: var(--hero-gradient); pointer-events: none; }
.glow-edge { box-shadow: var(--shadow); }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.03em; color: var(--text); user-select: none; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 30px; height: 30px; border-radius: 8px; }
.brand .grad { background: var(--text-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand.lg { font-size: 24px; }
.brand.lg img { width: 42px; height: 42px; border-radius: 11px; }
.brand.sm { font-size: 14px; gap: 8px; }
.brand.sm img { width: 24px; height: 24px; border-radius: 7px; }

.btn, button { font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; border: none; border-radius: var(--radius-card); padding: 9px 15px; background: var(--primary-gradient); color: var(--gradient-ink); transition: filter .12s ease, background .12s ease, opacity .12s ease; }
.btn:hover, button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost, button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover, button.ghost:hover { color: var(--text); border-color: var(--border-strong); filter: none; }
.btn.danger, button.danger { background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--surface)); color: var(--danger); }
.btn.danger:hover, button.danger:hover { filter: none; background: var(--err-soft); }
.btn.sm, button.sm { padding: 5px 10px; font-size: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px; box-shadow: var(--shadow); }

.badge, .tag, .pill { display: inline-block; font-family: var(--mono); font-size: 11px; line-height: 1.5; padding: 3px 9px; border-radius: var(--radius-pill); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge.ok, .pill.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--surface)); background: var(--ok-soft); }
.badge.warn, .pill.warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, var(--surface)); background: var(--warn-soft); }
.badge.err, .pill.err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--surface)); background: var(--err-soft); }
.badge.admin { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, var(--surface)); }

input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: var(--focus-ring) solid var(--accent); outline-offset: -1px; border-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: var(--surface-2); }
/* F3 (plan/09 §10): any wide media / code block is capped and scrollable so
   no single element can force the document wider than the 390px viewport.
   Wide tables use the .scroll / .table-scroll wrapper pattern. */
img, svg, video, canvas { max-width: 100%; }
pre { max-width: 100%; overflow-x: auto; }
.scroll, .table-scroll { overflow-x: auto; max-width: 100%; }

.notice { display: none; border-radius: var(--radius-card); padding: 10px 13px; font-size: 13px; margin: 12px 0; border: 1px solid transparent; }
.notice.show { display: block; }
.notice.ok { background: var(--ok-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--surface)); }
.notice.err { background: var(--err-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--surface)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 22px; margin-top: 6px; letter-spacing: -.5px; }
.stat .m { font-size: 12px; color: var(--muted); margin-top: 2px; }

.hidden { display: none !important; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); } .dim { color: var(--text-dim); }
.ok { color: var(--success); } .warn { color: var(--warning); } .err { color: var(--danger); }
.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; }

/* ---- global chrome (plan/09 §1, plan/02 nav/footer) ---- */
.icon { width: 16px; height: 16px; stroke-width: 1.75; }
.icon--nav { width: 20px; height: 20px; stroke-width: 2; }
.icon--hero { width: 24px; height: 24px; stroke-width: 2; }
.skip-link { position: absolute; left: var(--space-sm); top: -100px; z-index: var(--z-modal); background: var(--surface); color: var(--accent); border: 1px solid var(--border-strong); border-radius: var(--radius-card); padding: var(--space-xs) var(--space-md); }
.skip-link:focus { top: var(--space-sm); }
header[role="banner"].chrome { position: sticky; top: 0; z-index: var(--z-sticky); background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); }
.chrome-container { max-width: var(--container-max); margin: 0 auto; display: flex; align-items: center; gap: var(--space-md); padding: var(--space-sm) var(--space-lg); }
.chrome-nav { display: flex; align-items: center; gap: var(--space-md); }
.chrome-nav a { color: var(--muted); font-size: var(--type-label); }
.chrome-nav a[aria-current="page"] { color: var(--text); }
.chrome-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-sm); }
.theme-switcher, .lang-switcher, .icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: var(--touch-min); min-height: var(--touch-min); background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-pill); cursor: pointer; }
.theme-popover, .theme-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-panel); box-shadow: var(--shadow); }
.theme-popover { position: absolute; z-index: var(--z-drawer); }
.theme-sheet { position: fixed; z-index: var(--z-sheet); border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
.theme-row { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); min-height: var(--touch-min); }
.theme-row[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.theme-swatches { display: inline-flex; gap: var(--space-3xs); }
.theme-swatch { width: 12px; height: 12px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); }
.theme-scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 60%, transparent); z-index: var(--z-drawer); }
.theme-drag-handle { width: 40px; height: 4px; border-radius: var(--radius-pill); background: var(--border-strong); margin: var(--space-sm) auto; }
.key-hint { color: var(--muted); font-size: var(--type-micro); }
footer[role="contentinfo"].chrome-footer { border-top: 1px solid var(--border); background: var(--surface-2); }
/* F3: minmax(0,1fr) stops a nowrap footer column (e.g. #footerLocale) from
   expanding the grid track past the viewport at 1280/390; the >nav rules have
   higher specificity than any page-level `nav {display:flex}` rule. */
.footer-grid { max-width: var(--container-max); margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-lg); padding: var(--space-2xl) var(--space-lg); }
.footer-grid > nav { display: block; margin-left: 0; min-width: 0; max-width: 100%; }
#footerLocale { min-width: 0; max-width: 100%; }
.footer-grid h2 { font-size: var(--type-label); color: var(--text); }
.footer-grid a { display: block; color: var(--muted); font-size: var(--type-label); min-height: var(--touch-min); min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.footer-bottom { max-width: var(--container-max); margin: 0 auto; padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--border); color: var(--muted); font-size: var(--type-micro); }
.footer-safety { color: var(--text); }
.nav-drawer-toggle { display: none; }
/* Desktop: the two extra drawer links stay hidden here; .chrome-actions holds
   Console / Sign in. Boundary matches --bp-md (768px). */
@media (min-width: 769px) { .chrome-nav .nav-mobile-only { display: none; } }
/* 768px = --bp-md (CSS media conditions cannot read a custom property). */
@media (max-width: 768px) {
  .nav-drawer-toggle { display: inline-flex; }
  /* F3: the closed drawer is display:none — NO off-screen translateX box — so a
     hidden #primaryNav can never inflate documentElement.scrollWidth to 702.
     The open drawer sits inside the viewport; a clip-path reveal keeps the
     slide-in with zero off-screen geometry (reduced-motion collapses it). */
  .chrome-nav {
    display: none;
    position: fixed; z-index: var(--z-drawer); top: 0; right: 0; height: 100%;
    width: min(80vw, 320px); flex-direction: column; align-items: stretch; gap: 0;
    padding: var(--space-xl) var(--space-lg); background: var(--surface);
    border-left: 1px solid var(--border); box-shadow: var(--shadow);
    overflow-y: auto;
  }
  .chrome-nav.open { display: flex; animation: bx-drawer-in var(--dur-slow) var(--ease-out); }
  .chrome-nav a { display: flex; align-items: center; min-height: var(--touch-min); }
  /* F3: compact actions — theme + language + hamburger icons only; text links
     move into the drawer (.nav-mobile-only) / hide here (.action-desktop-only). */
  .chrome-actions .action-desktop-only { display: none; }
  /* theme + language menus become full-width bottom sheets on mobile */
  .theme-popover { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: var(--z-sheet); border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@keyframes bx-drawer-in {
  from { clip-path: inset(0 0 0 100%); }
  to   { clip-path: inset(0 0 0 0); }
}

/* ---- reduced motion (extends the original override, plan/10 §2) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  html { scroll-behavior: auto; }
  .theme-popover, .theme-sheet, .modal, .toast, .result-panel { transform: none !important; }
  /* F3: reduced motion shows the drawer fully — no slide/reveal animation. */
  .chrome-nav.open { animation: none !important; clip-path: none !important; }
}

/* ---- theme crossfade, colour-only, 180–240ms (plan/08 §8) ---- */
@media (prefers-reduced-motion: no-preference) {
  body, .card, .stat, header[role="banner"].chrome, input, select, textarea,
  .theme-switcher, .theme-popover, .theme-sheet, footer[role="contentinfo"].chrome-footer {
    transition: background-color var(--theme-dur) var(--ease-in-out),
                color var(--theme-dur) var(--ease-in-out),
                border-color var(--theme-dur) var(--ease-in-out);
  }
}

/* V2 TARGETED UX FIXES (human-scoped 2026-11-29): compact, surgical, no redesign. */
:root{--btn-h-sm:32px;--btn-h:40px;--btn-h-lg:48px;--btn-px:16px;--btn-px-sm:12px;--btn-px-lg:24px;--r-control:8px}
body .btn,body a.btn,body button,body .bx-submit,body .bx-chip,body .bx-copy-btn,body .copy-bin{box-sizing:border-box;min-height:var(--btn-h);padding:8px var(--btn-px);height:auto;font-size:14px;font-weight:600;line-height:1.2;text-align:center;overflow-wrap:anywhere;white-space:normal}
body .btn-sm,body .sm,body .bx-chip,body .bx-copy-btn,body .copy-bin{min-height:var(--btn-h-sm);padding:6px var(--btn-px-sm);font-size:13px}
body .btn-lg,body .lg,body .bx-submit{min-height:var(--btn-h-lg);padding:12px var(--btn-px-lg);font-size:16px}
body .theme-switcher,body .lang-switcher,body .icon-btn,body .nav-drawer-toggle{width:44px;height:44px;min-width:var(--touch-min);min-height:var(--touch-min);padding:0;gap:0;border-radius:var(--r-control);background:var(--surface);color:var(--text);border:1px solid var(--border-ui);position:relative}
body .theme-switcher .icon,body .lang-switcher .icon,body .icon-btn .icon,body .nav-drawer-toggle .icon{width:20px;height:20px;stroke-width:1.75}
body .theme-switcher::after,body .lang-switcher::after{content:"";position:absolute;right:5px;bottom:5px;width:0;height:0;border-left:3px solid transparent;border-right:3px solid transparent;border-top:3px solid currentColor;opacity:.6;pointer-events:none}
body .theme-switcher:hover,body .lang-switcher:hover,body .icon-btn:hover{background:var(--surface-2);border-color:var(--border-strong)}
.chrome-actions{position:relative}
.theme-popover{top:100%;right:0;margin-top:var(--space-1);min-width:220px;max-height:min(70vh,420px);overflow-y:auto}
@media (max-width:768px){.chrome-nav{height:100dvh}}
header[role="banner"].chrome{backdrop-filter:none;background:transparent}
header[role="banner"].chrome::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;background:color-mix(in srgb,var(--surface) 88%,transparent);backdrop-filter:blur(10px)}
input::placeholder,textarea::placeholder{color:var(--muted)}

/* ===========================================================================
   ===== BUTTON SYSTEM (premium redesign) BEGIN =====
   Owner Calis · 2026-11-29 · BUTTONS slice of the buttons+dropdowns overhaul.
   CSS-first, ONE shared layer: body-prefixed selectors out-specify page-level
   <style> blocks so marketing, console, admin, docs, directories and checkout
   all resolve through this system. Token-only colour (var()/color-mix in the
   §3 token table above); NO literal hex/rgb below this line. Per-theme
   --primary-gradient / --gradient-ink / --accent / --shadow make all five
   modes intentional. The sm/md/lg scale is the V2 token scale
   (--btn-h-sm/--btn-h/--btn-h-lg); this section owns fill, ink, border,
   depth, radius and every interaction state.
   =========================================================================== */

/* 1 — shared anatomy + md tier: CENTRED, small, crisp, tight rhythm, calm.
   One rule owns the everyday button; sm/lg override below. No fixed widths →
   ru/zh safe. Weight 600 (never 700+), near-zero letter-spacing. */
body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
         .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
         .nav-drawer-toggle, .linkbtn, .theme-row) {
  cursor: pointer;
  text-align: center;
  font-size: var(--btn-fs-md);
  font-weight: var(--btn-fw);
  letter-spacing: var(--btn-ls);
  padding: var(--btn-pad-y) var(--btn-pad-x);
  overflow-wrap: anywhere;
  white-space: normal;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              filter var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

/* 1b — sm / lg tiers: all labels 12.5–14px (< 15px body), tighter padding. */
body :is(.btn-sm, .btn.sm, button.sm, .sm, .bx-chip, .bx-copy-btn, .copy-bin) {
  font-size: var(--btn-fs-sm);
  padding: var(--btn-pad-y-sm) var(--btn-pad-x-sm);
}
body :is(.btn-lg, .btn.lg, button.lg, .lg, .bx-submit) {
  font-size: var(--btn-fs-lg);
  padding: var(--btn-pad-y-lg) var(--btn-pad-x-lg);
}

/* 2 — PRIMARY: confident per-theme gradient + computed ink + subtle depth. */
body .btn, body a.btn, body button, body .bx-submit, body .bx-btn.primary {
  background: var(--primary-gradient);
  color: var(--gradient-ink);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--btn-depth);
}

/* 3 — SECONDARY / ghost / outline / batch / copy: surface-aware, border-strong. */
body .btn.ghost, body a.btn.ghost, body button.ghost, body .ghost,
body .bx-btn, body .bx-copy-btn, body .copy-bin {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  box-shadow: none;
}

/* 4 — DANGER: calm + clear (danger token, confirm-worthy weight), not a loud fill. */
body .btn.danger, body a.btn.danger, body button.danger, body .danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-card);
  box-shadow: none;
}

/* 5 — CHIPS / pills: radius-pill, small, tappable (44px @ mobile, below). */
body .bx-chip {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: none;
}

/* 6 — link-style + theme rows stay flat (no gradient/fill), still get polish. */
body .linkbtn {
  background: transparent;
  color: var(--accent);
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  padding: 0;
  min-height: 0;
}
body .theme-row {
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: none;
}

/* 7 — icon controls keep their V2 square geometry; flatten the primary depth. */
body .icon-btn, body .theme-switcher, body .lang-switcher, body .nav-drawer-toggle {
  box-shadow: none;
}

/* 8 — interaction states on EVERY shared surface (the one :is() group). */
body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
         .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
         .nav-drawer-toggle, .linkbtn, .theme-row):hover:not(:disabled):not([disabled]):not([aria-disabled="true"]) {
  filter: brightness(1.06);
}
body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
         .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
         .nav-drawer-toggle, .linkbtn, .theme-row):active:not(:disabled):not([disabled]):not([aria-disabled="true"]) {
  filter: brightness(0.96);
}
body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
         .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
         .nav-drawer-toggle, .linkbtn, .theme-row):focus-visible {
  outline: var(--focus-ring) solid var(--text);
  outline-offset: var(--focus-offset);
  box-shadow: var(--btn-focus-halo);
}
body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
         .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
         .nav-drawer-toggle, .linkbtn, .theme-row):is(:disabled, [disabled], [aria-disabled="true"]) {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  box-shadow: none;
  filter: none;
  transform: none;
  opacity: 1;
  cursor: not-allowed;
}

/* 9 — transform lift/press ONLY when motion is allowed; reduced motion = instant swaps. */
@media (prefers-reduced-motion: no-preference) {
  body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
           .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
           .nav-drawer-toggle, .linkbtn, .theme-row):hover:not(:disabled):not([disabled]):not([aria-disabled="true"]) {
    transform: translateY(-1px);
    box-shadow: var(--btn-depth-hover);
  }
  body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
           .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
           .nav-drawer-toggle, .linkbtn, .theme-row):active:not(:disabled):not([disabled]):not([aria-disabled="true"]) {
    transform: scale(0.98);
    box-shadow: var(--btn-depth-active);
  }
}
@media (prefers-reduced-motion: reduce) {
  body :is(.btn, a.btn, button, .bx-submit, .bx-chip, .bx-copy-btn, .bx-btn,
           .copy-bin, .icon-btn, .theme-switcher, .lang-switcher,
           .nav-drawer-toggle, .linkbtn, .theme-row) {
    transform: none !important;
  }
}

/* 10 — WCAG 2.2 target size: chips/copy/small buttons 44px tap targets on mobile. */
@media (max-width: 768px) {
  body :is(.bx-chip, .bx-copy-btn, .copy-bin, .btn-sm, .sm, button.sm) {
    min-height: var(--touch-min);
  }
}

/* ===== BUTTON SYSTEM END ===== */

/* ===== UI CLEANUP BEGIN ===== additive centering+polish; token-only, all 5 themes, reduced-motion + 390px safe. */
main.editorial{max-width:var(--measure-lookup);margin:0 auto;padding:var(--space-xl) var(--space-lg) var(--space-16);min-width:0;overflow-wrap:anywhere}
main.editorial h1{font-size:var(--type-h1);text-align:center;line-height:1.2;margin:0 0 var(--space-lg)}
.editorial-article{max-width:72ch;margin:0 auto;min-width:0}
.editorial-article>h2{font-size:var(--type-h2);margin:var(--space-xl) 0 var(--space-md)}
.editorial-article>:is(p,ul,ol,dl){margin:0 0 var(--space-md);line-height:1.7}
.breadcrumb ol{list-style:none;display:flex;flex-wrap:wrap;justify-content:center;gap:var(--space-2xs);padding:0;margin:0 0 var(--space-lg);font-size:var(--type-label);color:var(--muted)}
.breadcrumb li{display:inline-flex;align-items:center;gap:var(--space-2xs);min-width:0}
.breadcrumb li+li::before{content:"/";color:var(--border-strong);margin-inline:var(--space-2xs)}
.breadcrumb [aria-current="page"]{color:var(--text)}
.related{margin:var(--space-xl) auto 0;padding-top:var(--space-md);border-top:1px solid var(--border);text-align:center}
.related h2{font-size:var(--type-h3);margin:0 0 var(--space-sm)}
.related ul,.source-categories{list-style:none;display:flex;flex-wrap:wrap;justify-content:center;gap:var(--space-sm);padding:0;margin:var(--space-md) 0}
.learn-grid{list-style:none;display:grid;grid-template-columns:repeat(auto-fill,minmax(min(220px,100%),1fr));gap:var(--space-md);padding:0;margin:var(--space-lg) 0 0}
.learn-card{min-width:0}
.learn-card>a{display:flex;flex-direction:column;gap:var(--space-2xs);height:100%;padding:var(--space-md);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-card);color:var(--text);text-decoration:none;text-align:center}
.learn-card h2{font-size:var(--type-h3);margin:0}
:is(.legal-facts,.health-facts){margin:var(--space-md) 0}
:is(.legal-facts,.health-facts) dt{font-size:var(--type-micro);text-transform:uppercase;letter-spacing:.05em;color:var(--muted);text-align:center}
:is(.legal-facts,.health-facts) dd{margin:0 0 var(--space-sm);padding-bottom:var(--space-sm);border-bottom:1px solid var(--border);text-align:center}
body main.dir .dir-head{text-align:center}
body main.dir .dir-lede{margin:0 auto}
body main.dir .dir-crumb ol{justify-content:center}
body .dir-dl dd{font-size:var(--type-h3);text-align:center}
@media (prefers-reduced-motion:reduce){main.editorial,.learn-card>a{transition:none!important;animation:none!important}}
/* ===== UI CLEANUP END ===== */

/* ===== PRODUCTION FINALIZATION BEGIN =====
   Owner Calis 2026-11-30 — final polish. A prior additive centering pass centred
   PROSE (paragraphs, list items, fact definitions, learn-card bodies, breadcrumbs,
   console labels) — "text floating weird / hero-itis". This ONE shared body-prefixed
   layer out-specifies page <style> blocks + the (intact) UI CLEANUP block above and
   restores the rule: prose/tables/forms = left (numeric cells right); ONLY hero
   titles, CTA/action rows and empty/no-match states centre. Token-only (no literal
   colour), no fixed px width >390 (var()/max-width), no motion = reduced-motion
   safe + all five themes. */
/* 1 — editorial / learn / legal PROSE back to a left reading flow. */
body .editorial-article :is(p, li, dt, dd){ text-align: left; }
body :is(.legal-facts, .health-facts) :is(dt, dd){ text-align: left; }
body .learn-card > a{ text-align: left; }
body .learn-card :is(h2, p, span){ text-align: left; }
/* 2 — related / source link rows + breadcrumbs read left, not float centred. */
body .related{ text-align: left; }
body .related ul, body .source-categories{ justify-content: flex-start; }
body .related :is(li, h2), body .source-categories li{ text-align: left; }
body .breadcrumb ol, body .dir-crumb ol{ justify-content: flex-start; }
body .breadcrumb li, body .dir-crumb li{ text-align: left; }
/* 3 — directory hero title stays centred; its lede is prose -> left flow. */
body main.dir .dir-head .dir-lede{ text-align: left; margin-left: 0; }
/* 4 — professional console: headings/labels/notes left; value cards, empty
   states, CTA/action rows and pager keep their intentional centred design. */
body :is(.console-h1, .console-intro, .console-section > h2, .console-section > h3,
         .note-line, .prefix-note, .tools-head, .tools-head :is(h2, p),
         .console-table caption, .timeline-card, .reveal-once-box,
         .upgrade-cta, .chart-card h3){ text-align: left; }
/* 5 — numeric table cells right-aligned with tabular figures (comparison). */
body :is(td.num, th.num){ text-align: right; font-variant-numeric: tabular-nums; }
/* 6 — responsive: wrap long locale strings, tappable controls, no overflow. */
body main.editorial, body main.dir{ overflow-wrap: anywhere; }
@media (max-width: 768px){
  body :is(.console-sidebar nav a, .chrome-nav a, .theme-row, .bx-dd-opt,
           .bx-dd-trigger, .footer-grid a){ min-height: var(--touch-min); }
  body .breadcrumb ol, body .dir-crumb ol{ flex-wrap: wrap; }
}
/* 7 — sign-in gate CTA sits on its own line (no cramped overlap at 390px).
   display:block on the child only; the parent keeps [hidden]{display:none}. */
body #consoleGate .btn{ display: block; width: max-content; margin: var(--space-sm) auto 0; }
/* ===== PRODUCTION FINALIZATION END ===== */
