@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("assets/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("assets/fonts/newsreader-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("assets/fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("assets/fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;
  --bg: #FAF9F6;
  --surface: #FFFFFF;
  --sunk: #F3F1EC;
  --line: #E5E3DC;
  --line-strong: #CFCBC0;
  --ink: #111315;
  --ink-2: #444B52;
  --ink-3: #5A6169;
  --accent: #0F766E;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6F3F1;
  --danger: #B91C1C;
  --warn-soft: #FEF3C7;
  --s1: #0F766E; --s2: #B45309; --s3: #3730A3; --s4: #BE123C;
  --principal: #D6D3C9;
  --shadow-sm: 0 1px 2px 0 rgb(17 19 21 / 0.05);
  --shadow: 0 8px 24px -6px rgb(17 19 21 / 0.08), 0 2px 6px -2px rgb(17 19 21 / 0.04);
  --shadow-lg: 0 20px 44px -12px rgb(17 19 21 / 0.14), 0 4px 12px -4px rgb(17 19 21 / 0.06);
  --radius: 16px;
  --radius-md: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --serif: "Newsreader", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1210; --surface: #121C18; --sunk: #090E0C; --line: #21302A; --line-strong: #32453D;
    --ink: #ECF2EE; --ink-2: #B8C6BE; --ink-3: #8E9F96;
    --accent: #2DD4BF; --accent-ink: #042F2E; --accent-soft: #13312B; --danger: #F87171; --warn-soft: #2C2412;
    --s1: #2DD4BF; --s2: #F59E0B; --s3: #818CF8; --s4: #FB7185; --principal: #33433B;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
    --shadow: 0 8px 24px -6px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 20px 44px -12px rgb(0 0 0 / 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1210; --surface: #121C18; --sunk: #090E0C; --line: #21302A; --line-strong: #32453D;
  --ink: #ECF2EE; --ink-2: #B8C6BE; --ink-3: #8E9F96;
  --accent: #2DD4BF; --accent-ink: #042F2E; --accent-soft: #13312B; --danger: #F87171; --warn-soft: #2C2412;
  --s1: #2DD4BF; --s2: #F59E0B; --s3: #818CF8; --s4: #FB7185; --principal: #33433B;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
  --shadow: 0 8px 24px -6px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 20px 44px -12px rgb(0 0 0 / 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--sans); font-variant-numeric: tabular-nums;
  min-width: 300px; padding-bottom: calc(var(--tab-h) + 56px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
svg use { pointer-events: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; margin: 0; text-wrap: balance; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg:not(.chart) { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Top bar & tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid var(--line);
}
/* blur lives on a pseudo-element: backdrop-filter on .topbar itself would trap the fixed tab bar inside it */
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 20px/1 var(--serif); margin-right: auto; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgb(17 19 21 / 0.05);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); text-decoration: none; font-size: 11.5px; font-weight: 600;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs a[aria-current="page"] svg { stroke-width: 2.1; }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink-2); list-style: none;
}
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn::-webkit-details-marker { display: none; }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: 48px; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu-list button, .menu-list .as-button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 8px;
  background: none; text-align: left; font-size: 15px; cursor: pointer;
}
.menu-list button:hover, .menu-list .as-button:hover { background: var(--sunk); }

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .topbar { padding: 12px 28px; }
  .brand { margin-right: 0; }
  .tabs {
    position: static; display: flex; gap: 4px; height: auto; padding: 0; margin: 0 auto;
    background: none; border: 0;
  }
  .tabs a { flex-direction: row; gap: 8px; padding: 9px 16px; border-radius: 999px; font-size: 15px; }
  .tabs a svg { width: 20px; height: 20px; }
  .tabs a:hover { color: var(--ink); background: var(--sunk); }
  .tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
}

/* ---------- Layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 16px; overflow-x: clip; }
@media (min-width: 768px) { main { padding: 24px 28px 48px; } }
.view-head { margin: 8px 0 20px; }
.view-head h1 { font-size: clamp(28px, 5vw, 40px); }
.lede { color: var(--ink-2); margin: 8px 0 0; max-width: 62ch; line-height: 1.55; }

/* ---------- Plan toolbar & dropdown ---------- */
.plan-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px;
  margin-bottom: 14px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.plan-switcher { display: flex; align-items: center; gap: 10px; flex: 1 1 280px; min-width: 0; }
