/* =============================================================
   Referent Systems — site styles
   Hand-rolled. No framework.
   Palette: Scientific Instrument (sole; SV palette retired 2026-10-01)
   Theme switch:   [data-theme="dark" | "light"]
   ============================================================= */

/* ---------- 1. Design tokens ---------- */

:root {
  /* Type system */
  --font-sans: "houschka-pro", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  --font-sans-text: "houschka-pro", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  --font-serif: "lyon-text", "Lyon Text", "Charter", "Iowan Old Style",
    "Georgia", "Times New Roman", serif;
  --font-mono: "jetbrains-mono", "JetBrains Mono", ui-monospace, "SF Mono",
    "Menlo", "Consolas", monospace;

  /* Modular scale (1.200 minor-third). Base = 17px */
  --fs-base: 1.0625rem;         /* 17px */
  --fs-sm: 0.9375rem;           /* 15px */
  --fs-xs: 0.8125rem;           /* 13px */
  --fs-lg: 1.125rem;            /* 18px */
  --fs-xl: 1.3125rem;           /* 21px */
  --fs-2xl: 1.5625rem;          /* 25px */
  --fs-3xl: 1.9375rem;          /* 31px */
  --fs-4xl: 2.4375rem;          /* 39px */
  --fs-5xl: 3rem;               /* 48px */
  --fs-6xl: 3.75rem;            /* 60px */

  /* Line-heights */
  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-normal: 1.5;
  --lh-prose: 1.65;
  --lh-loose: 1.75;

  /* Measure */
  --measure-prose: 68ch;
  --measure-narrow: 54ch;

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-10: 4rem;
  --space-12: 5rem;
  --space-16: 7rem;
  --space-20: 9rem;

  /* Radius */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* Transition */
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 320ms;
  --ease: cubic-bezier(0.2, 0.6, 0.2, 1);

  /* Container */
  --container: 1120px;

  /* Default = Instrument, dark */
  color-scheme: dark;
}

/* ---------- 2. Palette: Scientific Instrument ----------
   Deep ink neutrals, oxidized-copper accent (patina).
   The accent is a desaturated, slightly green-blue copper
   verdigris — reads as "measured" rather than "glow".
*/

[data-theme="dark"] {
  --bg: #34312d;             /* warm charcoal — midpoint between near-black and mid-grey */
  --bg-elev: #484541;        /* raised surface — instrument-panel brass tone */
  --bg-sunk: #2a2723;        /* sunken surface */
  --surface: #484541;        /* cards, insets */
  --border: #3f3c37;
  --border-strong: #807c75;  /* ≥3:1 vs bg per WCAG 1.4.11 */
  --text: #ece9e1;           /* paper-warm, nudged brighter for the lighter bg */
  --text-muted: #b4b1a8;
  --text-dim: #87847c;
  --accent: #4fb67a;         /* verdigris — saturated oxidized-copper */
  --accent-strong: #7acc9b;
  --accent-ink: #0e100f;     /* text on accent */
  --accent-glow: rgba(79, 182, 122, 0.16);
  --rule: #403d38;
  --focus: #d4e0d8;
  --code-bg: #484541;
  --warn: #d6b78b;           /* theodolite brass — brightened for new bg */
  --warn-bg: rgba(214, 183, 139, 0.1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f3ec;             /* paper */
  --bg-elev: #ffffff;
  --bg-sunk: #ece8df;
  --surface: #ffffff;
  --border: #d9d4c7;
  --border-strong: #797466;  /* ≥3:1 vs bg per WCAG 1.4.11 */
  --text: #1a1c1b;
  --text-muted: #4e524d;
  --text-dim: #7a7a73;
  --accent: #1f8a53;         /* saturated verdigris, dark enough for AA on paper */
  --accent-strong: #156a3f;
  --accent-ink: #f6f3ec;
  --accent-glow: rgba(31, 138, 83, 0.12);
  --rule: #e2ddd0;
  --focus: #156a3f;
  --code-bg: #ece8df;
  --warn: #815f30;
  --warn-bg: rgba(129, 95, 48, 0.08);
  color-scheme: light;
}

/* ---------- 4. Reset / base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans-text);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  letter-spacing: -0.005em;
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background var(--t-base) var(--ease),
              color var(--t-base) var(--ease);
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- 5. Typography ---------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
  margin: 0 0 var(--space-4);
  color: var(--text);
}

h1 {
  font-size: var(--fs-5xl);
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-weight: 500;
  font-kerning: none;
  font-feature-settings: "kern" 0, "liga" 1, "calt" 1;
}

h2 {
  font-size: var(--fs-3xl);
  letter-spacing: -0.028em;
  margin-top: var(--space-10);
  margin-bottom: var(--space-5);
  font-weight: 500;
}

h3 {
  font-size: var(--fs-xl);
  letter-spacing: -0.018em;
  margin-top: var(--space-7);
  margin-bottom: var(--space-3);
  font-weight: 500;
}

h4 {
  font-size: var(--fs-lg);
  font-weight: 500;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}

p {
  margin: 0 0 var(--space-5);
  max-width: var(--measure-prose);
  line-height: var(--lh-prose);
}

.prose p { font-family: var(--font-serif); font-size: 1.0625rem; }
.prose h2, .prose h3, .prose h4 { font-family: var(--font-sans); }

/* Reduce big top-margin for first heading in a section */
section > :first-child,
article > :first-child,
.prose > :first-child {
  margin-top: 0;
}

a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in oklab, var(--accent) 50%, transparent);
  transition: color var(--t-fast) var(--ease),
              text-decoration-color var(--t-fast) var(--ease);
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

