:root {
  --paper: #f7f7f4;
  --surface: #ffffff;
  --surface-subtle: #f0f2f1;
  --ink: #202526;
  --muted: #596568;
  --quiet: #758084;
  --line: #d4dad8;
  --line-strong: #879497;
  --state: #2f705c;
  --state-dark: #245544;
  --state-soft: #eaf3ef;
  --block: #35657d;
  --block-dark: #294e61;
  --block-soft: #edf3f6;
  --warm: #886a2e;
  --warm-soft: #f6f1e5;
  --alert: #a24d42;
  --alert-soft: #faefed;
  --code-bg: #202728;
  --code-ink: #edf2f1;
  --body-font: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --ui-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --page-width: 1260px;
  --measure: 72ch;
  --shadow: 0 12px 30px rgba(31, 42, 42, 0.09);
}

:root[data-theme="modern"] {
  --paper: #f8f8f6;
  --surface: #ffffff;
  --surface-subtle: #f1f3f2;
  --ink: #212827;
  --muted: #5b6663;
  --line: #d6dcd8;
  --state: #34745c;
  --state-soft: #edf5f0;
  --block: #3d6478;
  --block-soft: #eef3f5;
  --body-font: var(--ui-font);
}

:root[data-theme="bold"] {
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f1f1ee;
  --ink: #101414;
  --muted: #374143;
  --quiet: #4c5759;
  --line: #8b9494;
  --line-strong: #303a3b;
  --state: #176247;
  --state-dark: #104b36;
  --state-soft: #e2f2ea;
  --block: #1c5875;
  --block-dark: #143f54;
  --block-soft: #e3eff5;
  --warm: #72520a;
  --alert: #8d2f27;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body-font);
  font-size: 17px;
  line-height: 1.66;
  letter-spacing: 0;
}

a {
  color: var(--block-dark);
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

button,
input,
select {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--warm);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 14px;
  top: -64px;
  z-index: 100;
  padding: 8px 12px;
  color: #ffffff;
  background: var(--ink);
  font-family: var(--ui-font);
  font-size: 14px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(12px);
}

.header-inner {
  width: min(var(--page-width), calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 26px;
  font-family: var(--ui-font);
}

.brand {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand-word {
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
}

.brand-subtitle {
  color: var(--quiet);
  font-size: 12px;
  font-weight: 550;
}

.top-nav {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.top-nav a[aria-current="page"],
.top-nav a:hover {
  color: var(--ink);
}

.top-nav a[aria-current="page"] {
  box-shadow: inset 0 -2px var(--ink);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-shell {
  position: relative;
}

.global-search {
  width: 196px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--ui-font);
  font-size: 13px;
}

.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 9px);
  width: min(520px, calc(100vw - 32px));
  max-height: 68vh;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-family: var(--ui-font);
}

.search-results[hidden] {
  display: none;
}

.search-results a {
  display: block;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.search-results a:last-child {
  border-bottom: 0;
}

.search-results small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.mobile-menu {
  display: none;
  font-family: var(--ui-font);
  font-size: 20px;
}

.theme-switcher {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  font-family: var(--ui-font);
}

.theme-switcher button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 6px 8px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
}

.theme-switcher button:last-child {
  border-right: 0;
}

.theme-switcher button[aria-pressed="true"] {
  color: #ffffff;
  background: var(--ink);
}

.verification-strip {
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  font-family: var(--ui-font);
}

.verification-inner {
  width: min(var(--page-width), calc(100% - 40px));
  min-height: 34px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.verification-inner strong {
  color: var(--state-dark);
}

.page-shell {
  width: min(var(--page-width), calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 64px;
  padding: 54px 0 88px;
}

.page-shell.no-toc {
  grid-template-columns: minmax(0, 1fr);
}

main {
  min-width: 0;
}

.toc {
  position: sticky;
  top: 118px;
  align-self: start;
  max-height: calc(100vh - 144px);
  overflow: auto;
  border-left: 1px solid var(--line);
  padding-left: 18px;
  font-family: var(--ui-font);
}

.toc strong {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 12px;
}

.toc a {
  display: block;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-decoration: none;
}

.toc a:hover {
  color: var(--ink);
}

.eyebrow,
.path-label,
.chapter-number,
.result-grid dt,
.result-notes dt,
.proof-steps th,
.data-table th {
  font-family: var(--ui-font);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--warm);
  font-size: 12px;
  font-weight: 750;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--ink);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  max-width: 920px;
  margin-bottom: 20px;
  font-size: 44px;
}

h2 {
  margin-bottom: 16px;
  font-size: 29px;
}

h3 {
  margin-bottom: 10px;
  font-size: 21px;
}

h4 {
  margin-bottom: 7px;
  font-size: 17px;
}

p,
li,
dd {
  max-width: var(--measure);
}

.lede {
  max-width: 760px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
}

.hero {
  padding: 12px 0 50px;
  border-bottom: 1px solid var(--line);
}

.home-hero {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-hero h1 {
  font-size: 50px;
  overflow-wrap: anywhere;
}

.application-hero {
  position: relative;
  padding-right: min(36%, 390px);
}

.application-hero::after {
  position: absolute;
  right: 0;
  top: 22px;
  width: min(31%, 340px);
  height: 150px;
  border-top: 4px solid var(--state);
  border-bottom: 1px solid var(--line);
  content: "";
}

.block-hero::after {
  border-top-color: var(--block);
}

.hero-contract {
  width: min(560px, 100%);
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  font-size: 18px;
}

.hero-actions,
.link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 24px;
  font-family: var(--ui-font);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ink);
  border-radius: 3px;
  padding: 8px 14px;
  color: #ffffff;
  background: var(--ink);
  font-family: var(--ui-font);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  color: #ffffff;
  background: var(--alert);
  border-color: var(--alert);
}

