/* ==========================================================================
   williamhearn.co.uk: shared design system
   Dark-first, ledger-inspired, 2026 product-site aesthetic.
   Sections:
     1. Tokens (light default, dark via prefers-color-scheme + data-theme)
     2. Reset & base
     3. Typography
     4. Layout & utilities
     5. Backdrop (grid motif + glows)
     6. Header & nav
     7. Footer
     8. Buttons
     9. Cards, bento, spotlight
    10. Badges, kbd, callouts, code cards
    11. Forms (inputs, affixes, selects, segmented, chips, switch, range)
    12. Results (result panel, stats, ledger lists)
    13. Tables
    14. Tabs, toast, progress, misc components
    15. Tool page layout
    16. Landing page (/)
    17. About page (/about/)
    18. 404 page
    19. Animations & reveal
    20. Reduced motion
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f6f8f7;
  --bg-elev: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: #eef2f0;
  --surface-hover: #e8edea;
  --input-bg: #ffffff;
  --header-bg: rgba(246, 248, 247, 0.78);

  /* Lines */
  --border: rgba(9, 22, 16, 0.10);
  --border-strong: rgba(9, 22, 16, 0.18);
  --grid-line: rgba(9, 22, 16, 0.06);
  --grid-line-strong: rgba(9, 22, 16, 0.10);

  /* Text */
  --text: #08100c;
  --text-muted: #46524d;
  --text-faint: #5c6863;

  /* Accent: "Excel green" + cool secondary */
  --accent: #047857;
  --accent-strong: #065f46;
  --accent-text: #03664a;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(4, 120, 87, 0.10);
  --accent-soft-strong: rgba(4, 120, 87, 0.18);
  --accent-2: #0b6480;
  --accent-2-soft: rgba(14, 116, 144, 0.10);
  --gradient: linear-gradient(100deg, #047857 0%, #0f766e 50%, #0b6480 100%);
  --gradient-soft: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(6, 182, 212, 0.10));

  /* Status */
  --success: #03664a;
  --success-soft: rgba(4, 120, 87, 0.10);
  --warning: #8a5300;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(217, 45, 32, 0.10);

  /* Glows & effects */
  --glow-1: rgba(16, 185, 129, 0.20);
  --glow-2: rgba(6, 182, 212, 0.14);
  --spot: rgba(16, 185, 129, 0.10);
  --spot-border: rgba(4, 120, 87, 0.55);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --shadow-sm: 0 1px 2px rgba(9, 22, 16, 0.06);
  --shadow-md: 0 1px 2px rgba(9, 22, 16, 0.05), 0 8px 24px -12px rgba(9, 22, 16, 0.14);
  --shadow-lg: 0 1px 2px rgba(9, 22, 16, 0.05), 0 24px 60px -24px rgba(9, 22, 16, 0.22);
  --focus-ring: #0e7490;

  /* Type */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lead: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  --fs-h3: clamp(1.15rem, 1.05rem + 0.4vw, 1.375rem);
  --fs-h2: clamp(1.875rem, 1.25rem + 2.6vw, 3.25rem);
  --fs-h1: clamp(2.25rem, 1.35rem + 3.9vw, 4.25rem);
  --fs-display: clamp(2.5rem, 1.1rem + 6.2vw, 6.25rem);
  --tracking-tight: -0.035em;
  --tracking-display: -0.045em;

  /* Shape & space */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --container: 1200px;
  --container-narrow: 760px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 64px;
  --cell: 56px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-slow: 600ms;
}

