:root {
  --paper: #f8f4eb;
  --paper-deep: #f0eadf;
  --ink: #24211d;
  --muted: #70685f;
  --line: #d6cec0;
  --rust: #984328;
  --rust-dark: #702d1c;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--rust);
  text-decoration-color: color-mix(in srgb, var(--rust) 45%, transparent);
  text-underline-offset: 0.16em;
}

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

button,
input,
select {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 20;
  padding: 0.45rem 0.65rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.82rem;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 3rem));
  min-height: 4.2rem;
  margin: 0 auto;
}

.wordmark {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.7rem;
  font-size: 0.88rem;
}

.site-nav a {
  border-bottom: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

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

.nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.88rem;
  cursor: pointer;
}

.home-intro,
.reading-index,
.standard-page,
.site-footer {
  width: min(100%, 1080px);
  margin-inline: auto;
}

.home-intro {
  padding: 5.5rem 1.5rem 4rem;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--rust);
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  text-wrap: balance;
}

h1 {
  margin-bottom: 1.3rem;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  letter-spacing: -0.045em;
}

.home-intro .intro-copy {
  max-width: 580px;
  margin: 0;
  color: var(--muted);
  font-size: 1.18rem;
}

.source-byline {
  margin: 1.65rem 0 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
}

.reading-index {
  padding: 1rem 1.5rem 7rem;
}

.chapter {
  display: grid;
  grid-template-columns: minmax(180px, 0.34fr) minmax(0, 1fr);
  gap: 2.5rem;
  padding: 3.6rem 0;
  border-bottom: 1px solid var(--line);
}

.chapter-heading {
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

.chapter-heading > span,
.entry-number {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.chapter-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.chapter-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter-list li {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--line);
}

.chapter-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.chapter-list a {
  display: grid;
  grid-template-columns: minmax(180px, 0.6fr) minmax(220px, 1fr);
  gap: 1.5rem;
  color: var(--ink);
  text-decoration: none;
}

.chapter-list strong {
  font-size: 1.08rem;
  line-height: 1.4;
}

.chapter-list a > span {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.chapter-list a:hover strong {
  color: var(--rust);
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 70ch) 200px;
  gap: 5rem;
  width: min(100% - 3rem, 1000px);
  margin: 0 auto;
  padding: 5rem 0 8rem;
}

.note {
  min-width: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 3rem;
  font-family: var(--sans);
  font-size: 0.8rem;
}

.note-header {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}

.note-header h1 {
  margin-bottom: 1.1rem;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
}

.dek {
  max-width: 54ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1.5;
}

.provenance {
  max-width: 64ch;
  margin: 2rem 0 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.55;
}

.article-toc {
  position: sticky;
  top: 2rem;
  align-self: start;
  padding-top: 0.3rem;
  font-family: var(--sans);
  font-size: 0.77rem;
  line-height: 1.45;
}

.article-toc strong {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--ink);
}

.article-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-toc li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}

.article-toc a {
  color: var(--muted);
  text-decoration: none;
}

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

.mobile-toc,
.diagram-hint {
  display: none;
}

.system-diagram {
  margin: 3rem 0 1rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.system-diagram > div {
  overflow-x: auto;
}

.system-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.note-section {
  padding-top: 4rem;
  scroll-margin-top: 2rem;
}

.note-section h2,
.end-sources h2,
.standard-page section > h2 {
  margin-bottom: 1.4rem;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.025em;
}

.note-section h3 {
  margin-top: 2.7rem;
  margin-bottom: 0.7rem;
  font-size: 1.32rem;
}

.note-section p,
.note-section ul,
.note-section ol,
.note-section blockquote {
  max-width: 70ch;
}

.note-section blockquote {
  margin: 2rem 0;
  padding: 0.3rem 0 0.3rem 1.25rem;
  border-left: 1px solid var(--rust);
  color: var(--muted);
}

.note-section pre {
  max-width: 100%;
  padding: 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  font-size: 0.8rem;
  line-height: 1.55;
}

.note-section code {
  font-size: 0.84em;
}

.note-section table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

.end-sources {
  margin-top: 5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--ink);
}