.state-button {
  border-color: var(--state);
  background: var(--state);
}

.block-button {
  border-color: var(--block);
  background: var(--block);
}

.button.secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line-strong);
}

.button.secondary:hover {
  color: var(--alert);
  background: var(--surface);
  border-color: var(--alert);
}

.text-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 8px 2px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.content-section {
  padding: 52px 0;
  border-bottom: 1px solid var(--line);
}

.content-section:last-child {
  border-bottom: 0;
}

.section-heading {
  max-width: 790px;
  margin-bottom: 26px;
}

.section-heading > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}

.application-paths {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 34px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.application-path {
  min-width: 0;
  padding: 30px 34px 32px 0;
  border-top: 4px solid var(--state);
}

.application-path + .application-path {
  border-top-color: var(--block);
  border-left: 1px solid var(--line);
  padding-right: 0;
  padding-left: 34px;
}

.path-label {
  margin: 0 0 8px;
  color: var(--state-dark);
  font-size: 12px;
  font-weight: 750;
}

.block-path .path-label {
  color: var(--block-dark);
}

.application-path h3 {
  font-size: 27px;
}

.application-path p {
  color: var(--muted);
}

.application-path > a {
  font-family: var(--ui-font);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.contract-equation {
  margin: 20px 0 16px;
  font-size: 18px;
}

.use-paths {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.use-paths article {
  min-width: 0;
  padding: 24px 26px 26px 0;
}

.use-paths article + article {
  padding-left: 26px;
  border-left: 1px solid var(--line);
}

.use-paths span {
  color: var(--state-dark);
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.use-paths h3 {
  margin: 9px 0 8px;
  font-size: 20px;
}

.use-paths p {
  color: var(--muted);
}

.use-paths a {
  font-family: var(--ui-font);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.milestone-list {
  max-width: 850px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-strong);
}

.milestone-list li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 28px;
  padding: 19px 0;
  border-bottom: 1px solid var(--line);
}

.milestone-list time {
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 700;
}

.milestone-list p {
  margin: 4px 0 0;
  color: var(--muted);
}

.process-section .diagram-panel {
  border-top-width: 3px;
}

.state-section .diagram-panel {
  border-top-color: var(--state);
}

.block-section .diagram-panel {
  border-top-color: var(--block);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 28px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 26px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 20px 18px 20px 0;
  border-right: 1px solid var(--line);
}

.metric + .metric {
  padding-left: 18px;
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 27px;
  font-weight: 650;
}

.metric span {
  display: block;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 12px;
  line-height: 1.45;
}

.evidence-note {
  max-width: 850px;
  color: var(--muted);
}

.diagram-panel {
  overflow: auto;
  margin: 28px 0 8px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  padding: 18px 0 24px;
  background: transparent;
}

.diagram-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 12px;
}

.diagram-toolbar strong {
  color: var(--ink);
  font-weight: 650;
}

.mermaid {
  min-width: 720px;
  padding: 4px 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--ui-font);
  text-align: center;
}

.reading-tracks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 42px 48px;
}

.reading-track h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 750;
}

.chapter-list {
  border-top: 1px solid var(--line-strong);
}

.chapter-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  align-items: start;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.chapter-number {
  color: var(--quiet);
  font-size: 12px;
  font-weight: 700;
}

.chapter-copy {
  min-width: 0;
}

.chapter-copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
  line-height: 1.3;
}

.chapter-copy > span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.chapter-arrow {
  color: var(--quiet);
  font-family: var(--ui-font);
}

.chapter-link:hover,
.chapter-link:hover .chapter-copy > span {
  color: var(--alert);
}

.gate-example-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin: 30px 0 8px;
}

.gate-example {
  min-width: 0;
  border: 1px solid var(--line);
  border-top: 3px solid var(--state);
  border-radius: 4px;
  padding: 24px;
  background: var(--surface);
}

.x-example {
  border-top-color: var(--warm);
}

.gate-example h3 {
  margin-top: 22px;
  font-size: 19px;
}

.gate-example p {
  margin-bottom: 0;
  color: var(--muted);
}

.example-math {
  overflow-x: auto;
  font-size: 17px;
}

