:root {
  --ui: 'Inter', system-ui, sans-serif;
  --serif: 'Literata', Georgia, serif;
  --ink: #23211c; --muted: #6f6a60; --line: #e3ddd0; --line-strong: #cfc7b5;
  --paper: #fbf9f4; --card: #ffffff; --link: #1f6f8b; --chip: #f2eee4; --sel: #1f6f8b; --selink: #ffffff;
  /* the chart and download-row colors (chartdl.js reads the --mf-* names) */
  --mf-blue: #4472C4; --mf-ink: #23211c; --mf-muted: #6f6a60; --mf-bg: #ffffff; --mf-green: #70AD47; --mf-orange: #ED7D31;
  --core: #9a9385;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 18px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 28px; }
.wrap-wide { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
a { color: var(--link); }

.masthead { background: linear-gradient(180deg, #fff, var(--paper)); border-bottom: 1px solid var(--line); padding: 22px 0 26px; }
.backlink { display: inline-block; font-family: var(--ui); font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 14px; }
.backlink:hover { color: var(--ink); }
.eyebrow { font-family: var(--ui); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.masthead h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(28px, 4vw, 42px); line-height: 1.12; margin: .25em 0 .35em; }
.lede { font-size: 18.5px; line-height: 1.6; max-width: 62ch; color: #33302a; margin: .7em 0 0; }
.byline { font-family: var(--ui); font-size: 13.5px; line-height: 1.6; color: #4a463d; background: var(--card); border: 1px solid var(--line);
  border-left: 3px solid var(--link); border-radius: 6px; padding: 14px 16px; margin: 22px 0 0; max-width: 62ch; }

main { padding: 28px 0 8px; }
.toc { font-family: var(--ui); font-size: 14px; line-height: 1.6; margin: 14px 0 0; max-width: 70ch; }
.toc a { text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.part-h { font-family: var(--serif); font-size: clamp(24px, 3vw, 30px); font-weight: 700; margin: 6px 0 16px; scroll-margin-top: 16px; }
main.part2 { padding-top: 10px; border-top: 1px solid var(--line); }
.grid1 { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px 12px; }
.panel + .panel { margin-top: 28px; }
.panel-h { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 2px 0 10px; }
.gridnote { font-family: var(--ui); font-size: 13px; color: #4a463d; background: var(--chip); border-radius: 5px; padding: 8px 12px; margin: 0 0 10px; max-width: 900px; }
.answer.unsolved-note { font-family: var(--ui); font-size: 15px; color: #4a463d; background: #f6f3ec; border: 1px dashed var(--line-strong); border-radius: 6px; padding: 10px 14px; }
.rf-empty { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 180px; font-family: var(--ui); font-size: 13px; color: var(--muted); background: #faf8f3; border-radius: 4px; padding: 12px; }
.ctl { margin: 6px 0 12px; }
.ctl label { display: block; font-family: var(--ui); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.ctls { display: flex; flex-wrap: wrap; gap: 0 28px; }
.author { font-family: var(--ui); font-size: 15px; font-weight: 600; color: #33302a; margin: .5em 0 0; }
.intro { font-size: 16.5px; line-height: 1.6; max-width: 62ch; color: #33302a; margin: .8em 0 0; }
/* the caveat in every simulation (Jason, 2026-11-07): red, with a circled mark */
.caveat { display: flex; gap: 12px; align-items: center; border: 2px solid #b42318; background: #fdf2f1; color: #5c1a12; border-radius: 8px;
  padding: 10px 14px; margin: 6px 0 14px; font-family: var(--ui); font-size: 14px; line-height: 1.5; max-width: 900px; }
.caveat .mark { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 2px solid #b42318; color: #b42318; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 15px; }
.blurb { font-family: var(--ui); font-size: 14px; color: var(--muted); line-height: 1.55; margin: 0 0 8px; max-width: 900px; }
.answer { font-size: 18px; line-height: 1.5; margin: 6px 0 12px; max-width: 1000px; }

/* buttons: one fixed size, wrapping onto rows */
.seg { display: grid; grid-template-columns: repeat(auto-fill, 160px); gap: 6px; }
.seg button { font-family: var(--ui); font-size: 13px; width: 160px; height: 44px; border: 1px solid var(--line-strong); border-radius: 5px;
  background: var(--card); color: var(--ink); cursor: pointer; padding: 0 6px; white-space: normal; line-height: 1.15; }
.seg button[aria-pressed="true"] { background: var(--sel); border-color: var(--sel); color: var(--selink); font-weight: 600; }
.seg button:disabled { opacity: .35; cursor: default; }
/* a choice that did not solve: grayed and dashed, but still clickable so it can say why */
.seg button.unsolved { color: #9a9385; border-style: dashed; background: #f6f3ec; }
.seg button.unsolved[aria-pressed="true"] { background: #e9e3d6; border-color: #9a9385; color: #4a463d; }
.seg.tiles { grid-template-columns: repeat(auto-fill, 200px); }
/* a control set side by side lays its buttons out in one row, not a column (the .ctls flex item shrinks to one button) */
.ctls .seg { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 160px; }
.seg.tiles button { width: 200px; height: 52px; font-size: 14px; }
.btn { font-family: var(--ui); font-size: 14px; width: 250px; height: 40px; border: 1px solid var(--sel); border-radius: 6px; background: var(--sel); color: var(--selink); cursor: pointer; }
.btn.ghost { background: var(--card); color: var(--sel); }
.morebar { display: flex; justify-content: center; margin: 6px 0 10px; }

/* charts */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 8px; }
.chartbox { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 4px; background: var(--card); min-width: 0; }
.chart { min-height: 200px; }
.rf-fig { margin: 0; }
.rf-title { font-family: var(--serif); font-size: 15px; font-weight: 700; text-align: center; margin-bottom: 2px; }
.rf-units { font-family: var(--ui); font-size: 11px; color: var(--ink); }
.rf-plot svg { max-width: 100%; height: auto; overflow: visible; }
.rf-legend { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 4px; font-family: var(--ui); font-size: 11px; }
.rf-item { display: inline-flex; align-items: center; gap: 6px; }
.rf-swatch { width: 14px; height: 4px; border-radius: 1px; display: inline-block; }
.rf-foot { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--ui); font-size: 9px; color: var(--muted); }
.rf-src { font-style: italic; }
/* the download row: one centered row of three equal buttons under each chart */
.chartbox .ev-dlbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 540px; margin: 8px auto 6px; }
.chartbox .ev-dlbar .ev-dl { width: 100%; height: 34px; white-space: normal; line-height: 1.1; font-family: var(--ui); }

.prose { padding: 26px 28px 70px; }
.prose h2 { font-size: 24px; margin: 18px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 1.3em; }
.prose li { margin: 0 0 10px; }
.prose code { font-size: .85em; background: var(--chip); padding: 1px 4px; border-radius: 3px; }

@media (max-width: 820px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .wrap, .wrap-wide { padding: 0 16px; }
  .prose { padding: 20px 16px 60px; }
  .panel { padding: 14px; }
  .seg { grid-template-columns: repeat(auto-fill, 140px); }
  .seg button { width: 140px; font-size: 12px; }
  .seg.tiles { grid-template-columns: repeat(auto-fill, 150px); }
  /* every tile one size, tall enough for the longest case name in four lines (the Ukraine case) */
  .seg.tiles button { width: 150px; height: 60px; font-size: 13px; line-height: 1.1; }
  .ctls .seg { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, 140px); grid-auto-columns: auto; }
  .btn { width: 100%; }
  .answer { font-size: 16px; }
  .chartbox .ev-dlbar .ev-dl { font-size: 11px; height: 40px; }
}