strong, b { font-weight: 600; color: var(--text); }
em, i { font-style: italic; }

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-8) 0;
}

ul, ol {
  margin: 0 0 var(--space-5);
  padding-left: 1.4em;
  max-width: var(--measure-prose);
  line-height: var(--lh-prose);
}

li { margin-bottom: var(--space-2); }
li::marker { color: var(--text-dim); }

blockquote {
  margin: var(--space-6) 0;
  padding-left: var(--space-5);
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
  max-width: var(--measure-prose);
}

sup {
  font-size: 0.72em;
  line-height: 0;
  vertical-align: baseline;
  position: relative;
  top: -0.5em;
}

sup a {
  text-decoration: none;
  padding: 0 0.15em;
}

/* ---------- 6. Skip link ---------- */

.skip-link {
  position: absolute;
  top: -40px;
  left: var(--space-4);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  z-index: 100;
  font-weight: 500;
  text-decoration: none;
  transition: top var(--t-base) var(--ease);
}

.skip-link:focus {
  top: var(--space-4);
}

/* ---------- 7. Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
}

.brand:hover { color: var(--text); }

.brand__logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 100%;
}

@media (max-width: 640px) {
  .brand__logo { height: 36px; }
}

.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
  font-weight: 400;
  transition: color var(--t-fast), background var(--t-fast);
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav__divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 var(--space-2);
}

/* ---------- 8. Switches: palette + theme ---------- */

.switches {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.palette-switch,
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.palette-switch button,
.theme-switch button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: color var(--t-fast), background var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.palette-switch button:hover,
.theme-switch button:hover {
  color: var(--text);
}

.palette-switch button[aria-pressed="true"],
.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 0 color-mix(in oklab, var(--border-strong) 70%, transparent);
}

.palette-switch button:focus-visible,
.theme-switch button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.theme-switch svg { width: 14px; height: 14px; }

/* ---------- 9. Layout ---------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

main { display: block; }

.section {
  padding: var(--space-10) 0;
}

.section--hero {
  padding: var(--space-16) 0 var(--space-12);
}

.section--tight { padding: var(--space-8) 0; }

.rule {
  height: 1px;
  background: var(--rule);
  margin: var(--space-8) 0;
  border: 0;
}

.prose-column {
  max-width: var(--measure-prose);
}

/* ---------- 10. Home — hero ---------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

.eyebrow::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.hero__title {
  font-size: clamp(2.25rem, 5vw + 1rem, 4.25rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.02;
  font-kerning: none;
  font-feature-settings: "kern" 0, "liga" 1, "calt" 1;
  margin-bottom: var(--space-6);
  max-width: 18ch;
}

.hero__title em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}

.hero__lede {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  line-height: 1.55;
  color: var(--text);
  max-width: 60ch;
  margin-bottom: var(--space-7);
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---------- 11. Buttons / CTAs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), transform var(--t-fast);
  line-height: 1.1;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}

.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.btn--secondary:hover {
  background: var(--surface);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: var(--space-2) var(--space-3);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--surface);
}

.btn--large {
  padding: var(--space-4) var(--space-6);
  font-size: var(--fs-base);
}

.btn__arrow {
  display: inline-block;
  transition: transform var(--t-fast) var(--ease);
}

.btn:hover .btn__arrow { transform: translateX(2px); }

/* ---------- 12. Link row (home nav tiles) ---------- */

