:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --surface: #fffdf8;
  --surface-2: #efeadd;
  --ink: #18252d;
  --muted: #5d6a70;
  --line: #d6d0c2;
  --accent: #126a70;
  --accent-strong: #0c4f55;
  --accent-soft: #dbeff0;
  --link: #0d6474;
  --code-bg: #17232b;
  --code-ink: #edf8f7;
  --success: #176b43;
  --success-bg: #dff4e8;
  --warning: #875b00;
  --warning-bg: #fff0c7;
  --planned: #4d5e8d;
  --planned-bg: #e7ebf7;
  --blocked: #9b3535;
  --blocked-bg: #f8dddd;
  --stated: #694b82;
  --stated-bg: #eee4f5;
  --shadow: 0 14px 36px rgba(42, 49, 49, 0.08);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --site-sidebar-width: 19rem;
}

html[data-theme="modern"] {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #e9eef4;
  --ink: #17202a;
  --muted: #5b6673;
  --line: #d7dee7;
  --accent: #365ea8;
  --accent-strong: #24457f;
  --accent-soft: #e4edff;
  --link: #285ba8;
  --code-bg: #18212e;
  --code-ink: #f3f7ff;
  --radius: 10px;
  --serif: var(--sans);
}

html[data-theme="bold"] {
  color-scheme: dark;
  --bg: #10151c;
  --surface: #171e27;
  --surface-2: #222c38;
  --ink: #f3f6f8;
  --muted: #aebbc8;
  --line: #344253;
  --accent: #53d3be;
  --accent-strong: #8ce7d8;
  --accent-soft: #183c3b;
  --link: #7bdcca;
  --code-bg: #0a0e13;
  --code-ink: #f2f7f7;
  --success: #88e0ae;
  --success-bg: #173b2c;
  --warning: #ffd37a;
  --warning-bg: #3b3018;
  --planned: #b8c8ff;
  --planned-bg: #29314f;
  --blocked: #ffaaaa;
  --blocked-bg: #492829;
  --stated: #dfb5ff;
  --stated-bg: #3f2e4c;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--accent-soft) 64%, transparent), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}

a {
  color: var(--link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

:where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 78%, white);
  outline-offset: 3px;
  border-radius: 5px;
}

code,
pre {
  font-family: var(--mono);
}

code {
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 2px solid var(--accent);
}

.skip-link:focus {
  top: 1rem;
}

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

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

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0.8rem clamp(1rem, 3vw, 2.4rem);
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  margin-right: auto;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--serif);
  font-weight: 700;
}

.primary-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.primary-nav a {
  padding: 0.4rem 0.55rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 7px;
}

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

.theme-switcher {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.theme-switcher button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.58rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.77rem;
  cursor: pointer;
}

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

.search-shell {
  position: relative;
  min-width: min(19rem, 100%);
}

.global-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.48rem 0.8rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  width: min(32rem, 92vw);
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.search-results a {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 7px;
  text-decoration: none;
}

.search-results a:hover {
  background: var(--surface-2);
}

.search-kind {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.verification-strip {
  border-bottom: 1px solid var(--line);
  background: var(--success-bg);
  color: var(--success);
  text-align: center;
  padding: 0.42rem 1rem;
  font-size: 0.88rem;
}

.verification-strip.unverified {
  background: var(--warning-bg);
  color: var(--warning);
}

.page-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2.4rem) 5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}

.page-main {
  min-width: 0;
}

