:root {
  --bg: #15151c;
  --bg-raised: #22232c;
  --text: #e4e4e7;
  --text-muted: #9a9aa3;
  --accent: #a1a1aa;
  --border: #6b6b74;
  --serif: "Newsreader", Georgia, serif;
  --mono: "IBM Plex Mono", monospace;
  --color-error: #f87171;
  --color-success: #22c55e;
  --viz-warn: #d4a373;
  color-scheme: dark;

  /* Type scale — relative to html font-size (112.5% = 18px default) */
  --text-xs: 0.75rem;    /* ≈13.5px — metadata, timestamps, captions */
  --text-sm: 0.875rem;   /* ≈15.75px — nav links, UI labels, code */
  --text-lead: 1.1rem;   /* ≈19.8px — intro/lead text on listing pages */
  --text-prose: 1.15rem; /* ≈20.7px — long-form prose body in blog/tutorial posts */
}

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

html {
  font-size: 112.5%; /* 18px equivalent; scales with user browser font-size preference */
  scroll-behavior: smooth;
}

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1000px; /* pixel-based: at 18px root ≈55ch, within 45–75ch range at default font size;
                        blog/tutorial pages use 72ch for prose — this wider value is for page layout */
  margin: 0 auto;
  padding: 0 24px;
}

/* Nav */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 24px 40px;
  z-index: 100;
  background: var(--bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Soft fade-out below the nav so the hard edge doesn't pop against scrolling content */
.site-nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 24px;
  background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%);
  pointer-events: none;
}

/* Scroll progress indicator — thin line at top of viewport that fills as you scroll */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
  pointer-events: none;
}

.scroll-progress-bar {
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 50ms linear;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-progress-bar {
    transition: none;
  }
}

.site-nav .nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.site-nav .nav-logo {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-nav .nav-logo svg {
  width: 24px;
  height: 24px;
}

.site-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.site-nav .nav-links a {
  display: inline-block; /* same box model as the contact button, so they align */
  line-height: normal;
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  padding: 8px 16px;
  border: 1px solid transparent;
}

.site-nav .nav-links a:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-raised);
}

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

/* Contact action — a button, outlined so it reads as an action, not a page */
.site-nav .nav-contact {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text);
  letter-spacing: 0.05em;
  background: transparent;
  border: 1px solid var(--accent);
  line-height: normal; /* inline links size their box from the font, not line-height */
  padding: 8px 16px;
  margin-left: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.site-nav .nav-contact:hover,
.site-nav .nav-contact:focus-visible {
  background: var(--bg-raised);
}

@media (max-width: 600px) {
  .site-nav {
    padding: 16px 20px;
  }

  /* Logo shares the first row so the menu stays within two rows and
     the fixed header clears the 120px top padding of mobile pages */
  .site-nav .nav-inner {
    align-items: flex-start;
    gap: 12px;
  }

  .site-nav .nav-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .site-nav .nav-links a,
  .site-nav .nav-contact {
    font-size: var(--text-xs);
    letter-spacing: 0.02em;
    padding: 6px 8px;
  }

  .site-nav .nav-contact {
    margin-left: 0;
  }
}

/* Narrowest phones: tighten further so the menu still fits in two rows */
@media (max-width: 359px) {
  .site-nav {
    padding: 16px 12px;
  }

  .site-nav .nav-links {
    gap: 2px;
  }

  .site-nav .nav-links a,
  .site-nav .nav-contact {
    letter-spacing: 0;
    padding: 6px 6px;
  }
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 80px 24px;
  position: relative;
}

.logo {
  margin-bottom: 48px;
  animation: fadeIn 1s ease both;
}

.logo svg {
  width: 80px;
  height: 80px;
}

.hero h1 {
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  animation: fadeIn 1s ease 0.2s both;
}

.hero h1 i {
  font-style: italic;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1em;
  letter-spacing: -0.03em;
}

.hero .tagline {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  color: var(--text-muted);
  max-width: 500px;
  font-style: italic;
  animation: fadeIn 1s ease 0.4s both;
}

.hero .definition {
  margin-top: 32px;
  padding: 20px 28px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  max-width: 600px;
  text-align: left;
  animation: fadeIn 1s ease 0.6s both;
}