.wire {
  position: relative;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto 52px auto;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-family: var(--ui-font);
}

.wire::before {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 1px;
  background: var(--ink);
  content: "";
}

.wire span,
.wire b {
  position: relative;
  z-index: 1;
  background: var(--surface);
}

.wire span {
  padding: 0 5px;
}

.wire b {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  font-size: 16px;
}

.concept-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 28px;
  margin: 30px 0;
}

.block-concepts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.concept-list > div {
  padding: 17px 0 20px;
  border-top: 2px solid var(--state);
}

.block-concepts > div {
  border-top-color: var(--block);
}

.concept-list dt {
  margin-bottom: 5px;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 15px;
  font-weight: 750;
}

.concept-list dd {
  margin: 0;
  color: var(--muted);
}

.module-list {
  max-width: 820px;
  margin-top: 24px;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 13px;
}

.module-list summary,
.source-panel summary {
  cursor: pointer;
  color: var(--block-dark);
  font-family: var(--ui-font);
  font-weight: 700;
}

.textbook-lesson {
  border-top: 1px solid var(--line-strong);
}

.lesson-opening {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.8fr);
  gap: 52px;
  align-items: start;
}

.lesson-opening h2 {
  max-width: 18ch;
}

.lesson-lead {
  max-width: var(--measure);
  color: var(--muted);
  font-size: 20px;
  line-height: 1.55;
}

.lesson-objectives {
  border-left: 3px solid var(--state);
  padding: 2px 0 2px 22px;
}

.lesson-objectives h3 {
  margin: 0 0 10px;
  font-family: var(--ui-font);
  font-size: 15px;
}

.lesson-objectives ul {
  margin: 0;
  padding-left: 19px;
  color: var(--muted);
}

.lesson-steps {
  margin-top: 48px;
  border-top: 1px solid var(--line-strong);
}

.lesson-step {
  display: grid;
  grid-template-columns: minmax(150px, 0.55fr) minmax(250px, 1fr) minmax(270px, 1.25fr);
  gap: 30px;
  align-items: center;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.lesson-step h3 {
  margin: 0;
  font-size: 19px;
}

.lesson-step p {
  margin: 0;
  color: var(--muted);
}

.lesson-equation {
  min-width: 0;
  overflow-x: auto;
  color: var(--ink);
  font-size: 17px;
}

.lesson-checkpoint {
  margin-top: 30px;
  border-left: 3px solid var(--warm);
  padding: 4px 0 4px 20px;
}

.lesson-checkpoint strong {
  font-family: var(--ui-font);
  font-size: 14px;
}

.lesson-checkpoint p,
.source-note {
  margin-bottom: 0;
  color: var(--muted);
}

.source-note {
  margin-top: 24px;
  font-family: var(--ui-font);
  font-size: 13px;
}

.status {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 2px 7px;
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-compiled,
.status-lean-certified {
  color: var(--state-dark);
  background: var(--state-soft);
}

.status-partial-route,
.status-experimental {
  color: var(--warm);
  background: var(--warm-soft);
}

.status-planned {
  color: var(--block-dark);
  background: var(--block-soft);
}

.status-stated-proof-incomplete,
.status-blocked {
  color: var(--alert);
  background: var(--alert-soft);
}

.result {
  margin-top: 52px;
  padding-top: 30px;
  border-top: 2px solid var(--line-strong);
  scroll-margin-top: 118px;
}

.result:first-of-type {
  margin-top: 34px;
}

.result-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 28px;
}

.result-header h3 {
  margin-bottom: 8px;
  font-size: 25px;
}

.declaration-name {
  display: inline-block;
  max-width: 760px;
  color: var(--muted);
}

.status-pair {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 12px;
  font-family: var(--ui-font);
}

.status-pair > span {
  display: grid;
  gap: 3px;
}

.status-pair small {
  color: var(--quiet);
  font-size: 10px;
}

.math-block {
  overflow-x: auto;
  margin: 24px 0;
  border-left: 3px solid var(--state);
  padding: 12px 20px;
  background: var(--surface-subtle);
}

.result-story {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin: 28px 0 24px;
}

.result-story section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.result-story h4 {
  font-family: var(--ui-font);
  font-size: 14px;
}

.result-story p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.result-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin: 24px 0 30px;
}

.result-notes > div {
  padding: 14px 16px;
  background: var(--surface-subtle);
}

.result-notes dt {
  margin-bottom: 4px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 750;
}

.result-notes dd {
  margin: 0;
  font-size: 15px;
}

.proof-heading {
  margin-top: 30px;
  font-family: var(--ui-font);
}

.proof-steps {
  width: 100%;
  border-collapse: collapse;
}

.proof-steps th,
.proof-steps td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

.proof-steps th {
  color: var(--quiet);
  font-size: 11px;
}

.proof-steps td {
  font-size: 15px;
}

.source-panel {
  margin-top: 20px;
}

.paper-correspondence .declaration-list {
  display: grid;
  gap: 8px;
  padding-left: 20px;
}

