/* ───────────────────────────── tokens ───────────────────────────── */
:root {
  color-scheme: light;
  --ink-rgb: 23, 24, 26;
  --elev-rgb: 255, 255, 255;
  --shadow-rgb: 23, 24, 26;
  --bg: #ffffff;
  --surface: #f7f7f6;
  --surface-2: #f1f1f0;
  --elev: #ffffff;
  --ink: #17181a;
  --ink-2: #3c3b37;
  --ink-3: #5c5b56;
  --ink-4: #6f6e68;
  --ink-5: #85847e;
  --on-ink: #ffffff;
  --wash: .06;
  --rule: rgba(var(--ink-rgb), .09);
  --chart-surface: #fcfcfb;
  --card: #f7f7f7;
  --pill: #eaeaea;   /* the ink wash over the card, as one solid colour */
  --thumb: #ffffff;

  /* data colours (validated: ordinal green ramp + neutral + critical) */
  --c-dead: #e1e1e1;   /* the input-box gray (#eaeaea), one notch darker: beside the greens and red it reads lighter than it is */
  --c-broke: #d03b3b;
  --c-below: #8fcca0;
  --c-above: #46a368;
  --c-x5: #175c33;
  --c-good: #2a844c;

  /* one ink, four weights (money-flow bar) */
  --a-us: #17181a;
  --a-intl: #55544f;
  --a-bond: #a9a8a2;
  --a-cash: #d9d8d3;

  --font-head: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(.33, .55, .2, 1);
  --ease-pop: cubic-bezier(.3, 1.2, .4, 1);
  --r-card: 28px;
  --r-inlay: 18px;
}
/* Dark chart tones follow bencho's approach: each colour is mixed into the dark card (#111)
   rather than used at full strength, so big areas stay quiet. Green #1f9d55 at 16 / 42 / 78%,
   red #e5484d at 70%, "pass away" matches the input boxes (ink at 5.3% over the card). Adjacent bands: CVD ΔE 12.3, normal 12.8,
   backed by the 2px gaps, the legend and the tooltip. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink-rgb: 255, 255, 255;
    --elev-rgb: 32, 32, 32;
    --shadow-rgb: 0, 0, 0;
    --bg: #0a0a0a; --surface: #111111; --surface-2: #181818; --elev: #1c1c1c;
    --ink: #ffffff; --ink-2: #b4b4b4; --ink-3: #9a9a9a; --ink-4: #828282; --ink-5: #6b6b6b;
    --on-ink: #000000; --wash: .053; --rule: rgba(255,255,255,.08); --chart-surface: #1a1a19; --card: #111111; --pill: #1e1e1e; --thumb: rgba(255,255,255,.17);
    --c-dead: #1e1e1e; --c-broke: #a5383b;
    --c-below: #13271c; --c-above: #174c2e; --c-x5: #1c7e46; --c-good: #1c7e46;
    --a-us: #ffffff; --a-intl: #b4b4b4; --a-bond: #6b6b6b; --a-cash: #3a3a37;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink-rgb: 255, 255, 255;
  --elev-rgb: 32, 32, 32;
  --shadow-rgb: 0, 0, 0;
  --bg: #0a0a0a; --surface: #111111; --surface-2: #181818; --elev: #1c1c1c;
  --ink: #ffffff; --ink-2: #b4b4b4; --ink-3: #9a9a9a; --ink-4: #828282; --ink-5: #6b6b6b;
  --on-ink: #000000; --wash: .053; --rule: rgba(255,255,255,.08); --chart-surface: #1a1a19; --card: #111111; --pill: #1e1e1e; --thumb: rgba(255,255,255,.17);
  --c-dead: #1e1e1e; --c-broke: #a5383b;
  --c-below: #13271c; --c-above: #174c2e; --c-x5: #1c7e46; --c-good: #1c7e46;
  --a-us: #ffffff; --a-intl: #b4b4b4; --a-bond: #6b6b6b; --a-cash: #3a3a37;
}

/* ───────────────────────────── base ───────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 1320px; margin: 0 auto; padding: 20px 20px 40px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(var(--ink-rgb), var(--wash)); color: var(--ink-2);
  display: grid; place-items: center;
  transition: background .18s, transform .2s var(--ease-pop);
}
.icon-btn:hover { background: rgba(var(--ink-rgb), calc(var(--wash) + .03)); color: var(--ink); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 17px; height: 17px; }

/* layout */
.grid {
  display: grid;
  grid-template-columns: 384px minmax(0, 1fr);   /* your plan on the left, results on the right */
  gap: 14px;
  align-items: start;
}
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.results > * { min-width: 0; }