/* Dark tokens (applied when the OS prefers dark, unless the visitor chose light) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #050807;
    --bg-elev: #0b0f0d;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-solid: #0c100e;
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(255, 255, 255, 0.085);
    --input-bg: rgba(255, 255, 255, 0.04);
    --header-bg: rgba(5, 8, 7, 0.72);
    --border: rgba(255, 255, 255, 0.085);
    --border-strong: rgba(255, 255, 255, 0.16);
    --grid-line: rgba(255, 255, 255, 0.045);
    --grid-line-strong: rgba(255, 255, 255, 0.08);
    --text: #f1f5f3;
    --text-muted: #a4aea9;
    --text-faint: #8b9590;
    --accent: #34d399;
    --accent-strong: #6ee7b7;
    --accent-text: #4ade9a;
    --accent-contrast: #02170f;
    --accent-soft: rgba(52, 211, 153, 0.12);
    --accent-soft-strong: rgba(52, 211, 153, 0.22);
    --accent-2: #22d3ee;
    --accent-2-soft: rgba(34, 211, 238, 0.12);
    --gradient: linear-gradient(100deg, #86efac 0%, #34d399 38%, #22d3ee 100%);
    --gradient-soft: linear-gradient(135deg, rgba(52, 211, 153, 0.16), rgba(34, 211, 238, 0.08));
    --success: #4ade9a;
    --success-soft: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --danger: #ff8a80;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --glow-1: rgba(16, 185, 129, 0.26);
    --glow-2: rgba(34, 211, 238, 0.14);
    --spot: rgba(52, 211, 153, 0.09);
    --spot-border: rgba(110, 231, 183, 0.55);
    --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 30px 80px -30px rgba(0, 0, 0, 0.9);
    --focus-ring: #5eead4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050807;
  --bg-elev: #0b0f0d;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-solid: #0c100e;
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.085);
  --input-bg: rgba(255, 255, 255, 0.04);
  --header-bg: rgba(5, 8, 7, 0.72);
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --grid-line: rgba(255, 255, 255, 0.045);
  --grid-line-strong: rgba(255, 255, 255, 0.08);
  --text: #f1f5f3;
  --text-muted: #a4aea9;
  --text-faint: #8b9590;
  --accent: #34d399;
  --accent-strong: #6ee7b7;
  --accent-text: #4ade9a;
  --accent-contrast: #02170f;
  --accent-soft: rgba(52, 211, 153, 0.12);
  --accent-soft-strong: rgba(52, 211, 153, 0.22);
  --accent-2: #22d3ee;
  --accent-2-soft: rgba(34, 211, 238, 0.12);
  --gradient: linear-gradient(100deg, #86efac 0%, #34d399 38%, #22d3ee 100%);
  --gradient-soft: linear-gradient(135deg, rgba(52, 211, 153, 0.16), rgba(34, 211, 238, 0.08));
  --success: #4ade9a;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #ff8a80;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --glow-1: rgba(16, 185, 129, 0.26);
  --glow-2: rgba(34, 211, 238, 0.14);
  --spot: rgba(52, 211, 153, 0.09);
  --spot-border: rgba(110, 231, 183, 0.55);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 30px 80px -30px rgba(0, 0, 0, 0.9);
  --focus-ring: #5eead4;
}

/* 2. Reset & base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  background: var(--bg);
}
body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
  isolation: isolate;
}
@supports (overflow: clip) { body { overflow-x: clip; } }
main { flex: 1 0 auto; display: block; }
img, svg, video, canvas { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, h4, h5, h6, li, dd, dt, td, th { overflow-wrap: break-word; }
ul[role="list"], ol[role="list"], .list-reset { list-style: none; padding: 0; }
table { border-collapse: collapse; }
hr { border: 0; border-top: 1px solid var(--border); margin-block: var(--space-6); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft-strong); color: var(--text); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 1000;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }

/* 3. Typography -------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  text-wrap: balance;
}
h1, .h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: var(--tracking-display); line-height: 1.02; }
h2, .h2 { font-size: var(--fs-h2); font-weight: 680; line-height: 1.05; }
h3, .h3 { font-size: var(--fs-h3); line-height: 1.25; letter-spacing: -0.02em; }
h4, .h4 { font-size: var(--fs-md); line-height: 1.3; letter-spacing: -0.01em; }
.display {
  font-size: var(--fs-display);
  font-weight: 720;
  letter-spacing: var(--tracking-display);
  line-height: 0.98;
}
p { text-wrap: pretty; }
.lead { font-size: var(--fs-lead); color: var(--text-muted); line-height: 1.55; max-width: 40em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }
.num, .tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.strong { font-weight: 650; }
.text-accent { color: var(--accent-text); }
.text-gradient {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
@media (forced-colors: active) {
  .text-gradient { color: CanvasText; -webkit-text-fill-color: CanvasText; background: none; }
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.eyebrow-cell {
  display: inline-grid;
  place-items: center;
  min-width: 2.2em;
  padding: 0.15em 0.45em;
  border: 1px solid var(--accent-soft-strong);
  border-radius: 6px;
  background: var(--accent-soft);
  letter-spacing: 0.02em;
}
.prose { max-width: 42em; }
.prose > * + * { margin-top: 1em; }
.prose p, .prose li { color: var(--text-muted); }
.prose strong { color: var(--text); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li + li { margin-top: 0.35em; }
.link, .prose a, .footer-note a, .callout a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  transition: text-decoration-color var(--dur-fast);
}
.link:hover, .prose a:hover, .footer-note a:hover, .callout a:hover { text-decoration-color: currentColor; }

/* 4. Layout & utilities --------------------------------------------------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container-narrow { max-width: calc(var(--container-narrow) + 2 * var(--gutter)); }
.section { padding-block: clamp(4rem, 3rem + 5vw, 7.5rem); position: relative; }
.section-sm { padding-block: clamp(2.5rem, 2rem + 3vw, 4.5rem); }
.section-head { max-width: 48rem; margin-bottom: clamp(2rem, 1.5rem + 2vw, 3.5rem); }
.section-head > * + * { margin-top: 1rem; }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head.center .lead { margin-inline: auto; }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, 1rem); }
.stack-sm { --stack-gap: 0.5rem; }
.stack-lg { --stack-gap: 1.5rem; }
.stack-xl { --stack-gap: 2.5rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, 0.75rem); }
.cluster-between { justify-content: space-between; }
.grid { display: grid; gap: var(--grid-gap, 1rem); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.center { text-align: center; }
.mx-auto { margin-inline: auto; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-2); }
.mt-2 { margin-top: var(--space-4); }
.mt-3 { margin-top: var(--space-5); }
.mt-4 { margin-top: var(--space-6); }
.mt-5 { margin-top: var(--space-7); }
.mb-0 { margin-bottom: 0 !important; }
.w-full { width: 100%; }
.sr-only, .visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.divider { height: 1px; background: var(--border); border: 0; margin-block: var(--space-5); }
.hairline-top { border-top: 1px solid var(--border); }
.nowrap { white-space: nowrap; }

/* 5. Backdrop: faint animated ledger grid + radial glows ------------------ */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 85%);
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 85%);
  animation: grid-pan 40s linear infinite;
}
body::after {
  background:
    radial-gradient(600px 400px at 12% -5%, var(--glow-1), transparent 70%),
    radial-gradient(700px 480px at 92% 8%, var(--glow-2), transparent 70%),
    radial-gradient(900px 600px at 50% 120%, var(--glow-2), transparent 70%);
  opacity: 0.9;
}
.page-plain::before, .page-plain::after { display: none; }

