:root {
  --navy: #10243d;
  --blue: #234a73;
  --teal: #149c91;
  --mint: #e9f8f5;
  --light: #f6f9fc;
  --line: #d6e1ea;
  --red: #bd2e2e;
  --amber: #a66b00;
  --green: #146c43;
  --bg: #ffffff;
  --text: var(--navy);
  --muted: #526477;
  --static-tint: #fff5f5;
  --static-border: #f3b7b7;
  --agent-tint: #f4faff;
  --agent-border: #c8d8ea;
  --max-width: 1080px;
  --sysfont: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --monofont: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Ensure the HTML `hidden` attribute always wins over component-level display rules. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sysfont);
  font-size: 17px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 24px 80px;
}

h1, h2 { letter-spacing: -0.02em; font-weight: 800; }
h1 { font-size: clamp(38px, 6vw, 56px); margin: 0 0 14px; line-height: 1.05; }
h2 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 14px; line-height: 1.2; }
p { margin: 0 0 14px; }

a { color: var(--teal); }
a:hover { text-decoration-thickness: 2px; }

code, pre { font-family: var(--monofont); }
pre {
  background: var(--navy);
  color: #d6fff6;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.5;
}
pre code { color: inherit; background: transparent; padding: 0; }

section { padding: 36px 0; border-bottom: 1px solid var(--line); }
section:last-child { border-bottom: 0; }

/* HERO */
.hero { padding-top: 24px; }
.byline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  font-size: 14px;
}
.pill {
  background: var(--mint);
  color: var(--teal);
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.01em;
}
.byline a { color: var(--muted); text-decoration: none; font-weight: 600; }
.byline a:hover { color: var(--teal); }
.subtitle { font-size: 19px; color: var(--muted); max-width: 720px; }
.thesis {
  margin-top: 24px;
  padding: 18px 22px;
  background: var(--light);
  border-left: 4px solid var(--teal);
  border-radius: 0 12px 12px 0;
  font-size: 19px;
  max-width: 720px;
}
.hero-link { margin-top: 20px; font-size: 14px; }

/* STEELMAN */
.steelman {
  background: var(--light);
  border-radius: 16px;
  padding: 28px;
  border-bottom: 0;
  margin-top: 8px;
}
.steelman h2 { color: var(--blue); }
.steelman p { color: var(--text); max-width: 740px; }

/* PIVOT */
.pivot { padding: 56px 0; text-align: center; border-bottom: 0; }
.pivot h2 {
  font-size: clamp(26px, 4vw, 36px);
  color: var(--navy);
  max-width: 760px;
  margin: 0 auto 18px;
  line-height: 1.15;
}
.pivot p { max-width: 640px; margin: 0 auto 12px; color: var(--muted); }
.pivot p em { color: var(--text); font-style: normal; font-weight: 700; }