.card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 18px;
}
.inlay {
  background: var(--elev);
  border-radius: var(--r-inlay);
  box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .04), 0 1px 2px rgba(var(--shadow-rgb), .04);
}

/* ─────────────────────────── control panel ─────────────────────────── */
.panel {
  order: -1;
  position: sticky; top: 20px;
  height: calc(100vh - 60px);   /* refined in app.js to the space actually visible */
  display: flex; flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.panel-top { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 6px 20px; }
.panel-title { margin: 0; font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: -.015em; }
.panel-actions { display: flex; gap: 6px; }
.panel-actions .icon-btn { width: 32px; height: 32px; }
.panel-actions .icon-btn svg { width: 16px; height: 16px; }
/* scrolls inside the card; no scrollbar, a soft fade marks more content */
.panel-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
  padding: 10px 18px 18px;
  --ft: 0px; --fb: 0px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--ft), #000 calc(100% - var(--fb)), transparent 100%);
}
.panel-scroll::-webkit-scrollbar { display: none; }
.panel-scroll.fade-t { --ft: 22px; }
.panel-scroll.fade-b { --fb: 36px; }
.group { padding: 8px 0 12px; }
/* equal space above and below each heading, so a folded section's title sits centered between its lines */
.group + .group { border-top: 1px solid var(--rule); padding-top: 12px; }
.group-title {
  font-family: var(--font-head);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-4);
  text-transform: uppercase;
  white-space: nowrap;
}
/* collapsible sections */
.group-h { margin: 0; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% + 12px); margin: 0 -6px; padding: 6px 6px;
  border: 0; border-radius: 9px; background: none; color: inherit;
  cursor: pointer; text-align: left;
  transition: background .15s;
}
.group-head:hover { background: rgba(var(--ink-rgb), .035); }
.group-head:hover .group-title { color: var(--ink-2); }
.group-head:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(var(--ink-rgb), .3); }
.group-sum {
  flex: 1 1 auto; min-width: 0; text-align: right;
  font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .25s;
}
.group.closed .group-sum { opacity: 1; }
.group-head .chev { flex: 0 0 auto; transition: transform .35s var(--ease-pop); }
.group.closed .group-head .chev { transform: rotate(-90deg); }
.group-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .38s var(--ease); }
.group.closed .group-body { grid-template-rows: 0fr; }
.group-inner { min-height: 0; overflow: hidden; padding: 6px 3px 0; margin: 0 -3px; transition: padding .38s var(--ease); }
.group.closed .group-inner { visibility: hidden; padding-top: 0; transition: visibility 0s .38s, padding .38s var(--ease); }
.group:not(.closed) .group-inner { transition: visibility 0s, padding .38s var(--ease); }
.group.closed { padding-bottom: 12px; }
/* sources */
.about { padding: 2px 2px 4px; font-size: 12px; line-height: 1.5; color: var(--ink-3); }
.about p { margin: 0 0 9px; }
.about b { color: var(--ink-2); font-weight: 600; }
.about a { color: var(--ink-2); text-decoration: underline; text-decoration-color: rgba(var(--ink-rgb), .25); text-underline-offset: 2px; }
.about a:hover { color: var(--ink); text-decoration-color: currentColor; }
.about .disclaimer { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--rule); color: var(--ink-4); }
.ctl { padding: 3px 0; }
.ctl + .ctl { margin-top: 6px; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.ctl-label { color: var(--ink-2); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.hint { color: var(--ink-4); font-size: 12px; line-height: 1.4; margin: 7px 2px 2px; }

/* grouped fields (one rounded list, hairlines between rows) */
.fields {
  border-radius: 12px;
  background: rgba(var(--ink-rgb), var(--wash));
  overflow: hidden;
}
.field {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 13px;
  cursor: text;
  transition: background .15s;
}
.field:not([hidden]) ~ .field:not([hidden])::before {
  content: ""; position: absolute; top: 0; left: 13px; right: 0; height: 1px;
  background: var(--rule);
}
.field:hover { background: rgba(var(--ink-rgb), .022); }
.field:focus-within { background: rgba(var(--ink-rgb), .03); }
.field-label {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
}
.fl-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctl-head { display: flex; align-items: center; margin: 2px 2px 8px; }
.ctl-head .field-label { flex: 0 1 auto; }
/* "?" + bubble */
.q {
  flex: 0 0 auto; display: inline-grid; place-items: center;
  width: 16px; height: 16px; border-radius: 50%;
  font: 600 10.5px/1 var(--font-ui); color: var(--ink-4);
  background: rgba(var(--ink-rgb), .08);
  cursor: default; user-select: none; -webkit-user-select: none; outline: none;
  transition: background .15s, color .15s;
}
.q:hover, .q:focus-visible, .q[aria-describedby] { background: var(--ink); color: var(--on-ink); }
.bubble {
  position: fixed; z-index: 60; left: 0; top: 0;
  max-width: 280px; padding: 10px 12px 11px; border-radius: 12px;
  background: var(--ink); color: var(--on-ink);
  font: 400 12.5px/1.45 var(--font-ui); white-space: pre-line;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
  pointer-events: none;
  opacity: 0; transform: translateY(4px) scale(.98);
  transition: opacity .14s, transform .2s var(--ease-pop);
}
.bubble.below { transform: translateY(-4px) scale(.98); }
.bubble.rich { white-space: normal; max-width: 320px; padding: 12px 14px 12px; }
.bubble .nw { white-space: nowrap; }
.bubble p { margin: 0; }
.bubble .b-intro { margin-bottom: 10px; }
.bubble .b-item { padding-top: 8px; margin-top: 8px; border-top: 1px solid rgba(var(--elev-rgb), .14); }
.bubble .b-item:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.bubble b { display: block; font-weight: 600; }
.bubble .b-dim { opacity: .62; font-variant-numeric: tabular-nums; margin-top: 2px; }
.bubble .b-foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(var(--elev-rgb), .14); font-size: 11.5px; }   /* applies to every option above */
.bubble.show { opacity: 1; transform: none; }
.bubble::after {
  content: ""; position: absolute; left: var(--ax, 50%); bottom: -4px;
  width: 9px; height: 9px; margin-left: -4.5px;
  background: inherit; border-radius: 2px; transform: rotate(45deg);
}
.bubble.below::after { bottom: auto; top: -4px; }
.field-note { flex: 0 0 auto; color: var(--ink-5); font-size: 12px; font-variant-numeric: tabular-nums; }
.field-pct {
  flex: 0 0 auto; width: 3.4em; height: 30px;
  border: 0; outline: 0; background: transparent;
  padding: 0 6px; border-radius: 8px;
  color: var(--ink-4); font: 500 12.5px/1.2 var(--font-ui); font-variant-numeric: tabular-nums;
  text-align: right;
  transition: background .15s, box-shadow .15s, color .15s;
}
.field-pct:hover { background: rgba(var(--elev-rgb), .55); color: var(--ink-2); }
.field-pct:focus { background: var(--elev); color: var(--ink); box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .14), 0 2px 8px rgba(var(--shadow-rgb), .07); }
.field-input {
  flex: 0 0 auto; width: 8.6em; height: 30px;
  border: 0; outline: 0; background: transparent;
  margin: 0 -7px 0 0; padding: 0 7px; border-radius: 8px;
  color: var(--ink); font: 600 14px/1.2 var(--font-ui);
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: background .15s, box-shadow .15s;
}
.field:hover .field-input { background: rgba(var(--elev-rgb), .55); }
.field-input:focus { background: var(--elev); box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .14), 0 2px 8px rgba(var(--shadow-rgb), .07); }
.field.total { cursor: default; }
.field.total:hover { background: none; }
.field.total .field-label { color: var(--ink); font-weight: 600; }
.field-static { font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.switch-row { cursor: default; justify-content: space-between; }
.switch-row:hover { background: none; }

/* three ages in one row */
.ages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field.cell { flex-direction: column; align-items: stretch; gap: 2px; padding: 9px 12px 8px; }
.ages .field::before { top: 11px !important; bottom: 11px; left: 0 !important; right: auto !important; width: 1px; height: auto !important; }
.field.cell .field-label { flex: 0 0 auto; font-size: 12px; color: var(--ink-4); }
.field.cell .field-input {
  width: auto; height: auto; margin: 0 -6px; padding: 3px 6px; text-align: left;
  font: 600 18px/1.15 var(--font-head); letter-spacing: -.01em;
}

/* segmented control */
.seg {
  position: relative;
  display: flex; gap: 2px; padding: 2px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), var(--wash));
}
.seg.full { width: 100%; }
.seg.four .seg-btn { flex: 1 1 auto; padding: 0 8px; font-size: 12px; }   /* four options size to their words */
.seg-thumb {
  position: absolute; top: 2px; bottom: 2px; left: 0;
  border-radius: 999px;
  background: var(--thumb);
  box-shadow: 0 1px 2px rgba(var(--shadow-rgb), .08), 0 0 0 .5px rgba(var(--ink-rgb), .06);
  transition: transform .42s var(--ease-pop), width .42s var(--ease-pop);
}
.seg-btn {
  position: relative; z-index: 1; flex: 1 1 0;
  height: 32px; padding: 0 14px;
  border: 0; border-radius: 999px; background: none; cursor: pointer;
  color: var(--ink-3); font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: color .18s, transform .25s var(--ease-pop);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-checked="true"] { color: var(--ink); }