/* Grid texture you can put on any element */
.grid-bg {
  background-image:
    linear-gradient(to right, var(--grid-line-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-strong) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* 6. Header & nav ----------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.site-header.is-scrolled, .site-header.is-open { border-bottom-color: var(--border); }
.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  border-radius: 10px;
  white-space: nowrap;
}
.brand-monogram {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 10px;
  background: #080f1b;
  color: #a7f3d0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.7px;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.brand:hover .brand-monogram { color: #d1fae5; border-color: #6ee7b7; }

/* Minimal mission navigation: pages point back to the space homepage. */
.mission-header .header-inner { justify-content: space-between; }
.mission-header .header-actions { margin-left: auto; }
.mission-header .site-nav,
.mission-header .header-actions > button { display: none; }
.rocket-home {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  border-radius: 15px;
  color: #a7f3d0;
  background: rgba(5, 10, 24, 0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 28px rgba(34,211,238,.1);
  transition: transform var(--dur) var(--ease), border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.rocket-home:hover { transform: translateY(-2px); border-color: #67e8f9; box-shadow: 0 0 28px rgba(34,211,238,.22); }
.rocket-home img { width: 28px; height: 34px; }

.site-nav { margin-left: auto; }
.nav-list { list-style: none; padding: 0; display: flex; align-items: center; gap: 0.15rem; }
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 0.8rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link[aria-current="page"], .nav-link.is-active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.nav-link.is-section { color: var(--text); }
.nav-link[aria-current="page"]::after, .nav-link.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 18px;
  height: 2px;
  margin-left: -9px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.header-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: 0.5rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: color var(--dur-fast), background-color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.icon-btn:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme toggle icon swaps */
.theme-toggle .ti { display: none; }
:root[data-theme-choice="system"] .theme-toggle .ti-system,
:root:not([data-theme-choice]) .theme-toggle .ti-system,
:root[data-theme-choice="light"] .theme-toggle .ti-light,
:root[data-theme-choice="dark"] .theme-toggle .ti-dark { display: block; }

.nav-toggle { display: none; }
.nav-toggle .bars { position: relative; width: 16px; height: 12px; }
.nav-toggle .bars span {
  position: absolute; left: 0; right: 0; height: 1.5px; border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast), top var(--dur) var(--ease);
}
.nav-toggle .bars span:nth-child(1) { top: 1px; }
.nav-toggle .bars span:nth-child(2) { top: 5.25px; }
.nav-toggle .bars span:nth-child(3) { top: 9.5px; }
.nav-toggle[aria-expanded="true"] .bars span:nth-child(1) { top: 5.25px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bars span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .bars span:nth-child(3) { top: 5.25px; transform: rotate(-45deg); }

@media (max-width: 959.98px) {
  /* Without JS the nav simply wraps under the header */
  :root:not(.js) .site-header { height: auto; }
  :root:not(.js) .header-inner { flex-wrap: wrap; padding-block: 0.75rem; }
  :root:not(.js) .site-nav { order: 3; width: 100%; margin-left: 0; }
  :root:not(.js) .nav-list { flex-wrap: wrap; }
  :root:not(.js) .header-actions { margin-left: auto; }

  .js .nav-toggle { display: inline-grid; }
  .js .header-actions { margin-left: auto; }
  .js .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0.75rem var(--gutter) 1.25rem;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s linear var(--dur);
  }
  .js .site-header.is-open .site-nav {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), visibility 0s;
  }
  .js .nav-list { flex-direction: column; align-items: stretch; gap: 0.25rem; }
  .js .nav-link { height: 48px; font-size: 1.05rem; padding: 0 1rem; border-radius: var(--radius-md); }
  .js .nav-link[aria-current="page"]::after, .js .nav-link.is-active::after {
    left: auto; right: 1rem; bottom: auto; top: 50%; width: 6px; height: 6px; margin: -3px 0 0; border-radius: 50%;
  }
}
@media (max-width: 359.98px) {
  .brand-name { font-size: 0.95rem; }
  .header-inner { gap: 0.5rem; }
}

/* 7. Footer --------------------------------------------------------------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, transparent, var(--accent-soft) 300%);
  padding-top: clamp(2.5rem, 2rem + 3vw, 4rem);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.footer-inner {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}
.footer-brand .brand { margin-bottom: 0.75rem; }
.footer-tagline { max-width: 28rem; }
.footer-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.footer-heading {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}
.footer-nav ul { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.footer-nav a { color: var(--text-muted); transition: color var(--dur-fast); border-radius: 4px; }
.footer-nav a:hover { color: var(--text); }
.footer-nav a[aria-current="page"] { color: var(--text); }
.footer-bottom {
  margin-top: 2.5rem;
  padding-block: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 900px) {
  .footer-bottom { grid-template-columns: 1fr auto; align-items: start; gap: 2rem; }
}
.footer-note { max-width: 46rem; color: var(--text-muted); }
.footer-note strong { color: var(--text); font-weight: 600; }
.footer-meta { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); white-space: nowrap; }
@media (max-width: 419.98px) { .footer-meta { white-space: normal; } }

/* 8. Buttons -------------------------------------------------------------- */
.btn {
  --btn-h: 44px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--btn-h);
  padding: 0 1.2rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 560;
  letter-spacing: -0.01em;
  line-height: 1.1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn-arrow { display: inline-block; transition: transform var(--dur) var(--ease); }
.btn:hover .btn-arrow { transform: translateX(3px); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 0 1px var(--accent-soft-strong), 0 8px 24px -10px var(--glow-1);
}
.btn-primary:hover {
  background: var(--accent-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 0 4px var(--accent-soft), 0 12px 36px -10px var(--glow-1);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--inner-glow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-faint); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { --btn-h: 36px; padding: 0 0.9rem; font-size: 0.85rem; }
.btn-lg { --btn-h: 54px; padding: 0 1.6rem; font-size: 1.05rem; }
.btn-xl { --btn-h: 62px; padding: 0 2rem; font-size: 1.125rem; }
.btn-block { width: 100%; }
.btn-icon { --btn-h: 40px; width: var(--btn-h); padding: 0; }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* 9. Cards, bento, spotlight --------------------------------------------- */
.card {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--inner-glow), var(--shadow-sm);
  padding: clamp(1.25rem, 1rem + 1.2vw, 2rem);
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
}
.card-solid { background: var(--surface-solid); }
.card-glass {
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
}
.card-sm { padding: 1rem 1.15rem; border-radius: var(--radius-lg); }
.card-flush { padding: 0; }
.card-title { font-size: var(--fs-h3); font-weight: 640; letter-spacing: -0.02em; line-height: 1.25; }
.card-text { color: var(--text-muted); margin-top: 0.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-strong);
  margin-bottom: 1.1rem;
}
.card-icon svg { width: 22px; height: 22px; }
.card-link { display: block; color: inherit; transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.card-link:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--inner-glow), var(--shadow-md); }
.card-link:focus-visible { outline-offset: 4px; border-radius: var(--radius-xl); }
.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  font-weight: 560;
  font-size: var(--fs-sm);
  color: var(--accent-text);
}
.card-cta .btn-arrow { transition: transform var(--dur) var(--ease); }
.card-link:hover .card-cta .btn-arrow { transform: translateX(4px); }
.card-glow::after {
  content: "";
  position: absolute;
  inset: auto -20% -60% -20%;
  height: 80%;
  background: radial-gradient(closest-side, var(--glow-1), transparent);
  z-index: -1;
  pointer-events: none;
}

/* Spotlight: add class "spotlight" to any card; site.js feeds --mx/--my */
.spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, -30%), var(--spot), transparent 45%);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
  pointer-events: none;
}
.spotlight > .spot-border,
.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, -30%), var(--spot-border), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
  pointer-events: none;
}
.spotlight:hover::before, .spotlight:hover::after, .spotlight:focus-within::before, .spotlight:focus-within::after { opacity: 1; }

