/* GLP-1 model briefing — design tokens. "Lit room" (paper) is the default; "Dark room" for dim venues. */
:root {
  --paper:   #F3EEE4;
  --paper-2: #E9E2D4;
  --paper-3: #DDD4C2;
  --ink:     #16161A;
  --ink-2:   #4B4840;
  --ink-3:   #7A7568;
  --rule:    rgba(22, 22, 26, .16);
  --rule-strong: rgba(22, 22, 26, .55);
  --signal:  #C2361B;   /* your scenario */
  --signal-soft: rgba(194, 54, 27, .12);
  --sea:     #1E5E58;   /* good / fits */
  --ochre:   #A86F0C;   /* caution */
  --hatch:   rgba(22, 22, 26, .07);

  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-label: "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
  color-scheme: light;
}
html[data-theme="dark"] {
  --paper:   #0F1013;
  --paper-2: #17191D;
  --paper-3: #23262C;
  --ink:     #EEE7D7;
  --ink-2:   #B9B2A2;
  --ink-3:   #857F72;
  --rule:    rgba(238, 231, 215, .16);
  --rule-strong: rgba(238, 231, 215, .55);
  --signal:  #FF6B47;
  --signal-soft: rgba(255, 107, 71, .14);
  --sea:     #5CC3B6;
  --ochre:   #E2A33A;
  --hatch:   rgba(238, 231, 215, .06);
  color-scheme: dark;
}

/* Scales with the screen so the projector gets big type without a separate layout. */
html { font-size: clamp(14px, 0.55rem + 0.62vw, 23px); }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--f-label);
  line-height: 1.35;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.kicker {
  font-family: var(--f-label); font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; font-size: .72rem; color: var(--ink-2);
}

/* ---------- Masthead ---------- */
.mast {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--s3) var(--s5);
  padding: var(--s4) var(--s5) var(--s3);
  border-bottom: 3px solid var(--ink);
}
.mast h1 {
  margin: .15rem 0 0; font-family: var(--f-display); font-weight: 600;
  font-size: clamp(1.7rem, 1rem + 1.6vw, 2.6rem); line-height: 1.02; letter-spacing: -.015em;
  font-variation-settings: "opsz" 144;
}
.mast h1 em { font-style: italic; font-weight: 400; color: var(--signal); }
.mast .dek { margin: .3rem 0 0; font-family: var(--f-display); font-style: italic; font-size: 1rem; color: var(--ink-2); }
.mast-tools { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.status {
  display: inline-flex; align-items: center; gap: .5rem; min-height: 44px;
  padding: 0 .8rem; border: 1px solid var(--rule-strong);
  font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: .72rem;
}
.status .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ink-3); }
.status[data-live="1"] .dot { background: var(--signal); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.tbtn {
  min-height: 44px; min-width: 44px; padding: 0 .9rem; cursor: pointer;
  background: transparent; border: 1px solid var(--rule-strong);
  font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: .72rem;
}
.tbtn:hover { background: var(--paper-2); }
.tbtn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tbtn:focus-visible, .card:focus-visible, .seg button:focus-visible, .preset:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* ---------- Main grid ---------- */
main {
  display: grid; gap: 0;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr) minmax(16rem, 21rem);
  grid-template-areas: "find stage levers";
  min-height: 0;
}
.rail { padding: var(--s4) var(--s5); min-width: 0; }
.find { grid-area: find; border-right: 1px solid var(--rule); }
.stage { grid-area: stage; display: flex; flex-direction: column; min-width: 0; padding: var(--s4) var(--s5) var(--s3); }
.levers { grid-area: levers; border-left: 1px solid var(--rule); background: var(--paper-2); }