.link-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-10);
  max-width: 820px;
}

.link-card {
  display: block;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--t-base), background var(--t-base),
              transform var(--t-base);
}

.link-card:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.link-card__label {
  font-family: var(--font-sans-text);
  font-size: var(--fs-sm);
  letter-spacing: 0;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: var(--space-3);
  display: block;
}

.link-card__title {
  font-family: var(--font-sans);
  font-size: var(--fs-xl);
  font-weight: 500;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.012em;
  color: var(--text);
}

.link-card__desc {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-family: var(--font-sans-text);
  line-height: 1.5;
}

.link-card__arrow {
  display: inline-block;
  margin-top: var(--space-4);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* ---------- 13. Pitch page ---------- */

.pitch-header {
  padding: var(--space-16) 0 var(--space-10);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--space-10);
}

.pitch-header__kicker {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.pitch-header__kicker::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent);
  display: inline-block;
}

.pitch-header h1 {
  font-size: clamp(2.5rem, 5.5vw, 4.5rem);
  letter-spacing: -0.04em;
  line-height: 1.0;
  font-kerning: none;
  font-feature-settings: "kern" 0, "liga" 1, "calt" 1;
  margin-bottom: var(--space-6);
  max-width: 18ch;
}

/* Pass 4: thesis word in verdigris. Mirrors the home hero's
   <em>rational beings</em> treatment — same move, same reason:
   the h1 is the single moment of highest attention on the page,
   so one verdigris word sets the tonal expectation. Not italic. */
.pitch-header h1 em.accent {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}

.pitch-header__subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-xl);
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 56ch;
  margin-bottom: 0;
}

.pitch-prose {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
}

/* Removed: 128px left indent on wide viewports.
   Previously held the gutter for the hanging §-number chip. Chips
   are no longer surfaced; article now flushes left with the pitch
   header's title/subtitle edge at all breakpoints. */

.pitch-prose p {
  margin-bottom: var(--space-5);
}

/* Pass 3: dropped font-variant: small-caps on the opening first-line.
   The benchmark mark in the margin now carries the "start of section"
   signal; small-caps was reading as dated against the humanist serif. */

.pitch-prose h2 {
  font-family: var(--font-sans);
  font-size: var(--fs-2xl);
  margin-top: var(--space-12);
  margin-bottom: var(--space-5);
  letter-spacing: -0.018em;
  max-width: 32ch;
  color: var(--text);
}

/* Pass 4: converted from inline dim-grey mono to a verdigris chip,
   pulled out of the inline flow as hanging furniture. See §23.4 for
   the refined positioning. */
.pitch-prose h2 .num {
  display: inline-block;
  padding: 0.15em 0.4em;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0;
  border-radius: 2px;
  vertical-align: 0.3em;
}

.pitch-prose h3 {
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  color: var(--text);
  margin-top: var(--space-8);
}

.pitch-prose ul {
  padding-left: 1.2em;
  font-family: var(--font-serif);
}

.pitch-prose ul li { margin-bottom: var(--space-3); }

/* Pass 4: bullet openers (defined-term leads like "Sycophancy.",
   "Hallucination.", "Alignment faking.") shift to sans-serif
   verdigris. Marks the term as a conceptual anchor, not just bold
   serif text. */