.paper-correspondence .declaration-list a {
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

.paper-reading {
  max-width: 850px;
}

.paper-latex {
  border-left: 3px solid var(--warm);
  padding-left: 16px;
}

pre {
  overflow: auto;
  border-radius: 3px;
  padding: 17px;
  color: var(--code-ink);
  background: var(--code-bg);
  font-family: var(--mono-font);
  font-size: 13px;
  line-height: 1.52;
  tab-size: 2;
}

code {
  overflow-wrap: anywhere;
  font-family: var(--mono-font);
  font-size: 0.9em;
}

.map-groups,
.map-group + .map-group {
  padding-top: 34px;
}

.map-group + .map-group {
  margin-top: 28px;
  border-top: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.data-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink);
  background: var(--surface-subtle);
  font-size: 11px;
  font-weight: 750;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 180px));
  gap: 10px;
  margin: 24px 0;
  font-family: var(--ui-font);
}

.filter-bar input,
.filter-bar select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
}

.declaration-list {
  border-top: 1px solid var(--line-strong);
}

.declaration-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.declaration-row h3 {
  margin: 0 0 5px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.declaration-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.module-declaration {
  scroll-margin-top: 118px;
}

.module-declaration + .module-declaration {
  margin-top: 32px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.callout {
  max-width: 880px;
  margin: 24px 0;
  border-left: 3px solid var(--warm);
  padding: 15px 19px;
  background: var(--warm-soft);
}

.workflow-list {
  counter-reset: stage;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
  margin: 26px 0;
}

.workflow-step {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.workflow-step h3 {
  font-family: var(--ui-font);
  font-size: 17px;
}

.workflow-step p {
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  min-height: 116px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--line);
  padding: 34px max(20px, calc((100% - var(--page-width)) / 2));
  color: var(--muted);
  background: var(--surface);
  font-family: var(--ui-font);
  font-size: 12px;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px 18px;
}

.footer-provenance {
  display: grid;
  max-width: 700px;
  gap: 7px;
  line-height: 1.55;
}

.footer-provenance code {
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.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 (max-width: 1180px) {
  .top-nav {
    display: none;
    position: absolute;
    left: 20px;
    right: 20px;
    top: 64px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    padding: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .top-nav a {
    padding: 9px 6px;
  }

  .top-nav a[aria-current="page"] {
    box-shadow: none;
  }

  .top-nav.is-open {
    display: flex;
  }

  .mobile-menu {
    display: grid;
  }

  .header-inner {
    grid-template-columns: auto 1fr auto;
  }

  .search-shell {
    display: none;
  }
}

@media (max-width: 960px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .application-hero {
    padding-right: 0;
  }

  .application-hero::after {
    display: none;
  }

  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-strip .metric:nth-child(3) {
    border-right: 0;
  }

  .metric-strip .metric:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }

  .result-story {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 16px;
  }

  .header-inner,
  .verification-inner,
  .page-shell {
    width: min(100% - 24px, var(--page-width));
  }

  .brand {
    grid-template-columns: auto;
    gap: 0;
  }

  .brand-subtitle,
  .theme-switcher {
    display: none;
  }

  .verification-inner {
    min-height: 42px;
    flex-wrap: wrap;
    gap: 2px 12px;
    padding: 6px 0;
  }

  .verification-inner span:nth-of-type(2) {
    display: none;
  }

  .page-shell {
    padding: 34px 0 64px;
  }

  h1,
  .home-hero h1 {
    font-size: 31px;
  }

  h2 {
    font-size: 25px;
  }

  .lede {
    font-size: 18px;
  }

  .home-hero {
    min-height: 0;
  }

  .hero {
    padding-bottom: 38px;
  }

  .content-section {
    padding: 40px 0;
  }

  .application-paths,
  .gate-example-grid,
  .reading-tracks,
  .concept-list,
  .block-concepts,
  .lesson-opening,
  .lesson-step,
  .result-notes,
  .workflow-list,
  .metric-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .lesson-opening,
  .lesson-step {
    gap: 18px;
  }

  .lesson-step {
    align-items: start;
  }

  .application-path {
    padding: 24px 0;
  }

  .application-path + .application-path {
    border-left: 0;
    border-top: 4px solid var(--block);
    padding-left: 0;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-strip .metric:nth-child(2n) {
    border-right: 0;
  }

  .metric-strip .metric:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .metric {
    padding: 16px 12px 16px 0;
  }

  .metric + .metric {
    padding-left: 12px;
  }

  .result-header {
    flex-direction: column;
  }

  .status-pair {
    justify-content: start;
  }

  .filter-bar,
  .declaration-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .diagram-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .diagram-panel {
    margin-right: 0;
    padding-right: 0;
    overflow: visible;
  }

  .mermaid {
    min-width: 0;
  }

  .mermaid svg {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
  }

  .site-footer {
    flex-direction: column;
    padding: 28px 16px 38px;
  }

  .site-footer nav {
    justify-content: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Task Builder is part of the common book shell; all selectors stay scoped. */
.task-builder {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 24px;
  align-items: start;
  margin: 28px 0 56px;
  font-family: var(--ui-font);
}

.builder-panel {
  border-top: 3px solid var(--accent);
  padding-top: 18px;
}

.task-builder label,
.task-builder fieldset,
.task-builder details {
  display: block;
  margin: 0 0 16px;
}

.task-builder label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.task-builder input,
.task-builder select,
.task-builder textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.task-builder textarea {
  min-height: 108px;
  resize: vertical;
}

.task-builder fieldset,
.task-builder details {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.task-builder summary {
  cursor: pointer;
  font-weight: 700;
}

.task-builder .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.task-builder .check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-builder .check-row input {
  width: auto;
  margin: 0;
}

.executable-policy .section-heading {
  margin-bottom: 12px;
}

.backend-options {
  display: grid;
  border-top: 1px solid var(--line);
  margin-bottom: 20px;
}

.task-builder .option-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.task-builder .option-row input {
  width: auto;
  margin-top: 3px;
}

.task-builder .option-row span {
  display: grid;
  gap: 3px;
}

.task-builder .option-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.artifact-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.builder-actions,
.memory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 16px 0;
}

.builder-actions button,
.memory-actions button,
.file-button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font: 650 0.84rem var(--ui-font);
}

.builder-actions .secondary,
.memory-actions .secondary,
.file-button {
  background: transparent;
  color: var(--accent);
}

.file-button input {
  display: none;
}

.task-builder .packet,
.task-builder #dashboardView {
  max-height: 720px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--code-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.case-card {
  min-width: 0;
  padding: 24px 0 28px;
  border-top: 2px solid var(--line-strong);
}

.case-card h2 {
  margin: 5px 0 8px;
  font-size: 1.18rem;
}

.case-card > p:not(.eyebrow) {
  max-width: 60ch;
  color: var(--muted);
}

.case-formula {
  margin: 18px 0;
  overflow-x: auto;
  border-left: 3px solid var(--block);
  background: var(--surface-subtle);
}

.case-formula .math-block {
  min-width: max-content;
  margin: 0;
  padding: 14px 16px;
  font-size: 0.92rem;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font: 0.78rem var(--ui-font);
}

.case-reading-key {
  max-width: 78ch;
}

.case-hero {
  padding-bottom: 42px;
}

.case-status-line {
  max-width: 82ch;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 22px;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 14px;
}

.case-status-line .status {
  flex: 0 0 auto;
}

.case-problem > .math-block {
  margin: 28px 0;
  padding: 24px;
  overflow-x: auto;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-size: 1rem;
}

.contract-reading {
  max-width: 76ch;
  color: var(--ink);
  font-size: 18px;
}

.symbol-key {
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 28px 0 0;
  border-top: 1px solid var(--line);
}

.symbol-key > div {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(90px, 0.34fr) minmax(0, 1fr);
  gap: 14px;
  padding: 13px 18px 13px 0;
  border-bottom: 1px solid var(--line);
}

.symbol-key dt,
.symbol-key dd {
  margin: 0;
}

.symbol-key dd {
  color: var(--muted);
}

.circuit-registers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 20px;
  padding: 12px 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  font-family: var(--ui-font);
  font-size: 13px;
}

.circuit-registers span {
  color: var(--muted);
}

.circuit-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.circuit-stage {
  position: relative;
  min-width: 0;
  min-height: 190px;
  padding: 22px 24px 24px 0;
}

.circuit-stage + .circuit-stage {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.circuit-stage + .circuit-stage::before {
  content: "\2192";
  position: absolute;
  left: -11px;
  top: 38px;
  width: 21px;
  color: var(--block);
  background: var(--paper);
  text-align: center;
  font-family: var(--ui-font);
  font-size: 18px;
}

.stage-index {
  color: var(--quiet);
  font: 700 11px var(--ui-font);
}

.circuit-stage h3 {
  margin: 8px 0 6px;
  font-size: 18px;
}

.circuit-stage p {
  min-height: 48px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}

.gate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gate-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--block) 58%, var(--line));
  border-radius: 3px;
  color: var(--block-dark);
  background: var(--block-soft);
  font: 650 11px var(--ui-font);
}

.figure-caption {
  max-width: 78ch;
  margin: 0 0 26px;
  color: var(--muted);
  font-style: italic;
}

.evolution-track {
  position: relative;
  max-width: 1080px;
  border-top: 1px solid var(--line-strong);
}

.evolution-track::before {
  content: "";
  position: absolute;
  left: 28px;
  top: 28px;
  bottom: 28px;
  width: 1px;
  background: var(--line-strong);
}

.evolution-point {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(230px, 330px);
  gap: 24px;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.iteration-mark {
  position: relative;
  z-index: 1;
  width: 58px;
  height: 58px;
  display: grid;
  place-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  text-align: center;
  font-family: var(--ui-font);
}

.iteration-mark span {
  color: var(--quiet);
  font-size: 8px;
  text-transform: uppercase;
}

.iteration-mark strong {
  color: var(--block-dark);
  font-size: 18px;
}

.evolution-copy {
  min-width: 0;
}

.evolution-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
}

.evolution-heading h3 {
  margin: 0;
  font-size: 19px;
}

.evolution-heading span {
  color: var(--state-dark);
  font: 700 11px var(--ui-font);
  text-transform: uppercase;
}

.evolution-copy > p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 15px;
}

.stage-circuit-visual {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 12px 0;
  overflow-x: auto;
  padding: 10px 0;
  color: var(--quiet);
  font: 600 10px var(--ui-font);
}

.stage-circuit-wire {
  min-width: 18px;
  height: 1px;
  flex: 1 0 18px;
  background: var(--line-strong);
}

.stage-circuit-gate {
  flex: 0 0 auto;
  max-width: 150px;
  padding: 6px 8px;
  border: 1px solid var(--block);
  border-radius: 2px;
  color: var(--block-dark);
  background: var(--block-soft);
  overflow-wrap: anywhere;
  text-align: center;
}

.stage-circuit-input,
.stage-circuit-output {
  flex: 0 0 auto;
  white-space: nowrap;
}

.stage-circuit-render {
  margin: 14px 0 10px;
}

.stage-circuit-canvas,
.circuit-live-preview {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--paper);
}