.side-nav {
  position: sticky;
  top: 6.5rem;
  contain: inline-size;
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  overflow: auto;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

.side-nav strong {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav a {
  display: block;
  padding: 0.27rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.side-nav a:hover {
  color: var(--accent);
}

.side-nav a[aria-current="location"] {
  color: var(--accent-strong);
  font-weight: 700;
}

.site-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--site-sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 96%, var(--surface));
  box-shadow: 10px 0 28px color-mix(in srgb, var(--ink) 6%, transparent);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.2rem 1.15rem 1rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading .brand {
  order: 1;
  min-width: 0;
  margin: 0;
}

.sidebar-heading .brand > span:last-child {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

.sidebar-heading .brand strong {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.sidebar-heading .brand small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.sidebar-close {
  order: 2;
  display: none;
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.7rem;
  cursor: pointer;
}

.sidebar-search {
  min-width: 0;
  padding: 1rem 1.15rem 0.5rem;
}

.sidebar-search .global-search {
  margin-top: 0.4rem;
  border-radius: 6px;
  font-size: 0.86rem;
}

.sidebar-search .search-results {
  right: 1.15rem;
  left: 1.15rem;
  width: auto;
  max-height: 46vh;
}

.sidebar-nav {
  padding: 0 1.15rem 1.1rem;
}

.nav-group {
  display: grid;
  gap: 0.08rem;
  padding-top: 1rem;
}

.nav-group + .nav-group {
  margin-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.nav-group-title {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav a {
  display: block;
  padding: 0.31rem 0.45rem;
  border-radius: 5px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 0.91rem;
  line-height: 1.25;
  text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--accent-strong);
}

.sidebar-nav .book-nav-link,
.sidebar-nav .spine-nav-link {
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  align-items: start;
  gap: 0.2rem;
  font-family: var(--sans);
  font-size: 0.78rem;
}

.book-nav-link span,
.spine-nav-link span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.sidebar-footer {
  display: grid;
  gap: 0.85rem;
  margin-top: auto;
  padding: 1rem 1.15rem 1.2rem;
  border-top: 1px solid var(--line);
}

.sidebar-footer > a {
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
}

.sidebar-footer .theme-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: 7px;
}

.sidebar-footer .theme-switcher button {
  padding-inline: 0.3rem;
  border-radius: 5px;
  font-size: 0.67rem;
}

.site-content {
  min-width: 0;
  max-width: 100%;
  margin-left: var(--site-sidebar-width);
  overflow-x: clip;
}

.mobile-bar {
  display: none;
}

.sidebar-scrim {
  display: none;
}

.site-content .verification-strip {
  position: sticky;
  top: 0;
  z-index: 18;
}

.site-content .page-shell {
  max-width: 1460px;
}

.hero {
  padding: clamp(1.6rem, 5vw, 4.4rem) 0 clamp(1.5rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  line-height: 1.16;
  text-wrap: balance;
}

h1 {
  max-width: 19ch;
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5.4rem);
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.page-title {
  font-size: clamp(2.1rem, 4.8vw, 4rem);
}

h2 {
  margin: 3.2rem 0 1rem;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: -0.025em;
}

h3 {
  margin: 2rem 0 0.65rem;
  font-size: 1.28rem;
}

.lede {
  max-width: 72ch;
  margin: 1.15rem 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.hero-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-strong);
  font-weight: 650;
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  color: var(--surface);
}

.button.compact {
  min-height: 2.35rem;
  padding: 0.42rem 0.72rem;
  font-size: 0.86rem;
}

.hero-secondary-links {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.page-main > section > :is(p, ul, ol):not(.eyebrow, .result-count, .hero-actions) {
  max-width: 76ch;
}

.section-intro {
  color: var(--muted);
  font-size: 1.03rem;
}

.stats-grid,
.chapter-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.role-card {
  position: relative;
  min-height: 21rem;
  padding: clamp(1.2rem, 2.5vw, 1.8rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.role-card h3 {
  max-width: 18ch;
  margin-top: 0.5rem;
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}

.role-card p:not(.eyebrow) {
  color: var(--muted);
}

.role-card > a {
  display: inline-block;
  margin-top: 0.65rem;
  font-weight: 700;
}

.role-number {
  position: absolute;
  right: 0.8rem;
  top: -0.75rem;
  color: color-mix(in srgb, var(--accent) 14%, transparent);
  font-family: var(--serif);
  font-size: 6.6rem;
  font-weight: 800;
  line-height: 1;
}

.browse-role {
  border-top-color: var(--planned);
}

.contribute-role {
  border-top-color: var(--success);
}

.stat,
.chapter-card,
.info-card,
.theorem-panel,
.callout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat {
  padding: 1rem;
}

.stat-value {
  display: block;
  color: var(--accent-strong);
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.paper-title {
  max-width: 74ch;
  margin: 1rem 0 0;
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.two-system-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.chapter-card,
.info-card {
  padding: 1.1rem 1.2rem;
}

.chapter-card h3,
.info-card h3 {
  margin-top: 0.25rem;
}

.chapter-card p,
.info-card p {
  color: var(--muted);
}

.book-map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0;
}

.book-chapter-card {
  display: grid;
  grid-template-columns: 3.1rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  min-height: 12rem;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.book-chapter-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 18px 42px color-mix(in srgb, var(--ink) 12%, transparent);
}

.book-chapter-number {
  color: color-mix(in srgb, var(--accent) 76%, var(--muted));
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 750;
  line-height: 1;
}

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

.book-chapter-copy > strong {
  display: block;
  margin: 0.55rem 0 0.45rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.25;
}

.book-summary,
.book-audience {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.book-scope,
.book-source {
  display: block;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.book-scope {
  color: var(--accent-strong);
  font-weight: 700;
}

.book-audience {
  margin-top: 0.65rem;
}

.book-chapter-arrow {
  color: var(--accent);
  font-size: 1.3rem;
}

.contributor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.contributor-card {
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}

.contributor-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.contributor-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.contributor-card .contributor-handle {
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.035em;
}

.contributor-avatar {
  display: grid;
  width: 3.4rem;
  height: 3.4rem;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 800;
}

.contributor-invite {
  border-style: dashed;
  border-top-style: solid;
}

.contributor-invite:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.installation-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.installation-steps article {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.installation-steps article > span {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 800;
}

.installation-steps h3 {
  margin: 0.45rem 0;
}

.installation-steps p {
  color: var(--muted);
}

.installation-steps pre {
  margin-bottom: 0;
  font-size: 0.72rem;
}

.contribution-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
  counter-reset: contribution-step;
}

.contribution-steps li {
  position: relative;
  min-height: 12rem;
  padding: 3.2rem 1rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  counter-increment: contribution-step;
}

.contribution-steps li + li {
  border-left: 0;
}

.contribution-steps li::before {
  content: "0" counter(contribution-step);
  position: absolute;
  top: 0.85rem;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 800;
}

.contribution-steps strong,
.contribution-steps span {
  display: block;
}

.contribution-steps span {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.2rem 0.58rem;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status.compiled {
  background: var(--success-bg);
  color: var(--success);
}

.status.partial {
  background: var(--warning-bg);
  color: var(--warning);
}

.status.planned {
  background: var(--planned-bg);
  color: var(--planned);
}

.status.blocked {
  background: var(--blocked-bg);
  color: var(--blocked);
}

.status.stated {
  background: var(--stated-bg);
  color: var(--stated);
}

.status.source {
  background: var(--surface-2);
  color: var(--muted);
}

.status.integrated {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.level-label,
.community-domain {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.community-statuses {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.2rem 0;
}

.community-statuses > div {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.contract-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(20rem, 1.1fr);
  gap: 1rem;
  align-items: stretch;
  margin: 1.4rem 0;
}

.contract-copy,
.contract-example {
  margin: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-radius: var(--radius);
}

.contract-copy {
  border: 1px solid var(--line);
  background: var(--surface);
}

.contract-copy h3 {
  margin-top: 0;
}

.contract-example {
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 0.78rem;
  line-height: 1.55;
}

.community-entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
}

.community-entry-top {
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  align-items: center;
}

.community-credit {
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.contribution-export-note.exported {
  border-left-color: var(--success);
}

.callout {
  padding: 1rem 1.2rem;
  border-left: 5px solid var(--accent);
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.callout code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.callout.warning {
  border-left-color: var(--warning);
}

.diagram {
  contain: inline-size;
  width: 100%;
  max-width: 100%;
  margin: 1.5rem 0;
  padding: clamp(0.7rem, 2vw, 1.2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}

.diagram figcaption {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: center;
}

.mermaid {
  min-width: 38rem;
  text-align: center;
}

.table-wrap {
  width: 100%;
  margin: 1.2rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.91rem;
}

th,
td {
  padding: 0.72rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
}

.filter-bar {
  display: flex;
  gap: 0.7rem;
  align-items: end;
  flex-wrap: wrap;
  margin: 1.2rem 0;
}

.filter-field {
  display: grid;
  gap: 0.25rem;
}

.filter-field.grow {
  flex: 1 1 20rem;
}

.filter-field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.filter-field input,
.filter-field select {
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.result-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.source-guide {
  scroll-margin-top: 5rem;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.source-card,
.algorithm-panel,
.source-theorem-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-card {
  padding: 1.15rem;
  border-top: 4px solid var(--accent);
}

.panel-kicker {
  display: block;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.source-card h3,
.algorithm-panel h3,
.source-theorem-heading h3 {
  margin: 0.4rem 0 0.55rem;
}

.source-card > p {
  margin: 0 0 0.8rem;
  color: var(--muted);
}

.source-card dl,
.milestone-evidence dl {
  display: grid;
  gap: 0.65rem;
  margin: 0 0 1rem;
}

.source-card dl > div,
.milestone-evidence dl > div {
  display: grid;
  grid-template-columns: 5.4rem minmax(0, 1fr);
  gap: 0.6rem;
}

.source-card dt,
.milestone-evidence dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.source-card dd,
.milestone-evidence dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.algorithm-panel {
  margin: 1.5rem 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  overflow: hidden;
}

.algorithm-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
  gap: 0;
  max-width: none !important;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
}

.algorithm-flow li {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.7rem;
  min-height: 9rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent-soft) 30%, var(--surface));
}

.algorithm-flow li + li {
  border-left: 0;
}

.algorithm-step-number {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
}

.algorithm-flow p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.source-theorem-card {
  margin: 1.5rem 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border-top: 4px solid var(--success);
}

.source-theorem-heading {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.source-theorem-heading > a {
  flex: 0 0 auto;
  font-size: 0.86rem;
}

.source-note {
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--success);
  background: color-mix(in srgb, var(--success-bg) 62%, var(--surface));
}

.copyright-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.source-boundary {
  max-width: none;
}

.inventory-disclosure,
.maintainer-contract,
.exact-lean,
.milestone-evidence details {
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.inventory-disclosure > summary,
.maintainer-contract > summary,
.exact-lean > summary,
.milestone-evidence summary {
  padding: 0.75rem 0.9rem;
  color: var(--accent-strong);
  font-weight: 750;
  cursor: pointer;
}

.inventory-disclosure[open] > summary,
.maintainer-contract[open] > summary,
.exact-lean[open] > summary,
.milestone-evidence details[open] > summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.inventory-disclosure > :not(summary),
.maintainer-contract > div {
  margin-inline: 0.9rem;
}

.milestone-evidence > p {
  margin-top: 0;
}

.milestone-evidence details {
  box-shadow: none;
}

.milestone-evidence details dl {
  padding: 0.9rem;
}

.theorem-panel {
  margin: 1.5rem 0 2.3rem;
  overflow: clip;
}

.theorem-header {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.2rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.theorem-header h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.declaration-heading {
  min-width: 0;
}

.theorem-body {
  padding: 1rem 1.2rem 1.35rem;
}

.teaching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem 1.4rem;
}

.teaching-grid dt {
  color: var(--accent-strong);
  font-weight: 750;
}

.teaching-grid dd {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.math-statement {
  position: relative;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  overflow: hidden;
  overflow-wrap: anywhere;
}

.math-fallback {
  color: var(--ink);
}

.primary-textbook-banner {
  display: grid;
  grid-template-columns: minmax(13rem, 0.9fr) minmax(16rem, 1.35fr) auto;
  gap: 1rem 1.4rem;
  align-items: center;
  max-width: 76rem;
  margin: 1.35rem 0 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: linear-gradient(110deg, var(--accent-soft), var(--surface) 58%);
  box-shadow: var(--shadow);
}

.primary-textbook-identity {
  display: grid;
  gap: 0.18rem;
}

.primary-textbook-label {
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.primary-textbook-title {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  line-height: 1.15;
}

.primary-textbook-title cite {
  font-style: normal;
}

.primary-textbook-authors,
.primary-textbook-banner > p {
  color: var(--muted);
}

.primary-textbook-authors {
  font-size: 0.88rem;
}

.primary-textbook-banner > p {
  margin: 0;
  font-size: 0.92rem;
}

.primary-textbook-banner .button {
  justify-self: end;
  white-space: nowrap;
}

.math-tex {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.math-statement.math-rendered {
  overflow-x: auto;
}

.math-statement.math-rendered .math-fallback {
  display: none;
}

.math-statement.math-rendered .math-tex {
  position: static;
  display: inline;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
}

.math-statement mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.lean-code {
  margin: 1rem 0;
  padding: 0.95rem 1rem;
  overflow-x: auto;
  border-radius: 9px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 0.83rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lean-code .kw {
  color: #79d6ff;
  font-weight: 700;
}

.lean-code .str {
  color: #c8e78d;
}

.lean-code .num {
  color: #ffcd86;
}

.source-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.exact-lean .lean-code {
  margin: 0;
  border-radius: 0 0 8px 8px;
}

.module-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.module-meta > div {
  padding: 0.8rem;
  border-top: 2px solid var(--accent-soft);
}

.module-meta dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.module-meta dd {
  margin: 0.25rem 0 0;
}

.declaration-list {
  display: grid;
  gap: 0.65rem;
}

.declaration {
  scroll-margin-top: 7rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.declaration summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}

.declaration summary code {
  overflow-wrap: anywhere;
}

.declaration[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.declaration-content {
  padding: 0.85rem;
}

.kind {
  display: inline-block;
  min-width: 5.4rem;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
}

.docstring {
  color: var(--muted);
  white-space: pre-wrap;
}

.tag-list {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
}

.status-ledger {
  display: grid;
  gap: 1rem;
}

.status-entry {
  min-width: 0;
  max-width: 100%;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.status-entry code,
.status-entry a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-entry.compiled {
  border-left-color: var(--success);
}

.status-entry.partial {
  border-left-color: var(--warning);
}

.status-entry.planned {
  border-left-color: var(--planned);
}

.status-entry.blocked {
  border-left-color: var(--blocked);
}

.status-entry.stated {
  border-left-color: var(--stated);
}

.status-entry h3 {
  margin: 0.1rem 0 0.4rem;
}

.status-entry p {
  margin: 0.4rem 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2.4rem);
  display: flex;
  gap: 1rem 2rem;
  justify-content: space-between;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.84rem;
}

.footer-inner p {
  margin: 0;
  max-width: 78ch;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.ide-mode-banner {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.ide-mode-banner > span:last-child {
  color: var(--muted);
}

.mode-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--warning) 18%, transparent);
}

.ide-mode-banner.local .mode-dot {
  background: var(--success);
  box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--success) 18%, transparent);
}

.ide-toolbar {
  display: flex;
  gap: 0.7rem;
  align-items: end;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.ide-field {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.ide-field-grow {
  flex: 1 1 32rem;
}

.ide-field select {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}

.ide-toggle {
  display: flex;
  align-items: center;
  min-height: 2.6rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.ide-grid,
.ide-output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.ide-pane {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.ide-pane > header {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  min-height: 2.6rem;
  margin-bottom: 0.8rem;
}

.ide-pane > header > div {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  min-width: 0;
}

.ide-pane h3,
.ide-pane h4 {
  margin: 0;
}

.ide-step {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: 750 0.76rem var(--mono);
}

.ide-pane > label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ide-pane textarea {
  width: 100%;
  min-height: 12rem;
  resize: vertical;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font: 0.88rem/1.55 var(--mono);
  tab-size: 2;
}

.ide-pane textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ide-pane .lean-editor {
  min-height: 20.5rem;
  background: var(--code-bg);
  color: var(--code-ink);
}

.ide-math-preview {
  min-height: 6rem;
  margin: 0.6rem 0 0.8rem;
  padding: 1rem;
  overflow-x: auto;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}

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

.ide-source-actions {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
  font-size: 0.84rem;
}

.ide-diagnostics {
  min-height: 14rem;
  margin: 0;
  padding: 0.9rem;
  overflow: auto;
  border-radius: 9px;
  background: var(--code-bg);
  color: var(--code-ink);
  font: 0.82rem/1.55 var(--mono);
  white-space: pre-wrap;
}

.ide-diagnostics.success {
  box-shadow: inset 4px 0 var(--success);
}

.ide-diagnostics.failure {
  box-shadow: inset 4px 0 var(--blocked);
}

.ide-tree {
  min-height: 14rem;
  overflow: auto;
  padding: 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: var(--bg);
}

.ide-tree-root {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  min-width: 26rem;
}

.ide-tree-children {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.8rem;
  width: 100%;
  padding-top: 1.2rem;
}

.ide-tree-children::before {
  content: "";
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  border-top: 2px solid var(--line);
}

.ide-tree-node {
  display: block;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 0.75rem/1.4 var(--mono);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.ide-tree-node.root {
  position: relative;
  max-width: 42rem;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 750;
}

.ide-tree-node.root::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  height: 1.25rem;
  border-left: 2px solid var(--line);
}

.ide-tree-node.module {
  border-left: 4px solid var(--planned);
}

.ide-tree-node.dependency {
  border-left: 4px solid var(--success);
}

.ide-tree-node.empty-node {
  color: var(--muted);
  font-style: italic;
}

.formalization-result-pane {
  margin: 1rem 0;
  border-top: 3px solid var(--accent);
}

.formalization-result-pane > header > span {
  max-width: 54ch;
  color: var(--muted);
  font: 0.72rem/1.45 var(--mono);
  text-align: right;
}

.formalization-result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.formalization-result-grid > section {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}

.formalization-result-grid h4 {
  margin-bottom: 0.45rem;
  color: var(--accent-strong);
}

.formalization-result-grid pre,
.formalization-result-grid ul,
.formalization-result-grid p {
  margin: 0;
  overflow-wrap: anywhere;
}

.formalization-result-grid pre {
  max-height: 18rem;
  overflow: auto;
  white-space: pre-wrap;
}

.textbook-spine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0.9rem;
  margin: 1.4rem 0;
}

.spine-chapter-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem 0.8rem;
  min-width: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
}

.spine-chapter-card:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-1px);
}

.spine-chapter-card > strong,
.spine-chapter-card > p,
.spine-chapter-card > span:not(.spine-chapter-status):not(.spine-chapter-arrow) {
  grid-column: 1 / -1;
}

.spine-chapter-card > strong {
  font: 700 1.1rem/1.3 var(--serif);
}

.spine-chapter-card > p,
.spine-chapter-card > span {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.spine-chapter-number {
  color: var(--accent-strong) !important;
  font: 750 0.75rem/1.3 var(--mono) !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.spine-chapter-status {
  justify-self: end;
}

.spine-chapter-arrow {
  position: absolute;
  right: 1rem;
  bottom: 0.8rem;
  color: var(--accent) !important;
}

.spine-source-card {
  max-width: 52rem;
}

.spine-chapter-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.spine-definition-grid,
.spine-dependency-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 0.9rem;
  margin: 1rem 0;
}

.spine-definition-card,
.spine-dependency-node {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.spine-card-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: start;
  justify-content: space-between;
}

.spine-card-heading h3 {
  margin: 0;
}

.spine-dependency-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem 0.7rem;
  align-items: center;
}

.spine-dependency-node code {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.spine-dependency-node strong {
  font-family: var(--serif);
}

.spine-theorem-card .math-statement,
.spine-definition-card .math-statement {
  max-width: 100%;
  overflow-x: auto;
}

.table-wrap .lean-code {
  max-width: min(78vw, 70rem);
  overflow: auto;
}

@media (max-width: 1240px) {
  .contribution-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .contribution-steps li + li {
    border-left: 1px solid var(--line);
  }

  .contribution-steps li:nth-child(even) {
    border-left: 0;
  }

  .contribution-steps li:nth-child(n + 3) {
    border-top: 0;
  }
}

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

  .side-nav {
    position: static;
    max-height: none;
    grid-row: 1;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    columns: 2;
  }

  .side-nav strong {
    column-span: all;
  }

  .ide-grid,
  .ide-output-grid,
  .formalization-result-grid,
  .two-system-grid {
    grid-template-columns: 1fr;
  }

  .role-grid,
  .contract-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 45;
    display: flex;
    min-height: 3.45rem;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(12px);
  }

  .sidebar-toggle {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: 1.05rem;
    cursor: pointer;
  }

  .mobile-brand {
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 750;
    text-decoration: none;
  }

  .site-sidebar {
    width: min(var(--site-sidebar-width), 88vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar-close {
    display: block;
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  .site-content {
    margin-left: 0;
  }

  .site-content .verification-strip {
    top: 3.45rem;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    border: 0;
    background: rgba(9, 19, 24, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.sidebar-open {
    overflow: hidden;
  }

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

  body.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-nav a,
  .sidebar-footer > a,
  .theme-switcher button {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  .sidebar-nav .book-nav-link,
  .sidebar-nav .spine-nav-link {
    align-items: center;
  }
}

@media (max-width: 760px) {
  .site-header {
    position: static;
  }

  .header-inner {
    align-items: stretch;
  }

  .brand {
    width: 100%;
  }

  .primary-nav {
    order: 4;
    width: 100%;
  }

  .search-shell {
    order: 3;
    flex: 1 1 100%;
  }

  h1 {
    font-size: clamp(2.1rem, 13vw, 3.6rem);
  }

  .side-nav {
    display: block;
    columns: 1;
    max-width: 100%;
    padding: 0.65rem 0.8rem;
    overflow-x: auto;
    white-space: nowrap;
  }

  .side-nav strong {
    margin-bottom: 0.35rem;
  }

  .side-nav a {
    display: inline-flex;
    min-height: 2.5rem;
    align-items: center;
    margin-right: 0.9rem;
  }

  .theorem-header {
    display: grid;
  }

  .declaration summary {
    grid-template-columns: 1fr;
  }

  .kind {
    min-width: 0;
  }

  .mermaid {
    min-width: 32rem;
  }

  .community-statuses {
    grid-template-columns: 1fr;
  }

  .book-map-grid,
  .textbook-spine-grid,
  .spine-definition-grid,
  .spine-dependency-grid,
  .installation-steps,
  .contribution-steps {
    grid-template-columns: 1fr;
  }

  .book-chapter-card {
    grid-template-columns: 2.5rem minmax(0, 1fr);
    min-height: 0;
  }

  .book-chapter-arrow {
    display: none;
  }

  .source-theorem-heading {
    display: grid;
  }

  .algorithm-flow {
    grid-template-columns: 1fr;
  }

  .algorithm-flow li {
    min-height: 0;
  }

  .algorithm-flow li + li {
    border-left: 1px solid var(--line);
    border-top: 0;
  }

  .source-card dl > div,
  .milestone-evidence dl > div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .hero-actions .button {
    width: 100%;
    min-height: 2.75rem;
  }

  .primary-textbook-banner {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    padding: 1rem;
  }

  .primary-textbook-banner .button {
    justify-self: stretch;
    min-height: 2.75rem;
  }

  .math-statement,
  .lean-code,
  .table-wrap,
  .diagram {
    scrollbar-width: thin;
  }

  .contribution-steps li:nth-child(n) {
    min-height: 0;
    border: 1px solid var(--line);
  }

  .contribution-steps li + li {
    border-top: 0;
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .site-header,
  .site-sidebar,
  .mobile-bar,
  .sidebar-scrim,
  .side-nav,
  .theme-switcher,
  .search-shell,
  .verification-strip {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .page-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  .site-content {
    margin-left: 0;
  }

  .theorem-panel,
  .stat,
  .chapter-card,
  .callout {
    box-shadow: none;
    break-inside: avoid;
  }
}
