/* ==========================================================================
   Openbook — design system
   Tokens first, then layout, then components. Every colour is a token so the
   dark theme is a set of substitutions rather than a pile of overrides.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces & ink */
  --paper:        #F4F6F3;
  --paper-2:      #EAEFE8;
  --surface:      #FFFFFF;
  --surface-2:    #EDF1EC;
  --surface-3:    #E3EAE1;
  --ink:          #0F1F1A;
  --ink-soft:     #465750;
  --ink-faint:    #72847B;
  --border:       #DBE3D9;
  --border-soft:  #E8EDE6;

  /* Brand */
  --accent-fill:  #14624E;
  --accent-hover: #0E4E3E;
  --accent-text:  #105947;
  --on-accent:    #FFFFFF;
  --accent-soft:  #E1EDE7;
  --accent-line:  #BBD8CC;

  --brass-fill:   #9C6B26;
  --brass-hover:  #835820;
  --brass-text:   #6B4A1C;
  --brass-soft:   #F6EAD6;
  --brass-line:   #E4CBA0;

  --good:         #2C7A4F;
  --good-soft:    #E3F2E8;
  --bad:          #A83A2C;
  --bad-soft:     #FBE9E5;

  /* Chart series — validated for lightness, chroma, CVD separation and
     contrast against the light surface (see README). */
  --series-1: #0B7F5E;   /* principal & interest */
  --series-2: #C2751B;   /* property tax */
  --series-3: #2F6FB0;   /* homeowners insurance */
  --series-4: #A8477E;   /* PMI */
  --series-5: #6FA33B;   /* HOA */

  /* Type */
  --font-ui:      'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape & depth */
  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 31, 26, .05), 0 2px 8px rgba(15, 31, 26, .04);
  --shadow:    0 1px 2px rgba(15, 31, 26, .06), 0 10px 30px rgba(15, 31, 26, .07);
  --shadow-lg: 0 2px 4px rgba(15, 31, 26, .06), 0 24px 60px rgba(15, 31, 26, .12);

  --header-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:        #0E1613;
    --paper-2:      #121C18;
    --surface:      #172019;
    --surface-2:    #1E2822;
    --surface-3:    #26322B;
    --ink:          #E7EEE9;
    --ink-soft:     #A6B7AE;
    --ink-faint:    #7B8D84;
    --border:       #2B3A32;
    --border-soft:  #23302A;

    --accent-fill:  #46AE8D;
    --accent-hover: #59C09E;
    --accent-text:  #7CD7B4;
    --on-accent:    #06130E;
    --accent-soft:  #15352B;
    --accent-line:  #2C5648;

    --brass-fill:   #C99348;
    --brass-hover:  #DAA65C;
    --brass-text:   #EFCE94;
    --brass-soft:   #33260F;
    --brass-line:   #4E3A19;

    --good:         #5FBE85;
    --good-soft:    #1B3223;
    --bad:          #E28173;
    --bad-soft:     #38201B;

    --series-1: #2FA57E;
    --series-2: #BE8329;
    --series-3: #4E8ECF;
    --series-4: #C06894;
    --series-5: #739C3D;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .22);
    --shadow:    0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .35);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:        #0E1613;
  --paper-2:      #121C18;
  --surface:      #172019;
  --surface-2:    #1E2822;
  --surface-3:    #26322B;
  --ink:          #E7EEE9;
  --ink-soft:     #A6B7AE;
  --ink-faint:    #7B8D84;
  --border:       #2B3A32;
  --border-soft:  #23302A;

  --accent-fill:  #46AE8D;
  --accent-hover: #59C09E;
  --accent-text:  #7CD7B4;
  --on-accent:    #06130E;
  --accent-soft:  #15352B;
  --accent-line:  #2C5648;

  --brass-fill:   #C99348;
  --brass-hover:  #DAA65C;
  --brass-text:   #EFCE94;
  --brass-soft:   #33260F;
  --brass-line:   #4E3A19;

  --good:         #5FBE85;
  --good-soft:    #1B3223;
  --bad:          #E28173;
  --bad-soft:     #38201B;

  --series-1: #2FA57E;
  --series-2: #BE8329;
  --series-3: #4E8ECF;
  --series-4: #C06894;
  --series-5: #739C3D;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .22);
  --shadow:    0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .4), 0 24px 60px rgba(0, 0, 0, .5);
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/*
 * overflow-anchor: none turns off the browser's own scroll anchoring, which
 * otherwise fights every "Next" button on this page. The step gate reveals a
 * large amount of previously-hidden content (the ledger, the rules section,
 * the levers) the instant the third step is visited; Chromium's scroll
 * anchoring reacts to that layout change by jumping the viewport on its own,
 * to whatever it guesses will "look the least jarring" — landing deep in the
 * newly-revealed rules or ledger section, nowhere near the new panel — and
 * only then does the smooth scrollIntoView() below start correcting it,
 * visibly drifting back to the right spot over about a second. Anyone who
 * glances at their phone in that window sees the wrong, mid-drift position
 * and reasonably assumes that's where the button took them. Scroll anchoring
 * exists for content loading asynchronously above what you're reading — not
 * for a synchronous, single-page reveal this site already points the scroll
 * at itself — so it's switched off outright rather than patched per element.
 */
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); overflow-anchor: none; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }
img, svg { max-width: 100%; }
a { color: var(--accent-text); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-fill);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 8px;
  translate: -50% -200%;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.skip-link:focus { translate: -50% 0; }

.shell { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: 20px; }
.shell-narrow { max-width: 760px; }
@media (min-width: 720px) { .shell { padding-inline: 32px; } }

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 9px;
  vertical-align: 3px;
}