.stage-circuit-render figcaption {
  margin-top: 6px;
  color: var(--quiet);
  font: 11px/1.45 var(--ui-font);
}

.quantikz-preview {
  display: block;
  width: 100%;
  min-width: 430px;
  height: auto;
  min-height: 104px;
}

.qc-wire,
.qc-control,
.qc-target,
.qc-meter {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.qc-gate {
  fill: var(--block-soft);
  stroke: var(--block-dark);
  stroke-width: 1.4;
}

.qc-control-dot {
  fill: var(--ink);
}

.qc-register,
.qc-output,
.qc-gate-label {
  fill: var(--ink);
  font-family: var(--ui-font);
  font-size: 11px;
  letter-spacing: 0;
}

.qc-gate-label {
  font-size: 10px;
  font-weight: 700;
}

.qc-output {
  fill: var(--muted);
  font-size: 9px;
}

.stage-edit-link {
  display: inline-block;
  margin-top: 9px;
  font-size: 12px;
}

.case-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.case-editor-panel {
  min-width: 0;
  border-top: 2px solid var(--line-strong);
  padding-top: 12px;
}

.circuit-editor-panel {
  grid-column: 1 / -1;
}

.editor-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.editor-panel-heading h3 {
  margin: 0;
  font-size: 17px;
}

.editor-panel-heading button,
.case-editor-panel select {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--ink);
  background: var(--surface);
  font: 650 12px var(--ui-font);
}

