:root {
  --bg: #efeae1;
  --bg-2: #f7f4ee;
  --ink: #1b1714;
  --muted: #5e584e;
  --line: #ddd4c6;
  --copper: #8d3418;
  --copper-soft: #f3e2d6;
  --pine: #1d4a3c;
  --pine-soft: #e3f0ea;
  --amber: #7a4e0d;
  --amber-soft: #f8efd8;
  --bad: #8f2d2d;
  --bad-soft: #f8e4e1;
  --no: #5c564e;
  --no-soft: #ece7de;
  --code: #14211c;
  --code-ink: #e7f2ec;
  --shadow: 0 18px 40px rgba(60, 40, 20, 0.08);
  --serif: "Source Serif 4", "Liberation Serif", "Times New Roman", serif;
  --sans: Manrope, "Liberation Sans", "Noto Sans", sans-serif;
  --mono: "JetBrains Mono", "Liberation Mono", ui-monospace, monospace;
  --sticky: 0px;
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --bg-2: #1c1b18;
    --ink: #f4efe6;
    --muted: #c4baad;
    --line: #3a342c;
    --copper: #f0a07a;
    --copper-soft: #3a241c;
    --pine: #9ad7bc;
    --pine-soft: #173028;
    --amber: #f0cc88;
    --amber-soft: #332814;
    --bad: #ffb4ab;
    --bad-soft: #3f2422;
    --no: #b7b0a4;
    --no-soft: #2a2723;
    --code: #0c1411;
    --code-ink: #e7f2ec;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 0% -10%, var(--copper-soft), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--copper-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 3px;
}

img {
  max-width: 100%;
}

a {
  color: var(--copper);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--pine);
}

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

p {
  text-wrap: pretty;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 40;
  padding: 0.5rem 0.8rem;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}

.skip:focus {
  top: 0.6rem;
}

progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  height: 4px;
  border: 0;
  appearance: none;
  background: transparent;
}

progress::-webkit-progress-bar {
  background: transparent;
}

progress::-webkit-progress-value {
  background: var(--copper);
}

progress::-moz-progress-bar {
  background: var(--copper);
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
  padding-bottom: 4rem;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 3.2rem 0 2.4rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.hero__mark {
  position: absolute;
  right: 0;
  top: 0.4rem;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(5.5rem, 16vw, 11rem);
  line-height: 0.8;
  color: var(--copper-soft);
  pointer-events: none;
  user-select: none;
}

.eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0 0 1rem;
  color: var(--copper);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow span[aria-hidden="true"] {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: currentColor;
}

h1 {
  max-width: 14ch;
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 4.7rem);
}

.lede {
  max-width: 42rem;
  margin: 1.2rem 0 0;
  font-size: 1.18rem;
  line-height: 1.6;
}

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