.pitch-prose ul .bullet-opener {
  font-family: var(--font-sans);
  color: var(--accent);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.callout-cta {
  margin: var(--space-7) 0;
  padding: var(--space-6);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  max-width: var(--measure-prose);
}

.callout-cta p {
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  line-height: 1.45;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.005em;
}

.callout-cta strong { color: var(--accent); font-weight: 600; }

/* ---------- 14. Flowcharts ---------- */

.flowcharts {
  /* Pass 4: narrow to body-copy width and align flush-left with the
     prose column, so the whole page reads as a single column with
     margin furniture on the left (the §-chip indent lives on the
     article wrapper above). The flowchart SVGs downscale
     accordingly (they're vector; width:100% on the canvas handles
     it). Previous: max-width:100%, two-column grid above 920px. */
  margin: var(--space-8) 0 var(--space-10);
  max-width: var(--measure-prose);
}

.flowcharts__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

.flowchart {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
}

.flowchart__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.flowchart__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  letter-spacing: 0;
}

.flowchart__title {
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.3;
}

.flowchart__canvas {
  margin: var(--space-5) 0 var(--space-4);
  width: 100%;
}

.flowchart__canvas svg {
  width: 100%;
  height: auto;
  display: block;
}

.flowchart__caption {
  font-family: var(--font-sans-text);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}

.flowchart__caption strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------- 15. Footnotes ---------- */

.footnotes {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
  font-family: var(--font-sans-text);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: var(--measure-prose);
}

.footnotes h2 {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  letter-spacing: 0;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: var(--space-4);
  font-weight: 500;
}

.footnotes ol {
  padding-left: 1.5em;
  margin: 0;
}

.footnotes li { margin-bottom: var(--space-4); }

.footnote-backref {
  text-decoration: none;
  margin-left: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent);
}

/* ---------- 16. Contact form ---------- */

.contact {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  max-width: 640px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-field label {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}

.form-field label .req { color: var(--accent); margin-left: 2px; }

.form-field input,
.form-field textarea {
  font-family: var(--font-sans-text);
  font-size: var(--fs-base);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.4;
  min-height: 44px;
  width: 100%;
}

.form-field textarea {
  min-height: 140px;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-field .help {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0;
}

/* ---------- 17. CTA block (pitch page end) ---------- */

.cta-block {
  margin: var(--space-10) 0;
  padding: var(--space-8);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: left;
  max-width: var(--measure-prose);
}

.cta-block h2 {
  font-family: var(--font-sans);
  font-size: var(--fs-2xl);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.02em;
}

.cta-block p {
  color: var(--text-muted);
  font-family: var(--font-sans-text);
  font-size: var(--fs-base);
  margin-bottom: var(--space-5);
  max-width: 54ch;
}

.cta-block__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---------- 18. Signature block ---------- */

.signature {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-lg);
  color: var(--text-muted);
  max-width: var(--measure-prose);
}

/* ---------- 19. Footer ---------- */

.site-footer {
  margin-top: var(--space-20);
  padding: var(--space-10) 0 var(--space-8);
  border-top: 1px solid var(--rule);
  background: var(--bg-sunk);
}

.site-footer__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 760px) {
  .site-footer__inner {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.site-footer__logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 100%;
}

.site-footer__name {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}

.site-footer__tagline {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  max-width: 48ch;
  margin: 0;
}

.site-footer__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-sm);
}

.site-footer__links a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer__links a:hover { color: var(--text); }

.site-footer__meta {
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  color: var(--text-dim);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.site-footer__meta a { color: var(--text-dim); text-decoration: none; }
.site-footer__meta a:hover { color: var(--text-muted); }

/* ---------- 20. Palette-picker banner (dev / preview only) ---------- */

.preview-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  padding: var(--space-2) var(--space-5);
  text-align: center;
  letter-spacing: 0.02em;
}

.preview-banner strong {
  color: var(--text);
  font-weight: 500;
}

/* ---------- 21. Utilities ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }

/* ---------- 22. Small-screen tune ---------- */

