:root {
  color-scheme: light;
  --canvas: #f7f6f3;
  --surface: #ffffff;
  --ink: #2f3437;
  --muted: #787774;
  --line: #e5e3de;
  --blue: #e8f0f7;
  --green: #e8f2eb;
  --yellow: #f6f0d8;
  --red: #f6e7e4;
  --code: #f1f0ec;
  --radius: 12px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, Charter, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible,
summary:focus-visible { outline: 3px solid #a9c6df; outline-offset: 4px; border-radius: 4px; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}
.topbar-inner { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar-start { display: flex; align-items: center; min-width: 0; gap: 14px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}
.back-link svg { width: 16px; height: 16px; transition: transform 160ms ease; }
.back-link:hover { color: var(--ink); }
.back-link:hover svg { transform: translateX(-3px); }
.back-link:active { transform: translateY(1px); }
.topbar-divider { width: 1px; height: 18px; flex: 0 0 auto; background: var(--line); }
.brand { font-weight: 700; letter-spacing: -0.02em; text-decoration: none; }
.topbar nav { display: flex; gap: 18px; font-size: 14px; color: var(--muted); }

.hero { padding: 90px 0 56px; border-bottom: 1px solid var(--line); }
.eyebrow, .meta, .type, .source-ref {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.eyebrow { color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: -0.035em; }
h1 { max-width: 850px; margin-top: 14px; font-family: var(--serif); font-size: clamp(48px, 8vw, 94px); font-weight: 500; }
.lede { max-width: 670px; margin: 26px 0 0; color: #555a5d; font-size: clamp(18px, 2.2vw, 23px); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.tag { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12px; color: var(--muted); }

.section { padding: 72px 0; border-bottom: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: minmax(160px, 0.45fr) minmax(0, 1.55fr); gap: 36px; margin-bottom: 34px; }
.section-kicker { color: var(--muted); font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.section h2 { font-size: clamp(32px, 5vw, 56px); }
.section-intro { max-width: 730px; margin: 15px 0 0; color: var(--muted); }

.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 24px; }
.map-card { grid-column: span 4; min-height: 240px; display: flex; flex-direction: column; }
.map-card:nth-child(1), .map-card:nth-child(6) { grid-column: span 5; }
.map-card:nth-child(2), .map-card:nth-child(5) { grid-column: span 3; }
.map-card .number { font-family: var(--serif); font-size: 42px; line-height: 1; color: #b4b0a8; }
.map-card h3 { margin-top: auto; padding-top: 38px; font-size: 23px; }
.map-card p { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.type { width: fit-content; margin-top: 18px; padding: 4px 7px; border-radius: 4px; background: var(--blue); color: #48647a; }

.scope-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 12px; }
.scope-grid h3 { font-size: 22px; }
.scope-grid ul { margin: 18px 0 0; padding-left: 20px; }
.scope-grid li + li { margin-top: 8px; }
.note { background: var(--yellow); }

.lesson { scroll-margin-top: 82px; }
.lesson-layout { display: grid; grid-template-columns: minmax(190px, 0.42fr) minmax(0, 1fr); gap: 54px; }
.lesson-aside { position: sticky; top: 88px; align-self: start; }
.lesson-number { font-family: var(--serif); font-size: 72px; color: #b7b2a9; line-height: 0.9; }
.lesson-aside h2 { margin-top: 18px; font-size: 30px; }
.lesson-aside .type { margin-top: 16px; }
.objective { margin-top: 18px; color: var(--muted); font-size: 14px; }
.prose { max-width: 72ch; }
.prose h3 { margin: 40px 0 14px; font-size: 23px; }
.prose h3:first-child { margin-top: 0; }
.prose p { margin: 0 0 18px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 8px; }
.think, .misconception, .check { margin: 28px 0; padding: 20px 22px; border-left: 3px solid; border-radius: 0 8px 8px 0; }
.think { background: var(--blue); border-color: #8eb4d1; }
.misconception { background: var(--red); border-color: #d9a29a; }
.check { background: var(--green); border-color: #8eb89a; }
.callout-title { display: block; margin-bottom: 8px; font-weight: 700; }
code, pre { font-family: var(--mono); }
code { padding: 0.12em 0.35em; border-radius: 4px; background: var(--code); font-size: 0.88em; }
pre { overflow-x: auto; margin: 24px 0; padding: 21px; border: 1px solid var(--line); border-radius: 8px; background: var(--code); font-size: 14px; line-height: 1.55; }
pre code { padding: 0; background: transparent; }

.io-flow { margin: 28px 0; }
.io-flow svg { display: block; width: 100%; height: auto; }
.compare { width: 100%; border-collapse: collapse; margin: 26px 0; font-size: 15px; }
.compare th, .compare td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.compare th { color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
.compare tbody tr:last-child td { border-bottom: 0; }
.source-ref { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); text-transform: none; letter-spacing: 0; }

details { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
details + details { margin-top: 10px; }
summary { cursor: pointer; padding: 16px 18px; font-weight: 650; }
details > div { padding: 0 18px 18px; color: #555a5d; }

.quiz-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.question { display: flex; flex-direction: column; }
.question .meta { color: var(--muted); }
.question h3 { margin: 15px 0; font-size: 20px; line-height: 1.35; letter-spacing: -0.015em; }
.options { margin: 0 0 20px; padding-left: 22px; font-size: 15px; }
.question details { margin-top: auto; }

.source-list { counter-reset: sources; list-style: none; padding: 0; }
.source-list li { display: grid; grid-template-columns: 42px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.source-list li::before { counter-increment: sources; content: "0" counter(sources); color: #aaa69e; font-family: var(--mono); font-size: 12px; }
.source-list strong { display: block; }
.source-list span { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

.footer { padding: 38px 0 62px; color: var(--muted); font-size: 13px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; }

@media (max-width: 820px) {
  .shell { width: min(100% - 28px, 680px); }
  .topbar nav a:not(:last-child) { display: none; }
  .hero { padding-top: 60px; }
  .section-head, .lesson-layout { grid-template-columns: 1fr; gap: 24px; }
  .lesson-aside { position: static; }
  .lesson-number { font-size: 52px; }
  .map-card, .map-card:nth-child(1), .map-card:nth-child(2), .map-card:nth-child(5), .map-card:nth-child(6) { grid-column: span 6; }
  .scope-grid, .quiz-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  body { font-size: 16px; }
  .hero { padding: 48px 0 42px; }
  .section { padding: 54px 0; }
  .map-card, .map-card:nth-child(1), .map-card:nth-child(2), .map-card:nth-child(5), .map-card:nth-child(6) { grid-column: 1 / -1; min-height: 190px; }
  .compare { display: block; overflow-x: auto; white-space: nowrap; }
  .footer-inner { flex-direction: column; }
  .back-link span, .topbar-divider { display: none; }
  .topbar-start { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .back-link svg { transition: none; }
}

@media print {
  .topbar { display: none; }
  body { background: #fff; font-size: 11pt; }
  .shell { width: 100%; }
  .hero, .section { padding: 28px 0; }
  .lesson-layout { grid-template-columns: 150px 1fr; }
  .lesson-aside { position: static; }
  details > div { display: block; }
  .card, details { break-inside: avoid; }
}
