:root {
  --background: #faf9f6;
  --surface: #ffffff;
  --text: #202124;
  --muted: #64676c;
  --border: #d9d8d4;
  --link: #1857a4;
  --summary: #45484c;
  --on-solid: #ffffff;
  --arrow: #777777;
  --success: #397342;
  --table-head: #f1f0ec;
  --hover-border: #92918d;
  --code-background: #efeeea;
  --code-text: #323438;
  --pre-background: #282a2d;
  --pre-text: #f1f1ef;
  --callout-background: #eef3f8;
  --callout-border: #4778a8;
  --warning-background: #f6f0df;
  --warning-border: #a97c1d;
  --pass-background: #e6f1e8;
  --pass-text: #285d31;
  --pending-background: #f4ecd6;
  --pending-text: #725514;
  --blocked-background: #efe6e5;
  --blocked-text: #7a342d;
  --max-width: 860px;
}

html[data-theme="dark"] {
  --background: #151617;
  --surface: #1d1f21;
  --text: #ecebe7;
  --muted: #a8aaad;
  --border: #35383b;
  --link: #8db9ee;
  --summary: #c6c7c8;
  --on-solid: #151617;
  --arrow: #8f9295;
  --success: #82c58a;
  --table-head: #24272a;
  --hover-border: #707479;
  --code-background: #292c2f;
  --code-text: #e4e3df;
  --pre-background: #0f1011;
  --pre-text: #f1f1ef;
  --callout-background: #1b2935;
  --callout-border: #6f9fce;
  --warning-background: #302a1d;
  --warning-border: #c49a43;
  --pass-background: #1f3525;
  --pass-text: #9ed5a5;
  --pending-background: #3a311c;
  --pending-text: #e1c67b;
  --blocked-background: #382523;
  --blocked-text: #e0a09a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 160ms ease, color 160ms ease;
}

a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 12px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); }

header,
main,
footer {
  width: min(calc(100% - 40px), var(--max-width));
  margin-inline: auto;
}

header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.wordmark { color: var(--text); font-weight: 750; letter-spacing: .08em; text-decoration: none; }
nav { display: flex; gap: 22px; }
nav a { color: var(--muted); font-size: .88rem; text-decoration: none; }
nav a:hover { color: var(--text); }
nav a[aria-current="page"] { color: var(--text); font-weight: 650; }
.header-controls { display: flex; align-items: center; gap: 18px; }
.theme-toggle { padding: 5px 0; display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .76rem; cursor: pointer; }
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--link); outline-offset: 4px; border-radius: 3px; }
.theme-toggle-track { width: 30px; height: 17px; padding: 2px; display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); transition: border-color 160ms ease, background-color 160ms ease; }
.theme-toggle-track span { width: 11px; height: 11px; display: block; border-radius: 50%; background: var(--muted); transition: transform 160ms ease, background-color 160ms ease; }
html[data-theme="dark"] .theme-toggle-track span { transform: translateX(13px); background: var(--text); }

section { padding: 68px 0; border-bottom: 1px solid var(--border); }
.intro { padding-top: 88px; }
.label { margin: 0 0 14px; color: var(--muted); font-size: .78rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
h1 { max-width: 820px; margin: 0; font-size: clamp(2.5rem, 6vw, 4.3rem); line-height: 1.08; letter-spacing: -.04em; font-weight: 720; }
h2 { margin: 0 0 22px; font-size: clamp(1.65rem, 3vw, 2.25rem); line-height: 1.2; letter-spacing: -.025em; }
h3 { margin: 0 0 12px; font-size: 1rem; }
p { max-width: 760px; margin: 0 0 18px; }
.summary { margin-top: 27px; color: var(--summary); font-size: 1.2rem; line-height: 1.6; }
.byline { margin: 16px 0 0; color: var(--muted); font-size: .88rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 30px 0 18px; }
.actions a { padding: 9px 14px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); font-size: .9rem; font-weight: 600; text-decoration: none; }
.actions .primary { border-color: var(--text); background: var(--text); color: var(--on-solid); }
.note { color: var(--muted); font-size: .86rem; }