.seg-btn:active { transform: scale(.96); }
.seg-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(var(--ink-rgb), .35); }

/* switch */
.switch {
  position: relative; flex: 0 0 auto;
  width: 50px; height: 30px; border: 0; border-radius: 999px; cursor: pointer;
  background: rgba(var(--ink-rgb), .16);
  transition: background .2s;
}
.switch[aria-checked="true"] { background: var(--ink); }
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--elev);
  box-shadow: 0 1px 2px rgba(var(--shadow-rgb), .2);
  transition: translate .32s var(--ease), width .2s var(--ease);
}
.switch[aria-checked="true"] .switch-knob { translate: 20px; background: var(--on-ink); }
.switch:active .switch-knob { width: 28px; }
.switch[aria-checked="true"]:active .switch-knob { translate: 16px; }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(var(--ink-rgb), .35); }

/* state picker: the whole card is the button */
.picker {
  display: block; width: 100%;
  border: 0; outline: 0; margin: 0;
  padding: 12px 13px 12px; border-radius: 12px;
  background: rgba(var(--ink-rgb), var(--wash));
  color: inherit; text-align: left; cursor: pointer;
  transition: background .15s, transform .2s var(--ease-pop);
}
.picker:hover { background: rgba(var(--ink-rgb), calc(var(--wash) + .025)); }
.picker:active { transform: scale(.99); }
.picker:focus-visible { box-shadow: 0 0 0 2px rgba(var(--ink-rgb), .3); }
.picker-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.picker-val { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; }
.picker-sum { display: block; margin-top: 5px; font-size: 12px; color: var(--ink-4); line-height: 1.4; }
.chev { display: inline-flex; width: 14px; height: 14px; color: var(--ink-4); transition: transform .3s var(--ease-pop); }
.picker[aria-expanded="true"] .chev { transform: rotate(180deg); }
.pop {
  position: fixed; z-index: 50;
  width: 300px; max-height: min(420px, 70vh);
  display: flex; flex-direction: column;
  background: var(--elev);
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .07), 0 18px 48px rgba(var(--shadow-rgb), .16), 0 4px 12px rgba(var(--shadow-rgb), .06);
  transform-origin: top center;
  animation: pop-in .26s var(--ease-pop);
  overflow: hidden;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.pop-search {
  margin: 8px; height: 38px; border: 0; outline: 0; border-radius: 11px; padding: 0 12px;
  background: rgba(var(--ink-rgb), var(--wash)); color: var(--ink);
  font: 500 14px var(--font-ui);
}
.pop-list { overflow-y: auto; padding: 0 6px 6px; scrollbar-width: none; }
.pop-list::-webkit-scrollbar { display: none; }
.pop-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; height: 38px; padding: 0 10px;
  border: 0; border-radius: 10px; background: none; cursor: pointer; text-align: left;
  font-size: 14px; color: var(--ink);
}
.pop-opt small { color: var(--ink-4); font-size: 12px; }
.pop-opt[aria-selected="true"] { font-weight: 600; }
.pop-opt.active { background: rgba(var(--ink-rgb), var(--wash)); }

