/* Rich, Broke or Dead — Guided Planner ("The Almanac")
   Warm paper-and-ink editorial system. Fraunces display + Instrument Sans body.
   Chart colors are validated (see Plans/ notes): ordinal greens pass the
   light-surface ordinal checks; flow blue/terracotta/green pass categorical.

   Fonts are self-hosted (variable woff2, latin subset) so the page makes no
   requests to any third-party host — the tool is fully local by design. */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/fraunces.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/fraunces-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/instrument-sans.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/instrument-sans-italic.woff2') format('woff2');
}

:root {
  --paper: #f6f1e6;
  --paper-deep: #efe8d8;
  --card: #fdfbf5;
  --card-2: #faf6ec;
  --ink: #26221a;
  --ink-2: #57503f;
  --muted: #8b8577;
  --hairline: #e3dcc9;
  --hairline-2: #d5cdb6;
  --accent: #1e6f45;
  --accent-deep: #155d3b;
  --accent-wash: rgba(30, 111, 69, 0.08);
  --gold: #b98a2e;
  --danger: #c23a2b;
  --danger-wash: rgba(194, 58, 43, 0.08);
  --dead: #96907f;

  --w-dead: #96907f;
  --w-broke: #c23a2b;
  --w-below: #7fb163;
  --w-okay: #4a9a58;
  --w-2x: #27794a;
  --w-5x: #155d3b;
  --flow-in: #2a78d6;
  --flow-out: #c96a3f;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", -apple-system, "Segoe UI", sans-serif;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(52, 42, 18, 0.06), 0 8px 28px -12px rgba(52, 42, 18, 0.18);
  --shadow-lift: 0 2px 4px rgba(52, 42, 18, 0.08), 0 16px 40px -12px rgba(52, 42, 18, 0.22);
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html { scroll-behavior: smooth; }

body.plan-body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 500px at 85% -10%, rgba(185, 138, 46, 0.07), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(30, 111, 69, 0.06), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.17 0 0 0 0 0.1 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
}

/* ---------- Header ---------- */

.plan-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 28px 10px;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.wordmark .w-rich { color: var(--accent-deep); }
.wordmark .w-broke { color: var(--danger); }
.wordmark .w-dead { color: var(--dead); }
.wordmark .w-plain { color: var(--ink-2); font-weight: 400; font-style: italic; }

.header-sub {
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- Shell ---------- */

.plan-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 470px);
  gap: 28px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 28px 80px;
  align-items: start;
}

/* ---------- Progress rail ---------- */

.rail {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 14px 0 22px;
  flex-wrap: wrap;
}

.rail-step {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 999px;
  cursor: default;
}
.rail-step.visited { cursor: pointer; }
.rail-step.visited:hover { background: var(--accent-wash); color: var(--ink); }
.rail-step.current { color: var(--ink); font-weight: 600; }

.rail-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-2);
  background: var(--card);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.25s ease;
}
.rail-step.current .rail-dot {
  border-color: var(--accent);
  background: var(--accent);
  color: #fdfbf5;
}
.rail-step.done .rail-dot {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent-deep);
}

.rail-link {
  width: 18px;
  height: 1px;
  background: var(--hairline-2);
  flex: none;
}

/* ---------- Privacy badge ---------- */

.privacy-badge {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--accent-wash);
  border: 1px solid rgba(30, 111, 69, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 22px;
}
.privacy-badge svg { flex: none; margin-top: 2px; color: var(--accent-deep); }
.privacy-badge strong { color: var(--accent-deep); }

/* ---------- Step panels ---------- */

.step-panel {
  animation: step-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes step-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.plan-intro {
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.6;
  max-width: 62ch;
  margin: 2px 0 26px;
}
.plan-intro p { margin: 0 0 12px; }
.plan-intro p:last-child { margin-bottom: 0; }

.step-kicker {
  font-size: 12.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin: 0 0 6px;
}

.step-title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 550;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  font-variation-settings: "opsz" 40;
}

.step-lede {
  color: var(--ink-2);
  font-size: 16.5px;
  max-width: 56ch;
  margin: 0 0 26px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.card-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 14px;
}