/* A field revealed by the control above it. */
.field-followup { margin-top: 10px; }

.hint { font-size: 13px; line-height: 1.5; color: var(--ink-faint); margin-top: 8px; }
.optional { font-weight: 500; color: var(--ink-faint); text-transform: none; letter-spacing: 0; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--ink);
  --btn-bd: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }

.btn-primary { --btn-bg: var(--accent-fill); --btn-fg: var(--on-accent); --btn-bd: var(--accent-fill); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-brass { --btn-bg: var(--brass-fill); --btn-fg: #fff; --btn-bd: var(--brass-fill); box-shadow: var(--shadow-sm); }
.btn-brass:hover { background: var(--brass-hover); border-color: var(--brass-hover); }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { --btn-fg: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }

.btn-sm { font-size: 13px; padding: 8px 14px; }
.btn-lg { font-size: 15px; padding: 14px 24px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.site-header.is-stuck { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }

.header-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brandmark rect { fill: var(--accent-fill); }
.brandmark path, .brandmark line { fill: none; stroke: var(--paper); stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.brandname { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: -.02em; }

.nav-links { display: none; gap: 4px; margin-inline: auto; }
.nav-links a {
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  text-decoration: none; padding: 8px 12px; border-radius: 999px;
  transition: background-color .15s ease, color .15s ease;
}
.nav-links a:hover { background: var(--surface-2); color: var(--ink); }
@media (min-width: 900px) { .nav-links { display: flex; } }

.header-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
@media (min-width: 900px) { .header-actions { margin-left: 0; } }
.header-cta { display: none; }
@media (min-width: 560px) { .header-cta { display: inline-flex; } }

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  padding: 48px 0 56px;
  background:
    radial-gradient(900px 520px at 12% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 420px at 92% 0%, var(--brass-soft), transparent 62%),
    var(--paper);
  border-bottom: 1px solid var(--border);
}
@media (min-width: 900px) { .hero { padding: 76px 0 84px; } }

/* One column now the comparison card has gone. The headline and lede get their
   own measures so they don't run the full width of a desktop viewport, while the
   buttons and trust chips stay free to sit on one line. */
.hero-single { display: grid; }
.hero-single h1 { max-width: 24ch; }
.hero-single .lede { max-width: 58ch; }

.hero h1 { font-size: clamp(2.2rem, 1.35rem + 3.6vw, 3.9rem); }
.hero h1 em { font-style: italic; color: var(--accent-text); }
.lede { margin-top: 18px; font-size: clamp(1rem, .95rem + .3vw, 1.18rem); color: var(--ink-soft); max-width: 54ch; }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.trust-row { display: flex; flex-wrap: wrap; gap: 8px 20px; list-style: none; margin: 28px 0 0; padding: 0; }
.trust-row li { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-faint); }
.trust-row svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: var(--accent-text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   Value strip
   ========================================================================== */

.strip { padding: 44px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.strip-grid { display: grid; gap: 28px; }
@media (min-width: 760px) { .strip-grid { grid-template-columns: repeat(3, 1fr); gap: 36px; } }
.strip-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-text); margin-bottom: 14px;
}
.strip-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.strip h3 { font-size: 18px; margin-bottom: 8px; }
.strip p { font-size: 14.5px; color: var(--ink-soft); }

/* ==========================================================================
   Sections
   ========================================================================== */

.section { padding: 64px 0; }
@media (min-width: 900px) { .section { padding: 88px 0; } }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }
.section-calc { background: var(--paper-2); border-block: 1px solid var(--border); scroll-margin-top: var(--header-h); }

.section-head { max-width: 62ch; margin-bottom: 36px; }
.section-head h2 { font-size: clamp(1.6rem, 1.25rem + 1.5vw, 2.4rem); }
.section-head p { margin-top: 12px; font-size: 16px; color: var(--ink-soft); }
.jump-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* ---- Steps ---- */

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; counter-reset: step; }
@media (min-width: 820px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 24px; } }
.steps li {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px 24px;
  box-shadow: var(--shadow-sm);
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--accent-fill); color: var(--on-accent);
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  margin-bottom: 14px;
}
.steps h3 { font-size: 18px; margin-bottom: 8px; }
.steps p { font-size: 14.5px; color: var(--ink-soft); }

/* ==========================================================================
   Calculator
   ========================================================================== */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.toolbar-statuses { flex: 1 1 240px; display: flex; flex-direction: column; gap: 4px; }