/* Bento grid: 1 col mobile, 2 cols tablet, 6 cols desktop */
.bento { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento > .span-4, .bento > .span-5, .bento > .span-6, .bento > .span-full { grid-column: span 2; }
}
@media (min-width: 640px) and (max-width: 959.98px) {
  .bento > :last-child:nth-child(odd) { grid-column: span 2; }
}
@media (min-width: 960px) {
  .bento { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.25rem; }
  .bento > * { grid-column: span 2; }
  .bento > .span-2 { grid-column: span 2; }
  .bento > .span-3 { grid-column: span 3; }
  .bento > .span-4 { grid-column: span 4; }
  .bento > .span-5 { grid-column: span 5; }
  .bento > .span-6, .bento > .span-full { grid-column: 1 / -1; }
  .bento > .row-2 { grid-row: span 2; }
}

/* 10. Badges, kbd, callouts, code -------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 26px;
  padding: 0 0.7rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-accent { color: var(--accent-text); border-color: var(--accent-soft-strong); background: var(--accent-soft); }
.badge-cool { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 35%, transparent); background: var(--accent-2-soft); }
.badge-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-soft); }
.badge-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); }
.badge-lg { height: 32px; padding: 0 0.9rem; font-size: 0.8rem; }
.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse-dot 2.4s var(--ease) infinite;
}

kbd, .kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9em;
  height: 1.75em;
  padding: 0 0.45em;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.kbd-combo { display: inline-flex; align-items: center; gap: 0.3em; flex-wrap: wrap; }
.kbd-combo .plus { color: var(--text-faint); font-size: 0.8em; }

.callout {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.callout strong { color: var(--text); font-weight: 600; }
.callout-icon { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--accent-text); }
.callout-info { background: var(--accent-2-soft); border-color: color-mix(in srgb, var(--accent-2) 25%, transparent); }
.callout-info .callout-icon { color: var(--accent-2); }
.callout-warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.callout-warn .callout-icon { color: var(--warning); }
.callout-success { background: var(--success-soft); border-color: var(--accent-soft-strong); }

code, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
:not(pre) > code {
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.86em;
}
.code-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  overflow: hidden;
}
.code-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.code-card-head .fx { font-style: italic; font-weight: 600; color: var(--accent-text); font-family: Georgia, "Times New Roman", serif; font-size: 0.95rem; }
.code-card pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.tok-fn { color: var(--accent-text); font-weight: 600; }
.tok-ref { color: var(--accent-2); }
.tok-str { color: var(--warning); }
.tok-num { color: var(--text); font-weight: 600; }
.tok-op { color: var(--text-faint); }

/* 11. Forms -------------------------------------------------------------- */
.form-grid { display: grid; gap: 1.25rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.field { display: grid; gap: 0.45rem; min-width: 0; }
.label, .field > label, legend.label {
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--text);
  letter-spacing: -0.005em;
}
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.hint, .field-hint { font-size: 0.8125rem; color: var(--text-muted); line-height: 1.45; }
.field-error { font-size: 0.8125rem; color: var(--danger); font-weight: 500; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 0 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem; /* 16px avoids iOS zoom */
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur) var(--ease), background-color var(--dur-fast);
  -webkit-appearance: none;
  appearance: none;
}
.textarea { padding: 0.75rem 0.95rem; min-height: 110px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus,
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft-strong);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--danger-soft); }
.input:disabled, .select:disabled { opacity: 0.55; cursor: not-allowed; }
.input-lg { min-height: 56px; font-size: 1.25rem; font-weight: 560; letter-spacing: -0.01em; }
.input[type="number"] { -moz-appearance: textfield; }
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.select {
  padding-right: 2.5rem;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 52%, calc(100% - 0.8rem) 52%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}
.select option { background: var(--surface-solid); color: var(--text); }

/* Input with £ prefix / % suffix */
.input-affix {
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
}
.input-affix .input { flex: 1; min-width: 0; }
.input-affix .affix {
  position: absolute;
  top: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  min-width: 2.4rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}
.input-affix .affix-start { left: 0; }
.input-affix .affix-end { right: 0; }
.input-affix .affix-start ~ .input, .input-affix .input.has-prefix { padding-left: 2.3rem; }
.input-affix .input.has-suffix { padding-right: 2.6rem; }
.input-affix .input-lg ~ .affix, .input-affix .affix-lg { font-size: 1.15rem; }

/* Segmented control (radio group) */
.segmented { display: grid; gap: 0.45rem; min-width: 0; }
.segmented-options {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  width: fit-content;
  max-width: 100%;
}
.segmented-options.is-full { width: 100%; }
.segmented-options.is-full label { flex: 1 1 auto; }
.segmented-options label { position: relative; display: flex; cursor: pointer; }
.segmented-options input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.segmented-options span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 36px;
  padding: 0 0.95rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 540;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur-fast), box-shadow var(--dur) var(--ease);
}
.segmented-options label:hover span { color: var(--text); }
.segmented-options input:checked + span {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-sm);
}
.segmented-options input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* Choice chips (checkboxes or radios as toggleable pills) */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { position: relative; display: inline-flex; cursor: pointer; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0 0.95rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 520;
  transition: all var(--dur-fast);
}
.chip span::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
  opacity: 0.7;
  transition: all var(--dur-fast);
}
.chip input[type="radio"] + span::before { border-radius: 50%; }
.chip:hover span { color: var(--text); border-color: var(--text-faint); }
.chip input:checked + span { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.chip input:checked + span::before {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2.5px var(--bg-elev);
}
.chip input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Switch (checkbox role="switch") */
.switch { display: inline-flex; align-items: center; gap: 0.7rem; cursor: pointer; position: relative; font-size: var(--fs-sm); font-weight: 520; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch-track {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--surface-hover);
  border: 1px solid var(--border-strong);
  transition: background-color var(--dur) var(--ease), border-color var(--dur);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), background-color var(--dur);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--accent-contrast); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus-ring); outline-offset: 3px; }

/* Native checkbox / radio / range get the accent */
input[type="checkbox"], input[type="radio"], input[type="range"], progress { accent-color: var(--accent); }
.range { width: 100%; height: 28px; cursor: pointer; }