.editor-panel-heading button {
  padding: 6px 10px;
  cursor: pointer;
}

.case-editor-panel textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 145px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
  font: 12px/1.55 var(--mono-font);
}

.circuit-editor-panel textarea {
  min-height: 190px;
}

.case-live-preview {
  min-height: 100px;
  margin-top: 10px;
  padding: 14px;
}

.math-preview {
  display: grid;
  align-items: center;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--paper);
}

.proof-preview {
  box-sizing: border-box;
  padding-left: 38px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}

.proof-preview li + li {
  margin-top: 8px;
}

.field-label {
  display: grid;
  grid-template-columns: auto minmax(180px, 360px);
  gap: 10px;
  align-items: center;
  margin-bottom: 9px;
  color: var(--quiet);
  font: 700 11px var(--ui-font);
}

.case-editor-panel select {
  min-height: 34px;
  padding: 5px 8px;
}

.field-note {
  margin: 0 0 8px;
  color: var(--quiet);
  font: 11px/1.45 var(--ui-font);
}

.copy-source-panel {
  min-width: 0;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.copy-source-panel summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--ink);
  font: 700 12px var(--ui-font);
}

.copy-source-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 10px 8px;
}

.copy-source-actions button {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 5px 9px;
  color: var(--ink);
  background: var(--paper);
  font: 650 11px var(--ui-font);
  cursor: pointer;
}

.copy-source-panel pre {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  white-space: pre;
}

.copy-packet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.theorem-root {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-decoration: none;
}

.theorem-root span {
  color: var(--quiet);
  font: 700 9px var(--ui-font);
  text-transform: uppercase;
}

.theorem-root code {
  overflow-wrap: anywhere;
  font-size: 11px;
}