@media (max-width: 640px) {
  :root {
    --fs-5xl: 2.5rem;
    --fs-4xl: 2rem;
    --fs-3xl: 1.625rem;
  }

  .site-header__inner {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .site-nav {
    width: 100%;
    order: 3;
    margin-left: 0;
    justify-content: space-between;
  }

  .section--hero { padding: var(--space-10) 0 var(--space-8); }
  .pitch-header { padding: var(--space-10) 0 var(--space-6); }

  .palette-switch button span.full { display: none; }
}

/* Reduce aggressive stickiness on very small screens */
@media (max-height: 640px) {
  .site-header { position: relative; }
}

/* =============================================================
   23. Sophistication layer (pass 2)
   Hairline rule system, measurement-grid header motif,
   refined section numbers, elevation (no shadow), restrained
   scroll motion. All opt-in via existing class hooks.
   ============================================================= */

/* ---------- 23.1 Hairline rule system ----------
   A consistent sub-pixel-feel rule used as drafting lines.
   On retina, 0.5px renders as a true hairline; on 1x displays
   browsers rasterize at 1px — still thinner than the default
   1px when combined with lower opacity.
*/

:root {
  --hairline: 1px;
  --hairline-color: color-mix(in oklab, var(--border) 85%, transparent);
  --hairline-strong-color: color-mix(in oklab, var(--border-strong) 55%, transparent);
  --tick-size: 6px;
  --tick-color: color-mix(in oklab, var(--text-dim) 55%, transparent);
}

@media (min-resolution: 1.5dppx) {
  :root { --hairline: 0.5px; }
}

/* Drafting-rule — ultra-thin horizontal rule */
.rule-hairline {
  height: 1px;
  background: var(--hairline-color);
  border: 0;
  margin: var(--space-6) 0;
}

/* Double rule — hairline + ticks underneath, drafting-paper feel */
.rule-measured {
  height: var(--tick-size);
  margin: var(--space-7) 0;
  background:
    linear-gradient(to bottom, var(--hairline-color) 0, var(--hairline-color) var(--hairline), transparent var(--hairline)) top no-repeat,
    repeating-linear-gradient(90deg,
      var(--tick-color) 0, var(--tick-color) var(--hairline),
      transparent var(--hairline), transparent 8px) bottom no-repeat;
  background-size: 100% var(--hairline), 100% 3px;
  border: 0;
}

/* ---------- 23.2 Measurement-grid header motif ----------
   Replaces the plain 1px rule under .site-header and
   under .pitch-header with a drafting tick row.
   One major tick every 8px, with a slightly longer tick
   every 40px — reads as a surveyor's rule.
*/

.site-header {
  /* Keep the existing 1px border for layout, add ticks under it */
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 4px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to right,
      var(--tick-color) 0,
      var(--tick-color) var(--hairline),
      transparent var(--hairline),
      transparent 8px
    );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  opacity: 0.7;
}

/* The sticky header needs a positioning context for ::after */
.site-header { /* intentional reinforcement; keeps absolute child in flow */ }

/* Longer "major" ticks every fifth position — a second overlay */
.site-header::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -7px;
  height: 6px;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to right,
      var(--hairline-strong-color) 0,
      var(--hairline-strong-color) var(--hairline),
      transparent var(--hairline),
      transparent 40px
    );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  opacity: 0.9;
}

/* Make sure header has positioning context for the pseudo-elements. */
.site-header { position: sticky; }

/* ---------- 23.3 Hero / pitch-header: reference-line motif ----------
   A quiet horizontal reference line + crosshair at the eyebrow,
   evoking a surveyor's station marker.
*/

.section--hero,
.pitch-header {
  position: relative;
}

.section--hero::before,
.pitch-header::before {
  content: "";
  position: absolute;
  left: var(--space-5);
  right: var(--space-5);
  top: var(--space-10);
  height: 1px;
  background: var(--hairline-color);
  pointer-events: none;
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 20px,
    #000 calc(100% - 120px),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 20px,
    #000 calc(100% - 120px),
    transparent 100%
  );
  opacity: 0.6;
}

/* Micro-crosshair at the eyebrow — a station marker */
.eyebrow,
.pitch-header__kicker {
  position: relative;
}

.eyebrow::after {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border: 1px solid var(--accent);
  background: transparent;
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 1.5px var(--bg),
    0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent);
  opacity: 0.85;
}

@media (max-width: 640px) {
  .eyebrow::after { display: none; }
}

/* Pitch-header gets its own crosshair treatment next to the kicker */
.pitch-header__kicker {
  padding-left: 2px;
}