.card-label .card-action {
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

/* ---------- Person / sex pickers ---------- */

.person-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.person-name-input {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  border: none;
  border-bottom: 1.5px dashed var(--hairline-2);
  background: transparent;
  padding: 2px 2px 4px;
  width: 180px;
  transition: border-color 0.2s;
}
.person-name-input:focus { outline: none; border-bottom-color: var(--accent); border-bottom-style: solid; }
.person-name-input::placeholder { color: var(--muted); font-weight: 500; }

.sex-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.sex-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px 14px;
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.sex-btn:hover { transform: translateY(-2px); border-color: var(--hairline-2); box-shadow: var(--shadow); }
.sex-btn.selected {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.sex-btn svg { display: block; }
.sex-btn .glyph-stroke { stroke: var(--muted); transition: stroke 0.18s ease; }
.sex-btn.selected .glyph-stroke { stroke: var(--accent-deep); }
.sex-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 0;
}

/* ---------- Birthday drill-down ---------- */

.birthday-picker { margin-top: 18px; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-height: 28px;
}
.crumb {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border: none;
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
}
.crumb:hover { background: rgba(30, 111, 69, 0.16); }
.crumb-sep { color: var(--hairline-2); font-size: 12px; }
.crumb-q { font-size: 13.5px; color: var(--muted); }

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 8px;
}
.chip-grid.days {
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-width: 420px;
}
.cal-dow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  align-self: end;
  padding-bottom: 2px;
}

.chip {
  font: inherit;
  font-size: 15px;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--card-2);
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  animation: chip-in 0.3s ease backwards;
}
.chip:nth-child(2n) { animation-delay: 0.02s; }
.chip:nth-child(3n) { animation-delay: 0.045s; }
.chip:nth-child(5n) { animation-delay: 0.07s; }
@keyframes chip-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
.chip:hover { transform: translateY(-1.5px); border-color: var(--accent); color: var(--accent-deep); }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fdfbf5; }
.chip .chip-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.chip:hover .chip-sub { color: var(--accent); }

.birthday-done {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent-wash);
  border: 1px solid rgba(30, 111, 69, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.birthday-done .bd-date { font-weight: 650; color: var(--accent-deep); }
.birthday-done .bd-age { color: var(--ink-2); font-size: 14.5px; }

/* ---------- Health picker ---------- */

.health-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.health-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  padding: 12px 14px;
  border: 1.5px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.health-btn:hover { transform: translateY(-1.5px); border-color: var(--hairline-2); }
.health-btn.selected { border-color: var(--accent); background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.health-btn .h-name { font-weight: 650; font-size: 14.5px; color: var(--ink); }
.health-btn .h-desc { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* ---------- Partner add / remove ---------- */

.add-partner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1.5px dashed var(--hairline-2);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 18px;
}
.add-partner:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-wash); }

.remove-link {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.remove-link:hover { color: var(--danger); }

/* ---------- Currency input ---------- */

.money-input-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  border-bottom: 2px solid var(--hairline-2);
  padding-bottom: 6px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
  max-width: 420px;
}
.money-input-wrap:focus-within { border-color: var(--accent); }
.money-input-wrap .money-sign {
  font-size: 26px;
  font-weight: 600;
  color: var(--muted);
}
.money-input {
  font-family: var(--sans);
  font-size: 38px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  border: none;
  background: transparent;
  width: 100%;
  padding: 0;
  min-width: 0;
}
.money-input:focus { outline: none; }
.money-input::placeholder { color: var(--hairline-2); }
.money-suffix { font-size: 15px; color: var(--muted); white-space: nowrap; }

.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-chip {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.quick-chip:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-wash); }

/* ---------- Stream (income/expense) cards ---------- */

.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--card-2);
  border: 1.5px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-btn:hover { transform: translateY(-1.5px); border-color: var(--accent); color: var(--accent-deep); }
.preset-btn .p-plus { color: var(--gold); font-weight: 700; }

.stream-card {
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  animation: chip-in 0.25s ease;
}
.stream-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.stream-title-input {
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  border: none;
  background: transparent;
  border-bottom: 1px dashed transparent;
  min-width: 0;
  flex: 1 1 130px;
  padding: 2px 0;
}
.stream-title-input:hover, .stream-title-input:focus { border-bottom-color: var(--hairline-2); outline: none; }

.stream-amount {
  display: flex;
  align-items: baseline;
  gap: 2px;
  border-bottom: 1.5px solid var(--hairline-2);
}
.stream-amount:focus-within { border-color: var(--accent); }
.stream-amount .money-sign { font-size: 15px; color: var(--muted); font-weight: 600; }
.stream-amount input {
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
  border: none;
  background: transparent;
  width: 84px;
  padding: 1px 0;
}
.stream-amount input:focus { outline: none; }
.stream-amount .per { font-size: 12.5px; color: var(--muted); }