.toolbar-status { font-size: 13px; color: var(--ink-soft); }
.toolbar-status strong { color: var(--ink); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Which saved view, if any, the numbers on screen came from. Same spot the
   save status already occupies — top of the toolbar, and again by the result
   card at the end of the form — so it reads whether you've scrolled or not. */
.toolbar-viewing { font-size: 13px; font-weight: 700; color: var(--accent-text); }
#viewingStatusEnd.toolbar-viewing { margin: 0 0 10px; }

/* ---- The actions menu ---- */

/* The menu is anchored to the toolbar card, not to the trigger. The trigger
   moves — it shares a row with the status text on a wide screen and wraps below
   it on a narrow one — and chasing that with a breakpoint clipped the menu at
   the widths in between. The card is always inside the viewport, so anchoring
   there cannot clip. */
.toolbar { position: relative; }
.menu-wrap { flex-shrink: 0; }

.menu-trigger::after {
  content: ''; width: 6px; height: 6px; margin-left: 3px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  rotate: 45deg; translate: 0 -2px; transition: rotate .18s ease;
}
.menu-trigger[aria-expanded="true"]::after { rotate: -135deg; translate: 0 2px; }

.menu-list {
  position: absolute; z-index: 30; top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 6px;
  animation: menu-in .14s ease both;
}
.menu-list[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .menu-list { animation: none; } }

.menu-list [role="menuitem"] {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: none; font-family: var(--font-ui);
  padding: 9px 11px; border-radius: var(--radius-xs);
}
.menu-list [role="menuitem"]:hover { background: var(--surface-2); }
.menu-list [role="menuitem"]:focus-visible { outline-offset: -2px; }
.menu-list hr { border: none; border-top: 1px solid var(--border-soft); margin: 5px 3px; }

@media (min-width: 560px) {
  .menu-list { left: auto; width: 330px; }
}

.mi-name { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.mi-desc { display: block; font-size: 12px; line-height: 1.4; color: var(--ink-faint); margin-top: 1px; }
.menu-list .is-danger .mi-name { color: var(--bad); }
.menu-list .is-danger:hover { background: var(--bad-soft); }

/* A panel opened from the menu. */
.drawer {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow-sm);
  animation: drawer-in .18s ease both;
}
@keyframes drawer-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }

.drawer-block { padding: 16px 18px; }
.drawer-block + .drawer-block { border-top: 1px solid var(--border-soft); }
.drawer-title {
  display: block; font-size: 14.5px; font-weight: 700; color: var(--ink);
}
.drawer-block .hint { margin-top: 4px; }
.drawer-row { margin-top: 12px; }
.drawer-block .load-row { margin-top: 12px; }

.load-row { display: flex; gap: 8px; }
.load-row input { flex: 1; min-width: 0; }
@media (max-width: 430px) {
  .load-row { flex-wrap: wrap; }
  .load-row input { flex: 1 1 100%; }
  .load-row .btn { flex: 1 1 auto; }
}

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--good-soft); border: 1px solid var(--good);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; margin-bottom: 14px;
}
.banner button { border: none; background: none; cursor: pointer; font-family: var(--font-ui); font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.banner-actions { display: flex; gap: 10px; flex-shrink: 0; }
.banner-actions button:first-child { color: var(--accent-fill); }

.banner-sync { flex-direction: column; align-items: stretch; gap: 10px; }
.banner-sync-heading { margin: 0; font-weight: 600; }
.banner-sync-list { display: flex; flex-direction: column; gap: 7px; max-height: 200px; overflow-y: auto; }
.banner-sync-row { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.banner-sync-all { font-weight: 600; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.banner-sync .banner-actions { justify-content: flex-end; }

.calc-grid { display: grid; gap: 20px; align-items: start; }
@media (min-width: 1000px) { .calc-grid { grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 24px; } }

/* ---- Tabs ---- */

.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; margin-bottom: 16px;
  /* Below ~360px the three labels stop fitting; scroll rather than clip. */
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 700;
  color: var(--ink-soft); background: transparent; border: none; cursor: pointer;
  padding: 9px 10px; border-radius: 999px; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.tab-index {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-soft);
  font-size: 11px; font-weight: 800;
}
.tab.is-active .tab-index { background: var(--accent-fill); color: var(--on-accent); }
@media (max-width: 430px) { .tab { font-size: 12.5px; padding: 9px 8px; flex: 0 0 auto; } }

.panel { animation: panel-in .25s ease both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.panel-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }

/*
 * Below the width the grid itself goes single-column, the three panels stop
 * being a one-at-a-time wizard: all three render at once and the page reads
 * top to bottom, so there's nothing for a "Next" button to do that scrolling
 * doesn't already do. The tab bar stays, but as a jump nav — app.js switches
 * it from hide-the-other-panels to scroll-and-highlight once it detects this
 * same width.
 */
@media (max-width: 999px) {
  .panel[hidden] { display: block; }
  .panel-nav { display: none; }
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 560px) { .card { padding: 22px 24px; } }

.card-title { display: flex; align-items: center; gap: 11px; font-size: 18px; }
.card-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-text);
}
.card-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-sub { font-size: 13.5px; color: var(--ink-soft); margin: 8px 0 16px; }

.card-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 14px; font-weight: 700; color: var(--ink-soft);
}
.card-total span:last-child { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---- Fields ---- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 430px) { .field-row { grid-template-columns: 1fr; } }

input[type="text"], input[type="tel"], select, textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, background-color .15s ease;
}
input[type="text"]:hover, input[type="tel"]:hover, select:hover, textarea:hover { border-color: var(--accent-line); }
input[type="text"]::placeholder, input[type="tel"]::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { resize: vertical; font-variant-numeric: normal; line-height: 1.5; }

select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2372847B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.adorned { position: relative; }
.adorned .prefix, .adorned .suffix {
  position: absolute; top: 50%; translate: 0 -50%;
  color: var(--ink-faint); font-weight: 600; pointer-events: none;
}
.adorned .prefix { left: 12px; font-size: 15px; }
.adorned .suffix { right: 11px; font-size: 12.5px; }
.adorned input { padding-left: 26px; }
.adorned.has-suffix input { padding-right: 38px; }

/* ---- Segmented control ---- */

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
}
.segmented-wide { display: flex; width: 100%; }
.segmented button {
  flex: 1;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700;
  color: var(--ink-soft); background: transparent; border: none; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--accent-fill); color: var(--on-accent); }

/* ---- 401(k) row ---- */

