:root {
  color-scheme: light;
  --background: #edf2f8;
  --surface: #fff;
  --worksheet: #f7faff;
  --ink: #152640;
  --muted: #4a5c73;
  --line: #d5e0ec;
  --light-line: #e6edf5;
  --blue: #204fca;
  --blue-hover: #173da7;
  --blue-tint: #edf3ff;
  --coral: #ba4b3d;
  --slate: #61758f;
  --error: #a22732;
  --error-tint: #fff3f3;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 16px; line-height: 1.5; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.14; letter-spacing: -.025em; }
h2 { font-size: clamp(1.4rem, 2.8vw, 1.7rem); }
h3 { font-size: 1.05rem; }
a { color: var(--blue); text-underline-offset: .18em; }
button, input, select { font: inherit; }
button, select, input[type="range"], input[type="checkbox"], summary { cursor: pointer; }
button:disabled, input:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
small { color: var(--muted); font-size: .77rem; line-height: 1.45; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.wrap { width: min(100% - 64px, 1160px); margin-inline: auto; }
.skip-link {
  position: fixed;
  z-index: 2;
  top: .75rem;
  left: .75rem;
  padding: .75rem 1rem;
  color: var(--surface);
  background: var(--blue);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.site-header { border-bottom: 1px solid var(--line); }
.masthead, .footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.32rem; font-weight: 750; letter-spacing: -.045em; line-height: 1.12; text-decoration: none; }
.brand img { flex: none; display: block; }
.header-link, .footer-inner a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .86rem; font-weight: 600; text-decoration: none; }
.header-link:hover, .footer-inner a:hover { color: var(--blue); text-decoration: underline; }
.header-link span, .footer-inner a span { color: var(--blue); }

.intro { padding: clamp(34px, 4.3vw, 58px) 0 27px; }
.intro h1 { font-size: clamp(2.1rem, 5vw, 4rem); font-weight: 750; letter-spacing: -.063em; line-height: 1.02; }
.intro p { max-width: 60ch; margin-top: 14px; font-size: clamp(.98rem, 1.6vw, 1.15rem); color: var(--muted); }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 32px -24px #20385b44;
}
.worksheet { display: grid; align-content: start; gap: 15px; padding: 24px; border-right: 1px solid var(--line); background: var(--worksheet); }
.worksheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.worksheet-heading h2 { font-size: 1.26rem; }
.text-button { min-height: 32px; padding: 2px 0; border: 0; color: var(--blue); background: transparent; font-size: .77rem; font-weight: 650; white-space: nowrap; }
.text-button:hover { text-decoration: underline; text-underline-offset: .18em; }
.planning-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--light-line);
}
.mode-option { position: relative; cursor: pointer; }
.mode-option > input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.mode-option > span {
  display: grid;
  min-height: 36px;
  height: 100%;
  padding: 4px;
  place-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
}
.mode-option:hover > span { color: var(--blue); }
.mode-option input:checked + span { border-color: #99b3f1; color: var(--blue); background: var(--surface); }
.mode-option input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.field { display: grid; min-width: 0; gap: 5px; }
.field > label, .field legend { font-size: .86rem; font-weight: 650; }
.field legend { display: block; padding: 0; margin: 0 0 5px; }
.term-field { padding: 0; margin: 0; border: 0; }
.term-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.input-shell {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  padding-inline: 11px;
  border: 1px solid #bdcce0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: .83rem;
}
.input-shell:focus-within { outline: 2px solid var(--blue); outline-offset: 1px; }
.input-shell:has([aria-invalid="true"]) { border-color: var(--error); }
.input-shell input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 7px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.field-error { color: var(--error); }
.contribution { margin: 1px 0; }
.range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 27px;
  margin: 0;
  border-radius: 8px;
  background: transparent;
}
.range::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: linear-gradient(to right, var(--blue) var(--range-progress, 0%), #d7e3f2 var(--range-progress, 0%)); }
.range::-moz-range-track { height: 5px; border-radius: 999px; background: #d7e3f2; }
.range::-moz-range-progress { height: 5px; border-radius: 999px; background: var(--blue); }
.range::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin-top: -6px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.range::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.range:disabled { opacity: .45; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button {
  min-height: 30px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: .76rem;
  font-weight: 650;
}
.presets button:not(:disabled):hover, .presets [aria-pressed="true"] { border-color: #99b3f1; color: var(--blue); background: var(--blue-tint); }
.presets button:disabled { opacity: .47; }
.override-check { display: flex; align-items: center; gap: 7px; min-height: 24px; color: var(--ink); font-size: .81rem; font-weight: 600; cursor: pointer; }
.override-check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--blue); }
.override-fields { padding-top: 1px; }
.goal-fields { display: grid; min-width: 0; gap: 15px; }
.optional { color: var(--muted); font-size: .77rem; font-weight: 500; }
.goal-result {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 13px 12px;
  border: 1px solid #c6d5f5;
  border-top: 3px solid var(--blue);
  border-radius: 8px;
  background: var(--blue-tint);
}
.goal-result h3 { font-size: .96rem; }
.goal-ledger { display: grid; gap: 5px; font-size: .78rem; line-height: 1.3; }
.goal-ledger > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 7px; }
.goal-ledger dt { color: var(--muted); }
.goal-ledger dd { font-weight: 650; font-variant-numeric: tabular-nums; }
.goal-ledger .goal-payment { margin-bottom: 2px; }
.goal-payment dd { color: var(--blue); font-size: 1.03rem; }
.goal-ledger .goal-total, .goal-ledger .goal-gap:last-child { border-top: 1px solid #c6d5f5; padding-top: 6px; }
.goal-total dt, .goal-gap:last-child dt { color: var(--ink); font-weight: 650; }
.goal-note { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.privacy-note { color: var(--muted); font-size: .73rem; }

.outlook { min-width: 0; padding: 24px clamp(18px, 3.1vw, 37px); }
.outlook-heading { display: grid; gap: 5px; }
.outlook-heading p, .section-heading p { color: var(--muted); font-size: .89rem; }
.notice { padding: 14px 16px; border: 1px solid #ebbec3; border-radius: 9px; background: var(--error-tint); color: var(--error); }
.result-error { margin-top: 20px; }
.notice p { margin-top: 3px; font-size: .88rem; }
.scenario-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 15px; }
.scenario-switch button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: .78rem;
  font-weight: 650;
}
.scenario-switch button:hover, .scenario-switch [aria-pressed="true"] { border-color: #aac0f6; color: var(--ink); background: var(--blue-tint); }
.swatch { display: inline-block; flex: none; width: 13px; height: 0; border-top: 2px solid currentColor; }
.swatch.baseline { color: var(--slate); border-top-style: dotted; }
.swatch.recast { color: var(--blue); }
.swatch.early { color: var(--coral); border-top-style: dashed; }

.chart-summary { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 4px 24px; }
.summary-label { display: block; color: var(--muted); font-size: .79rem; font-weight: 600; }
.chart-summary strong { display: block; margin-top: 2px; color: var(--blue); font-size: clamp(1.75rem, 4.5vw, 2.55rem); font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1.05; }
.chart-summary[data-scenario="baseline"] strong { color: var(--ink); }
.chart-summary[data-scenario="early"] strong { color: var(--coral); }
.chart-summary p { max-width: 38ch; color: var(--muted); font-size: .8rem; line-height: 1.4; }

.chart-wrap { margin: 7px 0 1px; }
#chart { display: block; width: 100%; height: 244px; touch-action: pan-y; }
.chart-gridline { stroke: var(--light-line); }
.chart-origin { stroke: #a3b5cc; }
.chart-axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-axis-title { fill: var(--muted); font-size: 11px; font-weight: 650; }
.plot-baseline { color: var(--slate); }
.plot-recast { color: var(--blue); }
.plot-early { color: var(--coral); }
.chart-path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-path.plot-baseline { stroke-dasharray: 1 5; }
.chart-path.plot-early { stroke-dasharray: 7 4; }
.chart-path.is-selected { stroke-width: 3.25; }
.chart-area { fill: currentColor; opacity: .075; }
.chart-cursor { stroke: #8196b4; stroke-dasharray: 3 4; }
.chart-dot { fill: var(--surface); stroke: currentColor; stroke-width: 2; }

.time-control { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: baseline; }
.time-control label, #chart-period { color: var(--muted); font-size: .78rem; font-weight: 650; }
#chart-period { color: var(--ink); text-align: right; }
.time-control .range { grid-column: 1 / -1; }
.chart-balances { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 8px; border-top: 1px solid var(--light-line); }
.chart-balances > div { min-width: 0; }
.chart-balances dt { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .74rem; }
.chart-balances dd { margin-top: 1px; font-size: clamp(.76rem, 1.55vw, 1.05rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.025em; overflow-wrap: anywhere; }

.comparison { margin-top: 30px; padding: 24px clamp(16px, 2.8vw, 29px) 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 15px; }
.scenario-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 11px; overflow: clip; }
.scenario { --scenario-color: var(--slate); min-width: 0; }
.scenario + .scenario { border-left: 1px solid var(--line); }
.scenario[data-case="recast"] { --scenario-color: var(--blue); }
.scenario[data-case="early"] { --scenario-color: var(--coral); }
.scenario-heading { padding: 12px clamp(10px, 2.2vw, 19px) 10px; border-top: 3px solid var(--scenario-color); background: var(--worksheet); }
.scenario.is-selected .scenario-heading { background: var(--blue-tint); }
.scenario-heading p { margin-top: 4px; color: var(--muted); font-size: .75rem; }
.scenario dl { padding: 4px clamp(10px, 2.2vw, 19px); }
.scenario dl > div { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 1px 10px; padding: 7px 0; }
.scenario dl > div + div { border-top: 1px solid var(--light-line); }
.scenario dt { color: var(--muted); font-size: .77rem; }
.scenario dd { font-size: .87rem; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.scenario dl .scenario-payment dd { font-size: 1.11rem; letter-spacing: -.025em; }
.negative { color: var(--error); }
.comparison-note { margin-top: 12px; color: var(--muted); font-size: .78rem; line-height: 1.5; }

.schedule { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.schedule > summary, .guide-content summary { padding: 13px 42px 13px 16px; color: var(--ink); font-weight: 650; font-size: .92rem; list-style: none; position: relative; }
.schedule > summary::-webkit-details-marker, .guide-content summary::-webkit-details-marker { display: none; }
.schedule > summary::after, .guide-content summary::after { content: "+"; position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: var(--blue); font-size: 1.16rem; font-weight: 500; }
.schedule[open] > summary::after, .guide-content details[open] > summary::after { content: "−"; }
.schedule-body { padding: 0 16px 15px; }
.schedule-tools { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 11px; }
.schedule-tools label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .84rem; font-weight: 600; }
.schedule-tools select { min-height: 36px; padding: 3px 8px; border: 1px solid #bdcce0; border-radius: 6px; color: var(--ink); background: var(--surface); }
.solid-button { min-height: 36px; padding: 5px 12px; border: 0; border-radius: 7px; color: var(--surface); background: var(--blue); font-size: .83rem; font-weight: 650; }
.solid-button:hover { background: var(--blue-hover); }
.table-scroll { max-height: 350px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; min-width: 470px; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .82rem; }
th, td { padding: 7px 12px; border-bottom: 1px solid var(--light-line); text-align: right; }
th { position: sticky; top: 0; background: var(--worksheet); }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }

.guide { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.6fr); gap: clamp(18px, 4vw, 58px); margin-top: clamp(35px, 6vw, 68px); padding-bottom: clamp(36px, 6vw, 70px); }
.guide-intro p { margin-top: 10px; }
.guide p { color: var(--muted); font-size: .9rem; }
.guide-content { border-top: 1px solid var(--line); }
.guide-content details { border-bottom: 1px solid var(--line); }
.guide-content summary { padding-left: 0; }
.guide-content summary::after { right: 2px; }
.guide-content p { padding: 0 18px 13px 0; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { min-height: 56px; color: var(--muted); font-size: .85rem; }

@media (max-width: 930px) {
  .wrap { width: calc(100% - 42px); }
  .workspace { grid-template-columns: minmax(238px, 290px) minmax(0, 1fr); }
  .worksheet { padding-inline: 18px; }
}

@media (max-width: 740px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .worksheet { grid-template-columns: repeat(2, minmax(0, 1fr)); border-right: 0; border-bottom: 1px solid var(--line); }
  .worksheet-heading, .planning-mode, .goal-fields, .goal-result, #goal-error,
  .override-check, .override-fields, .privacy-note { grid-column: 1 / -1; }
  .goal-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .goal-result { max-width: 28rem; }
  .scenario-columns { grid-template-columns: 1fr; }
  .scenario + .scenario { border-left: 0; }
  .scenario-heading, .scenario dl { padding-inline: 13px; }
  .guide { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .wrap { width: calc(100% - 24px); }
  .masthead { min-height: 57px; }
  .brand { gap: 7px; font-size: 1rem; }
  .brand img { width: 31px; height: 31px; }
  .header-link { flex: none; max-width: 6.9rem; font-size: .76rem; line-height: 1.25; }
  .intro { padding: 28px 1px 20px; }
  .intro h1 { letter-spacing: -.05em; }
  .intro p { margin-top: 10px; }
  .workspace { border-radius: 13px; }
  .worksheet { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 14px; }
  .goal-fields { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .outlook { padding: 17px 12px; }
  #chart { height: 218px; }
  .scenario-switch { gap: 4px; margin-block: 14px; }
  .scenario-switch button { gap: 4px; padding-inline: 5px; font-size: .7rem; }
  .scenario-switch .swatch { width: 9px; }
  .chart-balances dt { gap: 3px; font-size: .67rem; }
  .chart-balances .swatch { width: 8px; }
  .comparison { margin-top: 18px; padding: 16px 12px; }
}

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