/* 12. Results ------------------------------------------------------------- */
.result-panel {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--inner-glow), var(--shadow-md);
  padding: clamp(1.25rem, 1rem + 1.2vw, 2rem);
  overflow: hidden;
  isolation: isolate;
  min-width: 0;
}
.result-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.8;
}
.result-panel::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 70%;
  height: 80%;
  background: radial-gradient(closest-side, var(--glow-1), transparent);
  opacity: 0.6;
  z-index: -1;
  pointer-events: none;
}
.result-hero { display: grid; gap: 0.25rem; }
.result-label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.result-value {
  font-size: clamp(2.25rem, 1.6rem + 3vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.result-value.text-gradient { padding-bottom: 0.06em; }
.result-sub { color: var(--text-muted); font-size: var(--fs-sm); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 0.75rem; }
.stat {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  min-width: 0;
}
.stat-label { display: block; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }
.stat-value { display: block; margin-top: 0.2rem; font-size: 1.25rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Ledger list: <dl class="ledger"><div><dt/><dd/></div>... <div class="is-total"> */
.ledger { display: grid; margin: 0; }
.ledger > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.ledger > div:last-child { border-bottom: 0; }
.ledger dt { color: var(--text-muted); min-width: 0; }
.ledger dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 560; text-align: right; white-space: nowrap; }
.ledger .is-negative dd { color: var(--text-muted); }
.ledger .is-total { border-bottom: 0; padding-top: 0.9rem; }
.ledger .is-total dt { color: var(--text); font-weight: 650; }
.ledger .is-total dd {
  font-weight: 700;
  font-size: 1.15rem;
  padding-bottom: 2px;
  border-bottom: 3px double var(--accent); /* the accountant's double underline */
}

/* Simple meter / bar */
.meter { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter-fill { height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--gradient); transition: width var(--dur-slow) var(--ease); }

/* Legend swatches for charts */
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: var(--fs-sm); color: var(--text-muted); list-style: none; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 0.45rem; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--swatch, var(--accent)); flex: none; }

/* Chart palette tokens (use in SVG fills) */
:root {
  --chart-1: #059669;
  --chart-2: #0891b2;
  --chart-3: #7c3aed;
  --chart-4: #d97706;
  --chart-5: #db2777;
  --chart-6: #64748b;
}

/* 13. Tables -------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.data-table caption { caption-side: top; text-align: left; padding: 0.9rem 1rem 0.25rem; font-weight: 600; color: var(--text); }
.data-table th, .data-table td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table thead th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.data-table tbody th { font-weight: 500; color: var(--text); }
.data-table tbody tr { transition: background-color var(--dur-fast); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num, .data-table td.num, .data-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tfoot th, .data-table tfoot td, .data-table tr.total > * {
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border-strong);
  border-bottom: 0;
}
.data-table tr.total .num, .data-table tfoot .num { text-decoration: underline double var(--accent); text-underline-offset: 5px; }
.data-table .is-negative { color: var(--danger); }
.data-table-compact th, .data-table-compact td { padding: 0.45rem 0.75rem; }

/* 14. Tabs, toast, misc -------------------------------------------------- */
.tabs { display: flex; gap: 3px; padding: 3px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  min-height: 38px;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 540;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--dur-fast), background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--bg-elev); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong), var(--shadow-sm); }
.tab:focus-visible { outline-offset: 1px; }
.tab-panel:focus-visible { outline-offset: 6px; border-radius: var(--radius-lg); }

.toast-region {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 560;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur) var(--ease) both;
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) both; }

.details {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  font-weight: 560;
}
.details > summary::-webkit-details-marker { display: none; }
.details > summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease);
}
.details[open] > summary::after { transform: rotate(45deg); }
.details > summary:focus-visible { outline-offset: -3px; border-radius: var(--radius-lg); }
.details-body { padding: 0 1.15rem 1.15rem; color: var(--text-muted); font-size: var(--fs-sm); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-size: var(--fs-sm); color: var(--text-muted); list-style: none; padding: 0; }
.breadcrumb a { color: var(--text-muted); border-radius: 4px; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb li + li::before { content: "/"; margin-right: 0.4rem; color: var(--text-faint); }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* Spreadsheet-style mini grid primitive (decorative or real) */
.sheet { width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--font-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0.4rem 0.6rem; height: 34px; }
.sheet th { background: var(--surface-2); color: var(--text-faint); font-weight: 500; font-size: 0.72rem; text-align: center; }
.sheet td.num { text-align: right; }

/* 15. Tool page layout ---------------------------------------------------- */
.tool-hero { padding-block: clamp(2.5rem, 2rem + 3vw, 4.5rem) clamp(1.5rem, 1rem + 2vw, 2.5rem); }
.tool-hero .breadcrumb { margin-bottom: 1.25rem; }
.tool-hero h1 { max-width: 16em; }
.tool-hero .lead { margin-top: 1rem; }
.tool-hero .badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.tool-layout {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
}
@media (min-width: 960px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.5rem; }
  .tool-layout.is-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-layout.is-results-narrow { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .tool-results.is-sticky, .tool-layout .is-sticky { position: sticky; top: calc(var(--header-h) + 1rem); }
}
.tool-layout.is-single { grid-template-columns: minmax(0, 1fr); }
.tool-panel {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--inner-glow), var(--shadow-sm);
  padding: clamp(1.25rem, 1rem + 1.2vw, 2rem);
  min-width: 0;
}
.tool-panel-title { font-size: var(--fs-h3); font-weight: 640; letter-spacing: -0.02em; margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.6rem; }
.tool-inputs, .tool-results { min-width: 0; display: grid; gap: 1.25rem; }
.tool-notes { padding-bottom: clamp(3rem, 2rem + 4vw, 6rem); }

