:root {
  --ink: #171813;
  --muted: #686b61;
  --line: #dedfd7;
  --paper: #f8f8f3;
  --accent: #68734c;
  --accent-soft: #e8eadf;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration-color: #a8aa9f;
  text-underline-offset: 0.2em;
}

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

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.35rem 2rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.78rem;
}

.page-shell {
  width: min(820px, calc(100% - 2.5rem));
  min-height: calc(100vh - 160px);
  margin: 0 auto;
  padding: 3.25rem 0 4rem;
}

.archive-heading { max-width: 630px; }

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

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vw, 4.7rem);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.intro, .lede {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
  line-height: 1.55;
}

.search {
  display: flex;
  margin: 1rem 0 1.1rem;
  border-bottom: 1px solid var(--ink);
}

.search:focus-within { border-bottom-width: 2px; }

.search input {
  min-width: 0;
  flex: 1;
  padding: 0.9rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}

.search input::placeholder { color: #94968d; }

.search button {
  padding: 0.7rem 0 0.7rem 1.5rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
}

.archive-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.4rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.archive-meta p { margin: 0; }

.problem-list {
  margin: 0;
  padding-left: 2.3rem;
}

.problem-list > li {
  padding-left: 0.7rem;
  border-top: 1px solid var(--line);
}

.problem-list > li:last-child { border-bottom: 1px solid var(--line); }

.problem-list > li::marker {
  color: #92958b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.problem-row { padding: 1.25rem 0 1.15rem; }

.problem-title {
  display: inline-block;
  max-width: 720px;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.04rem;
  line-height: 1.5;
}

.problem-title:hover { text-decoration: underline; }

.problem-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.035em;
  text-transform: lowercase;
}

.problem-meta span + span::before {
  content: "·";
  margin-right: 1.1rem;
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-top: 2.4rem;
  font-size: 0.75rem;
}

.pagination > :last-child { justify-self: end; }
.pagination > span { color: var(--muted); }

.empty-state {
  padding: 3rem;
  border: 1px solid var(--line);
  text-align: center;
}

.problem-page { max-width: 760px; }

.back-link {
  display: inline-block;
  margin-bottom: 4rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.problem-page-meta { margin-top: 0; }

.problem-statement {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.8;
}

.prose-page { max-width: 700px; }
.prose-page h1 { max-width: 650px; }

.club-page > h2:first-child { margin-top: 0; }

.prose-page h2 {
  margin: 4rem 0 1.2rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 400;
}

.prose-page > p:not(.eyebrow):not(.lede) { max-width: 650px; }

.meetup {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1.2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

.meetup:last-of-type { border-bottom: 1px solid var(--line); }

.meetup-number {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}

.meetup h3 { margin-bottom: 0.4rem; font-size: 0.92rem; }
.meetup p { margin-bottom: 0.65rem; color: var(--muted); font-size: 0.9rem; }

.resource-links { display: flex; flex-wrap: wrap; gap: 1rem; }
.email { white-space: nowrap; }

.work-in-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  margin: 4rem 0;
  padding: 2rem;
  border: 1px solid var(--line);
  background: var(--accent-soft);
}

.work-in-progress > span {
  font-family: Georgia, serif;
  font-size: 4rem;
  line-height: 1;
}

.work-in-progress h2 { margin: 0 0 0.6rem; }
.work-in-progress p { margin: 0; color: var(--muted); }

.series-index { max-width: 760px; }
.series-index h1 { max-width: 650px; }

.chapter-list { margin: 3rem 0 0; padding: 0; list-style: none; }
.chapter-list li { border-bottom: 1px solid var(--line); }
.chapter-list a { display: grid; grid-template-columns: 2.5rem 1fr auto; gap: 1rem; align-items: center; padding: 1.35rem 0; text-decoration: none; }
.chapter-list a:hover strong { text-decoration: underline; text-underline-offset: 0.2em; }
.chapter-number { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.68rem; }
.chapter-copy { display: flex; flex-direction: column; gap: 0.25rem; }
.chapter-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; font-weight: 400; }
.chapter-copy small { color: var(--muted); font-size: 0.75rem; }

.lesson { max-width: 760px; }
.lesson-header { max-width: 680px; }
.lesson-header h1 { font-size: clamp(2.5rem, 7vw, 4.4rem); }
.lesson-body { margin-top: 4.5rem; }
.lesson-body section { margin-top: 5rem; }
.lesson-body section:first-child { margin-top: 0; }
.lesson-body h2 { margin-bottom: 1.1rem; font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-weight: 400; }
.lesson-body h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.lesson-body p { max-width: 680px; font-family: Georgia, "Times New Roman", serif; font-size: 1.04rem; line-height: 1.8; }
.lesson-body strong { font-weight: 650; }

.equation-card {
  margin: 1.8rem 0;
  padding: 1.2rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  overflow-x: auto;
  text-align: center;
}

.hero-equation { padding-block: 1.8rem; }
.math-figure { margin: 2.5rem 0; }
.math-figure figcaption { margin-bottom: 1rem; color: var(--muted); font-size: 0.72rem; }

.number-sieve { display: grid; grid-template-columns: repeat(10, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.number-sieve span, .number-sieve b { display: grid; place-items: center; aspect-ratio: 1.25; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.76rem; font-weight: 400; }
.number-sieve b { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.factor-strip { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 2rem 0; }
.factor-strip span { padding: 0.6rem 0.8rem; border: 1px solid var(--line); font-size: 0.8rem; }

.idea { display: grid; grid-template-columns: 9rem 1fr; gap: 1.5rem; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--ink); color: var(--muted); font-size: 0.78rem; }
.idea strong { color: var(--accent); font-family: ui-sans-serif, system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.08em; }

.comparison-chart { padding: 1.5rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.chart-key { display: flex; gap: 1.2rem; justify-content: flex-end; margin-bottom: 1rem; color: var(--muted); font-size: 0.68rem; }
.chart-key span::before { display: inline-block; width: 0.8rem; height: 0.35rem; margin-right: 0.4rem; content: ""; background: var(--accent); }
.chart-key .estimate-key::before { height: 1px; background: var(--ink); }
.bar-row { display: grid; grid-template-columns: 5rem 1fr 6rem; gap: 0.8rem; align-items: center; min-height: 2.5rem; font-size: 0.7rem; }
.bar-row > div { position: relative; height: 1rem; }
.bar-row i, .bar-row em { position: absolute; left: 0; display: block; }
.bar-row i { top: 0; height: 0.55rem; background: var(--accent); }
.bar-row em { top: 0.8rem; height: 1px; background: var(--ink); }
.bar-row small { color: var(--muted); text-align: right; }

.unit-bar { display: flex; height: 4rem; margin: 2rem 0; border: 1px solid var(--ink); }
.unit-bar span { display: grid; place-items: center; min-width: 2.5rem; border-right: 1px solid var(--ink); background: var(--accent-soft); font-size: 0.7rem; }
.unit-bar .ellipsis { min-width: 1.5rem; border: 0; background: transparent; }
.grouped-sum { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 2rem 0; }
.grouped-sum span { padding: 0.7rem; border-bottom: 2px solid var(--accent); font-size: 0.74rem; }

.value-table { display: grid; grid-template-columns: 1fr 2fr; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.value-table span, .value-table b { padding: 0.75rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 0.75rem; font-weight: 400; }
.value-table span { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.factor-map { display: grid; grid-template-columns: 1fr auto 4rem; gap: 0.8rem 1.2rem; max-width: 320px; margin: 2rem auto; padding: 1.2rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 0.8rem; }
.factor-map strong { text-align: right; }

.complex-plane, .critical-strip { display: block; width: 100%; max-height: 390px; color: var(--ink); }
.complex-plane line, .complex-plane path, .critical-strip line { fill: none; stroke: currentColor; stroke-width: 1.5; }
.complex-plane .guide { stroke: var(--muted); stroke-dasharray: 5 5; }
.complex-plane .vector, .critical-strip .critical-line { stroke: var(--accent); stroke-width: 3; }
.complex-plane circle, .critical-strip circle { fill: var(--accent); }
.complex-plane text, .critical-strip text { fill: var(--muted); font: 13px ui-sans-serif, system-ui, sans-serif; }
.critical-strip rect { fill: var(--accent-soft); stroke: none; }
.critical-strip .zero-points circle { fill: var(--ink); }

.arrow-sum { position: relative; width: 260px; height: 150px; margin: 2rem auto; }
.arrow-sum i { position: absolute; left: 50%; top: 50%; width: 70px; height: 2px; background: var(--accent); transform-origin: left center; }
.arrow-sum i::after { position: absolute; right: 0; top: -4px; width: 8px; height: 8px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); transform: rotate(45deg); content: ""; }
.arrow-sum i:nth-child(1) { transform: rotate(0deg); }.arrow-sum i:nth-child(2) { transform: rotate(90deg); }.arrow-sum i:nth-child(3) { transform: rotate(180deg); }.arrow-sum i:nth-child(4) { transform: rotate(270deg); }
.arrow-sum span { position: absolute; bottom: 0; width: 100%; color: var(--muted); font-size: 0.72rem; text-align: center; }

.uncertainty-bands { margin: 2.5rem 0; }
.uncertainty-bands > div { display: grid; grid-template-columns: 8rem 1fr; align-items: center; min-height: 5rem; color: var(--muted); font-size: 0.72rem; }
.uncertainty-bands i { display: block; background: var(--accent-soft); border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.wide-band { height: 4rem; }.narrow-band { height: 1.2rem; }

.references { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.references h3 { font-size: 1rem; }
.references p { margin-bottom: 0.3rem; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.74rem; }

.lesson-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 6rem; padding-top: 1.5rem; border-top: 1px solid var(--ink); }
.lesson-navigation a { display: flex; flex-direction: column; gap: 0.3rem; text-decoration: none; }
.lesson-navigation a:last-child { text-align: right; }
.lesson-navigation small { color: var(--muted); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; }
.lesson-navigation span { font-family: Georgia, "Times New Roman", serif; }

footer {
  display: flex;
  justify-content: flex-end;
  width: min(1120px, calc(100% - 4rem));
  margin: 0 auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
}

.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: 640px) {
  .site-header {
    align-items: flex-start;
    padding: 1rem 1.25rem;
  }

  .site-header nav {
    justify-content: flex-end;
    gap: 0.55rem 1rem;
  }

  .page-shell {
    width: min(100% - 2rem, 820px);
    padding: 3.5rem 0 3rem;
  }

  h1 { font-size: 2.65rem; }
  .intro, .lede { font-size: 1.05rem; }
  .problem-list { padding-left: 1.8rem; }
  .problem-list > li { padding-left: 0.25rem; }
  .problem-title { font-size: 0.98rem; }
  .problem-meta span + span::before { margin-right: 0.7rem; }
  .problem-meta { gap: 0.3rem 0.7rem; }
  .back-link { margin-bottom: 3rem; }
  .problem-statement { font-size: 1rem; }
  .work-in-progress { grid-template-columns: 1fr; gap: 1rem; padding: 1.4rem; }
  .lesson-body { margin-top: 3.5rem; }
  .lesson-body section { margin-top: 4rem; }
  .idea { grid-template-columns: 1fr; gap: 0.5rem; }
  .bar-row { grid-template-columns: 4.5rem 1fr; }
  .bar-row small { display: none; }
  .lesson-navigation { gap: 1rem; }
  .chapter-copy small { line-height: 1.4; }
  footer { width: calc(100% - 2.5rem); }
}