/* ---------- 23.4 Section-number chip positioning ----------
   Pass 4: the chip hangs out in the left margin so h2 text sits
   flush with body copy. Below 900px (same breakpoint as the
   benchmark marks) the chip falls back inline so it stays visible.

   Positioning strategy: `right: 100%` anchors the chip's right
   edge to the h2's left edge; `margin-right` pushes it further
   into the margin. This auto-fits any chip width without em math.
   The h2 itself gets `position: relative` from §23.6 already.
*/

/* Removed: wide-viewport absolute-hanging chip rule. See the
   indent-removal note above. Chips now use the inline fallback at
   every breakpoint; markup .num spans that remain render inline
   with their h2. */

/* Inline fallback (<=900px): chip stays visible but sits inline before
   the h2 text with a modest gap. Vertical-align lifts the baseline so
   it reads as marginalia next to the heading, not jammed against it. */
@media (max-width: 900px) {
  .pitch-prose h2 .num {
    margin-right: var(--space-3);
  }
}

.pitch-prose h2 .num::before {
  content: "\00a7";
  margin-right: 0.1em;
  letter-spacing: 0;
  opacity: 0.72;
}

/* Pass 4: in instrument/light the plain --accent (#1f8a53) on
   --accent-ink (#f6f3ec) only clears WCAG AA-large (3.93:1), which
   is fine for h1 fragments but the chip is --fs-xs normal weight —
   so swap the chip bg to --accent-strong (#156a3f on #f6f3ec =
   5.99:1, AA normal). Dark theme is already 7.55:1 AAA at base
   accent, so no override there. */
[data-theme="light"] .pitch-prose h2 .num {
  background: var(--accent-strong);
}

/* ---------- 23.5 Elevation without skeuomorphism ----------
   Cards, callouts, flowcharts, contact form, cta-block.
   Inner stroke (box-shadow inset) + micro linear gradient.
   Works in both themes without a drop shadow.
*/

:root {
  --elev-inner-stroke: inset 0 0 0 1px color-mix(in oklab, var(--border) 70%, transparent),
                       inset 0 1px 0 color-mix(in oklab, #ffffff 4%, transparent);
  --elev-surface: linear-gradient(
    180deg,
    color-mix(in oklab, var(--bg-elev) 100%, transparent) 0%,
    color-mix(in oklab, var(--bg) 100%, var(--bg-elev)) 100%
  );
}

[data-theme="light"] {
  --elev-inner-stroke: inset 0 0 0 1px color-mix(in oklab, var(--border) 95%, transparent),
                       inset 0 1px 0 color-mix(in oklab, #ffffff 60%, transparent);
  --elev-surface: linear-gradient(
    180deg,
    color-mix(in oklab, var(--bg-elev) 100%, transparent) 0%,
    color-mix(in oklab, var(--bg-sunk) 60%, var(--bg-elev)) 100%
  );
}

.link-card,
.flowchart,
.cta-block,
.contact {
  background: var(--elev-surface);
  box-shadow: var(--elev-inner-stroke);
}

/* Callout-cta — paper-pulled-forward feel.
   Keep accent border, add inner stroke on the paper. */
.callout-cta {
  background: var(--elev-surface);
  box-shadow: var(--elev-inner-stroke),
              inset 3px 0 0 var(--accent);
  border-left: 0;
  padding-left: calc(var(--space-6) + 3px);
}

/* Flowchart gets a tiny tick row at the top-right — "fig 1" feel */
.flowchart {
  position: relative;
  overflow: hidden;
}

.flowchart__header {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--hairline-color);
  margin-bottom: var(--space-4);
}

.flowchart__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0;
  position: relative;
  padding-right: var(--space-3);
}

.flowchart__label::after {
  content: "";
  display: inline-block;
  width: 24px;
  height: 1px;
  margin-left: var(--space-2);
  background: var(--hairline-color);
  vertical-align: middle;
}

/* ---------- 23.8 Pitch header: reinforce "technical document" ---------- */

.pitch-header {
  padding-bottom: var(--space-10);
}

/* Removed: drafting-tick rule between pitch-header and body copy. */