.select-wrap { position: relative; flex: 1; min-width: 0; max-width: 380px; }
.select-wrap select {
  width: 100%; min-height: 44px; padding: 9px 38px 9px 14px;
  appearance: none; -webkit-appearance: none;
  border-radius: var(--radius-md); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font-weight: 600; font-size: 15px;
  cursor: pointer; text-overflow: ellipsis;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.select-wrap select:hover { border-color: var(--ink-3); }
.select-wrap select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-chevron {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-3); pointer-events: none;
}
.assumptions-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--sunk);
  color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}
.assumptions-pill:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 520px) {
  .plan-switcher { flex-wrap: nowrap; }
  .plan-switcher .btn span { display: none; }
  .assumptions-pill { width: 100%; justify-content: center; }
}

.plan-head { display: flex; align-items: center; gap: 8px; margin: 10px 0 16px; }
.plan-name {
  flex: 1; min-width: 0; border: 0; border-bottom: 1.5px solid transparent; background: none; padding: 4px 0;
  font: 600 clamp(26px, 6vw, 36px)/1.15 var(--serif); letter-spacing: -0.015em; color: var(--ink); border-radius: 0;
}
.plan-name { border-bottom: 1.5px dashed var(--line-strong); }
.plan-name:hover { border-bottom-color: var(--ink-3); }
.plan-name:focus { outline: none; border-bottom-color: var(--accent); }
.plan-head-actions { display: flex; }

.plan-grid { display: grid; gap: 20px; }
@media (min-width: 980px) {
  .plan-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 28px; align-items: start; }
  .plan-results { position: sticky; top: 84px; }
}

/* ---------- Holding cards ---------- */
.holding {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: clip;
}
.holding-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 12px 4px 18px; }
.holding-head .titles { flex: 1; min-width: 0; }
.holding-name {
  width: 100%; border: 0; background: none; padding: 0; font: 600 19px/1.25 var(--serif); color: var(--ink);
  border-bottom: 1px solid transparent; border-radius: 0;
}
.holding-name { border-bottom: 1px dashed var(--line-strong); }
.holding-name:hover { border-bottom-color: var(--ink-3); }
.holding-name:focus { outline: none; border-bottom-color: var(--accent); }
.holding-kind { font-size: 13px; color: var(--ink-3); }
.outcome { margin: 6px 18px 0; color: var(--ink-2); font-size: 14.5px; }
.outcome b { color: var(--ink); font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 14px; padding: 14px 18px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); min-width: 0; }
.field.compact { max-width: 340px; }
.field input, .field select {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 16px; font-weight: 500;
}
.field input:hover, .field select:hover { border-color: var(--ink-3); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: 12.5px; }
.hint { color: var(--ink-3); font-size: 12.5px; font-weight: 400; min-height: 1em; }
.input-affix { position: relative; display: block; }
.input-affix input { padding-right: 46px; }
.input-affix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--ink-3); pointer-events: none; font-size: 15px; }
.input-affix.pre input { padding-left: 28px; padding-right: 12px; }
.input-affix.pre em { left: 12px; right: auto; }
.toggle-field { flex-direction: row; align-items: center; gap: 10px; min-height: 46px; }

details.more { border-top: 1px solid var(--line); }
details.more > summary {
  list-style: none; cursor: pointer; padding: 12px 18px; font-size: 14px; font-weight: 600; color: var(--accent);
  display: flex; align-items: center; gap: 6px;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.75px solid; border-bottom: 1.75px solid; transform: rotate(45deg) translateY(-2px); margin-left: 4px; transition: transform .2s; }
details.more[open] > summary::after { transform: rotate(-135deg) translateY(-1px); }
details.more .fields { padding-top: 0; }