.k401-row { display: grid; gap: 10px; }
.k401-label { font-size: 15px; font-weight: 700; }
.k401-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.k401-value { flex: 1 1 120px; min-width: 110px; }
/* The 401(k) block heads the Savings card; a rule separates it from the line list. */
.k401-hint { padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.k401-hint + .group-label { margin-top: 16px; }

/* ---- Line items ---- */

.line-list { display: grid; }
.line-row { padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.line-row:first-child { padding-top: 4px; }
.line-row:last-child { border-bottom: none; }

.line-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

/* The row name is editable, so it keeps a field's affordance — but a quieter one
   than the amount beside it. Typed selector to outrank the generic input rule. */
input[type="text"].line-label {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600; color: var(--ink);
  background: var(--surface-2); border-color: transparent;
  padding: 8px 11px;
}
input[type="text"].line-label:hover { border-color: var(--border); }
input[type="text"].line-label:focus { border-color: var(--accent-fill); }

.line-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink-faint); cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.line-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.line-btn:disabled { opacity: .35; cursor: default; }
.line-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.line-btn.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.line-btn.is-remove:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.line-moves { display: flex; gap: 3px; }

.line-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.line-value { flex: 1 1 110px; min-width: 100px; }

.pretax-toggle {
  font-family: var(--font-ui); font-size: 11px; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
  border-radius: 999px; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-faint);
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.pretax-toggle[aria-pressed="true"] { background: var(--brass-soft); border-color: var(--brass-line); color: var(--brass-text); }

.line-row.is-excluded { opacity: .5; }
.line-row.is-excluded .line-label { text-decoration: line-through; }

.add-row {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 12px; padding: 7px 0;
  font-family: var(--font-ui); font-size: 14px; font-weight: 700;
  color: var(--accent-text); background: none; border: none; cursor: pointer;
}
.add-row svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.add-row:hover { text-decoration: underline; }

.line-empty { font-size: 13.5px; color: var(--ink-faint); font-style: italic; padding: 8px 0; }

/* ==========================================================================
   Results
   ========================================================================== */

.calc-results { display: grid; gap: 16px; }
@media (min-width: 1000px) { .calc-results { position: sticky; top: calc(var(--header-h) + 16px); } }

.result-card {
  background: linear-gradient(168deg, var(--accent-soft), var(--surface) 62%);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
@media (min-width: 560px) { .result-card { padding: 24px; } }

.result-eyebrow { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.result-hero {
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 1.7rem + 2.2vw, 3rem);
  font-weight: 600; line-height: 1.02;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.result-figure {
  font-family: var(--font-display); font-size: 1.9rem; font-weight: 600;
  color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; line-height: 1.1;
}
.result-sub { font-size: 13px; color: var(--ink-soft); margin-top: 8px; }

.result-card-soft { background: var(--surface); border-color: var(--border); }

/* ---- Cash-vs-down-payment notice ---- */

/* The caution palette already used for a readiness check that needs a
   second look (.check-mark.is-caution) — not an error, but not something to
   let a viewer scroll past unnoticed either. */
.cash-notice {
  margin-top: 16px; padding: 14px 16px;
  background: var(--brass-soft); border: 1px solid var(--brass-line);
  border-radius: var(--radius-sm);
}
.cash-notice[hidden] { display: none; }
/* One line by default; .rule-note (below, in the rules-of-thumb chart)
   already supplies the <details> arrow and open/close behaviour — only the
   summary's color needs to match this box's palette instead of that one's. */
.cash-notice .rule-note > summary { font-size: 13.5px; font-weight: 700; color: var(--brass-text); }
.cash-notice-compare { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; }
.cash-notice-figure { display: flex; flex-direction: column; gap: 2px; }
.cash-notice-label { font-size: 12px; color: var(--ink-soft); }
.cash-notice-value {
  font-family: var(--font-mono); font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.cash-notice-detail { margin: 12px 0 0; font-size: 13px; color: var(--ink-soft); }

/* ---- Payment composition ---- */

.payment-viz { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--accent-line); }
.payment-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.payment-total { font-family: var(--font-mono); font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }

.stack-bar { display: flex; gap: 2px; height: 14px; margin-top: 10px; }
.stack-seg {
  min-width: 2px;
  border-radius: 2px;
  transition: flex-basis .45s cubic-bezier(.22, .61, .36, 1);
  cursor: default;
}
.stack-seg:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.stack-seg:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.stack-seg.is-empty { display: none; }
@media (prefers-reduced-motion: reduce) { .stack-seg { transition: none; } }

.legend { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 7px; }
@media (min-width: 420px) { .legend { grid-template-columns: 1fr 1fr; gap: 7px 16px; } }
.legend li { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.legend .swatch { position: relative; top: 1px; }
.legend-label { color: var(--ink-soft); }
.legend-value { margin-left: auto; font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---- Stat lists ---- */

.stat-list { margin: 18px 0 0; }
.stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; font-size: 14px; }
.stat dt { color: var(--ink-soft); }
.stat dd { margin: 0; font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.is-negative dd { color: var(--bad); }
.stat.is-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 11px; font-weight: 700; }
.stat.is-total dt { color: var(--ink); font-weight: 700; }

/* ---- Partner slots ---- */

.partner {
  margin-top: 18px; padding: 12px 14px;
  background: var(--brass-soft); border: 1px solid var(--brass-line);
  border-radius: var(--radius-sm);
}
.partner[hidden] { display: none; }
.partner-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; font-size: 13px; }

/* The label is the disclosure, not decoration, so it is sized to be read.
   "Paid link" is the wording the FTC treats as adequate next to an affiliate
   link; "Partner" or "Sponsored" leaves too much to the reader to work out. */
.partner-tag {
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: #fff; background: var(--brass-fill); border-radius: 999px; padding: 3px 9px;
}
.partner-text { flex: 1 1 150px; color: var(--brass-text); }
.partner-link { color: var(--brass-text); font-weight: 800; text-decoration: none; white-space: nowrap; }
.partner-link:hover { text-decoration: underline; }

/* Sits with the link and needs no interaction to read — the two things the
   FTC's guidance is most consistently concerned with. */
.partner-disclosure {
  margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--brass-text);
}

/* ==========================================================================
   Ledger
   ========================================================================== */

.ledger-card { margin-top: 20px; scroll-margin-top: calc(var(--header-h) + 16px); }

.ledger-income, .ledger-net {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.ledger-income span:last-child, .ledger-net span:last-child {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.ledger-net.is-negative span:last-child { color: var(--bad); }

/* The running total where the deductions stop and your own choices start. */
.ledger-subtotal {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.ledger-subtotal span:last-child {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
/* Deductions are subtractions from the row above, so they read as negative. */
#ledgerPreRows .row-value { color: var(--bad); }

.group-label {
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); margin-top: 22px; margin-bottom: 4px;
}
.group-label-note { font-weight: 500; letter-spacing: 0; text-transform: none; }

.ledger-row { border-bottom: 1px solid var(--border-soft); }
.ledger-row > summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  list-style: none; cursor: pointer; padding: 10px 0; font-size: 14.5px;
}
.ledger-row > summary::-webkit-details-marker { display: none; }
.ledger-row .chev {
  display: inline-block; width: 9px; margin-right: 8px; color: var(--ink-faint);
  transition: transform .18s ease; transform: rotate(-90deg);
}
.ledger-row[open] .chev { transform: rotate(0); }
.ledger-row .row-label { color: var(--ink-soft); }
.ledger-row .row-value { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger-detail { padding: 2px 0 12px 17px; border-left: 2px solid var(--border-soft); margin-bottom: 6px; }
.ledger-detail .stat { font-size: 13px; padding: 4px 0; }
.ledger-detail .stat dt { color: var(--ink-faint); }
.ledger-detail .stat.is-excluded { opacity: .55; }
.ledger-detail .stat.is-excluded dt, .ledger-detail .stat.is-excluded dd { text-decoration: line-through; }
.ledger-detail .empty { font-size: 13px; font-style: italic; color: var(--ink-faint); padding: 4px 0; }
.excl-tag {
  text-decoration: none !important; display: inline-block; margin-left: 6px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--bad); border: 1px solid var(--bad); border-radius: 999px; padding: 1px 6px;
}
.price-mode-field { margin-top: 18px; }

/* ---- Details card (tax) ---- */

.details-card { padding: 0; }
.details-card > summary {
  display: flex; align-items: center; gap: 11px;
  list-style: none; cursor: pointer; padding: 18px 20px; font-size: 16px; font-weight: 700;
}
.details-card > summary::-webkit-details-marker { display: none; }
.details-card > summary::after { content: '▾'; margin-left: auto; color: var(--ink-faint); font-size: 12px; }
.details-card[open] > summary::after { content: '▴'; }
.summary-meta { font-size: 13px; font-weight: 600; color: var(--ink-faint); }
.details-body { padding: 0 20px 20px; }
.details-body .stat-list { margin-top: 0; }

.disclaimer {
  font-size: 12.5px; line-height: 1.65; color: var(--ink-faint);
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ==========================================================================
   Difference table
   ========================================================================== */

.compare-table { display: grid; gap: 18px; }
@media (min-width: 820px) { .compare-table { grid-template-columns: 1fr 1fr; gap: 24px; } }
.compare-col {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.compare-col.is-featured {
  background: linear-gradient(168deg, var(--accent-soft), var(--surface) 70%);
  border-color: var(--accent-line); box-shadow: var(--shadow);
}
.compare-col h3 { font-size: 19px; margin-bottom: 16px; }
.tick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.tick-list li { display: flex; gap: 11px; font-size: 14.5px; color: var(--ink); }
.tick-list.is-muted li { color: var(--ink-faint); }
.tick {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-fill); color: var(--on-accent); font-size: 11px; font-weight: 800;
}
.tick-no { background: var(--surface-3); color: var(--ink-faint); }

/* ==========================================================================
   FAQ
   ========================================================================== */

.faq { display: grid; gap: 10px; }
.faq details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.faq summary {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  list-style: none; cursor: pointer; padding: 16px 18px;
  font-size: 15.5px; font-weight: 700;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ''; flex-shrink: 0; width: 9px; height: 9px;
  border-right: 2px solid var(--ink-faint); border-bottom: 2px solid var(--ink-faint);
  rotate: 45deg; translate: 0 -2px; transition: rotate .2s ease;
}
.faq details[open] summary::after { rotate: -135deg; translate: 0 2px; }
.faq .details-body { padding: 0 18px 18px; }
.faq .details-body p { font-size: 14.5px; color: var(--ink-soft); }

/* ==========================================================================
   Support & footer
   ========================================================================== */

.section-support { padding-bottom: 72px; }
.support-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px;
  background: linear-gradient(168deg, var(--brass-soft), var(--surface) 72%);
  border: 1px solid var(--brass-line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
}
.support-card h2 { font-size: 22px; }
.support-card p { font-size: 14.5px; color: var(--ink-soft); margin-top: 8px; max-width: 52ch; }

.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 36px 0 44px; }
.footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
}
.footer-brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--accent-text); text-decoration: underline; }
.footer-fine { font-size: 12px; line-height: 1.65; color: var(--ink-faint); max-width: 90ch; }
.footer-fine + .footer-fine { margin-top: 10px; }

/* ==========================================================================
   Mobile summary & toast
   ========================================================================== */

.mobile-summary {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 35;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 9px 9px 9px 18px;
  box-shadow: var(--shadow-lg);
  animation: summary-in .25s ease both;
}
@keyframes summary-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mobile-summary[hidden] { display: none; }
.mobile-summary-figures { display: flex; flex-direction: column; min-width: 0; }
.mobile-summary-label { font-size: 11px; font-weight: 700; color: var(--ink-faint); }
.mobile-summary-value { font-family: var(--font-mono); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (min-width: 1000px) { .mobile-summary { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .mobile-summary { animation: none; } }

.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 60;
  translate: -50% 14px;
  max-width: min(88vw, 420px); text-align: center;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 700;
  padding: 12px 20px; border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, translate .2s ease;
}
.toast.is-visible { opacity: 1; translate: -50% 0; }
.toast.is-error { background: var(--bad); color: #fff; }
@media (min-width: 1000px) { .toast { bottom: 28px; } }

/* Chart tooltip */
.viz-tip {
  position: fixed; z-index: 70; pointer-events: none;
  background: var(--ink); color: var(--paper);
  font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 6px 10px; border-radius: var(--radius-xs);
  box-shadow: var(--shadow); opacity: 0; transition: opacity .12s ease;
  white-space: nowrap;
}
.viz-tip.is-visible { opacity: 1; }

@media print {
  .site-header, .mobile-summary, .toast, .toolbar, .partner, .cta-row, .section-support { display: none !important; }
  body { background: #fff; }
  .card, .result-card { box-shadow: none; break-inside: avoid; }
}

/* ==========================================================================
   Rules of thumb
   ========================================================================== */

.section-rules { background: var(--surface); border-block: 1px solid var(--border); }

.rules-verdict {
  font-family: var(--font-display); font-size: clamp(1.1rem, .95rem + .7vw, 1.5rem);
  font-weight: 600; letter-spacing: -.01em; color: var(--ink);
  margin-bottom: 28px; max-width: 46ch; text-wrap: balance;
}
.rules-verdict strong { color: var(--accent-text); }

.rules-chart { margin: 0 0 40px; }
.rules-caption {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 20px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.rules-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-weight: 600; color: var(--ink-faint); }
.key-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch-ceiling {
  background: repeating-linear-gradient(135deg, var(--ink-faint) 0 2px, transparent 2px 4px), var(--surface-3);
}

.rule-rows { list-style: none; margin: 0; padding: 0; }

.rule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border-soft);
}
.rule-row:last-child { border-bottom: none; }
@media (min-width: 860px) {
  .rule-row { grid-template-columns: minmax(200px, 270px) minmax(0, 1fr) auto; align-items: center; gap: 6px 20px; }
}

.rule-head { min-width: 0; }
.rule-name { display: block; font-size: 15.5px; font-weight: 700; color: var(--ink); }
.rule-basis { display: block; font-size: 13px; color: var(--ink-faint); margin-top: 2px; }

.rule-track {
  grid-column: 1 / -1;
  height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden;
}
@media (min-width: 860px) { .rule-track { grid-column: 2; } }
.rule-fill {
  height: 100%; border-radius: 7px; background: var(--ink-faint);
  transition: width .5s cubic-bezier(.22, .61, .36, 1);
}
.rule-row.is-you .rule-fill { background: var(--series-1); }
.rule-row.is-ceiling .rule-fill {
  background: repeating-linear-gradient(135deg, var(--ink-faint) 0 3px, transparent 3px 6px), var(--surface-3);
}
@media (prefers-reduced-motion: reduce) { .rule-fill { transition: none; } }

.rule-figures { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
@media (min-width: 860px) { .rule-figures { flex-direction: column; align-items: flex-end; gap: 5px; min-width: 132px; } }
.rule-price {
  font-family: var(--font-mono); font-size: 16px; font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.rule-row.is-you .rule-price { color: var(--accent-text); }

.verdict-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
  border: 1px solid transparent;
}
.verdict-chip .chip-icon { font-size: 10px; line-height: 1; }
.verdict-chip.is-pass { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.verdict-chip.is-over { background: var(--brass-soft); border-color: var(--brass-line); color: var(--brass-text); }
.verdict-chip.is-you { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }

.rule-note { grid-column: 1 / -1; margin-top: 6px; }
@media (min-width: 860px) { .rule-note { grid-column: 1 / -1; } }
.rule-note > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--accent-text);
}
.rule-note > summary::-webkit-details-marker { display: none; }
.rule-note > summary::after {
  content: ''; width: 6px; height: 6px;
  border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor;
  rotate: 45deg; translate: 0 -2px; transition: rotate .18s ease;
}
.rule-note[open] > summary::after { rotate: -135deg; translate: 0 1px; }
.rule-note p { font-size: 13.5px; line-height: 1.6; color: var(--ink-soft); margin-top: 8px; max-width: 72ch; }
.rule-note a { font-weight: 700; }

/* ---- Readiness ---- */

.readiness {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
@media (min-width: 560px) { .readiness { padding: 28px; } }
.readiness h3 { font-size: 20px; }
.readiness-sub { font-size: 14px; color: var(--ink-soft); margin-top: 8px; max-width: 62ch; }

.readiness-list { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 900px) { .readiness-list { grid-template-columns: 1fr 1fr; gap: 16px 28px; } }
.readiness-list li { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }

.check-mark {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; font-weight: 800; line-height: 1;
  border: 1px solid transparent; margin-top: 1px;
}
.check-mark.is-pass { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.check-mark.is-caution { background: var(--brass-soft); border-color: var(--brass-line); color: var(--brass-text); }
.check-mark.is-fail { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.check-mark.is-unknown { background: var(--surface-2); border-color: var(--border); color: var(--ink-faint); }

.check-label { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.check-detail { font-size: 13px; line-height: 1.55; color: var(--ink-soft); margin-top: 3px; }
.check-source {
  display: inline-block; margin-top: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- Results-rail link into this section ---- */

.result-card-link {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border-color: var(--border);
  transition: border-color .15s ease, transform .1s ease;
}
.result-card-link:hover { border-color: var(--accent-line); }
.result-card-link:active { transform: translateY(1px); }
.rules-score {
  display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
  color: var(--accent-text); margin-top: 2px; line-height: 1.2;
}
.rules-score-unit {
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--ink-faint); letter-spacing: .01em;
}

/* The offer to keep your numbers, at the end of the form rather than only in
   the menu at the top of the page. */
.save-card-sub {
  margin-top: 6px; font-size: 13px; line-height: 1.55; color: var(--ink-soft);
}
.save-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.save-card-actions .btn { flex: 1 1 auto; }
.save-card .hint { margin-top: 10px; }

/* --- Cash at closing ----------------------------------------------------- */

.cash-list { margin-top: 12px; }

/* --- Levers -------------------------------------------------------------- */

.section-levers { background: var(--surface-2); }

.lever-list { list-style: none; display: grid; gap: 12px; margin-top: 22px; }

.lever {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--accent-line);
}
.lever.is-tradeoff { border-left-color: var(--border); }
.lever-none { border-left-color: var(--good); color: var(--ink-soft); font-size: 14.5px; }

.lever-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px;
}
.lever-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); }
.lever-figure {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 18px; font-weight: 600; color: var(--accent-text); white-space: nowrap;
}
.is-tradeoff .lever-figure { color: var(--ink-faint); }
.lever-unit {
  font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-faint); margin-left: 6px;
}

.lever-detail { margin-top: 6px; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.lever-meta {
  margin-top: 8px; font-family: var(--font-mono); font-size: 12.5px;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.lever-note { margin-top: 6px; font-size: 12.5px; line-height: 1.55; color: var(--ink-faint); }

/* The optional balance on a debt row. */
.line-balance {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--ink-faint);
}
.line-balance input {
  width: 92px; padding: 7px 9px; font-size: 13px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  text-transform: none; letter-spacing: 0;
}

/* A breached ceiling, appended to the rules verdict. */
.verdict-alarm { color: var(--bad); }

/* ==========================================================================
   Saved views
   ========================================================================== */

#viewsList:not(:empty) {
  margin-top: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.view-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 14px; padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.view-row:last-child { border-bottom: none; }
/* The row for whichever view is on screen right now, if any. A left border
   rather than a filled background, so the "Viewing" badge — itself on an
   accent-soft fill — still stands out against the row behind it. */
.view-row-active { border-left: 3px solid var(--accent-fill); padding-left: 11px; margin-left: -14px; }

.view-main { min-width: 0; flex: 1 1 200px; }
.view-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* The name is the rename control: it has to look like the name, and behave
   like something you can click. */
.view-name {
  display: block; flex: 1 1 auto; min-width: 0; max-width: 100%; text-align: left;
  font: inherit; font-size: 15px; font-weight: 700; color: var(--ink);
  overflow-wrap: anywhere; background: none; border: 0; cursor: text;
  padding: 2px 6px; margin: -2px -6px; border-radius: 7px;
}
.view-name::after {
  content: 'Rename'; margin-left: 8px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint);
  opacity: .75; white-space: nowrap;
}
.view-name:hover { background: var(--surface-2); }
.view-name:hover::after, .view-name:focus-visible::after { opacity: 1; color: var(--accent-text); }
.view-name:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 1px; }