.score-tuple {
  display: grid;
  grid-template-columns: repeat(4, minmax(48px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.score-panel {
  min-width: 0;
}

.score-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 7px 0 0;
  color: var(--muted);
  font: 10px/1.45 var(--ui-font);
}

.score-breakdown strong {
  color: var(--ink);
}

.score-tier {
  margin: 5px 0 0;
  color: var(--quiet);
  font: 10px/1.4 var(--ui-font);
}

.case-score-audit {
  max-width: 1080px;
  margin: 14px 0 20px;
  padding: 12px 14px;
  border-left: 3px solid var(--state);
  background: var(--state-soft);
}

.case-score-audit strong {
  font: 750 12px var(--ui-font);
}

.case-score-audit p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.score-tuple span {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 10px 5px;
}

.score-tuple span + span {
  border-left: 1px solid var(--line);
}

.score-tuple strong {
  color: var(--ink);
  font: 700 18px var(--ui-font);
}

.score-tuple small {
  color: var(--quiet);
  font: 9px var(--ui-font);
}

.score-unranked {
  color: var(--quiet);
  font: 12px var(--ui-font);
  text-align: right;
}

.case-declaration-list {
  max-width: 1080px;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line-strong);
  list-style: none;
}

.case-declaration-list li {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.case-declaration-list code {
  overflow-wrap: anywhere;
}

.case-declaration-list li > span {
  color: var(--quiet);
  font: 11px var(--ui-font);
}

.export-section .definition-list pre {
  margin: 8px 0 0;
}

.example-nav a {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 3px;
  padding-left: 10px;
  font-size: 0.8rem;
  white-space: normal;
}

.example-nav a span:first-child {
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
}

.example-nav a span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .task-builder,
  .case-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 840px) {
  .symbol-key {
    grid-template-columns: minmax(0, 1fr);
  }

  .evolution-point {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 16px;
  }

  .evolution-point > .score-panel,
  .evolution-point > .score-unranked {
    grid-column: 2;
  }

  .score-unranked {
    text-align: left;
  }

  .copy-packet-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .case-editor-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .circuit-editor-panel {
    grid-column: 1;
  }
}

@media (max-width: 560px) {
  .task-builder .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .artifact-options {
    grid-template-columns: minmax(0, 1fr);
  }

  .case-status-line,
  .circuit-registers {
    display: grid;
  }

  .circuit-flow {
    grid-template-columns: minmax(0, 1fr);
  }

  .circuit-stage {
    min-height: 0;
    padding: 20px 0;
  }

  .circuit-stage + .circuit-stage {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .circuit-stage + .circuit-stage::before {
    content: "\2193";
    left: 16px;
    top: -12px;
  }

  .circuit-stage p {
    min-height: 0;
  }

  .evolution-point {
    grid-template-columns: minmax(0, 1fr);
  }

  .evolution-point > .score-panel,
  .evolution-point > .score-unranked {
    grid-column: 1;
  }

  .case-declaration-list li {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }
}

/* QuantumComputinglib book shell --------------------------------------------------- */

:root {
  --sidebar-width: 286px;
  --book-green: #285f4f;
  --book-blue: #315e76;
}

body {
  padding-left: var(--sidebar-width);
}

.site-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  font-family: var(--ui-font);
}

.sidebar-head {
  padding: 26px 24px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head .brand {
  display: block;
  white-space: normal;
}

.sidebar-head .brand-word {
  display: block;
  font-family: var(--body-font);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.05;
  white-space: nowrap;
}

.sidebar-head .brand-subtitle {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar-head p {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.sidebar-head p strong {
  color: var(--state-dark);
  font-size: 13px;
}

.sidebar-search {
  position: relative;
  padding: 16px 18px 8px;
}

.sidebar-search .global-search {
  width: 100%;
  min-height: 36px;
  background: var(--paper);
}

.sidebar-search .search-results {
  position: fixed;
  left: 18px;
  right: auto;
  top: 153px;
  width: min(520px, calc(100vw - 36px));
}

.book-nav {
  display: grid;
  gap: 2px;
  padding: 5px 13px 24px;
}

.book-nav > a,
.chapter-nav a {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 7px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-decoration: none;
}

.book-nav a:hover,
.book-nav a[aria-current="page"] {
  border-left-color: var(--state);
  color: var(--ink);
  background: var(--state-soft);
}

.nav-group-label {
  margin: 18px 10px 5px;
  color: var(--quiet);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.chapter-nav {
  display: grid;
}

.chapter-nav a {
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 3px;
}

.chapter-nav a span {
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px 20px;
  border-top: 1px solid var(--line);
}

.sidebar-footer .theme-switcher {
  width: 100%;
}

.sidebar-footer .theme-switcher button {
  flex: 1;
  min-width: 0;
}

.mobile-header {
  display: none;
}

.verification-inner {
  width: min(var(--page-width), calc(100% - 64px));
}

.page-shell {
  width: min(var(--page-width), calc(100% - 64px));
}

.site-footer {
  padding-left: max(32px, calc((100% - var(--page-width)) / 2));
  padding-right: max(32px, calc((100% - var(--page-width)) / 2));
}

/* Textbook and community pages ------------------------------------------ */

.people-list,
.ecosystem-list {
  border-top: 1px solid var(--line-strong);
}

.person-row,
.ecosystem-list article {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  gap: 30px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.person-row h3,
.person-row p,
.ecosystem-list h3,
.ecosystem-list p {
  margin: 0;
}

.person-row p,
.ecosystem-list p {
  color: var(--muted);
}

.ecosystem-list article {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.ecosystem-list h3 {
  margin-bottom: 5px;
}

.numbered-reading {
  max-width: 78ch;
  padding-left: 1.4em;
}

.numbered-reading li {
  margin: 12px 0;
  padding-left: 8px;
}

.contribution-paths {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.contribution-paths article {
  padding: 24px 24px 24px 0;
}

.contribution-paths article + article {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.contribution-paths article > span {
  color: var(--warm);
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 750;
}

.contribution-paths h3 {
  margin: 10px 0 8px;
}

.status-key {
  display: grid;
  gap: 10px;
}

.status-key p {
  margin: 0;
}

.contributor-steps {
  max-width: 820px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-strong);
}

.contributor-steps li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 18px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.contributor-steps li > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: white;
  background: var(--state-dark);
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 750;
}

.contributor-steps h3,
.contributor-steps p {
  margin-top: 0;
}

.contributor-steps pre {
  max-width: 570px;
}

.contributor-list {
  border-top: 1px solid var(--line-strong);
}

.contributor-record {
  display: grid;
  grid-template-columns: minmax(180px, 0.3fr) minmax(0, 0.45fr) minmax(0, 1fr);
  gap: 26px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.contributor-record h3,
.contributor-record p,
.contributor-record ul {
  margin: 0;
}

.contributor-invitation {
  display: block;
  max-width: 720px;
}

.contributor-invitation h3 {
  margin: 6px 0 8px;
}

/* Live formalization workspace ------------------------------------------ */

.workspace-mode {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 15px 0;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  font-family: var(--ui-font);
}

.workspace-mode p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--warm);
}

.workspace-mode.local .mode-dot {
  background: var(--state);
}

.security-note {
  padding: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace-toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-family: var(--ui-font);
}

.workspace-toolbar > label:first-child {
  min-width: min(100%, 360px);
  flex: 1;
}

.workspace-toolbar > label:nth-child(2) {
  min-width: 170px;
}

.compact-button {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.workspace-toolbar > button {
  flex: 0 0 auto;
}

.workspace-toolbar label,
.submit-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.workspace-toolbar select,
.submit-fields input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--ui-font);
  font-size: 13px;
}

.auto-check {
  display: flex !important;
  align-items: center;
  min-height: 40px;
}

.workspace-grid,
.workspace-output {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

.workspace-output {
  border-top: 0;
}

.workspace-pane {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
}

.workspace-pane > header {
  min-height: 44px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: -18px -18px 16px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  font-family: var(--ui-font);
}

.workspace-pane > header > span {
  color: var(--warm);
  font-size: 11px;
  font-weight: 750;
}

.workspace-pane > header h2 {
  flex: 1;
  margin: 0;
  font-size: 15px;
}

.workspace-pane > header b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.workspace-pane > label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 700;
}

.workspace-pane textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 13px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--mono-font);
  font-size: 13px;
  line-height: 1.55;
}

.lean-pane textarea {
  color: var(--code-ink);
  background: var(--code-bg);
}

.math-preview {
  min-height: 90px;
  display: grid;
  place-items: center;
  overflow-x: auto;
  padding: 18px 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

.source-actions,
.submission-note {
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 12px;
}

.workspace-pane pre {
  min-height: 150px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

.workspace-pane pre.success {
  color: var(--state-dark);
  background: var(--state-soft);
}

.workspace-pane pre.failure {
  color: var(--alert);
  background: var(--alert-soft);
}

.dependency-tree {
  display: grid;
  gap: 7px;
}

.dependency-node {
  padding: 8px 10px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  background: var(--paper);
  font-family: var(--mono-font);
  font-size: 11px;
  text-decoration: none;
}

.dependency-node.root {
  border-left-color: var(--state);
  color: var(--ink);
}

.dependency-node.module {
  border-left-color: var(--block);
}

.submit-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 250px;
  }

  .page-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    padding-left: 0;
    padding-top: 58px;
  }

  .mobile-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 70;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    font-family: var(--ui-font);
  }

  .mobile-header .brand {
    display: block;
  }

  .mobile-header .brand-word {
    display: block;
    font-size: 17px;
    overflow-wrap: anywhere;
  }

  .mobile-header .brand-subtitle {
    display: block;
    font-size: 10px;
  }

  .mobile-header .mobile-menu {
    display: grid;
  }

  .site-sidebar {
    width: min(340px, calc(100vw - 38px));
    padding-top: 58px;
    transform: translateX(-105%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }

  .site-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-head {
    display: none;
  }

  .sidebar-search .search-results {
    top: 112px;
  }

  .verification-inner,
  .page-shell {
    width: min(100% - 28px, var(--page-width));
  }

  .site-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .contribution-paths,
  .use-paths,
  .contributor-record,
  .workspace-grid,
  .workspace-output,
  .submit-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .contribution-paths article + article {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .use-paths article + article {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .milestone-list li {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-sidebar {
    transition: none;
  }
}