.diagram { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 11px; margin: 34px 0; }
.diagram div { min-height: 112px; padding: 18px 15px; display: flex; flex-direction: column; justify-content: center; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; text-align: center; }
.diagram strong { font-size: .9rem; }
.diagram span { margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.diagram b { color: var(--arrow); font-weight: 400; }

.checklist { margin: 0; padding: 0; list-style: none; }
.checklist li { padding: 14px 0 14px 27px; border-top: 1px solid var(--border); position: relative; }
.checklist li:last-child { border-bottom: 1px solid var(--border); }
.checklist li::before { content: "✓"; position: absolute; left: 2px; color: var(--success); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
th, td { padding: 14px 16px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--table-head); font-size: .78rem; letter-spacing: .03em; }
td:first-child { width: 34%; font-weight: 600; }
#results .note { margin-top: 18px; }

.boundaries { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.boundaries > div { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.boundaries ul { margin: 0; padding-left: 20px; }
.boundaries li { margin: 7px 0; font-size: .9rem; }

.documents { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.documents a { padding: 16px 18px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; color: var(--text); text-decoration: none; }
.documents a:hover { border-color: var(--hover-border); }
.documents strong { font-size: .92rem; }
.documents span { color: var(--muted); font-size: .78rem; }
.run-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 28px 0; }
.run-grid > div { min-width: 0; }
.command-block { height: calc(100% - 34px); margin: 0; padding: 18px 20px; overflow-x: auto; background: var(--pre-background); border-radius: 5px; color: var(--pre-text); font-size: .72rem; line-height: 1.6; }
.command-block code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.milestones { margin: 0; padding: 0; list-style: none; counter-reset: milestones; }
.milestones li { padding: 15px 0 15px 42px; border-top: 1px solid var(--border); position: relative; counter-increment: milestones; }
.milestones li:last-child { border-bottom: 1px solid var(--border); }
.milestones li::before { content: counter(milestones, decimal-leading-zero); position: absolute; left: 2px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .05em; }
.author-section { border-bottom: 0; }

/* Documentation */
.docs-shell { width: min(calc(100% - 40px), 1160px); }
.docs-intro { padding: 74px 0 52px; }
.docs-intro h1 { max-width: 1000px; font-size: clamp(2.35rem, 5vw, 3.85rem); }
.docs-intro .summary { max-width: 900px; }
.status-grid { padding: 0 0 44px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.status-grid > div { min-height: 128px; padding: 18px; display: flex; flex-direction: column; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.status-grid strong { margin-top: auto; font-size: .92rem; }
.status-grid small { color: var(--muted); font-size: .72rem; line-height: 1.4; }
.status { width: fit-content; padding: 2px 7px; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.status.pass { background: var(--pass-background); color: var(--pass-text); }
.status.pending { background: var(--pending-background); color: var(--pending-text); }
.status.blocked { background: var(--blocked-background); color: var(--blocked-text); }

.docs-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 58px; align-items: start; }
.toc { position: sticky; top: 24px; padding: 24px 0; display: flex; flex-direction: column; gap: 8px; }
.toc strong { margin-bottom: 5px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.toc a { color: var(--muted); font-size: .77rem; text-decoration: none; }
.toc a:hover { color: var(--text); }
.docs-content { min-width: 0; }
.docs-content section { padding: 58px 0; scroll-margin-top: 20px; }
.docs-content section:first-child { padding-top: 24px; }
.docs-content h2 { max-width: 760px; }
.docs-content h3 { margin-top: 28px; font-size: 1.05rem; }
.docs-content p, .docs-content li { font-size: .96rem; }
.docs-content code { padding: .08em .28em; background: var(--code-background); border-radius: 3px; color: var(--code-text); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .83em; }
.docs-content pre { margin: 26px 0; padding: 18px 20px; overflow-x: auto; background: var(--pre-background); border-radius: 5px; color: var(--pre-text); line-height: 1.55; }
.docs-content pre code { padding: 0; background: transparent; color: inherit; font-size: .78rem; }
.eyebrow { margin-bottom: 9px; color: var(--muted); font-size: .7rem !important; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.docs-diagram { margin-top: 30px; }
.split-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 26px 0; }
.split-notes > div { padding: 20px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.split-notes h3 { margin-top: 0; }
.split-notes ol, .split-notes ul { margin: 0; padding-left: 20px; }
.split-notes li { margin: 7px 0; }
.state-flow { margin: 28px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.state-flow span { padding: 6px 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; font-size: .7rem; font-weight: 700; }
.state-flow b { color: var(--muted); font-weight: 400; }
.callout { max-width: none; margin: 26px 0 0; padding: 16px 18px; background: var(--callout-background); border-left: 3px solid var(--callout-border); font-size: .86rem !important; }
.callout.warning { background: var(--warning-background); border-left-color: var(--warning-border); }
.source-note { max-width: none; padding: 14px 0 0; color: var(--muted); font-size: .8rem !important; }
.evidence-table .status { display: inline-block; margin-right: 5px; vertical-align: 1px; }
.compact-table table { max-width: 680px; }
.case-study { margin: 14px 0; padding: 20px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.case-study h3 { margin-top: 0; }
.case-study dl { margin: 0; display: grid; grid-template-columns: 125px 1fr; gap: 9px 16px; }
.case-study dt { color: var(--muted); font-size: .76rem; font-weight: 700; }
.case-study dd { margin: 0; font-size: .86rem; }
footer { min-height: 100px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 22px; color: var(--muted); font-size: .78rem; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  header { height: auto; min-height: 68px; }
  nav { gap: 12px; }
  nav a { font-size: .76rem; }
  nav a[href^="#"] { display: none; }
  section { padding: 52px 0; }
  .intro { padding-top: 62px; }
  .diagram { grid-template-columns: 1fr; }
  .diagram b { transform: rotate(90deg); }
  .diagram div { min-height: 88px; }
  .boundaries, .documents, .run-grid { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .docs-layout { grid-template-columns: 1fr; gap: 0; }
  .toc { position: static; padding: 24px 0; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
  .toc strong { grid-column: 1 / -1; }
  .docs-content section:first-child { padding-top: 48px; }
  .split-notes { grid-template-columns: 1fr; }
  .case-study dl { grid-template-columns: 1fr; gap: 3px; }
  .case-study dd { margin-bottom: 10px; }
  footer { padding: 26px 0; grid-template-columns: 1fr; gap: 5px; }
}

@media (max-width: 430px) {
  header, main, footer, .docs-shell { width: min(calc(100% - 28px), var(--max-width)); }
  nav a[href="/"] { display: none; }
  nav a[href^="https://github.com"] { display: none; }
  .status-grid { grid-template-columns: 1fr; }
  .toc { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .theme-toggle-track, .theme-toggle-track span { transition: none; }
}