.view-name-input {
  flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 700; padding: 4px 8px;
}

/* Asking in the row, because a browser dialog may never appear. */
.view-confirm {
  font-size: 13.5px; font-weight: 700; color: var(--bad); align-self: center; margin-right: 2px;
}
.btn-danger-solid {
  --btn-bg: var(--bad); --btn-fg: #FFFFFF; --btn-bd: var(--bad);
}
.btn-danger-solid:hover { filter: brightness(1.08); }

.confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.share-out {
  width: 100%; margin-top: 10px; font-family: var(--font-mono); font-size: 12.5px;
  line-height: 1.5; resize: vertical; overflow-wrap: anywhere;
}
.view-meta {
  margin-top: 2px; font-size: 12.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.view-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }

.views-list-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px 16px;
  flex-wrap: wrap; margin-top: 4px;
}
.views-list-head .hint { margin-top: 0; }
.views-list-head .btn { flex-shrink: 0; }
@media (max-width: 480px) {
  .view-actions { width: 100%; }
  .view-actions .btn { flex: 1 1 auto; }
}

/* --- Comparing views ---------------------------------------------------- */

.view-compare {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  padding: 0 8px 0 2px; cursor: pointer; user-select: none;
}
/*
 * A plain `accent-color` checkbox looked right in every browser this was
 * tested in during development, then showed up solid black on a Samsung
 * device — accent-color support (or its interaction with the device's own
 * dark theme forcing native form controls to a system colour) isn't
 * reliable enough to be the only styling. Built as a fully custom box
 * instead, so its colour comes from this stylesheet in every browser, not
 * from how well each one honours a CSS property still filling in.
 */