.stream-ages-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.age-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.age-stepper button {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  cursor: pointer;
  line-height: 1;
}
.age-stepper button:hover { color: var(--accent-deep); background: var(--accent-wash); }
.age-stepper input {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  width: 34px;
  text-align: center;
  border: none;
  background: transparent;
}
.age-stepper input:focus { outline: none; }

.stream-flags {
  display: inline-flex;
  gap: 12px;
  margin-left: auto;
}
.flag-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.flag-label input { accent-color: var(--accent); }

.owner-tag {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border-radius: 999px;
  padding: 2.5px 9px;
  white-space: nowrap;
}
.owner-tag.partner { color: #1c5cab; background: rgba(42, 120, 214, 0.1); }

.streams-empty-hint {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  padding: 6px 2px 2px;
}

/* ---------- Sliders & fine-tune ---------- */

.tune-grid { display: grid; grid-template-columns: 1fr; gap: 0; }

.tune-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}
.tune-row:last-child { border-bottom: none; }
.tune-name { flex: 0 0 150px; font-weight: 600; font-size: 14.5px; }
.tune-name .tune-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

input[type="range"].tune-slider {
  flex: 1 1 140px;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline-2);
  outline-offset: 4px;
}
input[type="range"].tune-slider.filled {
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill, 50%), var(--hairline-2) var(--fill, 50%));
}
input[type="range"].tune-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  border: 2.5px solid var(--accent);
  box-shadow: var(--shadow);
  cursor: grab;
}
input[type="range"].tune-slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--card); border: 2.5px solid var(--accent);
  cursor: grab;
}
.tune-value { flex: 0 0 auto; font-weight: 650; font-size: 14.5px; min-width: 74px; text-align: right; }

/* Question-mark tooltip (info on hover/focus) */
.qmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
}
.qmark:hover, .qmark:focus-visible {
  border-color: var(--accent);
  color: var(--accent-deep);
  outline: none;
}
.qmark .qtip {
  position: absolute;
  bottom: calc(100% + 9px);
  left: -14px;
  width: 250px;
  background: var(--ink);
  color: #f6f1e6;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 10px;
  padding: 10px 13px;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  z-index: 6;
  pointer-events: none;
}
.qmark .qtip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 17px;
  border: 6px solid transparent;
  border-top-color: var(--ink);
}
.qmark:hover .qtip, .qmark:focus-visible .qtip {
  opacity: 1;
  visibility: visible;
}

.risk-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.alloc-readout {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
  background: var(--hairline);
}
.alloc-readout .seg { transition: width 0.3s ease; }
.alloc-readout .seg.stocks { background: var(--accent); }
.alloc-readout .seg.bonds { background: var(--gold); }
.alloc-readout .seg.cash { background: var(--hairline-2); }
.alloc-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.alloc-legend .k { display: inline-flex; align-items: center; gap: 5px; }
.alloc-legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.seg-toggle {
  display: inline-flex;
  border: 1.5px solid var(--hairline);
  border-radius: 999px;
  background: var(--card-2);
  padding: 3px;
  gap: 2px;
}
.seg-toggle button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg-toggle button.active { background: var(--accent); color: #fdfbf5; }

details.advanced {
  border-top: 1px dashed var(--hairline-2);
  margin-top: 14px;
  padding-top: 8px;
}
details.advanced summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 6px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 7px;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::before {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
details.advanced[open] summary::before { transform: rotate(45deg); }

/* ---------- Nav buttons ---------- */

.step-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
}
.btn-primary {
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  color: #fdfbf5;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 13px 30px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  color: var(--ink-2);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 10px 6px;
}
.btn-ghost:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.nav-hint { font-size: 13px; color: var(--muted); margin-left: auto; }

/* ---------- Viz panel ---------- */

.plan-viz {
  position: sticky;
  top: 20px;
}

.viz-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 14px;
  overflow: hidden;
}

.viz-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 2px;
}
.viz-sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

.viz-stage { position: relative; }
.viz-stage svg { display: block; width: 100%; height: auto; }
.viz-stage.viz-refresh svg { animation: viz-in 0.5s ease; }
@keyframes viz-in {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

.viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 250px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}
.viz-empty .dotline {
  width: 70%;
  border-top: 2px dotted var(--hairline-2);
  position: relative;
}
.viz-empty .dotline::after {
  content: "";
  position: absolute;
  right: -5px; top: -6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--hairline-2);
}