/* switch */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* reinvest block */
.reinvest { background: var(--sunk); border-top: 1px solid var(--line); }
.reinvest-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; }
.reinvest-head .txt { flex: 1; }
.reinvest-head strong { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.reinvest-head strong svg { color: var(--accent); }
.reinvest-head small { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.reinvest .fields { padding-top: 0; }
.reinvest .field input, .reinvest .field select { background: var(--surface); }
.pot-line { margin: 0 18px; padding: 12px 0 16px; border-top: 1px dashed var(--line-strong); font-size: 14.5px; color: var(--ink-2); }
.pot-line b { color: var(--ink); }

.add-holding {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: transparent;
  color: var(--accent); font-weight: 600; font-size: 16px;
}
.add-holding:hover { border-color: var(--accent); background: var(--accent-soft); }

.empty-plan { padding: 22px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.empty-plan h2 { font-size: 22px; margin-bottom: 6px; }
.empty-plan p { color: var(--ink-2); margin: 0 0 14px; }

/* ---------- Results: passbook statement ---------- */
.statement { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.statement-top { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.statement-top .label { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.big { font: 600 clamp(38px, 9vw, 52px)/1.05 var(--serif); letter-spacing: -0.02em; margin: 4px 0 6px; font-variant-numeric: lining-nums tabular-nums; }
.sub { color: var(--ink-2); font-size: 15px; }
.sub b { color: var(--accent); font-weight: 600; }
.ledger { list-style: none; margin: 0; padding: 6px 20px 14px; }
.ledger li { display: flex; align-items: baseline; gap: 8px; padding: 9px 0; font-size: 15px; }
.ledger li + li { border-top: 1px dashed var(--line); }
.ledger .k { color: var(--ink-2); }
.ledger .k small { display: block; color: var(--ink-3); font-size: 12.5px; }
.ledger .v { margin-left: auto; font-weight: 600; text-align: right; white-space: nowrap; }
.ledger li.total { border-top: 1.5px solid var(--ink); margin-top: 2px; }
.ledger li.total .k { color: var(--ink); font-weight: 600; }
.ledger li.total .v { font-family: var(--serif); font-size: 19px; }
.rates { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.rates div { padding: 14px 12px 16px; text-align: center; }
.rates div + div { border-left: 1px solid var(--line); }
.rates b { display: block; font: 600 22px/1.2 var(--serif); }
.rates span { font-size: 12.5px; color: var(--ink-3); line-height: 1.3; display: block; margin-top: 3px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 14px; margin-top: 16px; box-shadow: var(--shadow); }
.panel h2 { font-size: 20px; }
.panel .panel-sub { color: var(--ink-3); font-size: 13.5px; margin: 4px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 4px; font-size: 13.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--ink-3) 0 4px, transparent 4px 7px) !important; }
.legend i.block { height: 10px; width: 10px; border-radius: 3px; }
.chart-wrap { position: relative; margin-top: 6px; }
.chart-wrap svg.chart { width: 100%; height: auto; display: block; color: var(--ink-3); touch-action: pan-y; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .tick { fill: var(--ink-3); }
svg.chart .barlabel, svg.chart .barvalue { fill: var(--ink); }
svg.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip {
  position: absolute; top: -6px; z-index: 5; pointer-events: none; min-width: 170px;
  background: var(--ink); color: var(--bg); border-radius: 10px; padding: 9px 11px; font-size: 13px; box-shadow: var(--shadow);
}
.tooltip strong { display: block; font-weight: 600; margin-bottom: 4px; }
.tooltip div { display: flex; align-items: center; gap: 7px; }
.tooltip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tooltip b { margin-left: auto; padding-left: 12px; }

.table-scroll { overflow-x: auto; margin: 8px -18px -14px; padding: 0 18px 14px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 12.5px; font-weight: 600; color: var(--ink-3); border-bottom-color: var(--line-strong); }
tbody tr:last-child td { border-bottom: 0; }
details.table-toggle > summary { list-style: none; cursor: pointer; font-weight: 600; color: var(--accent); display: flex; align-items: center; justify-content: space-between; }
details.table-toggle > summary::-webkit-details-marker { display: none; }
details.table-toggle > summary h2 { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 18px;
  border-radius: var(--radius-md); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 15px;
  text-decoration: none; color: var(--ink);
  transition: transform 150ms var(--ease), border-color 150ms var(--ease), background-color 150ms var(--ease), filter 150ms var(--ease);
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); border-color: var(--accent); }

/* ---------- Bottom result bar (phones) ---------- */
.result-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 25;
  display: flex; align-items: center; gap: 12px; padding: 9px 16px;
  background: var(--ink); color: var(--bg); font-size: 14px;
  transform: translateY(0); transition: transform .25s cubic-bezier(.2, .8, .2, 1), opacity .25s;
}
.result-bar.away { transform: translateY(100%); opacity: 0; pointer-events: none; }
.result-bar b { font: 600 18px/1.1 var(--serif); }
.result-bar .rb-rate { margin-left: auto; text-align: right; }
.result-bar small { display: block; opacity: .75; font-size: 12px; }
@media (min-width: 980px) { .result-bar { display: none; } }

/* ---------- Home ---------- */
/* Entrance: plays once each time Home opens (class added by JS, never on re-render). */
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes draw-under { from { transform: scaleX(0); } }
#view-home.entering :is(.home-hero h1, .home-hero .lede, .hero-actions, .stat-card, .home-grid > .panel, .home-explain, .plan-row, #home-strategies > .strategy) {
  animation: rise-in .55s cubic-bezier(.2, .8, .2, 1) both;
}
#view-home.entering .home-hero .lede { animation-delay: .07s; }
#view-home.entering .hero-actions { animation-delay: .14s; }
#view-home.entering .stat-card:nth-child(1) { animation-delay: .2s; }
#view-home.entering .stat-card:nth-child(2) { animation-delay: .26s; }
#view-home.entering .stat-card:nth-child(3) { animation-delay: .32s; }
#view-home.entering .home-grid > .panel { animation-delay: .36s; }
#view-home.entering .home-grid > .panel + .panel { animation-delay: .42s; }
#view-home.entering .plan-row { animation-delay: calc(.48s + var(--i, 0) * .06s); }
#view-home.entering #home-strategies > .strategy { animation-delay: .5s; }
#view-home.entering #home-strategies > .strategy:nth-child(2) { animation-delay: .55s; }
#view-home.entering #home-strategies > .strategy:nth-child(3) { animation-delay: .6s; }
#view-home.entering #home-strategies > .strategy:nth-child(n+4) { animation-delay: .65s; }
#view-home.entering .home-explain { animation-delay: .6s; }
/* A hand-ruled underline under "can become.", like a passbook entry */
.grow-word { position: relative; white-space: nowrap; }
.grow-word::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0.04em; height: 0.09em; min-height: 3px;
  background: var(--accent); border-radius: 2px; opacity: .85; transform-origin: left center;
}
#view-home.entering .grow-word::after { animation: draw-under .8s cubic-bezier(.6, 0, .2, 1) .35s both; }
/* Gentle responses on touch and hover */
.strategy > svg { transition: transform .2s var(--ease), color .2s var(--ease); }
.strategy:hover > svg { transform: translateX(4px); color: var(--accent); }
.strategy:active, .plan-row:active, .preset-chip:active, .hero-actions .btn:active { transform: scale(.98); }
.strategy, .preset-chip, .hero-actions .btn { transition-property: border-color, background-color, color, box-shadow, transform; transition-duration: .15s; }
.stat-card { transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
@media (hover: hover) { .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); } }
.stat-card b, .pr-num b { font-variant-numeric: tabular-nums; }
.home-hero { margin: 10px 0 22px; }
.home-hero h1 { font-size: clamp(32px, 6.5vw, 52px); letter-spacing: -0.025em; max-width: 19ch; }
.home-hero .lede { font-size: clamp(16px, 2vw, 18px); margin-top: 10px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
@media (max-width: 520px) { .hero-actions .btn { flex: 1 1 auto; } }

.home-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat-card small { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card b { display: block; font: 600 22px/1.2 var(--serif); color: var(--ink); margin-top: 4px; }
.stat-card span { display: block; font-size: 13px; color: var(--accent); font-weight: 500; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.amount-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.preset-chip {
  min-height: 34px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--sunk); color: var(--ink-2); font-size: 13px; font-weight: 600;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), color 150ms var(--ease);
}
.preset-chip:hover { border-color: var(--accent); color: var(--accent); }
.preset-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.home-grid { display: grid; gap: 0 22px; }
.home-plans { order: -1; } /* returning users see their plans first on phones */
@media (min-width: 980px) { .home-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } .home-plans { order: 0; } }
.home-grid .panel { margin-top: 0; margin-bottom: 18px; padding-bottom: 18px; }
.home-start .field { margin: 6px 0 4px; max-width: 380px; }
.home-start .strategy:last-child { margin-bottom: 0; }
.panel-title-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.text-link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; text-decoration: none; font-size: 15px; padding: 6px 0; }
.text-link svg { width: 18px; height: 18px; }
.plan-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 4px; border: 0; border-top: 1px dashed var(--line);
  background: none; text-align: left; border-radius: 8px; transition: background-color 150ms var(--ease);
}
.plan-row:first-child { border-top: 0; }
.plan-row:hover { background: var(--sunk); }
.plan-row:hover .pr-name { color: var(--accent); }
.plan-row .pr-main { flex: 1; min-width: 0; }
.pr-name { display: block; font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-meta { display: block; font-size: 13px; color: var(--ink-3); }
.pr-num { text-align: right; white-space: nowrap; }
.pr-num b { display: block; font: 600 18px/1.2 var(--serif); }
.pr-num span { font-size: 13px; color: var(--accent); font-weight: 600; }
.home-explain dl { margin: 12px 0 0; display: grid; gap: 14px; }
@media (min-width: 760px) { .home-explain dl { grid-template-columns: repeat(3, 1fr); gap: 24px; } }
.home-explain dt { font-weight: 600; margin-bottom: 3px; }
.home-explain dd { margin: 0; color: var(--ink-2); font-size: 14.5px; }

.goal-warn { margin: 8px 0 0; padding: 9px 11px; border-radius: 10px; background: var(--warn-soft); color: var(--ink); font-size: 13.5px; line-height: 1.45; }
.goal-corpus-text { font-size: 20px !important; }

.tax-strip { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--sunk); font-size: 14px; color: var(--ink-2); }
.tax-strip b { color: var(--ink); font-weight: 600; }
.tax-strip span:last-child b { color: var(--accent); }
.tax-nudge { margin-top: 10px; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; text-align: left; }
.tax-box { border: 0; padding: 0; margin: 4px 0 0; }
.tax-box legend { font: 600 17px var(--serif); padding: 0; margin-bottom: 2px; }
.bracket-list { display: grid; gap: 6px; margin: 10px 0 16px; }
.bracket { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.bracket input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.bracket .b-main { flex: 1; min-width: 0; }
.bracket b { display: block; font-size: 15px; font-weight: 600; }
.bracket small { display: block; color: var(--ink-3); font-size: 12.5px; }
.bracket .b-rate { font-weight: 600; color: var(--ink-2); }
.bracket.on { border-color: var(--accent); background: var(--accent-soft); }

/* scheme library management */
.scheme-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.badge.mine { background: var(--accent-soft); color: var(--accent); }
.icon-btn.sm { width: 36px; height: 36px; margin: -6px -8px 0 0; }
.link-btn { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.scheme-top .link-btn { color: var(--ink-3); font-weight: 500; }
.scheme-card.is-hidden { opacity: .55; }
.scheme-card.add-card {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; text-align: left; cursor: pointer;
  border: 1.5px dashed var(--line-strong); background: transparent; box-shadow: none; color: var(--ink-2); min-height: 170px; font: inherit;
}
.scheme-card.add-card svg { width: 26px; height: 26px; color: var(--accent); }
.scheme-card.add-card b { color: var(--accent); font-size: 16px; }
.scheme-card.add-card span { font-size: 13.5px; color: var(--ink-3); }
.scheme-card.add-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.filter-pill.add-pill { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); border-style: dashed; }
.filter-pill.add-pill svg { width: 16px; height: 16px; }
.hidden-note { color: var(--ink-3); font-size: 14px; margin: 14px 2px 0; }
.sc-sub { font-size: 17px; margin: 10px 0 2px; }
.sc-fields { padding: 10px 0 4px !important; }
.sheet-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 0 4px; background: var(--surface); border-top: 1px solid var(--line); margin-top: 8px; }
.sheet-actions .btn.primary { min-width: 150px; }
.danger-btn { color: var(--danger); margin-right: auto; }
.danger-btn:hover { border-color: var(--danger); }
.mine-tag { font: 600 11px var(--sans); color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; vertical-align: 2px; }
.manage-link { margin-top: 14px; border-style: dashed; }