.view-compare input,
.cmp-current input,
.banner-sync-row input {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; margin: 0; flex-shrink: 0;
  display: inline-grid; place-content: center;
  border: 1.5px solid var(--border); border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.view-compare input:checked,
.cmp-current input:checked,
.banner-sync-row input:checked {
  background: var(--accent-fill); border-color: var(--accent-fill);
}
.view-compare input:checked::after,
.cmp-current input:checked::after,
.banner-sync-row input:checked::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) translateY(-1px);
}
.view-compare input:focus-visible,
.cmp-current input:focus-visible,
.banner-sync-row input:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 2px; }
.banner-sync-row input:indeterminate {
  background: var(--accent-fill); border-color: var(--accent-fill);
}
.banner-sync-row input:indeterminate::after {
  content: '';
  width: 9px; height: 2px;
  background: var(--on-accent);
}

.cmp { margin-top: 16px; }
.cmp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cmp-current {
  display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 12px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}

/* The table scrolls sideways rather than squeezing four columns onto a phone;
   the row labels stay put so a figure never loses the row it belongs to. */
.cmp-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.cmp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cmp-caption {
  caption-side: bottom; text-align: left; margin-top: 10px;
  font-size: 12.5px; line-height: 1.5; color: var(--ink-faint);
}

.cmp-table th, .cmp-table td { padding: 8px 10px; text-align: right; white-space: nowrap; }
.cmp-table thead th { vertical-align: bottom; border-bottom: 1px solid var(--border); }
.cmp-table thead th:first-child {
  text-align: left; font-size: 11.5px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint);
}
.cmp-name { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.cmp-flag {
  display: block; margin-top: 2px; font-size: 11px; font-weight: 600;
  color: var(--ink-faint); white-space: normal; max-width: 150px; margin-left: auto;
}
.cmp-diff-head { font-size: 12px; color: var(--ink-faint); }

.cmp-table tbody th {
  text-align: left; font-weight: 500; color: var(--ink-soft);
  position: sticky; left: 0; background: var(--surface); white-space: normal; min-width: 150px;
}
.cmp-table tbody td {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink);
}
.cmp-row.is-deduction td { color: var(--bad); }
.cmp-row td.is-key { font-weight: 700; }
.cmp-row td.is-negative { color: var(--bad); }
.cmp-diff { color: var(--ink-faint); }