/* ---------- Findings ---------- */
.find h2, .levers h2 {
  margin: 0 0 var(--s3); font-family: var(--f-label); font-weight: 600; font-size: .72rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
  padding-bottom: var(--s2); border-bottom: 1px solid var(--rule-strong);
}
.finding { display: grid; grid-template-columns: 1.7rem 1fr; gap: 0 .4rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.finding:last-child { border-bottom: 0; }
.finding .n { font-family: var(--f-display); font-style: italic; font-size: 1.5rem; line-height: 1; color: var(--ink-3); }
.finding h3 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 1.12rem; line-height: 1.15; }
.finding .big { display: block; margin: .25rem 0 .1rem; font-family: var(--f-num); font-weight: 600; font-size: 1.7rem; line-height: 1; color: var(--signal); letter-spacing: -.02em; }
.finding .big small { font-size: .55em; color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.finding p { margin: .2rem 0 0; font-size: .8rem; line-height: 1.3; color: var(--ink-2); }

.policy-list { list-style: none; margin: .3rem 0 .2rem; padding: 0; font-size: .82rem; }
.policy-list li { display: flex; justify-content: space-between; gap: .6rem; padding: .15rem 0; border-bottom: 1px dotted var(--rule); color: var(--ink-2); }
.policy-list .pl-short { display: none; }
.policy-list li:only-child:not([title]) { border-bottom: 0; }
.policy-list li b { font-family: var(--f-num); font-weight: 600; color: var(--signal); white-space: nowrap; }
#f4big { font-family: var(--f-display); color: var(--ink); letter-spacing: 0; }

/* ---------- Stage: chart ---------- */
.stage-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); }
.stage-head h2 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 1.45rem; line-height: 1.1; }
.stage-head .unit { color: var(--ink-2); font-size: .85rem; margin-top: .15rem; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); }
.seg button { min-height: 44px; padding: 0 .75rem; border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.view-tools { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

.key { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; margin: var(--s2) 0 0; font-size: .78rem; color: var(--ink-2); }
.key i { display: inline-block; vertical-align: middle; margin-right: .35rem; }
.key .k-cur { width: 1.6rem; height: 4px; background: var(--signal); }
.key .k-pin { width: 1.6rem; height: 0; border-top: 2px dashed var(--ink-2); }
.key .k-obs { width: .65rem; height: .65rem; border: 2px solid var(--ink); background: var(--paper); }
.key .k-proj { width: 1.1rem; height: .8rem; background: repeating-linear-gradient(135deg, var(--rule-strong) 0 1px, transparent 1px 5px); }
.key [hidden] { display: none; }

/* Fixed height rather than filling the column: the content area scrolls as one unit, so the chart can never be squeezed off-screen. */
.chart { position: relative; flex: none; height: clamp(16rem, 52vh, 44rem); margin-top: var(--s2); touch-action: pan-y; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.chart .empty[hidden] { display: none; }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-family: var(--f-display); font-style: italic; font-size: 1.2rem; }
.ax text { font-family: var(--f-num); fill: var(--ink-2); }
.ax line { stroke: var(--rule); }
.ax .zero { stroke: var(--rule-strong); }
.zone-label { font-family: var(--f-label); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; fill: var(--ink-2); }
.edge { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; }
.l-cur { fill: none; stroke: var(--signal); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.l-pin { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 7 5; }
.a-cur { fill: var(--signal-soft); }
.obs rect { fill: var(--paper); stroke: var(--ink); stroke-width: 2.5; }
.obs text { font-family: var(--f-num); fill: var(--ink); font-weight: 600; paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.obs .src { font-family: var(--f-label); font-weight: 500; fill: var(--ink-2); }
.end-cur { font-family: var(--f-num); font-weight: 600; fill: var(--signal); }
.end-pin { font-family: var(--f-num); fill: var(--ink-2); }
.event line { stroke: var(--ink-3); stroke-width: 1; }
.event text { font-family: var(--f-label); fill: var(--ink-2); font-weight: 500; paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.ref line { stroke: var(--sea); stroke-width: 1.5; stroke-dasharray: 2 4; }
.ref text { fill: var(--sea); font-family: var(--f-label); font-weight: 600; }
.cross line { stroke: var(--ink); stroke-width: 1; }
.cross circle { stroke: var(--paper); stroke-width: 2; }

.readout {
  position: absolute; pointer-events: none; z-index: 3; min-width: 9rem;
  background: var(--ink); color: var(--paper); padding: .45rem .65rem; font-size: .8rem;
  box-shadow: 6px 6px 0 var(--signal-soft);
}
.readout b { font-family: var(--f-num); font-size: .95rem; display: block; margin-bottom: .15rem; }
.readout .r { display: flex; justify-content: space-between; gap: 1rem; font-family: var(--f-num); }
.readout .r span:first-child { font-family: var(--f-label); opacity: .75; }
.readout .r.cur span:last-child { color: var(--signal); filter: brightness(1.5); }

.banner { margin-top: var(--s2); padding: .5rem .75rem; border-left: 4px solid var(--signal); background: var(--signal-soft); font-size: .85rem; }
.banner[hidden] { display: none; }

/* ---------- Metric strip (small multiples double as the metric picker) ---------- */
.strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-top: var(--s3); border-top: 1px solid var(--rule-strong); border-left: 1px solid var(--rule); }
.card {
  text-align: left; background: transparent; border: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: .5rem .65rem .45rem; cursor: pointer; min-height: 44px; display: grid; gap: .1rem;
}
.card:hover { background: var(--paper-2); }
.card[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.card[aria-pressed="true"] .c-sub, .card[aria-pressed="true"] .c-delta { color: var(--paper-3); }
.card .c-top { display: flex; justify-content: space-between; gap: .4rem; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.card .c-top kbd { font-family: var(--f-num); font-weight: 500; opacity: .55; }
.card .c-val { font-family: var(--f-num); font-weight: 600; font-size: 1.25rem; line-height: 1.1; }
.card .c-sub { font-size: .68rem; color: var(--ink-3); }
.card .c-delta { font-family: var(--f-num); font-size: .7rem; color: var(--ink-2); }
.card svg { width: 100%; height: 1.6rem; display: block; }
.card .s-cur { fill: none; stroke: var(--signal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.card .s-pin { fill: none; stroke: currentColor; opacity: .45; stroke-width: 1.2; stroke-dasharray: 3 2; vector-effect: non-scaling-stroke; }
.card .s-edge { stroke: currentColor; opacity: .3; stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---------- Levers ---------- */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .3rem; margin-bottom: var(--s3); }
.preset {
  min-height: 44px; padding: .25rem .6rem; cursor: pointer; background: var(--paper); border: 1px solid var(--rule-strong);
  font-size: .78rem; font-weight: 500; text-align: left; line-height: 1.15;
}
.preset:hover { border-color: var(--ink); }
.preset[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: #fff; }
.tabs { display: flex; border-bottom: 1px solid var(--rule-strong); margin-bottom: var(--s2); }
.tabs button {
  flex: 1; min-height: 44px; background: transparent; border: 0; border-bottom: 3px solid transparent; cursor: pointer;
  font-weight: 600; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); position: relative;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button.changed::after { content: ""; position: absolute; top: .6rem; right: .5rem; width: .45rem; height: .45rem; border-radius: 50%; background: var(--signal); }
.group-note { font-family: var(--f-display); font-style: italic; font-size: .82rem; line-height: 1.25; color: var(--ink-2); margin: 0 0 .2rem; }

.lever { padding: .35rem 0 .2rem; border-bottom: 1px solid var(--rule); }
.lever[hidden] { display: none; }
.lever-top { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.lever label { font-size: .88rem; font-weight: 500; line-height: 1.15; }
.lever output { font-family: var(--f-num); font-weight: 600; font-size: 1rem; white-space: nowrap; }
.lever.changed output { color: var(--signal); }
.track { position: relative; height: 40px; }
.track .notch {
  position: absolute; bottom: 4px; width: 0; height: 0; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid var(--ink-2);
  pointer-events: none;
}
.track .notch[hidden] { display: none; }
.lever-desc { margin: .1rem 0 0; font-size: .74rem; line-height: 1.25; color: var(--ink-3); }
.lever-foot { display: flex; justify-content: space-between; gap: .5rem; font-size: .7rem; color: var(--ink-3); }
.lever-foot button { background: none; border: 0; padding: 0; cursor: pointer; font-size: .7rem; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; min-height: 24px; }
.lever-foot button[disabled] { text-decoration: none; cursor: default; color: var(--ink-3); }

input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 40px; margin: 0; background: transparent; cursor: pointer;
  --p: 50%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; background: linear-gradient(to right, var(--ink) 0 var(--p), var(--paper-3) var(--p) 100%);
}
.lever.changed input[type=range]::-webkit-slider-runnable-track {
  background: linear-gradient(to right, var(--signal) 0 var(--p), var(--paper-3) var(--p) 100%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 30px; margin-top: -12px; background: var(--ink); border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
}
input[type=range]::-moz-range-track { height: 6px; background: var(--paper-3); }
input[type=range]::-moz-range-progress { height: 6px; background: var(--ink); }
input[type=range]::-moz-range-thumb { width: 12px; height: 30px; border-radius: 0; background: var(--ink); border: 2px solid var(--paper); }
input[type=range]:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.lever-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: var(--s3); }

/* ---------- Footer, notices ---------- */
footer {
  border-top: 1px solid var(--rule-strong); padding: .45rem var(--s5); font-size: .7rem; color: var(--ink-3);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .25rem 1.5rem;
}
.foot-right { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.5rem; }
/* Theme menu: deliberately quiet, styled as footer text rather than as a control. */
.theme-pick { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-3); }
.theme-pick select {
  font: inherit; color: var(--ink-2); background: transparent; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; padding: .1rem .1rem;
}
.theme-pick select:hover { border-bottom-color: var(--rule-strong); }
.theme-pick select:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.theme-pick option { color: #16161A; background: #fff; }
@media (pointer: coarse) { .theme-pick select { min-height: 44px; } }
.notice {
  position: fixed; left: 50%; bottom: 3rem; transform: translateX(-50%); z-index: 10; max-width: min(40rem, 92vw);
  background: var(--ink); color: var(--paper); padding: .8rem 1rem; display: flex; gap: 1rem; align-items: flex-start;
  border-left: 6px solid var(--signal); box-shadow: 8px 8px 0 var(--signal-soft);
}
.notice[hidden] { display: none; }
.notice p { margin: 0; font-size: .9rem; }
.notice .nh { display: block; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; font-size: .68rem; margin-bottom: .2rem; opacity: .8; }
.notice button { background: transparent; border: 1px solid currentColor; color: inherit; min-height: 44px; min-width: 44px; cursor: pointer; }

/* ---------- Introduction (cover sheet over the live dashboard) ---------- */
.intro {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--paper);
  background-image: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 9px);
  display: grid; place-items: start center; padding: clamp(.75rem, 3vw, 2.5rem);
}
.intro[hidden] { display: none; }
.intro:focus { outline: none; }
.intro-sheet {
  width: min(100%, 72rem); background: var(--paper); border: 1px solid var(--rule-strong);
  border-top: 6px solid var(--ink); padding: clamp(1rem, 2.5vw, 2.25rem);
  box-shadow: 10px 10px 0 var(--signal-soft);
}
.intro-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.intro h1 {
  margin: .5rem 0 0; font-family: var(--f-display); font-weight: 600; line-height: 1;
  font-size: clamp(2rem, 1.2rem + 2.6vw, 3.6rem); letter-spacing: -.02em; font-variation-settings: "opsz" 144;
}
.intro h1 em { font-style: italic; font-weight: 400; color: var(--signal); }
.intro-dek { margin: .7rem 0 0; max-width: 46rem; font-family: var(--f-display); font-style: italic; font-size: 1.15rem; line-height: 1.35; color: var(--ink-2); }
.intro-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin-top: var(--s5); border-top: 3px solid var(--ink);
}
.intro-cols article { position: relative; padding: var(--s4) var(--s5) var(--s4) 0; border-bottom: 1px solid var(--rule); }
.intro-cols article + article { padding-left: var(--s5); border-left: 1px solid var(--rule); }
.intro-cols .n { font-family: var(--f-display); font-style: italic; font-size: 1.3rem; color: var(--ink-3); }
.intro h2 {
  margin: .1rem 0 .45rem; font-family: var(--f-label); font-weight: 600; font-size: .78rem;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink);
}
.intro p { margin: 0 0 .55rem; font-size: .92rem; line-height: 1.4; color: var(--ink-2); }
.intro p b { color: var(--ink); font-weight: 600; }
.flow { list-style: none; margin: .2rem 0 .7rem; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; counter-reset: s; }
.flow li {
  font-size: .8rem; font-weight: 600; padding: .3rem .55rem; border: 1px solid var(--rule-strong); background: var(--paper-2);
  position: relative;
}
.flow li:nth-child(3) { background: var(--signal); border-color: var(--signal); color: #fff; }
.flow li + li::before { content: "→"; position: absolute; left: -.85rem; color: var(--ink-3); font-weight: 400; }
.flow li + li { margin-left: .6rem; }
.legend { display: grid; grid-template-columns: 2rem 1fr; gap: .35rem .5rem; align-items: center; margin: .1rem 0 .7rem; font-size: .88rem; }
.legend dt { margin: 0; }
.legend dd { margin: 0; color: var(--ink-2); }
.legend i { display: inline-block; vertical-align: middle; }
.legend .k-cur { width: 1.6rem; height: 4px; background: var(--signal); }
.legend .k-pin { width: 1.6rem; height: 0; border-top: 2px dashed var(--ink-2); }
.legend .k-obs { width: .7rem; height: .7rem; border: 2px solid var(--ink); background: var(--paper); margin-left: .45rem; }
.legend .k-proj { width: 1.6rem; height: .9rem; background: repeating-linear-gradient(135deg, var(--rule-strong) 0 1px, transparent 1px 5px); }
.intro-can { margin-top: var(--s4); }
.intro-can-lede { max-width: 52rem; }
.intro-can ul {
  list-style: none; margin: .3rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  border-top: 1px solid var(--rule-strong); border-left: 1px solid var(--rule);
}
.intro-can li {
  padding: .6rem .8rem .7rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: .86rem; line-height: 1.35; color: var(--ink-2);
}
.intro-can li b { color: var(--ink); font-weight: 600; }
.intro-can .v { display: block; margin-bottom: .2rem; font-family: var(--f-display); font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.intro-try { margin-top: var(--s4); padding: var(--s3) var(--s4); background: var(--paper-2); border-left: 4px solid var(--signal); }
.intro-try ol { margin: 0; padding-left: 1.3rem; display: grid; gap: .3rem; font-size: .92rem; line-height: 1.35; }
.intro-try b { font-weight: 600; }
.intro-go { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3) var(--s5); margin-top: var(--s5); }
.intro-live { margin: 0; display: inline-flex; align-items: center; gap: .55rem; font-size: .92rem; color: var(--ink-2); }
.intro-live .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ink-3); flex: none; }
.intro-live[data-live="1"] .dot { background: var(--signal); animation: pulse 1.6s ease-in-out infinite; }
.intro-live b { font-family: var(--f-num); color: var(--signal); font-size: 1.15rem; }
.go {
  min-height: 3.2rem; padding: 0 1.6rem; cursor: pointer; border: 0; background: var(--ink); color: var(--paper);
  font-family: var(--f-display); font-weight: 600; font-size: 1.25rem; box-shadow: 6px 6px 0 var(--signal);
}
.go:hover { background: var(--signal); color: #fff; box-shadow: 6px 6px 0 var(--ink); }
.go:focus-visible { outline: 3px solid var(--signal); outline-offset: 4px; }
@media (max-width: 720px) {
  .intro-cols article, .intro-cols article + article { padding: var(--s3) 0; border-left: 0; }
  .go { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .intro-live[data-live="1"] .dot { animation: none; } }

.go-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.tbtn-lg { min-height: 3.2rem; font-size: .8rem; padding: 0 1.1rem; background: var(--paper); }

/* ---------- How it works: guided causal loop diagram ---------- */
.story {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: var(--paper);
  background-image: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 9px);
  padding: clamp(.5rem, 1.6vw, 1.5rem);
}
.story[hidden] { display: none; }
.story:focus { outline: none; }
.story-sheet {
  min-height: 100%; background: var(--paper); border: 1px solid var(--rule-strong); border-top: 6px solid var(--ink);
  box-shadow: 10px 10px 0 var(--signal-soft); display: flex; flex-direction: column;
}
.story-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--s3) var(--s5);
  padding: var(--s4) var(--s5) var(--s3); border-bottom: 3px solid var(--ink);
}
.story-head h1 {
  margin: .2rem 0 0; font-family: var(--f-display); font-weight: 600; line-height: 1.02; letter-spacing: -.015em;
  font-size: clamp(1.6rem, 1rem + 1.5vw, 2.5rem); font-variation-settings: "opsz" 144;
}
.story-head h1 em { font-style: italic; font-weight: 400; color: var(--signal); }
.story-body { flex: 1 1 auto; display: grid; grid-template-columns: minmax(18rem, 25rem) minmax(0, 1fr); min-height: 0; }
.story-text { padding: var(--s4) var(--s5); border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }

.chapters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--rule-strong); }
.ch {
  min-height: 44px; border: 0; background: transparent; cursor: pointer; padding: .3rem .2rem; display: grid; place-items: center; gap: .05rem;
  font-size: .62rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); line-height: 1.05;
}
.ch + .ch { border-left: 1px solid var(--rule-strong); }
.ch .num { font-size: .95rem; font-weight: 600; color: var(--ink); }
.ch-t { display: none; }
.ch[aria-current="step"] { background: var(--ink); color: var(--paper); }
.ch[aria-current="step"] .num { color: var(--paper); }
.ch:hover:not([aria-current="step"]) { background: var(--paper-2); }
.ch:focus-visible, .chip:focus-visible, .linkbtn:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.chapter .when { font-family: var(--f-num); font-size: .78rem; font-weight: 600; color: var(--signal); letter-spacing: .02em; }
.chapter h2 { margin: .15rem 0 .35rem; font-family: var(--f-display); font-weight: 600; font-size: 1.45rem; line-height: 1.1; }
.chapter p { margin: 0; font-size: .95rem; line-height: 1.42; color: var(--ink-2); }
.chapter p b { color: var(--ink); font-weight: 600; }