.end-sources ol {
  margin: 0;
  padding-left: 1.4rem;
}

.end-sources li {
  padding: 0.55rem 0;
}

.end-sources li span {
  display: block;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.76rem;
}

.note-neighbors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  font-size: 0.96rem;
}

.note-neighbors a {
  color: var(--ink);
  text-decoration: none;
}

.note-neighbors a:last-child {
  text-align: right;
}

.note-neighbors span {
  display: block;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
}

.standard-page {
  min-height: 68vh;
  padding: 6rem 1.5rem 8rem;
}

.page-intro {
  max-width: 760px;
  margin-bottom: 5rem;
  padding-bottom: 3.5rem;
  border-bottom: 1px solid var(--line);
}

.page-intro h1,
.not-found h1 {
  font-size: clamp(2.6rem, 7vw, 5rem);
}

.page-intro > p:not(.eyebrow) {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.1rem;
}

.coverage-note {
  font-family: var(--sans);
  font-size: 0.77rem !important;
}

.about-page section {
  max-width: 70ch;
  margin-top: 4rem;
}

.source-controls {
  display: flex;
  gap: 1rem;
  margin: 2rem 0;
  font-family: var(--sans);
  font-size: 0.78rem;
}

.source-controls label {
  display: grid;
  gap: 0.35rem;
  min-width: min(300px, 100%);
}

.source-controls input,
.source-controls select {
  min-height: 2.6rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.86rem;
}

.source-controls input:focus,
.source-controls select:focus {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

.source-table-wrap {
  overflow-x: auto;
}

.source-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.45;
}

.source-table th,
.source-table td {
  padding: 0.9rem 1rem 0.9rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.source-table th {
  color: var(--muted);
  font-weight: 600;
}

.source-table th:first-child,
.source-table td:first-child {
  width: 48%;
}

.source-table tr[hidden] {
  display: none;
}

.no-results {
  padding: 2rem 0;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.2rem 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
}

.not-found {
  max-width: 760px;
}

@media (max-width: 800px) {
  body {
    font-size: 17px;
  }

  .header-inner {
    width: min(100% - 2rem, 1180px);
    min-height: 3.8rem;
    flex-wrap: wrap;
  }

  .js .nav-toggle {
    display: block;
  }

  .js .site-nav {
    display: none;
    width: 100%;
    padding: 0.6rem 0 1rem;
    border-top: 1px solid var(--line);
  }

  .js .site-nav[data-open="true"] {
    display: grid;
  }

  .site-nav {
    width: 100%;
    gap: 0;
    padding-bottom: 0.8rem;
  }

  .site-nav a {
    padding: 0.45rem 0;
  }

  .home-intro {
    padding-top: 4.5rem;
  }

  .chapter {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .chapter-list a {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .article-layout {
    display: block;
    width: min(100% - 2rem, 70ch);
    padding-top: 3rem;
  }

  .article-toc {
    display: none;
  }

  .mobile-toc {
    display: block;
    margin-top: 1.75rem;
    font-family: var(--sans);
    font-size: 0.8rem;
  }

  .mobile-toc summary {
    cursor: pointer;
  }

  .mobile-toc ol {
    margin: 1rem 0 0;
    padding-left: 1.2rem;
  }

  .mobile-toc li {
    margin: 0.6rem 0;
  }

  .system-diagram svg {
    min-width: 640px;
  }

  .diagram-hint {
    display: block;
    margin-top: 0.9rem;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.75rem;
  }

  .note-neighbors,
  .source-controls {
    grid-template-columns: 1fr;
  }

  .source-controls {
    display: grid;
  }

  .site-footer {
    display: grid;
  }
}

@media (max-width: 520px) {
  h1 {
    letter-spacing: -0.035em;
  }

  .home-intro,
  .reading-index,
  .standard-page {
    padding-inline: 1rem;
  }

  .chapter-list li {
    grid-template-columns: 3.2rem minmax(0, 1fr);
  }

  .note-neighbors {
    display: grid;
  }

  .note-neighbors a:last-child {
    text-align: left;
  }
}

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