:root {
  --paper: #f3ecdf;
  --paper-2: #faf6ee;
  --ink: #1b1814;
  --muted: #5c554c;
  --line: #ddcfb8;
  --line-strong: #c9b89a;
  --stamp: #b8432f;
  --stamp-deep: #8d2e1d;
  --pine: #1b3832;
  --pine-2: #2c564c;
  --gold: #8d6424;
  --chip: #e8dcc8;
  --good: #1d6a45;
  --warn: #8a5610;
  --shadow: 0 16px 40px rgba(48, 32, 12, 0.08);
  --serif: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", ui-monospace, monospace;
  --nav-h: 4.6rem;
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(184, 67, 47, 0.06), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.55;
}
img { max-width: 100%; }
a { color: var(--stamp-deep); text-underline-offset: 0.18em; }
a:hover { color: var(--stamp); }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 3px; }
[id] { scroll-margin-top: calc(var(--nav-h) + 1rem); }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.8rem;
  z-index: 20;
}
.skip:focus { top: 0.5rem; }

.mast {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(243, 236, 223, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mast-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.25rem 0.55rem;
}
.mast-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  min-width: max-content;
}
.brand-mark {
  font-family: var(--serif);
  font-weight: 620;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.brand-mark i {
  font-style: normal;
  color: var(--stamp);
}
.brand small {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.search-wrap { margin-left: auto; position: relative; flex: 1; max-width: 280px; }
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.92rem;
}
.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  width: min(420px, 80vw);
  background: var(--paper-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  border-radius: 12px;
  display: none;
  max-height: 360px;
  overflow: auto;
}
.search-results.open { display: block; }
.search-results a {
  display: block;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.search-results a:hover { background: var(--chip); }
.search-results small { display: block; color: var(--muted); font-family: var(--mono); font-size: 0.72rem; }
.menu-btn {
  display: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  cursor: pointer;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.2rem;
  margin-top: 0.45rem;
}
.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.nav a[aria-current="page"] {
  color: var(--paper-2);
  background: var(--pine);
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.edition {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 0.4rem 0;
  margin-bottom: 1.4rem;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; line-height: 1.12; }
h1 { font-size: clamp(2.3rem, 5vw, 4.1rem); margin: 0.2rem 0 0.8rem; }
h2 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 0 0 0.6rem; }
h3 { font-size: 1.35rem; margin: 0 0 0.4rem; }
.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stamp);
  margin: 0;
}
.lede { font-size: 1.22rem; max-width: 42rem; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 0.92rem; }