.spark {
  border-top: 1px solid var(--rule); padding-top: var(--s2); margin-top: var(--s2);
  display: grid; grid-template-columns: minmax(9rem, 16rem) minmax(0, 1fr); gap: var(--s4); align-items: center;
}
.spark svg { width: 100%; height: 3.2rem; display: block; overflow: visible; }
.sp-win { fill: var(--signal-soft); }
.sp-edge { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.sp-line { fill: none; stroke: var(--signal); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-note { margin: 0; font-size: .78rem; line-height: 1.3; color: var(--ink-3); }
.spark-note b { color: var(--ink); }

.loops-here h3 { margin: 0 0 .35rem; font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip {
  min-height: 40px; padding: .2rem .6rem; cursor: pointer; background: var(--paper); border: 1px solid var(--rule-strong);
  font-size: .8rem; text-align: left; line-height: 1.15; color: var(--ink-2);
}
.chip b { font-family: var(--f-num); font-weight: 600; margin-right: .15rem; }
.chip-R b { color: var(--signal); }
.chip-B b { color: var(--sea); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.chip.sel { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.sel b { color: inherit; }
.linkbtn {
  background: none; border: 0; padding: .35rem 0; min-height: 36px; cursor: pointer; font-size: .8rem; font-weight: 600;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--signal); }

.loopcard { border-left: 4px solid var(--signal); background: var(--paper-2); padding: .65rem .85rem; }
.loopcard[hidden] { display: none; }
.loopcard.lc-B { border-left-color: var(--sea); }
.loopcard.lc-none { border-left-color: var(--rule-strong); }
.loopcard p { margin: .35rem 0 0; font-size: .9rem; line-height: 1.4; color: var(--ink-2); }
.loopcard .lc-chain { font-family: var(--f-display); font-style: italic; font-size: 1rem; line-height: 1.3; color: var(--ink); }
.lc-top { display: flex; gap: .6rem; align-items: center; }
.lc-top h3 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; line-height: 1.1; }
.lc-kind { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.lc-try { margin-top: .2rem; }
.kb {
  display: inline-grid; place-items: center; flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%;
  font-style: normal; font-family: var(--f-num); font-weight: 600; font-size: .85rem; color: #fff; background: var(--signal);
}
.kb-b { background: var(--sea); }
.pos { color: var(--signal); font-family: var(--f-num); }
.neg { color: var(--sea); font-family: var(--f-num); }

.story-step { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--rule); }
.step-count { color: var(--ink-3); font-size: .8rem; }
.step-next { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.step-next:hover { background: var(--signal); border-color: var(--signal); color: #fff; }
.tbtn:disabled { opacity: .35; cursor: default; }

.story-fig { margin: 0; padding: var(--s3) var(--s4) var(--s3); display: flex; flex-direction: column; min-width: 0; min-height: 30rem; }
#cld { flex: 1 1 auto; width: 100%; min-height: 24rem; display: block; }
.cld-key { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; padding-top: var(--s2); border-top: 1px solid var(--rule); font-size: .75rem; color: var(--ink-2); align-items: center; }
.cld-key b { font-size: 1rem; margin-right: .2rem; }
.cld-key .kb { width: 1.4rem; height: 1.4rem; font-size: .65rem; vertical-align: middle; margin-right: .2rem; }
.cld-key .kd { font-style: normal; font-weight: 700; color: var(--ink); margin-right: .2rem; letter-spacing: -.1em; }
.cld-key .kx { display: inline-block; width: 1.6rem; height: .9rem; border: 1.5px dashed var(--ink-2); vertical-align: middle; margin-right: .3rem; }
.cld-key .hint { font-style: italic; font-family: var(--f-display); color: var(--ink-3); }

/* diagram */
#cld text { font-family: var(--f-label); font-size: 17px; fill: var(--ink); }
.nd { opacity: 0; transition: opacity .35s; pointer-events: none; }
.nd.on { opacity: 1; }
.nd-box { fill: none; stroke: none; }
.nd-stock .nd-box { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.nd-stock text { font-weight: 600; font-size: 18px; }
.nd-hero .nd-box { fill: var(--ink); }
#cld .nd-hero text { fill: var(--paper); }
.nd-aux .nd-box { fill: var(--paper); }
.nd-flow text { font-style: italic; fill: var(--ink-2); font-size: 15.5px; }
.nd-flow .nd-box { fill: var(--paper); }
.valve { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.nd-ext .nd-box { fill: var(--paper); stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
#cld .nd-ext text { fill: var(--ink-2); font-size: 15px; }
#cld .nd.sel:not(.nd-stock):not(.nd-flow) text { font-weight: 600; }
.nd-stock.sel .nd-box { stroke: var(--signal); stroke-width: 3; }

.ln { opacity: 0; transition: opacity .35s; pointer-events: none; }
.ln.on { opacity: 1; }
.ln-p { fill: none; stroke: var(--ink-3); stroke-width: 1.6; }
.ln-core .ln-p { stroke: var(--ink); stroke-width: 4; }
.ln.lit .ln-p { stroke: var(--ink-2); stroke-width: 2; }
.ln.sel .ln-p { stroke: var(--signal); stroke-width: 3.2; }
.ln-core.lit .ln-p { stroke: var(--ink); stroke-width: 4; }
.ln-core.sel .ln-p { stroke: var(--signal); stroke-width: 5; }
.ln-ext .ln-p { stroke: var(--ink-3); stroke-dasharray: 5 4; stroke-width: 1.5; }
.ln-core .sgn { display: none; }
.ln-core.sel .sgn { display: inline; }
.ln .sgn { font-family: var(--f-num); font-weight: 700; font-size: 17px; paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
#cld .sgn.pos { fill: var(--signal); }
#cld .sgn.neg { fill: var(--sea); }
.ln:not(.sel):not(.lit) .sgn { opacity: .7; }
.dly { stroke: var(--ink); stroke-width: 2.4; fill: none; }
.ah { fill: var(--ink-3); }
.ah-core { fill: var(--ink); }
.ah-mid { fill: var(--ink-2); }
.ah-on { fill: var(--signal); }
.ah-ext { fill: var(--ink-3); }

.bdg { cursor: pointer; outline: none; }
.bdg-c { fill: var(--paper); stroke: var(--rule-strong); stroke-width: 1.5; stroke-dasharray: 3 3; }
#cld .bdg text { font-family: var(--f-num); font-weight: 600; font-size: 13px; fill: var(--ink-3); }
.bdg:hover .bdg-c, .bdg:focus-visible .bdg-c { stroke: var(--ink); stroke-dasharray: none; }
.bdg:focus-visible .bdg-c { stroke: var(--signal); stroke-width: 3; }
.bdg.open .bdg-c { stroke-dasharray: none; stroke: var(--signal); stroke-width: 2; }
.bdg-B.open .bdg-c { stroke: var(--sea); }
#cld .bdg.open text { fill: var(--signal); }
#cld .bdg-B.open text { fill: var(--sea); }
.bdg.sel .bdg-c { fill: var(--signal); stroke: var(--signal); }
.bdg-B.sel .bdg-c { fill: var(--sea); stroke: var(--sea); }
#cld .bdg.sel text { fill: #fff; }

@media (max-width: 899px) {
  .story-body { grid-template-columns: minmax(0, 1fr); }
  .story-text { border-right: 0; border-bottom: 1px solid var(--rule); order: 2; }
  .story-fig { order: 1; min-height: 0; }
  #cld { min-height: 0; height: auto; aspect-ratio: 1000 / 600; }
}
@media (max-width: 720px) {
  .story-head, .story-text { padding-left: var(--s4); padding-right: var(--s4); }
  .story-fig { padding: var(--s2); }
  .story { padding: 0; }
}
@media (prefers-reduced-motion: reduce) { .nd, .ln { transition: none; } }

@media (min-width: 721px) { .strip { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* ---------- Narrower screens: stack in reading order ---------- */
@media (max-width: 899px) {
  main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "stage stage" "levers find";
  }
  .find { border-right: 0; }
  .levers { border-left: 0; border-right: 1px solid var(--rule); order: 2; }
}
@media (max-width: 720px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "levers" "find"; }
  .levers { border-right: 0; border-top: 1px solid var(--rule-strong); }
  .find { border-top: 1px solid var(--rule-strong); }
  .mast, .stage, .rail, footer { padding-left: var(--s4); padding-right: var(--s4); }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .status[data-live="1"] .dot { animation: none; }
}

/* Introduction pages */
.intro-page[hidden] { display: none; }
.intro-pg { color: var(--ink-3); font-weight: 500; }

/* ======================================================================
   Fit to the screen (900px wide and up). Every view fits 1066 x 600 with
   no scrolling: type scales with the window height as well as its width,
   the page is locked to the window, and the chart and diagram take
   whatever height is left. Each column can still scroll on its own as a
   fallback on screens shorter than 600px.
   ====================================================================== */
@media (min-width: 900px) {
  html { font-size: clamp(12px, min(0.55rem + 0.62vw, 0.35rem + 1.3vh), 23px); }
  body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }

  /* masthead: one row */
  .mast { flex-wrap: nowrap; align-items: center; padding: .45rem 1rem .4rem; border-bottom-width: 2px; }
  .mast h1 { margin: 0; font-size: clamp(1.3rem, .6rem + 1.4vw, 2.4rem); white-space: nowrap; }
  .mast .kicker { font-size: .64rem; }
  .mast .dek { font-size: .86rem; margin-top: .15rem; }
  .mast-tools { flex-wrap: nowrap; gap: .35rem; }

  /* three columns, each fills the height */
  main {
    grid-template-columns: 16rem minmax(0, 1fr) 17.5rem;
    overflow: hidden;
  }
  .rail, .stage { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .rail { padding: .55rem .8rem; }
  .stage { padding: .55rem .9rem .5rem; }

  /* results */
  .find h2, .levers h2 { margin-bottom: .3rem; padding-bottom: .25rem; font-size: .66rem; }
  .finding { grid-template-columns: 1.3rem 1fr; padding: .4rem 0; }
  .finding .n { font-size: 1.15rem; }
  .finding h3 { font-size: .95rem; line-height: 1.15; }
  .finding .big { font-size: 1.12rem; margin: .2rem 0 .05rem; }
  .finding p { font-size: .76rem; line-height: 1.3; margin-top: .15rem; }
  .policy-list { font-size: .74rem; margin: .15rem 0 .1rem; }
  .policy-list li { padding: .08rem 0; }

  /* stage */
  .stage-head { flex-wrap: nowrap; align-items: flex-start; gap: .5rem; }
  .stage-head h2 { font-size: 1.15rem; }
  .stage-head .unit { font-size: .74rem; margin-top: .05rem; }
  .view-tools { flex-wrap: nowrap; gap: .3rem; }
  .key { margin-top: .3rem; font-size: .7rem; gap: .2rem .9rem; }
  .chart { flex: 1 1 auto; height: auto; min-height: 8rem; margin-top: .3rem; }
  .banner { padding: .3rem .6rem; font-size: .76rem; }
  .strip { margin-top: .4rem; }
  .card { padding: .3rem .45rem .3rem; gap: 0; }
  .card .c-top { font-size: .6rem; letter-spacing: .05em; }
  .card .c-val { font-size: 1.02rem; }
  .card .c-sub, .card .c-delta { font-size: .62rem; }
  .card svg { height: 1.2rem; }

  /* scenarios and parameters */
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; margin-bottom: .3rem; }
  .preset { min-height: 2.05rem; padding: .15rem .45rem; font-size: .72rem; }
  .group-note { font-size: .72rem; line-height: 1.2; margin-bottom: .15rem; }
  .tabs { margin-bottom: .2rem; }
  .tabs button { min-height: 2.1rem; font-size: .66rem; }
  .lever { padding: .2rem 0 .1rem; }
  .lever label { font-size: .78rem; }
  .lever output { font-size: .86rem; }
  .track, input[type=range] { height: 26px; }
  input[type=range]::-webkit-slider-thumb { width: 11px; height: 20px; margin-top: -7px; }
  input[type=range]::-moz-range-thumb { width: 11px; height: 20px; }
  .track .notch { bottom: 0; }
  .lever-desc { font-size: .66rem; line-height: 1.2; }
  .lever-foot, .lever-foot button { font-size: .62rem; min-height: 0; }
  .lever-actions { margin-top: .4rem; gap: .25rem; }
  .lever-actions .tbtn { flex: 1 1 auto; padding: 0 .45rem; font-size: .62rem; letter-spacing: .05em; }

  /* buttons: compact with a mouse, full 44px targets on touch screens */
  .tbtn, .seg button, .status { min-height: 2.15rem; font-size: .64rem; }
  .tbtn { padding: 0 .65rem; }
  .seg button { padding: 0 .55rem; }

  /* footer: one line */
  footer { flex-wrap: nowrap; padding: .25rem 1rem; font-size: .64rem; gap: 1rem; }
  footer > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .foot-right { flex-wrap: nowrap; white-space: nowrap; gap: 1rem; }

  /* introduction: two pages, each fits on one screen */
  .intro { padding: .6rem; place-items: center; }
  .intro-sheet { width: min(100%, 70rem); padding: .9rem 1.3rem 1rem; border-top-width: 5px; box-shadow: 8px 8px 0 var(--signal-soft); }
  .intro h1 { margin-top: .3rem; font-size: clamp(1.6rem, .5rem + 3.2vh, 3.2rem); }
  .intro-dek { margin-top: .4rem; font-size: .92rem; max-width: 52rem; }
  .intro h2 { margin-bottom: .3rem; font-size: .7rem; }
  .intro p { font-size: .86rem; line-height: 1.4; margin-bottom: .45rem; }
  .intro-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: .8rem; border-top-width: 2px; }
  .intro-cols article { padding: .6rem 1rem .5rem 0; border-bottom: 0; }
  .intro-cols article + article { padding-left: 1rem; }
  .intro-cols .n { font-size: 1.05rem; }
  .flow { margin: .15rem 0 .5rem; }
  .flow li { font-size: .72rem; padding: .2rem .45rem; }
  .legend { font-size: .84rem; gap: .3rem .5rem; margin-bottom: .55rem; }
  .intro-can { margin-top: .8rem; }
  .intro-can ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .intro-can li { padding: .45rem .7rem .5rem; font-size: .82rem; line-height: 1.35; }
  .intro-can .v { font-size: .98rem; margin-bottom: .1rem; }
  .intro-try { margin-top: .6rem; padding: .5rem .8rem; }
  .intro-try ol { font-size: .84rem; gap: .15rem; }
  .intro-go { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
  .intro-live { font-size: .8rem; }
  .go { min-height: 2.6rem; padding: 0 1.2rem; font-size: 1.05rem; box-shadow: 5px 5px 0 var(--signal); }
  .tbtn-lg { min-height: 2.6rem; font-size: .66rem; padding: 0 .8rem; }

  /* feedback-loop story: text left, diagram right, nothing scrolls */
  .story { overflow: hidden; padding: .5rem; }
  .story-sheet { height: 100%; min-height: 0; border-top-width: 5px; box-shadow: 6px 6px 0 var(--signal-soft); }
  .story-head { flex-wrap: nowrap; align-items: center; padding: .45rem 1rem .4rem; border-bottom-width: 2px; }
  .story-head .kicker { font-size: .62rem; }
  .story-head h1 { margin-top: .1rem; font-size: clamp(1.25rem, .4rem + 2.4vh, 2.3rem); }
  .story-body { grid-template-columns: minmax(19rem, 29rem) minmax(0, 1fr); }
  .story-text { padding: .55rem .9rem .5rem; gap: .45rem; overflow-y: auto; overscroll-behavior: contain; }
  .ch { min-height: 2.15rem; padding: .15rem; }
  .ch .num { font-size: .85rem; }
  .chapter .when { font-size: .7rem; }
  .chapter h2 { font-size: 1.15rem; margin: .05rem 0 .25rem; }
  .chapter p { font-size: .8rem; line-height: 1.4; }
  .loops-here { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .3rem; }
  .loops-here h3 { margin: 0 .2rem 0 0; font-size: .62rem; }
  .chips { display: contents; }
  .chip { min-height: 1.9rem; padding: .1rem .45rem; font-size: .7rem; }
  .linkbtn { min-height: 1.9rem; padding: 0 .2rem; font-size: .72rem; }
  .loopcard { padding: .45rem .7rem .4rem; }
  .loopcard p { font-size: .76rem; line-height: 1.36; margin-top: .25rem; }
  .loopcard .lc-chain { font-size: .84rem; line-height: 1.28; }
  .lc-top h3 { font-size: .98rem; }
  .lc-top .kb { width: 1.75rem; height: 1.75rem; font-size: .72rem; }
  .lc-try { min-height: 1.6rem; padding: .1rem 0 0; }
  .story-step { padding-top: .35rem; }
  .story-fig { min-height: 0; padding: .4rem .8rem .4rem; }
  #cld { min-height: 0; }
  .spark { padding-top: .25rem; margin-top: .2rem; gap: .8rem; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); }
  .spark svg { height: 2.3rem; }
  .spark-note { font-size: .7rem; }
  .cld-key { padding-top: .25rem; font-size: .66rem; gap: .2rem .9rem; }
  .cld-key .kb { width: 1.2rem; height: 1.2rem; font-size: .58rem; }
}
/* Short windows: drop the masthead's secondary lines and the loop names on the chips (the card names the selected loop). */
@media (min-width: 900px) and (max-height: 760px) {
  .mast .kicker, .mast .dek { display: none; }
  .chip .chip-n { display: none; }
  .lever-desc { display: none; }   /* shown as the slider's tooltip instead */
  /* the policy summary becomes wrapped chips with short names; the policy panel states the start date */
  #f4when, .find.many #f2txt, .find.many #f3txt { display: none; }
  .policy-list { display: flex; flex-wrap: wrap; gap: .2rem; }
  .policy-list li { border: 1px solid var(--rule); padding: .05rem .35rem; gap: .3rem; }
  .policy-list .pl-long { display: none; }
  .policy-list .pl-short { display: inline; }
}
@media (min-width: 900px) and (pointer: coarse) {
  .tbtn, .seg button, .preset, .tabs button, .ch, .chip, .go, .tbtn-lg { min-height: 44px; }
}
