/* Common Tools — design system ("colour chapters").
   The tools come in five chapters, and each chapter owns one flat colour: Money ultramarine, Health & safety signal red,
   Everyday yellow, Privacy & security ink (black on light pages, white on dark ones), Work & study pink. The hub hangs the
   chapters as full-bleed poster fields; every tool page wears its chapter's colour as the band behind its title and as
   its closing field. Inside the working area the chrome is neutral and the chapter's data hue goes on the main figure
   and the main chart series only. One typeface, Chivo, with tabular figures everywhere.
   Grid: a centred 1152px column, 12 columns x 12px gutters: 12 x 85 + 11 x 12 = 1152. */

:root {
  --ground: #f3f3f3;
  --surface: #ffffff;
  --raised: #efefef;
  --active: #e5e5e5;
  --border: #e2e2e2;
  --rule: #ededed;
  --control: #cbcbcb;
  --text: #0a0a0a;
  --muted: #555555;
  --faint: #636363;
  --primary: #0a0a0a;
  --primary-ink: #ffffff;
  --secondary: #e5e5e5;
  --positive: #247b50;
  --negative: #c4242a;
  --warning: #92400e;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e; --notice-border: #fde68a;
  --pill-neutral-bg: #ececec; --pill-neutral-ink: #3a3a3a;
  --data: #1423b8;
  --data-ink: #ffffff;
  --chart-muted: #c4c4c4;
  --chart-span: 0.07;
  --grid: #e8e8e8;
  --focus: #1423b8;

  /* the chapter colours, flat, at full strength */
  --c-money: #1423b8;    --c-money-ink: #ffffff;
  --c-health: #d0262c;   --c-health-ink: #ffffff;
  --c-everyday: #f7dd47; --c-everyday-ink: #0a0a0a;
  --c-privacy: #0a0a0a;  --c-privacy-ink: #ffffff;
  --c-work: #e9479f;     --c-work-ink: #0a0a0a;
  --c-accent: #1fc27a;   --c-accent-ink: #0a0a0a;

  --font: "Chivo", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-fig: var(--font);
  --font-display: var(--font);
  --font-code: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 30px; --fs-lead: 36px; --fs-body: 15px; --fs-small: 13px;

  --col: 1152px;
  --gap: 12px;
  --pad: 20px;
  --radius-card: 8px;
  --radius-control: 6px;
  --control-height: 40px;
  --row-height: 44px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 220ms;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0e0e0e; --surface: #171717; --raised: #202020; --active: #2a2a2a;
    --border: #2a2a2a; --rule: #212121; --control: #444444;
    --text: #f5f5f5; --muted: #b4b4b4; --faint: #969696;
    --primary: #f5f5f5; --primary-ink: #0a0a0a; --secondary: #2a2a2a;
    --positive: #3fc07a; --negative: #f0727a; --warning: #e8b04a;
    --pill-positive-bg: #15281c; --pill-positive-ink: #5fd393;
    --pill-negative-bg: #2e1a1d; --pill-negative-ink: #ff8f95;
    --pill-warning-bg: #2b2414; --pill-warning-ink: #f0bf5a; --notice-border: #5a4718;
    --pill-neutral-bg: #262626; --pill-neutral-ink: #dcdcdc;
    --data: #8b97ff; --data-ink: #0a0a0a;
    --chart-muted: #4d4d4d; --chart-span: 0.14; --grid: #262626; --focus: #8b97ff;
    --c-privacy: #f2f2f2; --c-privacy-ink: #0a0a0a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0e0e0e; --surface: #171717; --raised: #202020; --active: #2a2a2a;
  --border: #2a2a2a; --rule: #212121; --control: #444444;
  --text: #f5f5f5; --muted: #b4b4b4; --faint: #969696;
  --primary: #f5f5f5; --primary-ink: #0a0a0a; --secondary: #2a2a2a;
  --positive: #3fc07a; --negative: #f0727a; --warning: #e8b04a;
  --pill-positive-bg: #15281c; --pill-positive-ink: #5fd393;
  --pill-negative-bg: #2e1a1d; --pill-negative-ink: #ff8f95;
  --pill-warning-bg: #2b2414; --pill-warning-ink: #f0bf5a; --notice-border: #5a4718;
  --pill-neutral-bg: #262626; --pill-neutral-ink: #dcdcdc;
  --data: #8b97ff; --data-ink: #0a0a0a;
  --chart-muted: #4d4d4d; --chart-span: 0.14; --grid: #262626; --focus: #8b97ff;
  --c-privacy: #f2f2f2; --c-privacy-ink: #0a0a0a;
  color-scheme: dark;
}

