:root {
  --paper: #f6f4ee;
  --ink: #16211d;
  --ink-soft: #3c4a44;
  --muted: #5b6b64;
  --card: #ffffff;
  --rule: #d9d3c4;
  --rule-strong: #b9ae95;
  --accent: #7a5c19;
  --accent-text: #6a4f16;
  --accent-soft: #e8dcb8;
  --link: #1f5c4d;
  --danger-bg: #fbe9e4;
  --danger-ink: #7a2c14;
  --danger-rule: #d98866;
  --focus: #1f5c4d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10201b;
    --ink: #ecebe4;
    --ink-soft: #c3cec6;
    --muted: #93a49b;
    --card: #17281f;
    --rule: #2c3f34;
    --rule-strong: #4a6152;
    --accent: #d8c184;
    --accent-text: #e6d8a8;
    --accent-soft: #2e3524;
    --link: #7fd6b8;
    --danger-bg: #2c1c15;
    --danger-ink: #f3c3ab;
    --danger-rule: #8a4a2c;
    --focus: #7fd6b8;
  }
}

:root[data-theme="dark"] {
  --paper: #10201b;
  --ink: #ecebe4;
  --ink-soft: #c3cec6;
  --muted: #93a49b;
  --card: #17281f;
  --rule: #2c3f34;
  --rule-strong: #4a6152;
  --accent: #d8c184;
  --accent-text: #e6d8a8;
  --accent-soft: #2e3524;
  --link: #7fd6b8;
  --danger-bg: #2c1c15;
  --danger-ink: #f3c3ab;
  --danger-rule: #8a4a2c;
  --focus: #7fd6b8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}
.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1.4rem; }
section { scroll-margin-top: 4.5rem; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; line-height: 1.15; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 4.4vw, 2.7rem); margin: 0.3rem 0 1rem; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); margin: 0 0 0.9rem; }
p { margin: 0 0 1rem; }
a { color: var(--link); }
.read p, .read li { color: var(--ink-soft); }
hr.rule { border: none; border-top: 1px solid var(--rule); margin: 2.2rem 0; }

.sr-only {
  position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;
}
[hidden] { display: none !important; }

.skip-link {
  position: absolute; left: -9999px; z-index: 99; background: var(--card); color: var(--ink);
  padding: 0.5rem 0.9rem; border-radius: 0.3rem; border: 1px solid var(--rule-strong);
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.7rem;
  height: 2.9rem; padding: 0 1rem; background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topbar .home { font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; flex: none; }
.topnav {
  display: flex; gap: 1rem; overflow-x: auto; scrollbar-width: none; white-space: nowrap;
  flex: 1 1 auto; min-width: 2.6rem;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--ink-soft); text-decoration: none; font-size: 0.92rem; flex: none; }