/* ---------- Compare ---------- */
.compare-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.compare-selected { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 260px; }
.cmp-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 5px 10px 5px 12px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 14px; font-weight: 600; color: var(--ink);
}
.cmp-chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cmp-chip .cmp-rm {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3); font-size: 16px; line-height: 1; padding: 0;
}
.cmp-chip .cmp-rm:hover { background: var(--sunk); color: var(--danger); }
.compare-add-wrap { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 210px; }
.compare-add-wrap .select-wrap { min-width: 200px; }
.compare-add-wrap .select-wrap select { min-height: 40px; font-size: 14px; }

.compare-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-pill {
  min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 600;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), color 150ms var(--ease);
}
.filter-pill:hover { border-color: var(--ink-3); color: var(--ink); }
.filter-pill.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.compare-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px;
}
.kpi-card .kpi-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.kpi-card .kpi-val { font: 600 26px/1.15 var(--serif); color: var(--ink); }
.kpi-card .kpi-plan { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.kpi-card .kpi-plan i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.verdict { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.verdict h2 { font-size: 21px; margin-bottom: 10px; }
.verdict ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.verdict li { display: flex; gap: 10px; align-items: baseline; color: var(--ink-2); }
.verdict li b { color: var(--ink); font-weight: 600; }
.verdict .swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; transform: translateY(1px); }

.compare-table th, .compare-table td { min-width: 130px; }
.compare-table th:first-child, .compare-table td:first-child { min-width: 165px; max-width: 220px; white-space: normal; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.compare-table thead th { color: var(--ink); font-size: 14px; vertical-align: bottom; }
.compare-table thead th .sw { display: block; width: 24px; height: 3px; border-radius: 2px; margin: 0 0 6px auto; }
.compare-table td small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.compare-table tr.group td { font: 600 12.5px var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); text-align: left; padding-top: 18px; }
.best { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; vertical-align: 1px; }
.compare-table td.win { font-weight: 600; color: var(--ink); background: color-mix(in srgb, var(--accent-soft) 35%, transparent); }
/* Phones get plan cards + an expandable list; wider screens keep the table. */
.cmp-cards, .cmp-more { display: none; }
@media (max-width: 639px) {
  .panel:has(> .cmp-cards) > .table-scroll { display: none; }
  .cmp-cards { display: grid; gap: 10px; margin-top: 4px; }
  .cmp-more { display: block; margin-top: 12px; }
}
.cmp-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; background: var(--surface); }
.cc-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15.5px; color: var(--ink); }
.cc-name i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.cc-big { font: 600 24px/1.2 var(--serif); color: var(--ink); margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.cc-big small { display: block; font: 500 12px var(--sans); color: var(--ink-3); }
.cmp-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 0; }
.cmp-card dt { font-size: 12px; color: var(--ink-3); }
.cmp-card dd { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cmp-more > summary { min-height: 44px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 12px; font-weight: 600; color: var(--accent); cursor: pointer; list-style: none; }
.cmp-more > summary::-webkit-details-marker { display: none; }
.cmp-more[open] > summary { margin-bottom: 6px; }

/* Comparison basis */
.compare-modes { margin: 0 0 12px; }
.mode-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.mode-select { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-2); font-size: 14.5px; flex: 0 1 320px; }
.mode-select .select-wrap select { min-height: 42px; font-size: 14.5px; }
.mode-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mode-extra > span { font-size: 14px; color: var(--ink-2); margin-right: 2px; }
.mini-field { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 10px; min-height: 36px; background: var(--surface); }
.mini-field input { width: 84px; border: 0; background: transparent; font: inherit; font-size: 14px; color: var(--ink); padding: 6px 0; }
.mini-field input:focus { outline: none; }
.mini-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mini-field em { font-style: normal; color: var(--ink-3); font-size: 13px; }
.mode-notes { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; color: var(--ink-2); font-size: 14.5px; }
.mode-notes p { margin: 0 0 6px; }
.mode-notes p:last-child { margin-bottom: 0; }
.mode-left { margin-top: 8px; }
.mode-left ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.mode-left li { display: flex; gap: 8px; align-items: baseline; }
.mode-left li i { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.kpi-card .kpi-caution { font-size: 12px; color: var(--ink-3); }

/* Cashflow timeline */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; flex: none; }
.seg-btn { min-height: 36px; padding: 4px 12px; border: 0; background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn.active { background: var(--ink); color: var(--bg); }
.cf-scroll { overflow-x: auto; }
.cf-scroll svg { max-width: none; }
.cf-plan + .cf-plan { margin-top: 10px; }
.cf-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--ink-2); margin-bottom: 2px; }
.cf-name i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chart.cashflow rect[fill="transparent"]:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }

/* What-if */
.whatif .diff-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 6px 0 0; }
.whatif dt { font-size: 12.5px; color: var(--ink-3); }
.whatif dd { margin: 2px 0 0; font: 600 18px/1.2 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
#whatif-plan { white-space: nowrap; }

/* Tax assumption + version */
.tax-assume { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.tax-assume summary { cursor: pointer; font-weight: 600; color: var(--ink-2); min-height: 32px; display: inline-flex; align-items: center; }
.tax-assume ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.about-version, .foot-version { font-variant-numeric: tabular-nums; }
.foot-version { display: block; margin-top: 6px; }
.cs-group { font: 600 12.5px var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); margin: 18px 0 4px; }
.cs-group:first-child { margin-top: 4px; }
.cs-metric { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.cs-label { font-weight: 600; color: var(--ink); margin-bottom: 6px; font-size: 14.5px; }
.cs-label small { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.cs-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 14.5px; color: var(--ink-2); }
.cs-plan { display: inline-flex; align-items: baseline; gap: 7px; min-width: 0; }
.cs-plan i { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.cs-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-row.win .cs-val { color: var(--ink); font-weight: 600; }
.compare-grid { display: grid; gap: 0 18px; }
@media (min-width: 980px) { .compare-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Schemes & Goal Planner ---------- */
.goal-panel { margin-top: 0; margin-bottom: 20px; }
.goal-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-top: 12px; }
.goal-controls .field { flex: 1 1 220px; max-width: 300px; }
.goal-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.goal-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.goal-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.goal-card-head strong { font-size: 15px; color: var(--ink); }
.goal-card-head span { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.goal-corpus { font: 600 24px/1.15 var(--serif); color: var(--ink); }
.goal-meta { font-size: 13px; color: var(--ink-3); }

.schemes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.scheme-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.scheme-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.scheme-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--sunk); color: var(--ink-2);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.scheme-card h3 { font-size: 18px; margin-top: 2px; }
.scheme-card p { margin: 0; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.scheme-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--line); margin-top: 4px; }
.scheme-rate { font: 600 18px/1 var(--serif); color: var(--ink); }
.scheme-rate small { font: 500 12px var(--sans); color: var(--ink-3); display: block; margin-top: 2px; }

/* ---------- Visual Strategy Flow & Rates Banner ---------- */
.flow-panel { margin-top: 0; margin-bottom: 16px; }
.flow-list { display: grid; gap: 10px; margin-top: 10px; }
.flow-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg); border: 1px solid var(--line);
}
.flow-node {
  display: inline-flex; flex-direction: column; padding: 4px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); font-size: 13px; line-height: 1.25;
}
.flow-node small { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.flow-node b { font-weight: 600; color: var(--ink); }
.flow-node.end { border-color: var(--accent); background: var(--accent-soft); }
.flow-node.end b { color: var(--accent); }
.flow-arrow { color: var(--ink-3); font-weight: 600; font-size: 14px; user-select: none; }

.rates-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  padding: 12px 16px; margin-top: 18px; border-radius: var(--radius-md);
  background: var(--sunk); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2);
}
.rates-banner b { color: var(--ink); }