/* TRACE */
.trace .trace-line {
  font-size: 18px;
  color: var(--navy);
  background: var(--mint);
  padding: 14px 18px;
  border-radius: 10px;
  margin: 0 0 22px;
  font-weight: 600;
  line-height: 1.4;
  border-left: 4px solid var(--teal);
}
.trace-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.trace-controls button {
  background: var(--teal);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.trace-controls button:hover { filter: brightness(0.95); }
.trace-controls button:active { transform: translateY(1px); }
.trace-controls input[type="range"] {
  flex: 1;
  min-width: 140px;
  max-width: 260px;
  accent-color: var(--teal);
}
.trace-controls input[type="number"] {
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}
.trace-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.trace-live-controls {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
#trace-step-label { font-size: 13px; color: var(--muted); min-width: 56px; }
.static-note { font-size: 13px; color: var(--muted); text-decoration: underline; }

.trace-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.trace-col {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px 18px;
  min-height: 220px;
}
.trace-col-static { background: var(--static-tint); border-color: var(--static-border); }
.trace-col-agent { background: var(--agent-tint); border-color: var(--agent-border); }
.trace-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.actor-label { font-weight: 800; font-size: 15px; }
.actor-label-static { color: var(--red); }
.actor-label-agent { color: var(--blue); }
.actor-outcome {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  border: 1px solid rgba(0, 0, 0, 0.05);
}
.actor-outcome.success { background: var(--mint); color: var(--teal); border-color: transparent; }
.actor-outcome.stopped { background: #fdecec; color: var(--red); border-color: transparent; }
.actor-outcome.running { background: white; color: var(--blue); }

.trace-step {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.trace-step.recent {
  box-shadow: 0 0 0 2px var(--teal), 0 4px 12px rgba(20, 156, 145, 0.15);
}
.trace-step .step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.trace-step .step-num {
  background: var(--navy);
  color: white;
  width: 22px; height: 22px; line-height: 22px;
  border-radius: 50%;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}
.trace-step .tool { font-weight: 700; flex: 1; }
.trace-step .status {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.trace-step .status::before { margin-right: 4px; }
.trace-step .status-ok { background: #e7f6ed; color: var(--green); }
.trace-step .status-ok::before { content: "✓"; }
.trace-step .status-warn { background: #fff4db; color: var(--amber); }
.trace-step .status-warn::before { content: "△"; }
.trace-step .status-err { background: #fdecec; color: var(--red); }
.trace-step .status-err::before { content: "×"; }

.trace-step .reason { color: var(--muted); margin-top: 4px; font-size: 13px; }
.trace-step .observation { margin-top: 6px; color: var(--text); }
.trace-step .memory-note {
  margin-top: 10px;
  background: var(--mint);
  border-left: 3px solid var(--teal);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--blue);
}
.trace-step .memory-note .memory-label {
  font-weight: 700;
  color: var(--teal);
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.trace-step .memory-entries { margin: 0; padding-left: 18px; }
.trace-step .memory-entries li { margin-bottom: 2px; }
.trace-empty { color: var(--muted); font-style: italic; font-size: 14px; }

.rule-based-disclosure {
  background: var(--light);
  border-left: 3px solid var(--muted);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.rule-based-disclosure strong { color: var(--text); }

/* MONTE CARLO */
.mc h2 { color: var(--navy); }
.mc-caption { color: var(--muted); max-width: 760px; }
.mc-chart-wrapper {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
}
#mc-chart { display: block; width: 100%; height: auto; max-width: 720px; margin: 0 auto; }
.mc-runs-note { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* EQUATION */
.equation { padding: 24px 0; }
.equation summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  color: var(--blue);
  padding: 8px 0;
}
.equation-body {
  margin-top: 14px;
  padding: 18px 20px;
  background: var(--light);
  border-radius: 12px;
}
.equation-body p { margin: 10px 0; }
.equation-body p:first-child { margin-top: 0; }

/* STEELMAN — explicit traditional model bullets + closing rule */
.steelman-model {
  margin: 8px 0 18px;
  padding-left: 22px;
  max-width: 740px;
  color: var(--text);
}
.steelman-model li {
  margin-bottom: 6px;
  line-height: 1.5;
}
.steelman-rule {
  margin-top: 18px;
  font-weight: 700;
  color: var(--blue);
}

/* PIVOT — closed-loop frame */
.pivot-loop {
  display: block;
  max-width: 720px;
  margin: 8px auto 18px;
  text-align: left;
}
.pivot-callout {
  font-size: 19px;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 24px;
}
.pivot-callout em { color: var(--teal); font-style: italic; font-weight: 700; }

/* CONTROLS */
.controls h2 { color: var(--navy); }
.controls-sub {
  color: var(--muted);
  max-width: 760px;
  font-size: 16px;
  margin-bottom: 22px;
}

.controls-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.controls-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 18px 18px;
  margin: 0;
  background: white;
}
.controls-group-traditional { background: var(--static-tint); border-color: var(--static-border); }
.controls-group-agentic { background: var(--agent-tint); border-color: var(--agent-border); }

.controls-group legend {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 8px;
  margin-left: -4px;
}
.controls-group-traditional legend { color: var(--red); }
.controls-group-agentic legend { color: var(--blue); }

.control-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: start;
  padding: 10px 4px;
  min-height: 44px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
}
.control-row:last-child { border-bottom: 0; }
.control-row:hover { background: rgba(255, 255, 255, 0.5); border-radius: 8px; }

.control-row input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1 / span 2;
  margin: 4px 0 0;
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  cursor: pointer;
  flex-shrink: 0;
}
.control-row .control-label-text {
  grid-column: 2;
  grid-row: 1;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  line-height: 1.35;
}
.control-row .control-paren {
  grid-column: 2;
  grid-row: 2;
  display: block;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

.controls-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

#controls-reset {
  background: var(--teal);
  color: white;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease;
}
#controls-reset:hover { filter: brightness(0.95); }
#controls-reset:active { transform: translateY(1px); }

#detection-signal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.signal-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.signal-pill-logged {
  background: var(--light);
  color: var(--muted);
  border-color: var(--line);
}
.signal-pill-flagged {
  background: #fff4db;
  color: var(--amber);
  border-color: #f0d68a;
}

.controls-trace {
  margin-bottom: 14px;
}

.controls-caption {
  font-style: italic;
  color: var(--muted);
  font-size: 15px;
  margin: 6px 0 0;
  transition: opacity 0.2s ease;
}

/* Two-column toggle layout above 720px */
@media (min-width: 720px) {
  .controls-panel {
    grid-template-columns: 1fr 1fr;
    gap: 22px;
  }
}

/* EQUATION — extended */
.equation-lede {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  background: var(--light);
  border-left: 4px solid var(--teal);
  padding: 14px 18px;
  border-radius: 0 12px 12px 0;
  max-width: 760px;
  margin: 0 0 12px;
}
.equation-vars,
.equation-stress {
  margin: 8px 0 14px;
  padding-left: 22px;
}
.equation-vars li,
.equation-stress li {
  margin-bottom: 4px;
  font-size: 15px;
  line-height: 1.5;
}
.equation-shift {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--mint);
  border-left: 3px solid var(--teal);
  border-radius: 0 10px 10px 0;
  color: var(--blue);
  font-size: 15px;
}
.equation-shift em { font-style: italic; font-weight: 600; }

/* SOURCE */
.source { padding-top: 36px; }
.closing-line {
  font-size: clamp(18px, 2.4vw, 22px);
  background: var(--navy);
  color: white;
  padding: 22px 26px;
  border-radius: 14px;
  text-align: center;
  margin: 0 0 12px;
  line-height: 1.4;
}
.source hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.source p { color: var(--muted); }
.source p strong { color: var(--text); }
.reproduce { font-size: 14px; }

/* MOBILE */
@media (max-width: 720px) {
  body { font-size: 16px; }
  main { padding: 18px 16px 60px; }
  section { padding: 28px 0; }
  .pivot { padding: 36px 0; }
  .steelman { padding: 22px 18px; }
  .trace-columns { grid-template-columns: 1fr; }
  .thesis { font-size: 17px; padding: 14px 16px; }
  .closing-line { padding: 16px 18px; }
  .trace-live-controls {
    border-left: 0;
    padding-left: 0;
    width: 100%;
    border-top: 1px solid var(--line);
    padding-top: 10px;
    margin-top: 6px;
  }

  /* Controls panel: ensure single-column stack and 44px tap targets */
  .controls-panel { grid-template-columns: 1fr; gap: 14px; }
  .controls-group { padding: 12px 14px 14px; }
  .control-row { padding: 12px 4px; min-height: 48px; }
  .control-row .control-label-text { font-size: 15px; }
  .control-row .control-paren { font-size: 13px; }
  #detection-signal { width: 100%; }
  .equation-lede { font-size: 16px; padding: 12px 14px; }
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .trace-step { transition: none; }
}

/* PIVOT — curl-question list (manifesto §28 alignment) */
.pivot-questions {
  list-style: none;
  padding: 0;
  margin: 14px auto 18px;
  max-width: 640px;
  text-align: left;
  color: var(--text);
}
.pivot-questions li {
  padding: 8px 12px;
  margin: 6px 0;
  border-left: 2px solid var(--teal);
  background: var(--light);
  border-radius: 0 8px 8px 0;
  font-size: 15px;
  line-height: 1.5;
}
.pivot-questions li code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--mint);
  padding: 1px 5px;
  border-radius: 3px;
}

/* EQUATION — KaTeX display-math blocks */
.equation-block {
  margin: 12px 0;
  padding: 6px 0;
  text-align: center;
  overflow-x: auto;
}
.equation-block .katex-display {
  margin: 0;
}
.equation-intro {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.equation-h {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  margin: 22px 0 8px;
  letter-spacing: 0.01em;
}
.equation-h:first-of-type {
  margin-top: 6px;
}

/* SOURCE — manifesto link */
.manifesto-link {
  font-size: 14px;
  margin-top: 6px;
}
.manifesto-link a {
  color: var(--blue);
  font-weight: 600;
}

@media (max-width: 720px) {
  .pivot-questions { font-size: 14px; }
  .pivot-questions li { padding: 8px 10px; }
  .equation-block { font-size: 14px; padding: 4px 0; }
}