.hero .definition p {
  font-family: var(--serif);
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.hero .definition strong {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.02em;
}

.hero .definition em {
  font-style: italic;
  color: var(--accent);
}

.hero .definition cite {
  display: block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-style: normal;
  color: var(--text-muted);
}

.hero .definition cite a {
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: all 0.2s ease;
}

.hero .definition cite a:hover {
  color: var(--text);
  border-color: var(--accent);
}

.scroll-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  animation: fadeIn 1s ease 0.8s both, float 3s ease-in-out infinite 1.8s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(8px);
  }
}

/* Sections */
section {
  padding: 120px 0;
  border-top: 1px solid var(--border);
}

section h2 {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 48px;
}

/* Evidence Cards */
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.evidence-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 32px;
  transition: all 0.3s ease;
  text-decoration: none; /* For clickable links */
  display: flex;
  flex-direction: column;
}

.evidence-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.evidence-card .source {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 16px;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.evidence-card .source::after {
  content: "↗";
  font-size: var(--text-sm);
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.evidence-card:hover .source::after {
  opacity: 1;
}

.evidence-card p {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
}

.evidence-card .stat-wrapper {
  display: block;
  margin-bottom: 0;
}

.evidence-card .stat {
  font-family: var(--mono);
  font-size: 3rem;
  color: var(--text);
  font-weight: 500;
  line-height: 1;
  float: left;
  width: 90px;
  margin-right: 12px;
  margin-bottom: 0;
  shape-outside: margin-box;
}

.evidence-card .stat-wrapper p {
  margin: 0;
  padding-left: 0;
  text-align: left;
}

.evidence-title {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin: 0 0 12px;
}

/* Measured / Meant: the gap each example is about */
.evidence-gap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 16px;
  font-size: var(--text-sm);
}

.evidence-gap div {
  display: contents;
}

.evidence-gap dt {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  align-self: baseline;
}

.evidence-gap dd {
  margin: 0;
  color: var(--text);
}

.evidence-card--internal .source::after {
  content: "→";
}

.evidence-quote {
  max-width: 40rem;
  margin: 0 auto 32px;
  text-align: center;
}

.evidence-quote p {
  font-size: var(--text-lead);
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 8px;
}

.evidence-quote cite {
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-style: normal;
  color: var(--text-muted);
}

.evidence-quote cite a {
  color: inherit;
}

.closing-line {
  font-style: italic;
  color: var(--text-muted);
  font-size: var(--text-lead);
  text-align: center;
}

/* Distinction */
.distinction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

@media (max-width: 700px) {
  .distinction-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  
  .viz-container {
    padding: 16px;
  }
  
  .path-viz {
    height: 200px;
  }
}

.distinction-col h3 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.distinction-col p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 12px;
}

.distinction-col .example {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--accent);
  padding: 16px;
  background: var(--bg-raised);
  border-left: 2px solid var(--border);
  margin-top: 16px;
  line-height: 1.6;
}

.key-insight {
  margin: 48px auto 0;
  padding: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-style: italic;
  color: var(--text);
  font-size: 1.5rem;
  max-width: 800px;
  text-align: center;
  position: relative;
}

.key-insight::before {
  content: "\201C"; /* decorative open-quote only — no readable text in this pseudo-element */
  font-family: Georgia, serif;
  font-size: 6rem;
  color: var(--accent);
  opacity: 0.5;
  line-height: 0.5; /* intentional: collapses decorative glyph to not push text down; selector is tightly scoped to .key-insight */
  vertical-align: top;
  margin-right: 8px;
}

/* Cartoon */
.cartoon {
  margin: 48px auto;
  text-align: center;
}

.cartoon img {
  max-width: 360px;
  width: 100%;
  border-radius: 4px;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.cartoon img:hover {
  opacity: 1;
}

/* Math example styling */
.example-math {
  margin-top: 12px;
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
}

/* Prompt Comparison */
.prompt-comparison {
  margin-top: 64px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
}

.prompt-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.prompt-label {
  font-family: var(--mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 3px;
}

.prompt-header code {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text);
}

.response-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 800px) {
  .response-grid {
    grid-template-columns: 1fr;
  }
}