/* 16. Landing page (/) ------------------------------------------------- */
.landing { min-height: 100vh; min-height: 100svh; }
.landing::before, .landing::after { display: none; }
.landing-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.landing-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-strong) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 10%, transparent 75%);
}
.landing-cells { position: absolute; inset: 0; -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 10%, transparent 75%); mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, #000 10%, transparent 75%); }
.landing-cell {
  position: absolute;
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center end;
  padding-right: 6px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent-text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft-strong);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  animation: cell-blink 3.6s var(--ease) forwards;
}
.landing-cell.is-active { box-shadow: inset 0 0 0 2px var(--accent); }
.landing-floor {
  position: absolute;
  left: -50%;
  right: -50%;
  bottom: -10%;
  height: 55%;
  background-image:
    linear-gradient(to right, var(--grid-line-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-strong) 1px, transparent 1px);
  background-size: 80px 80px;
  transform: perspective(500px) rotateX(62deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 85%);
  mask-image: linear-gradient(to top, #000 0%, transparent 85%);
  animation: floor-scroll 6s linear infinite;
  opacity: 0.8;
}
.landing-glow {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
}
.landing-glow-1 { top: -35vmax; left: -20vmax; background: radial-gradient(closest-side, var(--glow-1), transparent); animation: drift-1 22s var(--ease-in-out) infinite alternate; }
.landing-glow-2 { bottom: -40vmax; right: -25vmax; background: radial-gradient(closest-side, var(--glow-2), transparent); animation: drift-2 26s var(--ease-in-out) infinite alternate; }
.landing-main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(5rem, 12vh, 8rem) var(--gutter) 2rem;
  text-align: center;
}
.landing-inner { display: grid; justify-items: center; gap: clamp(2rem, 1.5rem + 2vw, 3rem); max-width: 1100px; }
.landing-title {
  font-size: clamp(2.6rem, 1rem + 7.4vw, 7.25rem);
  font-weight: 720;
  letter-spacing: -0.05em;
  line-height: 0.98;
  text-wrap: balance;
}
.landing-title .line { display: block; }
.landing-title .text-gradient { padding-bottom: 0.08em; display: inline-block; }
.landing-cellref {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
}
.landing-cellref > span { padding: 0.35rem 0.7rem; }
.landing-cellref > span + span { border-left: 1px solid var(--border); }
.landing-cellref .fx { font-family: Georgia, "Times New Roman", serif; font-style: italic; color: var(--accent-text); }
.landing-footer {
  padding: 1.25rem var(--gutter) max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.landing-footer a { color: var(--text-muted); border-radius: 4px; }
.landing-footer a:hover { color: var(--text); }
.landing-theme { position: fixed; top: 16px; right: 16px; z-index: 10; }
.btn-hero {
  --btn-h: 58px;
  padding: 0 1.4rem 0 1.8rem;
  font-size: 1.075rem;
  gap: 0.85rem;
}
.btn-hero .btn-arrow-circle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: -0.7rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent-contrast) 14%, transparent);
  transition: transform var(--dur) var(--ease);
}
.btn-hero:hover .btn-arrow-circle { transform: translateX(3px) rotate(-45deg); }
.btn-hero svg { width: 16px; height: 16px; }

/* Entrance sequence */
.enter { animation: enter-up 900ms var(--ease) both; animation-delay: var(--d, 0ms); }