.topnav a:hover, .topnav a[aria-current="true"] { color: var(--ink); }
.topbar .spacer { flex: 0 1 0.5rem; }
.chip {
  color: var(--ink-soft); text-decoration: none; font-size: 0.85rem; padding: 0.25rem 0.55rem;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap; flex: none;
}
.chip[aria-current="true"] { color: var(--ink); border-color: var(--rule-strong); }
.chip:hover { color: var(--ink); }
.chip .abbr { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem;
  border-radius: 999px; border: 1px solid var(--rule-strong); background: transparent; color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn svg[hidden] { display: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.hero { padding: 2.6rem 0 1.6rem; }
.kicker { color: var(--accent-text); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 0.4rem; }
.deck { font-size: 1.1rem; color: var(--ink-soft); }
.byline { color: var(--muted); font-size: 0.88rem; }

section { padding: 2.2rem 0; }
.lede { font-size: 1.05rem; }

table.mgtable { width: 100%; border-collapse: collapse; margin: 1rem 0 0.6rem; font-size: 0.94rem; }
table.mgtable caption { text-align: left; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
table.mgtable th, table.mgtable td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--rule); }
table.mgtable thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.mgtable td.num, table.mgtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mgtable td.pct { font-weight: 700; color: var(--accent-text); }
.table-scroll { overflow-x: auto; }

.barchart { margin: 1.1rem 0 1.4rem; display: flex; flex-direction: column; gap: 0.55rem; }
.barrow { display: grid; grid-template-columns: 8.5rem 1fr 3.6rem; align-items: center; gap: 0.6rem; }
.barlabel { font-size: 0.85rem; color: var(--ink-soft); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bartrack { background: var(--rule); border-radius: 999px; height: 0.65rem; overflow: hidden; }
.barfill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.barval { font-size: 0.85rem; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 26rem) {
  .barrow { grid-template-columns: 6.4rem 1fr 3rem; align-items: start; }
  .barlabel { font-size: 0.74rem; white-space: normal; line-height: 1.15; padding-top: 0.12rem; }
  .bartrack { margin-top: 0.15rem; }
}

.strength-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: 0.1rem 0.55rem;
  margin-left: 0.6rem; vertical-align: middle; white-space: nowrap;
}

.spotlight {
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0.4rem;
  padding: 1.1rem 1.2rem; margin: 0.6rem 0 1.3rem;
}
.spotlight-kicker { color: var(--accent-text); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 0.4rem; }
.spotlight h4 { margin: 0 0 0.6rem; font-size: 1.15rem; color: var(--ink); font-family: Georgia, serif; }
.spotlight > p { color: var(--ink-soft); font-size: 0.94rem; }
.spotlight-chart { margin: 0.9rem 0; }
.spotlight-chart .barlabel { color: var(--ink-soft); }
.spotlight-fill { background: var(--accent); }
.spotlight-fill-muted { background: var(--rule-strong); }
.spotlight-caveat-h { font-weight: 700; font-size: 0.82rem; color: var(--ink); margin: 0.9rem 0 0.4rem; }
.spotlight-caveats { list-style: none; margin: 0; padding: 0; }
.spotlight-caveats li {
  font-size: 0.85rem; color: var(--muted); margin: 0 0 0.35rem; padding-left: 1.1rem; position: relative;
}
.spotlight-caveats li::before { content: "–"; position: absolute; left: 0; }
.spotlight-caveats li:last-child { margin-bottom: 0; }
.table-note { color: var(--muted); font-size: 0.85rem; margin-top: 0.4rem; }

.quickguide { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.9rem; margin: 1.2rem 0 1.4rem; }
.qg-card { background: var(--card); border: 1px solid var(--rule); border-left: 3px solid var(--rule-strong); border-radius: 0.4rem; padding: 1rem 1.1rem; }
.qg-goal { font-weight: 700; color: var(--ink); margin: 0 0 0.5rem; font-size: 0.98rem; }
.qg-body { font-size: 0.92rem; color: var(--ink-soft); margin: 0; }
.quickguide-section { background: var(--card); border-radius: 0.6rem; margin: 0 auto; padding-top: 0.4rem; }
.quickguide-section .wrap { padding-top: 1rem; padding-bottom: 0.5rem; }
p.transition { text-align: center; color: var(--muted); font-style: italic; margin: 1.4rem 0 0; }

.evidence-group { margin: 0 0 1.7rem; }
.evidence-group h3 { font-size: 1.08rem; margin: 0 0 0.6rem; color: var(--ink); }
.evidence-group ul { margin: 0; padding-left: 1.2rem; }
.evidence-group li { color: var(--ink-soft); margin: 0 0 0.75rem; }
.evidence-group li:last-child { margin-bottom: 0; }

.callout {
  background: var(--danger-bg); color: var(--danger-ink); border-left: 3px solid var(--danger-rule);
  padding: 0.85rem 1rem; border-radius: 0.25rem; margin: 1rem 0;
}
.callout p { margin: 0 0 0.5rem; color: var(--danger-ink); }
.callout p:last-child { margin-bottom: 0; }

.source-list { list-style: none; margin: 0; padding: 0; }
.source-list li {
  padding: 0.6rem 0; border-bottom: 1px solid var(--rule); color: var(--ink-soft); font-size: 0.94rem;
}
.source-list a { font-weight: 600; }

footer.site-footer {
  border-top: 1px solid var(--rule); padding: 1.6rem 0 3rem; color: var(--muted); font-size: 0.88rem;
}
footer.site-footer a { color: var(--muted); }

nav.rail {
  position: fixed; right: 1.4rem; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.9rem; z-index: 15;
}
nav.rail a {
  display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--muted);
}
nav.rail .dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--rule-strong); flex: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
nav.rail a[aria-current="true"] .dot { background: var(--accent); transform: scale(1.45); }
nav.rail .label {
  font-size: 0.78rem; opacity: 0; max-width: 0; overflow: hidden; white-space: nowrap;
  transition: opacity 0.15s ease, max-width 0.15s ease;
}
nav.rail a:hover .label, nav.rail a:focus-visible .label { opacity: 1; max-width: 10rem; }
@media (max-width: 75.9375rem) {
  nav.rail { display: none; }
}
@media print {
  nav.rail, .topbar { display: none; }
}

@media (max-width: 30rem) {
  .topnav a:nth-child(n+3) { display: none; }
  .chip .full { display: none; }
  .chip .abbr { display: inline; }
  .chip { padding: 0.25rem 0.4rem; }
  .topbar { gap: 0.4rem; }
}