.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 10px 2px 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 2px 4px;
  border-radius: 6px;
}
button.legend-key { cursor: pointer; }
button.legend-key:hover { background: var(--paper-deep); }
button.legend-key.off { opacity: 0.38; text-decoration: line-through; }
.legend-key .lk-line { width: 14px; height: 0; border-top: 2.5px solid; border-radius: 2px; }
.legend-key .lk-rect { width: 11px; height: 11px; border-radius: 3px; }

.viz-caption {
  border-top: 1px solid var(--hairline);
  margin-top: 8px;
  padding: 11px 2px 4px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-2);
}
.viz-caption strong { color: var(--ink); }

.viz-table { margin-top: 6px; }
.viz-table summary {
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 2px;
}
.viz-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 6px;
}
.viz-table th, .viz-table td {
  text-align: right;
  padding: 4px 8px;
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums;
}
.viz-table th:first-child, .viz-table td:first-child { text-align: left; }
.viz-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }

/* Chart internals (SVG classes) */
.axis-text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.grid-line { stroke: var(--hairline); stroke-width: 1; }
.axis-line { stroke: var(--hairline-2); stroke-width: 1; }
.chart-label { font-family: var(--sans); font-size: 12px; font-weight: 600; fill: var(--ink); }
.chart-sublabel { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); }

/* Tooltip */
.viz-tip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #f6f1e6;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 5;
  min-width: 130px;
}
.viz-tip.show { opacity: 1; }
.viz-tip .tip-age { font-weight: 700; font-size: 12px; letter-spacing: 0.04em; margin-bottom: 3px; color: #cfc7b2; }
.viz-tip .tip-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.viz-tip .tip-key { width: 12px; border-top: 2.5px solid; border-radius: 2px; flex: none; }
.viz-tip .tip-val { font-weight: 700; }
.viz-tip .tip-name { color: #cfc7b2; }

/* ---------- Outlook (results) step ---------- */

.verdict-hero {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  margin: 4px 0 4px;
}
.verdict-num {
  font-size: 74px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent-deep);
}
.verdict-num.mid { color: var(--gold); }
.verdict-num.low { color: var(--danger); }
.verdict-label { font-size: 15px; color: var(--ink-2); max-width: 30ch; line-height: 1.4; }

.verdict-phrase {
  font-family: var(--serif);
  font-style: italic;
  font-size: 21px;
  color: var(--ink);
  margin: 10px 0 20px;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--card-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat-tile .st-label { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-tile .st-value { font-size: 23px; font-weight: 650; margin-top: 2px; }

.warning-strip {
  background: rgba(185, 138, 46, 0.1);
  border: 1px solid rgba(185, 138, 46, 0.35);
  border-radius: var(--radius-sm);
  color: #7a5a17;
  font-size: 13.5px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.solve-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 2px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink-2);
  border-bottom: 1px solid var(--hairline);
}
.solve-row:last-of-type { border-bottom: none; }
.solve-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  position: relative;
  top: -1px;
}

.save-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.save-name-input {
  font: inherit;
  font-size: 15px;
  border: 1.5px solid var(--hairline);
  border-radius: 999px;
  background: var(--card);
  padding: 10px 18px;
  min-width: 190px;
}
.save-name-input:focus { outline: none; border-color: var(--accent); }
.saved-note { color: var(--accent-deep); font-size: 13.5px; font-weight: 600; }

/* ---------- Resume banner ---------- */

.resume-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  background: var(--accent-wash);
  border: 1px solid rgba(30, 111, 69, 0.25);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--accent-deep);
  margin-bottom: 16px;
}
.resume-banner button {
  font: inherit; font-size: 13px; font-weight: 600;
  background: none; border: none; cursor: pointer;
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- Footer credit ---------- */

.plan-footer {
  text-align: center;
  padding: 0 24px 28px;
  font-size: 12px;
  color: var(--muted);
}

.plan-footer a {
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
}

.plan-footer a:hover {
  color: var(--ink);
}

/* ---------- Responsive ---------- */

@media (max-width: 1020px) {
  .plan-shell { grid-template-columns: 1fr; }
  .plan-viz { position: static; }
  .viz-card { padding: 14px 14px 10px; }
  .step-title { font-size: 27px; }
  .verdict-num { font-size: 56px; }
  .health-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .plan-header { flex-wrap: wrap; padding: 18px 16px 6px; }
  .plan-shell { padding: 4px 14px 60px; }
  .money-input { font-size: 30px; }
  .rail-step span.rail-name { display: none; }
  .rail-step.current span.rail-name { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