/* Netlify's free plan adds a fixed "Powered by Netlify" badge at the bottom right.
   When it is there, reserve a strip at the bottom so it never covers tabs or buttons. */
body.host-badge { --safe-b: calc(env(safe-area-inset-bottom, 0px) + 70px); }

/* ---------- Guided Tour ---------- */
.tour { position: fixed; inset: 0; z-index: 60; }
.tour[hidden] { display: none; }
.tour-catch { position: absolute; inset: 0; }
.tour-spot {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 200vmax rgb(15 20 18 / 55%);
  transition: left .28s var(--ease), top .28s var(--ease), width .28s var(--ease), height .28s var(--ease);
}
.tour-card {
  position: fixed; width: min(400px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 14px 18px 16px; outline: none;
}
.tour-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 0 0; }
.tour-count { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tour-title { font-size: 21px; margin: 2px 0 8px; }
.tour-body { color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.tour-body p { margin: 0 0 10px; }
.tour-body ul { margin: 0 0 10px; padding-left: 18px; display: grid; gap: 6px; }
.tour-body b { color: var(--ink); }
.tour-note { font-size: 13.5px; color: var(--ink-3); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.tour-actions .btn { min-width: 84px; }
.tour-dots { display: flex; justify-content: center; gap: 5px; flex: 1; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); transition: background-color 150ms var(--ease), width 150ms var(--ease); }
.tour-dots i.active { width: 18px; border-radius: 999px; background: var(--accent); }
@media (max-width: 719px) {
  .tour-card { left: 12px; right: 12px; width: auto; bottom: calc(12px + var(--safe-b)); max-height: 52vh; }
}
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }

/* ---------- Report ---------- */
.report-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 18px; }
.report-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.paper {
  /* the report is always printed light, so pin light tokens inside it even in dark mode */
  color-scheme: light; --ink: #16241E; --ink-2: #44534B; --ink-3: #5F6B63; --line: #E1DACA; --line-strong: #CFC6B2;
  --accent: #0F6B4B; --accent-soft: #E3EFE7; --surface: #FFFFFF;
  background: #FFFFFF; color: #16241E; border-radius: 6px; box-shadow: var(--shadow); padding: clamp(18px, 4vw, 44px); overflow-x: auto; border: 1px solid var(--line); }
.native .web-only { display: none; }

/* ---------- Sheets (dialogs) ---------- */
dialog.sheet {
  width: min(560px, 100%); max-height: min(88vh, 900px); margin: auto auto 0; padding: 0 18px 24px;
  border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -10px 40px rgb(0 0 0 / 20%);
  overflow-y: auto; padding-bottom: calc(24px + var(--safe-b));
}
dialog.sheet[open] { animation: sheet-in .32s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgb(15 20 18 / 45%); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 20px; } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 0 10px; background: var(--surface); }
.sheet-head h2 { font-size: 23px; }
.template-group h3 { font: 600 13px var(--sans); color: var(--ink-3); margin: 14px 0 6px; }
.tpl, .strategy {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.tpl:hover, .strategy:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl .t, .strategy .t { flex: 1; min-width: 0; }
.tpl b, .strategy b { display: block; font-size: 15.5px; font-weight: 600; }
.tpl span, .strategy span { display: block; font-size: 13.5px; color: var(--ink-2); line-height: 1.4; margin-top: 2px; }
.tpl > svg, .strategy > svg { color: var(--ink-3); }
.strategy-list { margin-top: 14px; }
.sheet .field { margin-bottom: 14px; }
.fine { font-size: 13px; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 70px + var(--safe-b)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14.5px; max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 860px) { .toast { bottom: 28px; } }

.foot { max-width: 1240px; margin: 8px auto 0; padding: 0 16px 24px; color: var(--ink-3); font-size: 13px; }
@media (min-width: 860px) { .foot { padding: 0 28px 32px; } }

/* ---------- API Playground ---------- */
.pg-layout { display: grid; gap: 18px; align-items: start; }
@media (min-width: 960px) { .pg-layout { grid-template-columns: 260px minmax(0, 1fr); } }
.pg-sidebar { margin-top: 0; }
.pg-list { display: grid; gap: 6px; margin-top: 10px; }
.pg-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: var(--bg); color: var(--ink-2); font-size: 14px; font-weight: 500; text-align: left;
}
.pg-item:hover { border-color: var(--accent); color: var(--ink); }
.pg-item.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pg-method {
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; min-width: 44px; text-align: center;
  background: var(--sunk); color: var(--ink-2);
}
.pg-method.post { background: var(--accent-soft); color: var(--accent); }
.pg-card { margin-top: 0; margin-bottom: 16px; }
.pg-row { display: grid; gap: 10px; }
@media (min-width: 720px) { .pg-row { grid-template-columns: 1.2fr 120px 1.5fr; } }
.pg-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.pg-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-status-row { display: flex; align-items: center; gap: 10px; }
.badge.danger { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.pg-editor {
  width: 100%; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--ink); font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical;
}
.pg-editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pg-exec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.pg-output {
  margin: 0; padding: 14px; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--sunk); color: var(--ink); font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto; max-height: 480px; white-space: pre-wrap; word-break: break-word;
}
.json-key { color: var(--accent); font-weight: 600; }
.json-str { color: var(--s2); }
.json-num { color: var(--s3); }
.json-bool { color: var(--s4); font-weight: 600; }
.json-null { color: var(--ink-3); font-style: italic; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  body { background: #fff; padding: 0; }
  .topbar, .tabs, .result-bar, .foot, .view:not(#view-report), .view-head, .report-tools, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  #view-report { display: block !important; }
  .paper { box-shadow: none; border: 0; padding: 0; }
}