.stats div {
  padding: 0.9rem 0.95rem 0.8rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats dt {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 600;
}

.stats dd {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.lineage {
  display: flex;
  gap: 0.85rem;
  margin: 1.6rem 0 0;
  padding: 0.2rem 0 0.7rem;
  overflow-x: auto;
  list-style: none;
}

.lineage li {
  position: relative;
  flex: 0 0 auto;
  min-width: 5.05rem;
  padding: 0.65rem 0.4rem;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.lineage li strong,
.lineage li span {
  display: block;
}

.lineage li span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.lineage li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -0.72rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--copper);
}

.lineage .is-focus {
  border-color: var(--copper);
  background: var(--copper-soft);
}

.branch-note {
  max-width: 62ch;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 14.5rem minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
  min-width: 0;
}

.toc {
  position: sticky;
  top: 1.2rem;
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding-top: 0.4rem;
}

.toc p {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc a {
  display: block;
  padding: 0.38rem 0 0.38rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

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

.toc a[aria-current="true"] {
  border-left-color: var(--copper);
}

main,
.section,
.table-wrap,
.lineage,
.timeline,
.filters,
.dialect,
.code,
.code pre {
  min-width: 0;
  max-width: 100%;
}

.section {
  margin: 0 0 3.4rem;
  scroll-margin-top: calc(var(--sticky) + 0.8rem);
}

.section h2,
.section h3 {
  scroll-margin-top: calc(var(--sticky) + 0.8rem);
}

.section--chapter h2::before {
  content: counter(chapter, decimal-leading-zero);
  counter-increment: chapter;
  display: block;
  margin-bottom: 0.35rem;
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
}

main {
  counter-reset: chapter;
}

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
}

h3 {
  margin: 2rem 0 0.6rem;
  font-size: 1.45rem;
}

.section > p,
.section > ul,
.section > ol,
.callout p,
.feature__body p,
.dialect__pane > p,
.remember li,
.pipeline p {
  max-width: 68ch;
}

.section ul,
.section ol {
  padding-left: 1.2rem;
}

.section li + li {
  margin-top: 0.35rem;
}

.timeline {
  display: flex;
  gap: 0.5rem;
  margin: 1.2rem 0 1.4rem;
  padding: 0 0 0.4rem;
  overflow-x: auto;
  list-style: none;
}

.timeline a {
  display: block;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font-size: 0.86rem;
  text-decoration: none;
  white-space: nowrap;
}

.timeline a[aria-current="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.standards,
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

caption {
  caption-side: top;
  padding: 0 0 0.7rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  text-align: left;
}

.standards th,
.standards td,
.compare th,
.compare td {
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.standards th,
.compare th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.standards td:first-child,
.compare td:first-child {
  font-weight: 650;
}

.standards tr.is-focus td {
  background: var(--copper-soft);
}

.table-wrap {
  max-width: 100%;
  margin: 1rem 0 0.4rem;
  overflow-x: auto;
}

.compare {
  min-width: 36rem;
}

@media (min-width: 861px) {
  .compare {
    min-width: 0;
    font-size: 0.84rem;
  }
}

.compare td:not(:first-child),
.compare th:not(:first-child) {
  text-align: center;
}

.scroll-hint {
  display: none;
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.tag {
  display: inline-block;
  min-width: 2.4rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  white-space: nowrap;
}

.tag--yes {
  background: var(--pine-soft);
  color: var(--pine);
}

.tag--no {
  background: var(--no-soft);
  color: var(--no);
}

.tag--opt,
.tag--shift {
  background: var(--copper-soft);
  color: var(--copper);
}

.tag--old {
  background: var(--amber-soft);
  color: var(--amber);
}

.tag--gone {
  background: var(--bad-soft);
  color: var(--bad);
}

.pull {
  margin: 1.8rem 0;
  padding: 0.2rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.pull blockquote {
  max-width: 18ch;
  margin: 1rem 0;
  font-family: var(--serif);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  font-style: italic;
  font-weight: 500;
  line-height: 1.25;
}

.pull figcaption {
  max-width: 62ch;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.adjectives {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.adjectives a {
  display: block;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  text-decoration: none;
}

.adjectives a:hover,
.adjectives a[aria-current="true"] {
  border-color: var(--copper);
  background: var(--copper-soft);
  color: var(--ink);
}

.principles {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.principles li {
  padding: 0.85rem 1rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.principles strong {
  font-family: var(--serif);
}

.pipeline {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  border-left: 2px solid var(--line);
  counter-reset: step;
}

.pipeline li {
  position: relative;
  padding: 0 0 1.15rem 1.3rem;
}

.pipeline li::before {
  content: counter(step);
  counter-increment: step;
  position: absolute;
  left: -0.72rem;
  top: 0.15rem;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--copper);
  border-radius: 50%;
  background: var(--bg);
  color: var(--copper);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.pipeline h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

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

.triad article,
.concepts article,
.remember,
.callout {
  padding: 1rem 1rem 0.9rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.triad h3,
.concepts h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.triad pre,
.concepts pre {
  margin: 0.7rem 0 0;
  padding: 0.7rem 0.75rem;
  overflow: auto;
  border-radius: 10px;
  background: var(--code);
  color: var(--code-ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.callout {
  margin: 1.2rem 0;
  border-left: 4px solid var(--copper);
}

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

.callout p:first-child {
  margin-top: 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout .label {
  margin-bottom: 0.3rem;
  color: var(--copper);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.callout--warn .label {
  color: var(--amber);
}

.code {
  margin: 1rem 0 1.2rem;
}

.code figcaption {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.code pre {
  margin: 0;
  padding: 1rem 1.1rem 1.15rem;
  overflow: auto;
  border-radius: 12px;
  background: var(--code);
  color: var(--code-ink);
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 4;
}

.code code {
  font-family: inherit;
}

.copy {
  margin-left: auto;
  padding: 0.28rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.copy:hover {
  border-color: var(--copper);
}

.dialect__tabs,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.8rem 0;
}

.dialect__tabs {
  display: none;
}

html.js .dialect__tabs {
  display: flex;
}

html.js .dialect__pane {
  display: none;
}

html.js .dialect__pane.is-active {
  display: block;
}

.btn,
.dialect__tabs button,
.filters button,
.quiz__options button {
  padding: 0.42rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
}

.dialect__tabs button[aria-selected="true"],
.filters button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.feature {
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

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

.feature summary {
  cursor: pointer;
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 600;
}

.feature summary:hover {
  color: var(--copper);
}

.feature__body {
  padding-top: 0.6rem;
}

.is-hidden {
  display: none !important;
}

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

.remember {
  margin-top: 1.4rem;
}

.remember ol {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.remember li + li {
  margin-top: 0.45rem;
}

.quiz__item {
  min-inline-size: 0;
  margin: 0 0 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.quiz__item legend {
  padding: 0 0.2rem;
  font-family: var(--serif);
  font-size: 1.12rem;
}

.quiz__options {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.quiz__options button {
  border-radius: 10px;
  text-align: left;
}

.quiz__options button:disabled {
  cursor: default;
}

.quiz__options button.is-key {
  background: var(--pine-soft);
  border-color: var(--pine);
}

.quiz__options button.is-wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.quiz__why {
  max-width: 68ch;
  margin: 0.75rem 0 0;
  color: var(--muted);
}

html.js .quiz__why {
  display: none;
}

html.js .quiz__item.is-answered .quiz__why {
  display: block;
}

.quiz__score {
  min-height: 1.5rem;
  font-weight: 700;
}

.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;
}

.colophon {
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 860px) {
  :root {
    --sticky: 3.5rem;
  }

  .shell {
    width: min(100% - 1.4rem, 1120px);
  }

  .stats,
  .triad,
  .concepts {
    grid-template-columns: 1fr 1fr;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .toc {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.55rem 0;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
  }

  .toc p {
    display: none;
  }

  .toc a {
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 0.35rem 0.65rem;
    white-space: nowrap;
  }

  .toc a[aria-current="true"] {
    border-bottom-color: var(--copper);
  }

  .hero__mark {
    display: none;
  }

  .scroll-hint {
    display: block;
  }
}

@media (max-width: 560px) {
  .stats,
  .triad,
  .concepts {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .skip,
  progress,
  .toc,
  .dialect__tabs,
  .filters,
  .copy,
  .hero__mark {
    display: none !important;
  }

  .layout {
    display: block;
  }

  html.js .dialect__pane,
  html.js .quiz__why {
    display: block !important;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