.response-col {
  padding: 24px;
}

.response-bad {
  border-right: 1px solid var(--border);
  background: rgba(248, 113, 113, 0.08);
}

.response-good {
  background: rgba(34, 197, 94, 0.08);
}

@media (max-width: 800px) {
  .response-bad {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.response-label {
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 500;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.response-bad .response-label {
  color: var(--color-error);
}

.response-good .response-label {
  color: var(--color-success);
}

.response-content {
  font-size: var(--text-sm);
  line-height: 1.6;
}

.response-content p {
  margin-bottom: 12px;
  color: var(--text-muted);
}

.response-content ul {
  list-style: none;
  margin-bottom: 16px;
}

.response-content li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.response-content li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

.response-content code {
  font-family: var(--mono);
  font-size: var(--text-xs);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text);
}

.response-content .result {
  font-family: var(--mono);
  font-size: var(--text-xs);
  margin-bottom: 0;
}

.response-bad .result {
  color: var(--color-error);
}

.response-good .result {
  color: var(--color-success);
}

.response-verdict {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-style: italic;
}

.response-bad .response-verdict {
  color: var(--color-error);
}

.response-good .response-verdict {
  color: var(--color-success);
}

/* Prompt insight line */
.prompt-insight {
  font-style: italic;
  color: var(--text);
  font-size: 1.5rem;
  text-align: center;
  margin-top: 32px;
  padding: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  position: relative;
}

.prompt-insight::before {
  content: "\201C"; /* decorative open-quote only — no readable text in this pseudo-element */
  font-family: Georgia, serif;
  font-size: 6rem;
  color: var(--accent);
  opacity: 0.5;
  line-height: 0.5; /* intentional: collapses decorative glyph; selector is tightly scoped to .prompt-insight */
  vertical-align: top;
  margin-right: 8px;
}

/* Solution */
.solution-container {
  display: flex;
  justify-content: center;
}

/* Probability Paths Visualization */
.viz-container {
  max-width: 700px;
  margin: 0 auto 48px;
  padding: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.path-viz {
  width: 100%;
  height: auto;
}

.viz-caption {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
  margin-bottom: 0;
}

/* Solution diagram — colors as CSS so light mode and contrast modes can
   override them (SVG presentation attributes do not read CSS variables).
   Agent A amber, Agent B sky, human purple; misses and catches use the
   site's error and success tokens. */
.path-viz .prob-space { stroke: var(--border); stroke-dasharray: 4 4; fill: none; }
.path-viz text { font-family: var(--mono); font-size: 11px; }
.prob-space-label { fill: var(--text-muted); font-size: 10px; letter-spacing: 0.08em; }
.grid-dots circle { fill: var(--border); }

.path-viz { --viz-a: #f59e0b; --viz-b: #38bdf8; --viz-h: #c084fc; }
@media (prefers-color-scheme: light) {
  .path-viz { --viz-a: #b45309; --viz-b: #0369a1; --viz-h: #7e22ce; }
}

.path-viz .c-a { stroke: var(--viz-a); fill: var(--viz-a); }
.path-viz .c-b { stroke: var(--viz-b); fill: var(--viz-b); }
.path-viz .c-h { stroke: var(--viz-h); fill: var(--viz-h); }
.path-viz text.c-a, .path-viz text.c-b, .path-viz text.c-h { stroke: none; }
.path-viz .c-miss { fill: var(--color-error); }
.path-viz .c-ok { fill: var(--color-success); }

.path-viz .coverage { stroke: none; opacity: 0.1; }
.path-viz .agent-path, .path-viz .handoff { fill: none; stroke-width: 2; }
.path-viz .handoff { stroke-dasharray: 4 4; stroke-width: 1.5; }
.path-viz .miss { fill: none; stroke: var(--color-error); stroke-width: 1.5; stroke-dasharray: 3 3; }
.path-viz .caught { fill: none; stroke: var(--color-success); stroke-width: 2; }
.path-viz .node-ring { fill: var(--bg); stroke: var(--text-muted); stroke-width: 2; }
.path-viz .node-ring.c-h { fill: var(--bg); stroke: var(--viz-h); }
.path-viz .node-label { fill: var(--text-muted); font-size: 10px; }
.path-viz .node-label.c-h { fill: var(--viz-h); }

/* Staging. The final state is the default; script.js arms a diagram only
   when motion is allowed, then plays it once when it scrolls into view. */
.solution-viz.is-armed .step { opacity: 0; }
.solution-viz.is-armed .draw { stroke-dasharray: 1; stroke-dashoffset: 1; }
.solution-viz.is-armed .coverage.step { opacity: 0; }

.solution-viz.is-playing .step { opacity: 1; transition: opacity 0.5s ease; }
.solution-viz.is-playing .coverage.step { opacity: 0.1; }
.solution-viz.is-playing .draw { stroke-dashoffset: 0; transition: stroke-dashoffset 1.1s ease-in-out; }
.solution-viz.is-playing .fades-at-4 {
  transition: none;
  animation: viz-miss-then-caught 3.8s ease forwards;
}
@keyframes viz-miss-then-caught {
  0%, 29% { opacity: 0; }   /* hidden until A has finished (1.1s) */
  37%, 89% { opacity: 1; }  /* "A misses" */
  100% { opacity: 0; }      /* replaced by "B catches it" at 3.4s */
}

.solution-viz.is-playing .step-1 { transition-delay: 0s; }
.solution-viz.is-playing .step-2 { transition-delay: 1.1s; }
.solution-viz.is-playing .step-3 { transition-delay: 1.8s; }
.solution-viz.is-playing .step-4 { transition-delay: 3.4s; }
.solution-viz.is-playing .step-5 { transition-delay: 4.4s; }
/* The miss that A makes is shown, then replaced by B's catch at step 4:
   in the final state only the catch remains. */
.solution-viz:not(.is-armed) .fades-at-4 { opacity: 0; }

.viz-steps {
  list-style: none;
  counter-reset: viz-step;
  margin: 16px auto 0;
  padding: 0;
  max-width: 30rem;
  display: grid;
  gap: 4px;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.viz-steps li { counter-increment: viz-step; }
.viz-steps li::before { content: counter(viz-step) " "; color: var(--text); }
.solution-viz.is-armed .viz-steps li { opacity: 0.35; transition: opacity 0.4s ease; }
.solution-viz.is-playing .viz-steps li { opacity: 1; }
.solution-viz.is-playing .viz-steps li[data-step="2"] { transition-delay: 1.1s; }
.solution-viz.is-playing .viz-steps li[data-step="3"] { transition-delay: 1.8s; }
.solution-viz.is-playing .viz-steps li[data-step="4"] { transition-delay: 3.4s; }
.solution-viz.is-playing .viz-steps li[data-step="5"] { transition-delay: 4.4s; }

.viz-replay {
  display: block;
  margin: 14px auto 0;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 14px;
  cursor: pointer;
}
.viz-replay[hidden] { display: none; }
.viz-replay:hover, .viz-replay:focus-visible { color: var(--text); border-color: var(--text); }

/* In Practice — the thesis mapped to how the work is done */
.section-lead {
  font-size: var(--text-prose);
  color: var(--text);
  max-width: 60ch;
  margin-bottom: 40px;
}
.practice-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: practice;
  border-top: 1px solid var(--border);
}
.practice-list li {
  counter-increment: practice;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 3fr;
  gap: 24px;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.practice-claim {
  font-family: var(--mono);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.practice-claim::before {
  content: counter(practice, decimal-leading-zero) "  ";
  color: var(--text-muted);
}
.practice-list p { margin: 0; color: var(--text-muted); }
@media (max-width: 700px) {
  .practice-list li { grid-template-columns: 1fr; gap: 8px; }
}

/* Explore link */
.explore-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  margin-top: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s ease;
}

.explore-link:hover {
  color: var(--text);
  border-color: var(--text);
}

.solution-content {
  max-width: 700px;
  text-align: left;
}

.solution-content p {
  margin-bottom: 24px;
  color: var(--text-muted);
}

.solution-content p:first-of-type {
  color: var(--text);
  font-size: var(--text-prose);
}

.math-block {
  font-family: var(--mono);
  font-size: var(--text-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 24px;
  margin: 32px 0;
}

.math-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 600px) {
  .math-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.math-col {
  padding: 16px;
  border-left: 2px solid var(--border);
}

.math-label {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.math-line {
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.6;
}

.math-line.muted {
  opacity: 0.7;
}

.math-line.result {
  color: var(--text);
  font-weight: 500;
  font-size: 1rem;
}

.math-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
  opacity: 0.8;
}

.math-footnote {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  opacity: 0.75;
}

.math-block .result {
  color: var(--text);
  font-weight: 500;
}

.human-note {
  font-style: italic;
  color: var(--text);
  font-size: 1.5rem;
  text-align: center;
  margin-top: 32px;
  padding: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  position: relative;
}

.human-note::before {
  content: "\201C"; /* decorative open-quote only — no readable text in this pseudo-element */
  font-family: Georgia, serif;
  font-size: 6rem;
  color: var(--accent);
  opacity: 0.5;
  line-height: 0.5; /* intentional: collapses decorative glyph; selector is tightly scoped to .human-note */
  vertical-align: top;
  margin-right: 8px;
}

/* Footer */
footer {
  padding: 80px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

footer p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 1rem;
}

/* Contact pitch: a question the right visitor answers yes to, then the offer */
footer .footer-pitch {
  font-family: var(--mono);
  font-size: var(--text-prose);
  color: var(--text);
  margin-bottom: 12px;
}

footer .footer-offer {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.contact-btn {
  font-family: var(--mono);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.contact-btn:hover {
  border-color: var(--text);
  background: var(--bg-raised);
}

.footer-links {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links a {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.3s ease;
}

.footer-links a:hover {
  color: var(--text);
}

.copyright {
  margin-top: 48px;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Page dates */
.page-dates {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  /* opacity removed: at 80% on --text-muted in light mode yielded ~4.15:1, below 4.5:1 AA */
  margin-bottom: 24px;
}

.hero-dates {
  text-align: center;
  padding: 24px 24px 0;
}

.hero-cta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}

.cta-primary {
  font-family: var(--mono);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  padding: 12px 28px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.cta-primary:hover {
  opacity: 0.85;
}

.cta-secondary {
  font-family: var(--mono);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
  padding: 12px 28px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.cta-secondary:hover {
  border-color: var(--accent);
}

/* 404 Error Page */
.error-main {
  min-height: 80vh;
  display: flex;
  align-items: center;
  padding: 120px 24px 80px;
}

.error-content {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
}

.error-code {
  font-family: var(--mono);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 24px;
}

.error-content h1 {
  font-family: var(--mono);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 500;
  margin-bottom: 16px;
}

.error-message {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 40px;
}

.error-links {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.error-nav {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.error-nav a {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.error-nav a:hover {
  color: var(--text);
}

/* Resource Page Specific */
main.resource-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 160px 24px 120px;
}

main.resource-main h1 {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  margin-bottom: 16px;
}

main.resource-main > p.intro {
  color: var(--text-muted);
  font-size: var(--text-lead);
  margin-bottom: 48px;
  max-width: 600px;
}

.resource-section {
  margin-bottom: 64px;
}

.resource-section h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.resource-list {
  list-style: none;
}

.resource-list li {
  margin-bottom: 24px;
}

.resource-list a {
  color: var(--text);
  text-decoration: none;
  display: block;
  padding: 24px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.resource-list a:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}

.resource-list .title {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.resource-list .desc {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.resource-list .meta {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 12px;
}

/* Focus styles for keyboard accessibility */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Visually hidden (screen-reader only) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip navigation link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 200;
  padding: 12px 24px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-sm);
  border: 1px solid var(--accent);
  text-decoration: none;
  transition: top 0.2s ease;
}

/* Defensive placeholder styles — no inputs exist in the current codebase (confirmed via grep),
   but these rules prevent browser-default placeholder contrast failures if inputs are added. */
::placeholder {
  color: var(--text-muted);
  opacity: 1; /* override Firefox default of 0.54 which reduces contrast */
}

/* Light mode — respects system preference.
   No manual theme toggle is provided; theme is controlled by the OS prefers-color-scheme
   preference only. Users who want to override must change their OS setting. (O6) */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-raised: #f4f4f5;
    --text: #18181b;
    --text-muted: #52525b;
    --accent: #52525b;
    --border: #71717a;
    --color-error: #b91c1c;  /* red-700 — 6.4:1 on white, 5.8:1 on --bg-raised; was red-600 (#dc2626, 4.0:1 on tinted bg) */
    --color-success: #166534; /* green-800 — 6.4:1 on white, 5.9:1 on --bg-raised; was green-700 (#15803d, 3.9:1 on tinted bg) */
    --viz-warn: #b45309; /* amber-700 — 4.7:1 on white, passes AA */
    color-scheme: light;
  }
}

/* High-contrast override for dark mode */
@media (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root {
    --text-muted: #c4c4c9;
    --border: #8b8b96;
    --bg-raised: #2a2b36;
    /* Status colors boosted for HC users — standard values already pass AA but HC raises bar */
    --color-error: #fca5a5;   /* red-300 — 10.1:1 on dark bg */
    --color-success: #4ade80; /* green-400 — 9.6:1 on dark bg */
    --viz-warn: #fcd34d;      /* amber-300 — 10.3:1 on dark bg */
  }
}

/* High-contrast override for light mode — separate block prevents
   near-white text-muted (#c4c4c9) from landing on a white background */
@media (prefers-color-scheme: light) and (prefers-contrast: more) {
  :root {
    --text-muted: #3f3f46; /* zinc-700 — 9.7:1 on white, passes AAA */
    --border: #52525b;     /* zinc-600 — 7.2:1 on white */
    --bg-raised: #e4e4e7;  /* zinc-200 — clear separation from white bg */
    /* Status colors further darkened from light-mode defaults for HC */
    --color-error: #991b1b;   /* red-800 — 8.0:1 on white */
    --color-success: #14532d; /* green-900 — 8.3:1 on white */
    --viz-warn: #92400e;      /* amber-800 — 7.3:1 on white */
  }
}

.skip-link:focus {
  top: 16px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .scroll-hint {
    animation: none;
    opacity: 1;
  }

  .logo {
    opacity: 1;
    animation: none;
  }

  .hero h1,
  .hero .tagline,
  .hero .definition {
    opacity: 1;
    animation: none;
  }

}

/* Get-in-touch emphasis: a small light travels once along the outline at
   a constant speed, then rests; hovering keeps it circling. It follows the
   border itself (offset-path), so it doesn't race across the short ends. */
.site-nav .nav-contact,
.contact-btn {
  position: relative;
  background-color: var(--bg); /* opaque, so the glow behind shows only outside */
}

@supports (offset-path: inset(0)) {
  .site-nav .nav-contact::before,
  .contact-btn::before,
  .site-nav .nav-contact::after,
  .contact-btn::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    offset-path: inset(-1px);
    offset-rotate: auto;
    opacity: 0;
    pointer-events: none;
    animation: cta-lap 9s linear infinite;
  }

  /* the light: a short streak, brightest at its leading end */
  .site-nav .nav-contact::before,
  .contact-btn::before {
    width: 26px;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, var(--text));
    z-index: 1;
  }

  /* a soft glow that travels with it, behind the button */
  .site-nav .nav-contact::after,
  .contact-btn::after {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text);
    filter: blur(7px) opacity(0.4);
    z-index: -1;
  }

  .contact-btn::before,
  .contact-btn::after {
    animation-delay: 4.5s; /* never in step with the menu button */
  }

  .site-nav .nav-contact:hover::before,
  .site-nav .nav-contact:hover::after,
  .site-nav .nav-contact:focus-visible::before,
  .site-nav .nav-contact:focus-visible::after,
  .contact-btn:hover::before,
  .contact-btn:hover::after,
  .contact-btn:focus-visible::before,
  .contact-btn:focus-visible::after {
    animation: cta-loop 2.4s linear infinite;
  }
}

/* one lap, then rest */
@keyframes cta-lap {
  0% { offset-distance: 0%; opacity: 0; }
  3% { opacity: 1; }
  31% { opacity: 1; }
  34% { offset-distance: 100%; opacity: 0; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* hovering: keep circling */
@keyframes cta-loop {
  from { offset-distance: 0%; opacity: 1; }
  to { offset-distance: 100%; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav .nav-contact::before,
  .contact-btn::before,
  .site-nav .nav-contact::after,
  .contact-btn::after {
    animation: none !important;
    display: none;
  }
}

/* Diagram zoom: a magnifier on each diagram expands the live diagram to
   fill the screen (script.js); a fixed bar holds replay, fit/zoom, close */
[data-zoomable] {
  position: relative;
}

.zoom-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.zoom-btn:hover,
.zoom-btn:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.zoom-btn svg {
  width: 18px;
  height: 18px;
}

html.zoom-open {
  overflow: hidden;
}

/* Expanded is an override mode: page-scoped figure styles (margins,
   frames, widths) must not shrink or reshape it, hence !important */
[data-zoomable].is-expanded {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  margin: 0 !important;
  padding: 72px 16px 32px !important;
  overflow: auto;
  border: 0 !important;
  background: var(--bg) !important;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
}

[data-zoomable].is-expanded > .zoom-btn {
  display: none;
}

/* Fit: the whole diagram on screen */
[data-zoomable].is-expanded svg:not(.zoom-btn svg) {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 220px);
  margin: 0 auto;
}

/* Images fit the screen; zoomed, they show at their own pixel size */
[data-zoomable].is-expanded img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 220px);
  object-fit: contain;
  margin: 0 auto;
}

[data-zoomable].is-expanded.is-zoomed img {
  width: auto !important;
  max-width: none !important;
  max-height: none !important;
}

/* Zoom: draw it large and let the visitor pan */
[data-zoomable].is-expanded.is-zoomed svg:not(.zoom-btn svg) {
  width: 1100px;
  max-width: none;
  max-height: none;
}

.zoom-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.zoom-bar[hidden],
.zoom-bar [hidden] {
  display: none;
}

.zoom-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.zoom-toggle {
  min-width: 5.5em; /* "Zoom" and "Fit" swap without resizing the bar */
}

.zoom-replay,
.zoom-toggle,
.zoom-close {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 12px;
  cursor: pointer;
}

.zoom-close {
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px 12px 6px;
}

.zoom-replay:hover,
.zoom-toggle:hover,
.zoom-close:hover,
.zoom-replay:focus-visible,
.zoom-toggle:focus-visible,
.zoom-close:focus-visible {
  border-color: var(--accent);
}

/* Glossary terms (build.py) and their definition card (script.js) */
.term {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline dashed;
  text-decoration-color: var(--text-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.2s ease;
}

.term:hover,
.term:focus-visible {
  text-decoration-color: var(--text);
}

.term-card {
  width: min(28rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 20px 24px 22px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

.term-card::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.term-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.term-card h2 {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
  padding-top: 4px;
}

.term-card-close {
  font-family: var(--mono);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 2px 10px 4px;
  cursor: pointer;
}

.term-card-close:hover,
.term-card-close:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.term-card-def {
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

.term-card-link {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.term-card-link:hover,
.term-card-link:focus-visible {
  color: var(--text);
}

.term-card-link[hidden] {
  display: none;
}

/* Phones: rise from the bottom like a sheet */
@media (max-width: 600px) {
  .term-card {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-width: 1px 0 0;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
}

/* Code boxes (script.js): a header with the language and a copy button,
   wrapped around any <pre><code> in post or tutorial prose */
.code-box {
  margin: 32px 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.code-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.code-box-lang {
  text-transform: lowercase;
}

.code-copy {
  position: relative;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 22px 4px 10px; /* trailing room reserved for the mark */
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

/* Result mark: overlaid at the trailing edge so the button never resizes
   (see the UI action feedback guide); fades in, holds, fades out */
.code-copy-mark {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--color-success, var(--text));
  pointer-events: none;
}

.code-copy-mark.is-error {
  color: var(--color-error, var(--text));
}

.code-copy.is-flashing .code-copy-mark {
  animation: copy-flash 1.4s ease forwards;
}

@keyframes copy-flash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .code-copy.is-flashing .code-copy-mark {
    animation: none;
    opacity: 1;
  }
}

.code-copy:hover,
.code-copy:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

/* The box now draws the frame; the pre inside is just the scrolling body */
.blog-post .post-content .code-box pre,
.tutorial-post .tutorial-content .code-box pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