/* ---------- each tool takes its chapter: the band colour, its ink, and the data hue (light, then dark) ---------- */
[data-tool="loan"], [data-tool="debt"], [data-tool="savings"], [data-tool="split"], [data-tool="energy"], [data-cat="money"] {
  --band: var(--c-money); --band-ink: var(--c-money-ink); --data: #1423b8; --data-ink: #ffffff; }
[data-tool="cpr"], [data-tool="ice"], [data-tool="bmi"], [data-tool="duedate"], [data-cat="health"] {
  --band: var(--c-health); --band-ink: var(--c-health-ink); --data: #d0262c; --data-ink: #ffffff; }
[data-tool="units"], [data-tool="dates"], [data-tool="timezones"], [data-tool="qr"], [data-cat="everyday"] {
  --band: var(--c-everyday); --band-ink: var(--c-everyday-ink); --data: #8f7200; --data-ink: #ffffff; }
[data-tool="password"], [data-tool="photoclean"], [data-cat="privacy"] {
  --band: var(--c-privacy); --band-ink: var(--c-privacy-ink); --data: #13804a; --data-ink: #ffffff; }
[data-tool="contrast"], [data-tool="readability"], [data-tool="gpa"], [data-cat="work"] {
  --band: var(--c-work); --band-ink: var(--c-work-ink); --data: #c4237c; --data-ink: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is([data-tool="loan"], [data-tool="debt"], [data-tool="savings"], [data-tool="split"], [data-tool="energy"], [data-cat="money"]) { --data: #8b97ff; --data-ink: #0a0a0a; }
  :root:not([data-theme="light"]) :is([data-tool="cpr"], [data-tool="ice"], [data-tool="bmi"], [data-tool="duedate"], [data-cat="health"]) { --data: #ff6b6b; --data-ink: #0a0a0a; }
  :root:not([data-theme="light"]) :is([data-tool="units"], [data-tool="dates"], [data-tool="timezones"], [data-tool="qr"], [data-cat="everyday"]) { --data: #f7dd47; --data-ink: #0a0a0a; }
  :root:not([data-theme="light"]) :is([data-tool="password"], [data-tool="photoclean"], [data-cat="privacy"]) { --data: #1fc27a; --data-ink: #0a0a0a; }
  :root:not([data-theme="light"]) :is([data-tool="contrast"], [data-tool="readability"], [data-tool="gpa"], [data-cat="work"]) { --data: #f06bb5; --data-ink: #0a0a0a; }
}
:root[data-theme="dark"] :is([data-tool="loan"], [data-tool="debt"], [data-tool="savings"], [data-tool="split"], [data-tool="energy"], [data-cat="money"]) { --data: #8b97ff; --data-ink: #0a0a0a; }
:root[data-theme="dark"] :is([data-tool="cpr"], [data-tool="ice"], [data-tool="bmi"], [data-tool="duedate"], [data-cat="health"]) { --data: #ff6b6b; --data-ink: #0a0a0a; }
:root[data-theme="dark"] :is([data-tool="units"], [data-tool="dates"], [data-tool="timezones"], [data-tool="qr"], [data-cat="everyday"]) { --data: #f7dd47; --data-ink: #0a0a0a; }
:root[data-theme="dark"] :is([data-tool="password"], [data-tool="photoclean"], [data-cat="privacy"]) { --data: #1fc27a; --data-ink: #0a0a0a; }
:root[data-theme="dark"] :is([data-tool="contrast"], [data-tool="readability"], [data-tool="gpa"], [data-cat="work"]) { --data: #f06bb5; --data-ink: #0a0a0a; }

body {
  --data-soft: color-mix(in srgb, var(--data) 13%, var(--surface));
  --chart-1: var(--data);
  --chart-2: var(--text);
  --chart-mark: var(--text);
  --ink: var(--text);
  --axis-ink: var(--muted);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 var(--fs-body)/1.5 var(--font); font-variant-numeric: lining-nums tabular-nums; -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--data) 25%, transparent); }
.num, .fig, table, .kpi-value, .lead-value { font-variant-numeric: lining-nums tabular-nums; }
.fig, .kpi-value, .lead-value, td.n, .mono { font-family: var(--font-fig); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- column ---------- */
.col {
  width: 100%;
  max-width: calc(var(--col) + 2 * 24px);
  margin-inline: auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}

/* ---------- top bar: in the chapter colour, a soft edge only once content scrolls under it ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--band, var(--ground)); color: var(--band-ink, var(--text)); transition: box-shadow var(--t-ui) ease; }
.topbar.scrolled { box-shadow: 0 8px 24px rgb(0 0 0 / 16%); }
.topbar-in { display: flex; align-items: center; gap: 20px; height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.logo-mark { width: 22px; height: 22px; flex: none; }
.logo-mark .m-ink { fill: currentColor; }
.logo-mark .m-data { fill: currentColor; fill-opacity: 0.45; }
.crumb { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: color-mix(in srgb, currentColor 78%, transparent); text-decoration: none; }
.crumb::before { content: "/"; margin-right: 12px; opacity: 0.5; }
a.crumb:hover { color: currentColor; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.private { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; color: color-mix(in srgb, currentColor 80%, transparent); }
.private svg { width: 14px; height: 14px; }
.topbar .btn { background: transparent; border-color: color-mix(in srgb, currentColor 45%, transparent); color: inherit; font-weight: 700; }
.topbar .btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }

/* tools menu: a sheet that floats, so it may carry a shadow */
.menu-sheet {
  position: fixed; z-index: 40;
  top: calc(60px + env(safe-area-inset-top, 0px));
  right: max(24px, calc((100vw - var(--col)) / 2));
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 84px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 18%), 0 2px 6px rgb(0 0 0 / 6%);
  padding: 8px;
  transform-origin: top right;
  animation: sheet-in var(--t-ui) var(--ease-out);
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.menu-group { padding: 8px; }
.menu-group h2 { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text); padding: 4px 8px 6px; }
.menu-group h2::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--band); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent); }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.menu-grid a { display: grid; gap: 1px; padding: 8px; border-radius: 6px; text-decoration: none; transition: background-color var(--t-hover) ease; }
.menu-grid a:hover, .menu-grid a:focus-visible { background: var(--raised); }
.menu-grid a[aria-current="page"] { background: var(--active); }
.menu-grid b { font-weight: 700; font-size: 14px; }
.menu-grid span { color: var(--muted); font-size: 13px; line-height: 1.35; }

/* ---------- title row ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 28px 0 20px; flex-wrap: wrap; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; }
.title-row .sub { margin-top: 6px; color: var(--muted); max-width: 72ch; }
.title-row .sub strong { color: var(--text); font-weight: 700; }
.title-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- grid and panels ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: 1 / -1; }
.stack { display: grid; gap: var(--gap); min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--pad); min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel > header, .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.panel h3 { font-size: 14px; font-weight: 700; }
.meta { color: var(--faint); font-size: var(--fs-small); }
.chart { position: relative; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: var(--fs-small); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- the lead figure and KPI strip ---------- */
.lead { display: grid; gap: 4px; }
.lead-label { color: var(--muted); }
.lead-value { font-size: var(--fs-lead); line-height: 1.1; font-weight: 800; letter-spacing: -0.035em; overflow-wrap: anywhere; color: var(--data); }
.lead-value small { font-size: 0.5em; color: var(--muted); font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.lead-note { color: var(--muted); }
.lead-note strong { color: var(--text); font-weight: 700; }
.kpis { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border-top: 1px solid var(--rule); margin: 18px calc(-1 * var(--pad)) calc(-1 * var(--pad)); }
.kpis.standalone { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.kpi { padding: 14px var(--pad); min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { margin-top: 4px; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.kpi-value small { display: block; margin-top: 2px; font-family: var(--font); font-size: 13px; line-height: 1.35; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.kpi-value.data { color: var(--data); }

/* ---------- forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.field { display: grid; gap: 7px; min-width: 0; align-content: start; }
.field > label, .field > .label { font-weight: 700; font-size: 14px; }
.field .hint { color: var(--muted); font-size: var(--fs-small); line-height: 1.4; }
.field .err { color: var(--negative); font-size: var(--fs-small); font-weight: 700; }
.input, select.input, textarea.input {
  width: 100%; min-width: 0;
  height: var(--control-height);
  padding: 0 12px;
  font-size: 16px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-hover) ease, box-shadow var(--t-hover) ease;
}
.input:hover { border-color: color-mix(in srgb, var(--control) 55%, var(--text)); }
.input:focus-visible { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.input::placeholder { color: var(--faint); }
input.input[type="number"], .input.fig { font-family: var(--font-fig); font-size: 16px; }
textarea.input { height: auto; min-height: 140px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select.input { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5l3-3' fill='none' stroke='%23777777' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px; }
.input[aria-invalid="true"] { border-color: var(--negative); }
.affix { display: flex; align-items: stretch; min-width: 0; }
.affix .input { border-radius: 0; }
.affix .input:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.affix .input:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.affix > span { display: grid; place-items: center; padding: 0 11px; background: var(--raised); border: 1px solid var(--control); color: var(--muted); font-size: 14px; white-space: nowrap; }
.affix > span:first-child { border-right: 0; border-radius: var(--radius-control) 0 0 var(--radius-control); }
.affix > span:last-child { border-left: 0; border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 2px 0 0; flex: none; accent-color: var(--text); }
input[type="range"] { width: 100%; accent-color: var(--text); height: 24px; }
input[type="color"] { width: 44px; height: var(--control-height); padding: 3px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); cursor: pointer; }

/* segmented control: as wide as its options */
.segmented { display: inline-flex; width: max-content; max-width: 100%; padding: 3px; border-radius: 8px; background: var(--raised); flex-wrap: wrap; gap: 2px; }
.segmented button, .segmented label { position: relative; height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented button:hover, .segmented label:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented label:has(input:checked) { background: var(--primary); color: var(--primary-ink); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); color: var(--text); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--primary) 82%, var(--ground)); }
.btn.secondary { background: var(--secondary); border-color: transparent; }
.btn.secondary:hover { background: color-mix(in srgb, var(--secondary) 80%, var(--text)); }
.btn.ghost { background: transparent; border-color: transparent; padding: 0 8px; }
.btn.ghost:hover { background: var(--raised); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 6px; color: var(--muted); cursor: pointer; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--text); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--control); }
.link-btn:hover { text-decoration-color: currentColor; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
.table-wrap.tall { max-height: 460px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface); height: 38px; padding: 0 12px; text-align: left; font-weight: 400; font-size: var(--fs-small); color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
th:first-child, td:first-child { padding-left: var(--pad); }
th:last-child, td:last-child { padding-right: var(--pad); }
tbody tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; }
td.n { font-size: 14px; white-space: nowrap; }
td .sub { display: block; font-size: var(--fs-small); color: var(--muted); }
tr.year-row td { font-weight: 700; }
td.dim, .dim { color: var(--muted); }

/* ---------- pills, notices ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; flex: none; }
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-control); background: var(--raised); color: var(--text); font-size: 14px; line-height: 1.45; }
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.notice.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); box-shadow: inset 0 0 0 1px var(--notice-border); }
.notice.warn svg { color: currentColor; }
.notice.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.notice.neg svg { color: currentColor; }
.notice p + p { margin-top: 4px; }
.empty { display: grid; place-items: center; min-height: 96px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-control); color: var(--muted); text-align: center; grid-column: 1 / -1; }
.up { color: var(--positive); } .down { color: var(--negative); }

/* ---------- editable rows (debts, people, courses, appliances) ---------- */
.erows { display: grid; gap: 8px; }
.erow { display: grid; gap: 8px; align-items: end; padding: 12px; border-radius: var(--radius-control); background: var(--raised); }
.erow .field > label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.erow .input { height: 38px; }
.erow-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.swatch-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- method section ---------- */
.method { padding: 48px 0 24px; }
.method-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.method-main { grid-column: span 8; }
.method-side { grid-column: span 4; }
.method h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 12px; }
.method h3 { font-size: 15px; font-weight: 700; margin: 22px 0 6px; }
.method p, .method li { max-width: 70ch; color: var(--text); }
.method p + p { margin-top: 8px; }
.method ul, .method ol { padding-left: 1.2em; margin-top: 6px; display: grid; gap: 4px; }
.formula { margin: 10px 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control); font-family: var(--font-code); font-size: 13.5px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.sources { display: grid; gap: 10px; font-size: 14px; }
.sources a { color: var(--text); text-decoration-color: var(--control); text-underline-offset: 3px; overflow-wrap: anywhere; }
.sources a:hover { text-decoration-color: currentColor; }
.sources li { color: var(--muted); }

/* ---------- footer: the chapter's closing field, with the rest of the chapter (assets/common.js) ---------- */
.foot { margin-top: 56px; padding: 44px 0 36px; background: var(--band, var(--text)); color: var(--band-ink, var(--surface)); font-size: 14px; }
.foot-in { display: flex; gap: 8px 24px; flex-wrap: wrap; justify-content: space-between; }
.foot a { color: inherit; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.foot a:hover { text-decoration-color: currentColor; }
.foot p { max-width: 70ch; }
.foot-more { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; align-items: end; margin-bottom: 40px; }
.foot-more h2 { grid-column: 1 / -1; font-size: 15px; font-weight: 700; }
.foot-more ul { list-style: none; padding: 0; display: grid; gap: 2px; }
.foot-more li a { display: inline-block; font-size: clamp(30px, 4.6vw, 60px); font-weight: 900; text-transform: uppercase; letter-spacing: -0.04em; line-height: 0.95; text-decoration: none; transition: opacity var(--t-hover) ease, transform var(--t-ui) var(--ease-out); }
.foot-more li a:hover { opacity: 0.72; transform: translateX(6px); }
.foot-more .all { font-weight: 700; font-size: 16px; white-space: nowrap; }
.foot-in:has(.foot-more) > p:last-child:not(:first-of-type) { display: none; }

/* ---------- toast (floats) ---------- */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--primary); color: var(--primary-ink); padding: 10px 16px; border-radius: 8px; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / 18%); animation: toast-in var(--t-ui) var(--ease-out); max-width: calc(100vw - 32px); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- motion: feedback only ---------- */
.flash { animation: flash 600ms var(--ease-out); }
@keyframes flash { from { background-color: var(--data-soft); } to { background-color: transparent; } }

/* ---------- tablet and phone ---------- */
@media (max-width: 960px) {
  .grid > [class*="span-"] { grid-column: 1 / -1; }
  .method-main, .method-side { grid-column: 1 / -1; }
  .private-text { display: none; }
}
@media (max-width: 640px) {
  :root { --pad: 16px; --fs-lead: 30px; --fs-title: 22px; }
  .col { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .title-row { padding: 20px 0 16px; }
  .crumb { display: none; }
  .kpis { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .kpi:nth-child(2n) { border-left: 1px solid var(--rule); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .menu-grid { grid-template-columns: minmax(0, 1fr); }
  .menu-sheet { right: 16px; left: 16px; width: auto; }
  .segmented { display: flex; width: 100%; }
  .segmented button, .segmented label { flex: 1; }
  .foot-more { grid-template-columns: minmax(0, 1fr); }
  .foot-more li a { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
@media print {
  .topbar, .no-print, .foot, .menu-sheet, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { border-color: #ccc; break-inside: avoid; }
  .grid > [class*="span-"] { grid-column: 1 / -1; }
}

/* =====================================================================================
   The band: the tool's chapter colour runs full width behind the top bar and the title, flat, with the
   name set large in capitals and the tool's own line illustration beside it (assets/common.js).
   ===================================================================================== */
:root { --band: #0a0a0a; --band-ink: #ffffff; }
body.has-band { overflow-x: clip; }

.has-band .title-row { position: relative; background: var(--band); display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 48px; align-items: center; padding: 26px 0 44px; margin-bottom: 28px; color: var(--band-ink); }
.has-band .title-row::before { content: ""; position: absolute; z-index: -1; top: -1px; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw); background: var(--band); }
.has-band .title-row > div:first-child { grid-column: 1; grid-row: 1; }
.has-band .title-row h1 { font-family: var(--font-display); font-size: clamp(34px, 5vw, 64px); font-weight: 900; text-transform: uppercase; line-height: 0.92; letter-spacing: -0.045em; text-wrap: balance; }
.has-band .title-row .sub { margin-top: 18px; color: var(--band-ink); font-size: 17px; line-height: 1.5; max-width: 62ch; }
.has-band .title-row .sub strong { color: var(--band-ink); font-weight: 800; }
.has-band .title-row .sub .dim { color: var(--band-ink); font-weight: 400; }
.has-band .title-actions { grid-column: 1; grid-row: 2; margin-top: 22px; }
.has-band .title-actions .btn { background: transparent; border-color: color-mix(in srgb, var(--band-ink) 50%, var(--band)); color: var(--band-ink); }
.has-band .title-actions .btn:hover { background: color-mix(in srgb, var(--band-ink) 12%, var(--band)); }
.has-band .title-actions .btn.primary { background: var(--band-ink); color: var(--band); border-color: transparent; }
.has-band .title-actions .btn.ghost { border-color: transparent; }
.band-art { grid-column: 2; grid-row: 1 / span 2; width: clamp(150px, 21vw, 250px); color: var(--band-ink); }
.band-art .art { width: 100%; height: auto; overflow: visible; }

/* the illustrations */
.art { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; --sw: 2.4; }
.art * { stroke-width: var(--sw); }
.art .f { fill: currentColor; fill-opacity: 0.18; }
.art .s { fill: currentColor; stroke: none; }
.art .o { opacity: 0.5; }
.art .thick { stroke-width: calc(var(--sw) * 1.8); }
.art text { stroke: none; font-family: var(--font-display); font-weight: 900; letter-spacing: -0.02em; }
.art .cut { fill: var(--band); }
.art .txt { fill: currentColor; }
/* draw-in and rise only start once frames are painting (.play is added on the second animation frame), so a
   paused or throttled page still shows the whole drawing */
.band-art.play .art .d { stroke-dasharray: 1; stroke-dashoffset: 1; animation: art-draw 1.5s var(--ease-out) 0.15s forwards; }
.band-art.play .art .grow { transform-box: fill-box; transform-origin: 50% 100%; animation: art-grow 0.9s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 90ms + 0.15s); }
.art .tw { animation: art-tw 2.4s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 0.4s); }
.art .beat { transform-box: fill-box; transform-origin: center; animation: art-beat 1.1s ease-in-out infinite; }
.art .ecg { stroke-dasharray: 0.24 0.76; stroke-width: calc(var(--sw) * 1.5); animation: art-ecg 2.2s linear infinite; }
.art .spin { transform-box: fill-box; transform-origin: center; animation: art-spin 6s ease-in-out infinite; }
.art .clock { transform-box: view-box; transform-origin: 172px 118px; animation: art-clock 10s linear infinite; }
.band-art.play .art .needle { transform-box: view-box; transform-origin: 110px 128px; animation: art-needle 2.4s var(--ease-out) both, art-draw 0.01s forwards; }
.band-art.done .art .d { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
.band-art.done .art .grow, .band-art.done .art .needle { animation: none; }
@keyframes art-draw { to { stroke-dashoffset: 0; } }
@keyframes art-grow { from { transform: scaleY(0.04); } to { transform: none; } }
@keyframes art-tw { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes art-beat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.09); } 24% { transform: scale(0.97); } 36% { transform: scale(1.05); } 52% { transform: scale(1); } }
@keyframes art-ecg { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes art-spin { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(0.12); } }
@keyframes art-clock { to { transform: rotate(360deg); } }
@keyframes art-needle { from { transform: rotate(-64deg); } 60% { transform: rotate(9deg); } to { transform: rotate(0deg); } }
/* small copies (menus, the hub): crisp thin strokes, no motion */
.art.mini { --sw: 1.6; }
.art.mini * { vector-effect: non-scaling-stroke; animation: none !important; }
.art.mini .ecg { display: none; }
@media (prefers-reduced-motion: reduce) {
  .art * { animation: none !important; }
  .band-art.play .art .d { stroke-dashoffset: 0; }
  .art .ecg { display: none; }
}

/* the phone: the illustration sits above the name like a sign's pictogram, so the name gets the full width */
@media (max-width: 640px) {
  .has-band .title-row { grid-template-columns: minmax(0, 1fr); align-items: start; padding: 18px 0 30px; margin-bottom: 20px; }
  .band-art { grid-column: 1; grid-row: 1; width: 96px; margin-bottom: 14px; }
  .has-band .title-row > div:first-child { grid-row: 2; }
  .has-band .title-actions { grid-column: 1; grid-row: 3; }
  .has-band .title-row h1 { font-size: clamp(28px, 8.4vw, 40px); }
  .has-band .title-row .sub { font-size: 16px; margin-top: 12px; }
}
@media print { .has-band .title-row { color: #000; } .has-band .title-row::before, .band-art { display: none; } }