/* --- Opening a row ------------------------------------------------------ */

.cmp-toggle {
  display: inline-flex; align-items: baseline; gap: 6px; width: 100%;
  font: inherit; color: inherit; text-align: left;
  background: none; border: 0; padding: 2px 6px; margin: -2px -6px;
  border-radius: 7px; cursor: pointer;
}
.cmp-toggle:hover { background: var(--surface-2); }
.cmp-toggle:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 1px; }
.cmp-toggle .chev {
  font-size: 10px; color: var(--ink-faint); transition: transform .15s ease;
  transform: rotate(-90deg); display: inline-block;
}
.cmp-toggle[aria-expanded="true"] .chev { transform: none; }

.cmp-child th, .cmp-child td { padding-top: 5px; padding-bottom: 5px; }
.cmp-child-label {
  padding-left: 26px !important; font-weight: 500 !important;
  font-size: 12.5px; color: var(--ink-faint) !important;
}
.cmp-child td { font-size: 12.5px; color: var(--ink-soft); }
.cmp-child td.is-absent { color: var(--ink-faint); }
.cmp-child.is-deduction td { color: var(--ink-soft); }

/* A note that differs between columns — "excluded", "Roth" — under its figure. */
.cmp-note {
  display: block; margin-top: 1px; font-family: var(--font-ui); font-size: 10.5px;
  font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-faint);
  white-space: normal;
}