/* 17. About page (/about/) ---------------------------------------------- */
.hero { position: relative; padding-block: clamp(3rem, 2rem + 5vw, 7rem) clamp(3rem, 2rem + 4vw, 6rem); }
.hero-grid { display: grid; gap: clamp(2.5rem, 2rem + 3vw, 4rem); align-items: center; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1040px) { .hero-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.hero-title { font-size: clamp(2.5rem, 1.2rem + 4.6vw, 5.25rem); font-weight: 720; letter-spacing: -0.05em; line-height: 0.98; }
.hero-title .line { display: block; }
.hero-title .text-gradient { padding-bottom: 0.08em; }
.hero .lead { margin-top: 1.5rem; }
.hero .btn-group { margin-top: 2rem; }
.hero-meta { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Animated ledger window */
.ledger-window {
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  box-shadow: var(--inner-glow), var(--shadow-lg), 0 0 0 1px var(--accent-soft), 0 40px 120px -40px var(--glow-1);
  overflow: hidden;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.ledger-window::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, var(--accent), transparent 35%, transparent 65%, var(--accent-2));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0.6;
  pointer-events: none;
}
.lw-chrome { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.lw-dots { display: flex; gap: 6px; }
.lw-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.lw-dots i:first-child { background: var(--accent); opacity: 0.8; }
.lw-file { font-size: 0.75rem; color: var(--text-muted); }
.lw-file b { color: var(--text); font-weight: 500; }
.lw-status { margin-left: auto; }
.lw-formula { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.lw-namebox { flex: none; width: 3.6rem; display: grid; place-items: center; border-right: 1px solid var(--border); color: var(--text); padding: 0.55rem 0; }
.lw-fx { flex: none; display: grid; place-items: center; padding: 0 0.7rem; border-right: 1px solid var(--border); font-family: Georgia, "Times New Roman", serif; font-style: italic; color: var(--accent-text); }
.lw-input { flex: 1; min-width: 0; padding: 0.55rem 0.75rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: clip; }
.lw-caret { display: inline-block; width: 1.5px; height: 1.05em; margin-left: 1px; vertical-align: -0.15em; background: var(--accent); animation: caret 1s steps(1) infinite; }
.lw-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: clamp(0.72rem, 0.66rem + 0.3vw, 0.85rem); table-layout: fixed; }
.lw-grid col.c-row { width: 2.4rem; }
.lw-grid col.c-b { width: 38%; }
.lw-grid th, .lw-grid td { height: 40px; padding: 0 0.7rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lw-grid th:last-child, .lw-grid td:last-child { border-right: 0; }
.lw-grid thead th { height: 28px; background: var(--surface-2); color: var(--text-faint); font-weight: 500; font-size: 0.7rem; text-align: center; }
.lw-grid tbody th { background: var(--surface-2); color: var(--text-faint); font-weight: 500; font-size: 0.7rem; text-align: center; padding: 0; }
.lw-grid td { color: var(--text); position: relative; transition: background-color var(--dur) var(--ease); }
.lw-grid td.num { text-align: right; }
.lw-grid td.is-head { color: var(--text-muted); font-weight: 500; }
.lw-grid tr.is-total td { font-weight: 600; border-bottom: 0; }
.lw-grid tr.is-total td.num { color: var(--accent-text); }
.lw-grid .neg { color: var(--text-muted); }
.lw-grid td.is-selected { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.lw-grid td.is-selected::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border: 1.5px solid var(--surface-solid);
}
.lw-grid td.in-range { background: var(--accent-soft); }
.lw-grid td.in-range-edge { box-shadow: inset 0 0 0 1px var(--accent-2); }
.lw-grid td .val { display: inline-block; }
.lw-grid td .val.pop { animation: pop-in 420ms var(--ease) both; }
.lw-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.9rem; background: var(--surface-2); font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); flex-wrap: wrap; }
.lw-tabs { display: flex; gap: 0.25rem; }
.lw-tabs span { padding: 0.15rem 0.6rem; border-radius: 6px; }
.lw-tabs span.on { background: var(--bg-elev); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.lw-balanced { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--accent-text); opacity: 0; transform: translateY(4px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.lw-balanced.is-on { opacity: 1; transform: none; }
.hero-visual { position: relative; }
.hero-visual .float-chip {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  box-shadow: var(--shadow-md);
  animation: float-y 6s var(--ease-in-out) infinite alternate;
}
.hero-visual .float-chip.c1 { top: -18px; right: 8%; }
.hero-visual .float-chip.c2 { bottom: -20px; right: 26%; animation-delay: -3s; }
@media (max-width: 479.98px) { .hero-visual .float-chip { display: none; } }
@media (max-width: 1039.98px) { .hero-visual .float-chip.c2 { display: none; } }

/* Marquee */
.marquee {
  position: relative;
  overflow: hidden;
  border-block: 1px solid var(--border);
  background: var(--surface);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track { display: flex; width: max-content; animation: marquee 48s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-list { display: flex; flex: none; list-style: none; padding: 0; }
.marquee-list li { display: inline-flex; align-items: center; gap: 1.25rem; padding: 1.1rem 0 1.1rem 1.25rem; font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.marquee-list li::after { content: ""; width: 5px; height: 5px; border-radius: 1px; background: var(--accent); opacity: 0.7; transform: rotate(45deg); }

/* About section */
.about-grid { display: grid; gap: clamp(2rem, 1.5rem + 3vw, 4rem); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 960px) { .about-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.inspector { font-size: var(--fs-sm); }
.inspector-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding-bottom: 1rem; margin-bottom: 0.25rem; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); }
.inspector dl { display: grid; margin: 0; }
.inspector dl > div { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 1rem; padding: 0.8rem 0; border-bottom: 1px dashed var(--border); }
.inspector dl > div:last-child { border-bottom: 0; }
.inspector dt { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 0.15rem; }
.inspector dd { margin: 0; color: var(--text); }
@media (max-width: 419.98px) { .inspector dl > div { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; } }

/* Mini visuals inside bento cards */
.mini-bars { display: flex; align-items: flex-end; gap: 6px; height: 72px; margin-top: 1.25rem; }
.mini-bars span { flex: 1; border-radius: 5px 5px 2px 2px; background: var(--accent-soft-strong); height: var(--h, 50%); transition: height var(--dur-slow) var(--ease), background-color var(--dur); }
.mini-bars span:last-child { background: var(--gradient); }
.card:hover .mini-bars span { background: var(--accent-soft-strong); }
.card:hover .mini-bars span:last-child { background: var(--gradient); }
.mini-ledger { margin-top: 1.25rem; display: grid; gap: 0; font-family: var(--font-mono); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.mini-ledger div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.mini-ledger div:last-child { border-bottom: 0; color: var(--text); font-weight: 600; }
.mini-ledger div:last-child span:last-child { border-bottom: 3px double var(--accent); }
.mini-cells { margin-top: 1.25rem; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.mini-cells i { aspect-ratio: 1.6; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); transition: background-color var(--dur) var(--ease), border-color var(--dur); }
.mini-cells i.on { background: var(--accent-soft-strong); border-color: var(--accent-soft-strong); }
.card:hover .mini-cells i:nth-child(3n) { background: var(--accent-soft); }

/* Formula showcase */
.formula-card .code-card { margin-top: 1rem; }
.formula-card .card-text { font-size: var(--fs-sm); }
.formula-card .mac { margin-top: 0.75rem; font-size: var(--fs-xs); color: var(--text-faint); font-family: var(--font-mono); }
.shortcut-list { list-style: none; padding: 0; display: grid; gap: 0; margin-top: 0.75rem; }
.shortcut-list li { display: grid; gap: 0.35rem; padding: 0.85rem 0; border-bottom: 1px solid var(--border); }
.shortcut-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.shortcut-list .what { font-size: var(--fs-sm); color: var(--text-muted); }
.pivot-demo { margin-top: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; }
.pivot-demo .sheet th, .pivot-demo .sheet td { height: 30px; }
.pivot-demo .sheet tr:last-child td, .pivot-demo .sheet tr:last-child th { border-bottom: 0; }
.pivot-demo .sheet td:last-child, .pivot-demo .sheet th:last-child { border-right: 0; }
.pivot-demo .sheet tbody th { text-align: left; color: var(--text); font-size: 0.8rem; font-weight: 500; background: transparent; }
.pivot-demo .sheet tfoot td, .pivot-demo .sheet tfoot th { font-weight: 650; color: var(--text); background: var(--surface-2); text-align: left; }
.pivot-demo .sheet tfoot td { text-align: right; }

/* Tool teaser cards */
.tool-card { display: flex; flex-direction: column; min-height: 100%; }
.tool-card .card-text { flex: 1; }
.tool-preview {
  position: relative;
  height: 132px;
  margin: -0.25rem -0.25rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.tool-preview.grid-bg { background-color: var(--surface-2); }
.tool-preview svg { width: auto; height: 92px; }
.tp-donut circle { fill: none; stroke-width: 12; }
.tp-donut .d-bg { stroke: var(--border-strong); }
.tp-donut .d-1 { stroke: var(--accent); }
.tp-donut .d-2 { stroke: var(--accent-2); }
.tp-donut .d-3 { stroke: var(--text-faint); }
.tp-vat { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tp-vat span { padding: 0.45rem 0.7rem; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-solid); font-size: 0.85rem; }
.tp-vat span.hl { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.tp-vat i { font-style: normal; color: var(--text-faint); }
@media (max-width: 419.98px) {
  .tp-vat { gap: 0.3rem; }
  .tp-vat span { padding: 0.35rem 0.4rem; font-size: 0.72rem; border-radius: 8px; }
}
.tp-sheet { width: 82%; font-family: var(--font-mono); font-size: 0.72rem; display: grid; grid-template-columns: 1.6rem repeat(3, 1fr); border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface-solid); }
.tp-sheet span { padding: 0.3rem 0.4rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: right; color: var(--text-muted); white-space: nowrap; overflow: hidden; }
.tp-sheet span.h { background: var(--surface-2); color: var(--text-faint); text-align: center; }
.tp-sheet span.sel { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent-text); font-weight: 600; }
.tp-quiz { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; width: 78%; }
.tp-quiz span { display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.6rem; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-solid); font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.tp-quiz span b { color: var(--text-faint); font-weight: 600; }
.tp-quiz span.ok { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

/* Tax calendar */
.cal-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .cal-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); } }
.cal-next .result-label { margin-bottom: 0.75rem; display: block; }
.cal-next-title { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); font-weight: 680; letter-spacing: -0.03em; line-height: 1.15; }
.cal-next-date { margin-top: 0.35rem; color: var(--text-muted); font-family: var(--font-mono); font-size: var(--fs-sm); }
.countdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; margin-top: 1.5rem; }
.countdown div { padding: 0.8rem 0.4rem; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface-2); text-align: center; min-width: 0; }
.countdown b { display: block; font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem); font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.countdown div:first-child b { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.countdown span { display: block; margin-top: 0.25rem; font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cal-detail { margin-top: 1.25rem; color: var(--text-muted); font-size: var(--fs-sm); }
.taxyear { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.taxyear-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: var(--fs-sm); margin-bottom: 0.6rem; flex-wrap: wrap; }
.taxyear-row b { font-weight: 600; }
.cal-list { list-style: none; padding: 0; display: grid; gap: 0.5rem; }
.cal-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.cal-item:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.cal-item.is-next { border-color: var(--accent-soft-strong); background: var(--accent-soft); }
.cal-date { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface-solid); font-family: var(--font-mono); line-height: 1.05; text-align: center; }
.cal-date b { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cal-date span { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.cal-item.is-next .cal-date { border-color: var(--accent); }
.cal-item h3, .cal-item h4 { font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.cal-item p { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; line-height: 1.45; }
.cal-when { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; text-align: right; }
.cal-item.is-next .cal-when { color: var(--accent-text); font-weight: 600; }
@media (max-width: 519.98px) {
  .cal-item { grid-template-columns: auto minmax(0, 1fr); }
  .cal-when { grid-column: 2; text-align: left; margin-top: -0.6rem; }
}

/* Closing CTA */
.cta-panel {
  position: relative;
  border-radius: calc(var(--radius-xl) + 8px);
  border: 1px solid var(--border-strong);
  padding: clamp(2.5rem, 2rem + 4vw, 5.5rem) clamp(1.25rem, 1rem + 3vw, 4rem);
  text-align: center;
  overflow: hidden;
  isolation: isolate;
  background: var(--surface);
}
.cta-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, var(--grid-line-strong) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-strong) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 100%, #000, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 70% at 50% 100%, #000, transparent 75%);
}
.cta-panel::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -60%;
  width: 90%;
  height: 100%;
  transform: translateX(-50%);
  z-index: -1;
  background: radial-gradient(closest-side, var(--glow-1), transparent);
}
.cta-panel h2 { font-size: clamp(2.2rem, 1.3rem + 4vw, 4.5rem); letter-spacing: -0.05em; line-height: 1; }
.cta-panel .lead { margin: 1.25rem auto 0; }
.cta-panel .btn-group { justify-content: center; margin-top: 2rem; }

/* 18. 404 page ---------------------------------------------------------- */
.error-main { display: grid; place-items: center; padding-block: clamp(3rem, 2rem + 6vw, 8rem); }
.error-card { width: 100%; max-width: 720px; text-align: center; }
.error-code {
  font-family: var(--font-sans);
  font-size: clamp(4rem, 2rem + 12vw, 10rem);
  font-weight: 750;
  letter-spacing: -0.055em;
  line-height: 0.9;
}
.error-cell {
  display: inline-block;
  padding: 0.05em 0.2em;
  border-radius: 0.12em;
  box-shadow: inset 0 0 0 3px var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  position: relative;
}
.error-cell::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border: 2px solid var(--bg);
}
.error-formula { margin: 2rem auto 0; max-width: 560px; text-align: left; }
.error-tips { margin-top: 1.5rem; display: grid; gap: 0.35rem; text-align: left; max-width: 560px; margin-inline: auto; font-size: var(--fs-sm); color: var(--text-muted); list-style: none; padding: 0; }
.error-tips li { position: relative; padding-left: 1.5em; }
.error-tips li::before { content: "\2192"; position: absolute; left: 0; color: var(--accent-text); font-family: var(--font-mono); }

/* 19. Animations & reveal ---------------------------------------------- */
@keyframes grid-pan { from { background-position: -1px -1px; } to { background-position: calc(var(--cell) - 1px) calc(var(--cell) - 1px); } }
@keyframes floor-scroll { from { background-position: 0 0; } to { background-position: 0 80px; } }
@keyframes drift-1 { from { transform: translate(0, 0) scale(1); } to { transform: translate(12vmax, 8vmax) scale(1.15); } }
@keyframes drift-2 { from { transform: translate(0, 0) scale(1.1); } to { transform: translate(-10vmax, -6vmax) scale(0.95); } }
@keyframes cell-blink { 0% { opacity: 0; } 18% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes enter-up { from { opacity: 0; transform: translateY(18px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
@keyframes caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes float-y { from { transform: translateY(-4px); } to { transform: translateY(5px); } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes reveal-failsafe { to { opacity: 1; transform: none; filter: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Scroll reveal: add data-reveal; optional style="--d: 120ms" for stagger.
   Hidden only when JS is running; a failsafe reveals content if site.js fails. */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  filter: blur(4px);
  transition: opacity 800ms var(--ease), transform 800ms var(--ease), filter 800ms var(--ease);
  transition-delay: var(--d, 0ms);
}
.js:not(.site-ready) [data-reveal] { animation: reveal-failsafe 0s 2.5s forwards; }
.js [data-reveal].is-visible { opacity: 1; transform: none; filter: none; }

/* Animated number/flash helper */
.flash { animation: pop-in 380ms var(--ease) both; }

/* 20. Reduced motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
  body::before, .landing-floor, .landing-glow, .marquee-track, .hero-visual .float-chip { animation: none !important; }
  .js [data-reveal] { opacity: 1; transform: none; filter: none; }
  .lw-caret { animation: none; }
  .marquee-track { flex-wrap: wrap; width: 100%; }
  .marquee-list[aria-hidden="true"] { display: none; }
  .marquee-list { flex-wrap: wrap; justify-content: center; }
  .marquee { -webkit-mask-image: none; mask-image: none; }
  .card-link:hover, .btn:active { transform: none; }
}
:root.reduced-motion .landing-cell { display: none; }

/* Print: keep it clean */
@media print {
  body::before, body::after, .site-header, .site-footer, .landing-bg, .skip-link, .toast-region { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .result-panel, .tool-panel { box-shadow: none; border-color: #ccc; }
}