/* ---------- 23.9 Link-card refinements ----------
   Add a tiny vertical index-tick on the left edge that extends
   on hover. One restrained interaction cue beats a shadow lift.
*/

.link-card {
  position: relative;
  padding-left: calc(var(--space-6) + 1px);
}

.link-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--space-6);
  bottom: var(--space-6);
  width: 2px;
  background: var(--accent);
  opacity: 0.5;
  transition: opacity var(--t-base) var(--ease),
              top var(--t-base) var(--ease),
              bottom var(--t-base) var(--ease);
  border-radius: 1px;
}

.link-card:hover::before {
  opacity: 1;
  top: var(--space-5);
  bottom: var(--space-5);
}

/* ---------- 23.10 Footer: mono meta row refined ---------- */

.site-footer__meta {
  position: relative;
}

.site-footer__meta::before {
  content: "";
  position: absolute;
  left: var(--space-5);
  right: var(--space-5);
  top: 0;
  height: 1px;
  background:
    repeating-linear-gradient(
      to right,
      var(--hairline-color) 0,
      var(--hairline-color) var(--hairline),
      transparent var(--hairline),
      transparent 8px
    );
}

/* Replace the solid top border with the hairline-tick row */
.site-footer__meta {
  border-top: 0;
}

/* ---------- 23.11 Backdrop reference grid ----------
   A deeply faint column grid behind the hero / pitch-header
   that evokes drafting paper. Only visible on wider viewports,
   only in light mode (where it reads as paper); hidden on dark
   so we don't pollute the deep-neutral palette with grid noise.
*/

@media (min-width: 920px) {
  [data-theme="light"] .section--hero::after,
  [data-theme="light"] .pitch-header::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
      linear-gradient(
        to right,
        color-mix(in oklab, var(--border) 40%, transparent) 0,
        color-mix(in oklab, var(--border) 40%, transparent) var(--hairline),
        transparent var(--hairline)
      );
    background-size: calc((var(--container) - var(--space-10)) / 12) 100%;
    background-repeat: repeat-x;
    background-position: calc(50% - var(--container) / 2 + var(--space-5)) 0;
    mask-image: linear-gradient(
      to bottom,
      transparent 0,
      #000 40px,
      #000 calc(100% - 40px),
      transparent 100%
    );
    -webkit-mask-image: linear-gradient(
      to bottom,
      transparent 0,
      #000 40px,
      #000 calc(100% - 40px),
      transparent 100%
    );
    opacity: 0.5;
  }

  /* The hero/pitch content must sit above the grid */
  .section--hero > *,
  .pitch-header > * {
    position: relative;
    z-index: 1;
  }
}

/* ---------- 23.12 Pitch-header gets ticks on top of grid override ---------- */

/* pitch-header had ::after reassigned to tick row; keep that.
   For light-theme pitch-header, grid lives on ::after competing
   with the tick row. We give the grid a dedicated class in
   markup OR keep tick row only. Simplest: in light theme on
   pitch-header, suppress the grid, keep ticks. */

[data-theme="light"] .pitch-header::after {
  /* Prefer ticks over grid on the pitch header */
  background:
    repeating-linear-gradient(
      to right,
      var(--tick-color) 0,
      var(--tick-color) var(--hairline),
      transparent var(--hairline),
      transparent 8px
    );
  background-size: 100% 100%;
  inset: auto 0 -1px 0;
  height: 4px;
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 10%,
    #000 90%,
    transparent 100%
  );
  opacity: 0.55;
}

/* Same for section--hero in light: show tick-row AND grid is kept
   because section--hero only has ::before (reference line) +
   ::after (grid, light-mode only). Those don't conflict. */

/* ---------- 23.13 Minor: palette-switch typographic polish ---------- */

.palette-switch button[aria-pressed="true"]::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

.palette-switch button[aria-pressed="false"]::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ---------- 23.14 .num-rule — standalone section index block ----------
   For heading styles outside the pitch-prose context (e.g. about-page
   section headers if we later number them). Not currently used but
   available if needed. */

.num-rule {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0;
  margin-bottom: var(--space-4);
}

.num-rule::after {
  content: "";
  width: 48px;
  height: 1px;
  background: var(--hairline-color);
}