/* The cascade's shape, carried into the table: a line where the deductions
   stop, and another where the debits are totted up. */
.cmp-row.is-income th, .cmp-row.is-income td,
.cmp-row.is-subtotal th, .cmp-row.is-subtotal td,
.cmp-row.is-total:first-of-type th, .cmp-row.is-total:first-of-type td {
  border-top: 1px solid var(--border-soft);
}
.cmp-row.is-subtotal th, .cmp-row.is-subtotal td { font-weight: 700; color: var(--ink); }
.cmp-row.is-outcome th, .cmp-row.is-outcome td { font-size: 15px; font-weight: 700; color: var(--ink); }
.cmp-row.is-total th { font-weight: 700; color: var(--ink); }

/* ==========================================================================
   The step gate
   ========================================================================== */

body[data-steps="incomplete"] .reveal-on-complete { display: none !important; }
body:not([data-steps="incomplete"]) .show-until-complete { display: none !important; }

.gate-card { background: var(--surface); border-color: var(--border); }
.gate-heading {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
  color: var(--ink); line-height: 1.15; margin-top: 2px;
}

.gate-steps { list-style: none; margin: 16px 0 18px; padding: 0; display: grid; gap: 9px; counter-reset: gate; }
.gate-steps li {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: center;
  font-size: 14.5px; font-weight: 600; color: var(--ink-faint);
  counter-increment: gate;
}
.gate-steps li.is-done { color: var(--ink); }
.gate-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 800;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-faint);
}
.gate-mark::before { content: counter(gate); }
.gate-steps li.is-done .gate-mark {
  background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text);
}
.gate-steps li.is-done .gate-mark::before { content: none; }

.gate-notice {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; font-size: 14.5px; color: var(--ink-soft); box-shadow: var(--shadow-sm);
  max-width: 62ch;
}

/* Which step you're on, in each panel's footer. */
.panel-step {
  font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); align-self: center;
}