/* ─────────────────────────── results ─────────────────────────── */
.main-card { padding: 22px 24px 12px; container-type: inline-size; display: flex; flex-direction: column; }
.main-card > .card-title, .main-card > .chart-bar { flex: 0 0 auto; }
.summary {
  flex: 0 0 auto;
  padding-bottom: 18px; margin-bottom: 16px; border-bottom: 1px solid var(--rule);
}
/* the result strip: chance, savings at retirement, spending, withdrawal rate — on the card itself */
.facts {
  margin: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  font-variant-numeric: tabular-nums;
}
.fact { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 2px 18px; min-width: 0; }
.fact:first-child { padding-left: 0; }
.fact + .fact::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 1px; background: var(--rule); }
.fact dt { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the four results are the headline: large, and sized to the card's width */
.fact dd { margin: 2px 0 0; font-family: var(--font-head); font-size: clamp(24px, 4.1cqi, 38px); line-height: 1.1; font-weight: 600; letter-spacing: -.03em; color: var(--ink); white-space: nowrap; }
.fact-input {
  display: block; width: calc(100% + 12px); margin: -3px -6px; padding: 3px 6px;
  border: 0; outline: 0; border-radius: 8px; background: transparent;
  font: inherit; letter-spacing: inherit; color: inherit; font-variant-numeric: tabular-nums;
  cursor: text; transition: background .15s, box-shadow .15s;
}
.fact-input:hover { background: rgba(var(--elev-rgb), .6); }
.fact-input:focus { background: var(--elev); box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .14), 0 2px 8px rgba(var(--shadow-rgb), .07); }
@container (max-width: 640px) {
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 0; }
  .fact dd { font-size: clamp(24px, 6.4cqi, 36px); }
  .fact { padding: 12px 18px; }
  .fact:nth-child(odd) { padding-left: 0; }
  .fact:nth-child(-n+2) { padding-top: 2px; }
  .fact + .fact::before { display: none; }
  .fact:nth-child(even)::before { content: ""; display: block; position: absolute; left: 0; top: 4px; bottom: 4px; width: 1px; background: var(--rule); }
  .fact:nth-child(n+3)::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--rule); }
}
@container (max-width: 420px) {
  .facts { grid-template-columns: minmax(0, 1fr); }
  .fact, .fact:nth-child(odd), .fact:nth-child(-n+2) { flex-direction: row; align-items: baseline; justify-content: space-between; padding: 10px 0; }
  .fact:first-child { padding-top: 2px; }
  .fact:nth-child(even)::before { display: none; }
  .fact::after { display: none; }
  .fact + .fact::after { content: ""; display: block; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--rule); }
  .fact dd { font-size: 22px; }
  .fact-input { width: 8em; text-align: right; }
}
.eyebrow { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.headline { display: flex; align-items: flex-end; gap: 14px; min-width: 0; }
/* the text block moves as one unit; its last line sits on the digits' baseline
   (digit baseline is .906em down the 1em number box; the caption's descent is ~4.5px) */
.headline-text { min-width: 0; padding-bottom: calc(68px * .094 - 4.5px); }
.headline-title { margin: 0; min-width: 0; font-family: var(--font-head); font-size: 17px; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; color: var(--ink); text-wrap: pretty; font-variant-numeric: tabular-nums; }

.big {
  flex: 0 0 auto;
  font-family: var(--font-head); font-weight: 600;
  font-size: 68px; line-height: 1; letter-spacing: -.045em;
  display: flex; align-items: flex-start;
}
.big .pct { font-size: .42em; margin-top: .14em; margin-left: .08em; letter-spacing: -.02em; color: var(--ink-3); }
/* clip only top and bottom, so wide digits never lose their edges */
.odo { display: inline-flex; height: 1em; clip-path: inset(0 -.25em); margin-right: .04em; }
.odo-col { position: relative; width: .62em; height: 1em; clip-path: inset(0 -.25em); }
.odo-col.narrow { width: .4em; }
.odo-strip { display: flex; flex-direction: column; will-change: transform; }
.odo-strip span { height: 1em; line-height: 1; display: block; text-align: center; }


.tile { padding: 16px 16px 15px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; min-height: 117px; }
.tile-label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; line-height: 1.3; }
.tile-value { font-family: var(--font-head); font-weight: 600; font-size: 26px; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* chart */
.card-title { font-family: var(--font-head); font-weight: 600; font-size: 17px; letter-spacing: -.015em; margin: 0 0 12px; }
/* legend chips and the two toggles share one row, all 28px tall */
.chart-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 8px; }
.head-ctl { display: flex; flex-wrap: wrap; gap: 6px; }
.head-ctl .seg { padding: 2px; }
.head-ctl .seg-btn { height: 24px; padding: 0 11px; font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; transition: opacity .2s; }
/* compact key for narrow cards */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.title-row .card-title { margin: 0; }
/* compact key: three overlapping dots + "Key", only on narrow cards */
.key-pill {
  display: none; align-items: center; gap: 7px;
  height: 30px; padding: 0 11px 0 8px;
  border: 0; border-radius: 999px; background: var(--pill); cursor: pointer;
  color: var(--ink-2); font-size: 12.5px; font-weight: 500;
  transition: background .15s, transform .2s var(--ease-pop);
}
.key-pill:hover { background: color-mix(in srgb, var(--pill) 92%, var(--ink)); }
.key-pill:active { transform: scale(.96); }
.key-pill:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(var(--ink-rgb), .3); }
.key-dots { display: inline-flex; }
.key-dots i { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 0 2px var(--pill), inset 0 0 0 1px rgba(var(--ink-rgb), .16); position: relative; }
.key-dots i + i { margin-left: -5px; }
.key-dots i:nth-child(1) { z-index: 3; }
.key-dots i:nth-child(2) { z-index: 2; }
.key-dots i:nth-child(3) { z-index: 1; background: color-mix(in srgb, var(--c-dead) 78%, var(--ink)) !important; }   /* the gray dot would vanish into the pill otherwise */
@container (max-width: 560px) {
  .legend { display: none; }
  .key-pill { display: inline-flex; }
}
.sheet-root { position: fixed; inset: 0; z-index: 70; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .32); opacity: 0; transition: opacity .28s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 520px; margin: 0 auto;
  padding: 8px 18px max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--elev);
  box-shadow: 0 -12px 40px rgba(var(--shadow-rgb), .18);
  transform: translateY(100%); transition: transform .34s var(--ease-pop);
}
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet-root.open .sheet { transform: none; }
.sheet-grab { width: 36px; height: 5px; border-radius: 99px; background: rgba(var(--ink-rgb), .18); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h3 { margin: 0; font-family: var(--font-head); font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
.sheet-close { width: 32px; height: 32px; }
.sheet-close svg { width: 15px; height: 15px; }
.sheet-list { list-style: none; margin: 0; padding: 0; }
.sheet-list li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.sheet-list li > span { flex: 1 1 auto; min-width: 0; }
.sheet-list li > .switch { align-self: center; }
.sheet-list li + li { border-top: 1px solid var(--rule); }
.sheet-list i { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 3.5px; margin-top: 3px; }
.sheet-list b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.sheet-list small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.legend.dim { opacity: .5; pointer-events: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(var(--ink-rgb), var(--wash));
  color: var(--ink-2); font-size: 12px; font-weight: 500;
  transition: background .15s, opacity .2s, transform .2s var(--ease-pop);
}
.chip:hover { background: rgba(var(--ink-rgb), calc(var(--wash) + .03)); }
.chip:active { transform: scale(.95); }
.chip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
/* a faint outline keeps dark swatches visible against dark chips, tooltips and sheets */
.chip i, .tip-row i, .sheet-list i { box-shadow: inset 0 0 0 1px rgba(var(--ink-rgb), .16); }
.chip[aria-pressed="false"] { opacity: .45; }
.chip.static { cursor: default; }
.chip.static:active { transform: none; }
.plot { position: relative; padding: 10px 6px 4px 0; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
@media (min-width: 921px) {
  .plot { flex: 1 1 0; min-height: 0; }
}
.plot .axis text { fill: var(--ink-4); font-size: 11px; font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.plot .gridline { stroke: rgba(var(--ink-rgb), .07); stroke-width: 1; }
.plot .band { transition: opacity .25s; }
.plot.focus .band { opacity: .28; }
.plot.focus .band.on { opacity: 1; }
.plot .gap { fill: none; stroke: var(--card); stroke-width: 2; stroke-linejoin: round; }
.plot .retire { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .55; }
.plot .retire-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--font-ui); }
.plot .cross { stroke: var(--ink); stroke-width: 1.5; opacity: 0; transition: opacity .15s; }
.plot.hover .cross { opacity: .55; }
.tip {
  position: absolute; top: 8px; z-index: 5; pointer-events: none;
  min-width: 196px; padding: 12px 13px 10px;
  background: var(--elev); border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(var(--ink-rgb), .07), 0 12px 32px rgba(var(--shadow-rgb), .14);
  opacity: 0; transform: translateY(4px) scale(.98);
  transition: opacity .16s, transform .22s var(--ease-pop);
  font-size: 12.5px;
}
.plot.hover .tip { opacity: 1; transform: none; }
.tip-age { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-head); font-weight: 600; font-size: 15px; margin-bottom: 8px; letter-spacing: -.01em; }
.tip-age small { font-family: var(--font-ui); font-size: 11.5px; font-weight: 500; color: var(--ink-4); letter-spacing: 0; }
.tip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 2.5px 0; color: var(--ink-2); }
.tip-row span { display: inline-flex; align-items: center; gap: 7px; }
.tip-row i { width: 8px; height: 8px; border-radius: 3px; }
.tip-row b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tip-sep { height: 1px; background: var(--rule); margin: 7px 0; }



/* ─────────────────────────── responsive ─────────────────────────── */
@media (max-width: 920px) {
  .app { padding: 0 16px 90px; }
  .grid { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none !important; height: auto !important; overflow: visible; order: 2; }
  .main-card { height: auto !important; }
  .panel-scroll { overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .results { order: 1; }
}
@media (max-width: 520px) {
  .card { border-radius: 24px; }
  .big { font-size: 58px; }
  .headline-text { padding-bottom: calc(58px * .094 - 4.5px); }
  .tile { min-height: 104px; padding: 14px; }
  .tile-value { font-size: 22px; }
  .main-card { padding: 18px 16px 10px; }
  .field.cell .field-input { font-size: 16px; }
  .field-input { width: 7.1em; }
  .field-pct { width: 3em; padding: 0 4px; }
  .seg.four .seg-btn { padding: 0 5px; font-size: 11.5px; }
  .field { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