.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 2rem;
}
.stat-stack { display: grid; gap: 0.7rem; }
.stat {
  background: var(--pine);
  color: #f6f1e6;
  padding: 0.9rem 1rem;
  border-radius: 14px;
}
.stat b { display: block; font-family: var(--serif); font-size: 1.55rem; font-weight: 560; }
.stat span { color: #d5cbb8; font-size: 0.88rem; }

.section { margin: 2.6rem 0; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
}
.num {
  font-family: var(--mono);
  color: var(--stamp);
  font-size: 0.8rem;
}

.path-grid, .card-grid, .preset-grid { display: grid; gap: 0.8rem; }
.path-grid { grid-template-columns: repeat(3, 1fr); }
.card-grid { grid-template-columns: repeat(2, 1fr); }
.preset-grid { grid-template-columns: repeat(2, 1fr); }
.card, .path, .preset, .note, .result, .quiz, .toc a, .app {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.path, .card, .preset, .app { padding: 1rem 1.05rem 1.05rem; }
.path { text-decoration: none; color: inherit; display: block; min-height: 100%; }
.path:hover, .preset:hover, .app:hover { border-color: var(--stamp); }
.path .num { display: block; margin-bottom: 0.35rem; }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.7rem; }
.tag, .chip {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-family: var(--mono);
}
button.chip, .preset button, .controls button, .text-btn {
  cursor: pointer;
  font-family: var(--sans);
}
button.chip[aria-pressed="true"], .seg button[aria-pressed="true"] {
  background: var(--pine);
  color: var(--paper-2);
  border-color: var(--pine);
}

.story { display: grid; grid-template-columns: 7.2rem 1fr; gap: 0.8rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.story time, .when { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.story h3 { font-size: 1.18rem; margin: 0 0 0.25rem; }
.story h3 a { color: inherit; text-decoration: none; }
.story h3 a:hover { color: var(--stamp-deep); }
.live-flag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--good);
  margin-left: 0.4rem;
}

.note, .result, .quiz { padding: 1rem 1.1rem; }
.note.warn { border-color: #e2c48a; background: #fbf3e2; }
.note.good { border-color: #b7d4c4; background: #f1f7f3; }

.controls, .seg { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 1rem; align-items: center; }
label.field { display: grid; gap: 0.25rem; font-size: 0.92rem; }
label.field span { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
input[type="number"], input[type="text"], input[type="search"], select {
  border: 1px solid var(--line-strong);
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  width: 100%;
}
.checks { display: flex; flex-wrap: wrap; gap: 0.45rem 0.9rem; }
.checks label { display: flex; gap: 0.35rem; align-items: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 760px; }
th, td { text-align: left; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; background: #f6f0e4; position: sticky; top: 0; }
tr.is-hidden { display: none; }
tr.is-picked { background: #f8ebe4; }
.index-num { font-variant-numeric: tabular-nums; font-weight: 640; }
.compare-bar {
  position: sticky;
  bottom: 0.6rem;
  display: none;
  gap: 0.8rem;
  align-items: start;
  background: var(--pine);
  color: #f6f1e6;
  border-radius: 16px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  margin-top: 0.8rem;
}
.compare-bar.show { display: grid; }
.compare-bar a { color: #f1c7bc; }
.compare-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; }
.pick { font-size: 0.85rem; }

.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line-strong); }
.timeline li { padding: 0 0 1.15rem 1rem; position: relative; }
.timeline li::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--stamp);
  position: absolute;
  left: -0.42rem;
  top: 0.3rem;
}
.timeline .era { font-family: var(--mono); font-size: 0.75rem; color: var(--gold); }

.advisor {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 1rem;
  align-items: start;
}
.form-card, .result { background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; }
.form-card { display: grid; gap: 0.75rem; }
.primary {
  background: var(--stamp);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { background: var(--stamp-deep); }
.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  cursor: pointer;
}
.result h3 { margin-top: 0.8rem; }
.result ul { margin: 0.3rem 0 0.6rem; padding-left: 1.1rem; }
.stack-list { display: grid; gap: 0.45rem; }
.stack-list div { border-top: 1px solid var(--line); padding-top: 0.45rem; }

.toc { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 1rem; }
.toc a { text-decoration: none; color: var(--ink); padding: 0.35rem 0.7rem; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); font-size: 0.9rem; }

.quiz-opt {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0.4rem 0;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: white;
  font: inherit;
  cursor: pointer;
}
.quiz-opt:hover { border-color: var(--stamp); }

footer.colophon {
  border-top: 1px solid var(--ink);
  padding: 1.2rem 0 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.colophon-inner { max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.filter-dim { opacity: 0.38; }

@media (max-width: 860px) {
  .hero-grid, .path-grid, .advisor, .card-grid, .compare-cols { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: 1fr; }
  .menu-btn { display: none; }
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }
  .nav a { flex: 0 0 auto; }
  .search-wrap { max-width: 11rem; }
  .edition span:last-child { display: none; }
  .story { grid-template-columns: 1fr; gap: 0.15rem; }
  h1 { font-size: 2.15rem; }
}

@media print {
  .mast, .search-wrap, .menu-btn, .compare-bar, footer.colophon, .no-print { display: none !important; }
  body { background: white; }
  .card, .result, .form-card { break-inside: avoid; }
}
