:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --line: #e3e0d8;
  --fg: #1a1a17;
  --muted: #625e56;
  --accent: #0b7a4b;
  --accent-strong: #075e39;
  --accent-soft: #e2f2e9;
  --on-accent: #ffffff;
  --warn: #8f5300;
  --warn-soft: #fcf1de;
  --warn-line: #f0d6a8;
  --wa: #128c4b;
  /* Chart series: validated categorical slots 1-4 (adjacent CVD ΔE ≥ 8). */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --shadow: 0 1px 2px rgba(20, 20, 15, 0.04), 0 4px 16px rgba(20, 20, 15, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121311;
    --surface: #1b1c1a;
    --surface-2: #252623;
    --line: #34352f;
    --fg: #ecebe6;
    --muted: #a8a49a;
    --accent: #3fbf84;
    --accent-strong: #6dd6a3;
    --accent-soft: #15301f;
    --on-accent: #07150e;
    --warn: #f0a548;
    --warn-soft: #2b2113;
    --warn-line: #4a3517;
    --wa: #25a35f;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121311;
  --surface: #1b1c1a;
  --surface-2: #252623;
  --line: #34352f;
  --fg: #ecebe6;
  --muted: #a8a49a;
  --accent: #3fbf84;
  --accent-strong: #6dd6a3;
  --accent-soft: #15301f;
  --on-accent: #07150e;
  --warn: #f0a548;
  --warn-soft: #2b2113;
  --warn-line: #4a3517;
  --wa: #25a35f;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2 { text-wrap: balance; }
p { text-wrap: pretty; }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--fg); text-decoration: none; font-size: 15px; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 16px; }
.checked { font-size: 13px; color: var(--muted); text-align: right; }

/* Hero */
.hero { padding: 32px 0 20px; max-width: 720px; }
.eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); line-height: 1.1; letter-spacing: -0.015em; }
.lede { margin: 12px 0 0; font-size: 17px; color: var(--muted); }

/* Layout */
.layout { display: grid; gap: 20px; align-items: start; padding-bottom: 32px; }
@media (min-width: 960px) {
  .layout { grid-template-columns: 380px minmax(0, 1fr); gap: 28px; }
  .controls { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }

/* Controls */
.controls { display: grid; gap: 20px; }
.field { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 8px; }
.label { padding: 0; font-size: 14px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 14px; font-weight: 550; line-height: 1.25; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.chip small { font-size: 12px; font-weight: 450; color: var(--muted); }
.chip:hover span { border-color: var(--muted); }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); box-shadow: inset 0 0 0 1px var(--accent); }
.chip input:checked + span small { color: var(--accent-strong); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.money-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.money-input span { padding: 0 4px 0 14px; color: var(--muted); font-weight: 600; }
.money-input input { flex: 1; min-width: 0; height: 44px; padding: 0 14px 0 4px; border: 0; background: transparent; font-size: 16px; font-variant-numeric: tabular-nums; outline: none; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.link { padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

.fine { border-top: 1px solid var(--line); padding-top: 16px; }
.fine summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent); }
.fine[open] summary { margin-bottom: 16px; }
.fine .field + .field { margin-top: 16px; }
.noscript { margin: 0; color: var(--warn); }

/* Results */
.results { display: grid; gap: 16px; min-width: 0; }
.summary { margin: 0; font-size: 14px; color: var(--muted); }
.kicker { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.hero-num { margin: 0; font-size: clamp(40px, 8vw, 56px); font-weight: 750; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero-sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; }
.big { margin: 0; font-size: 32px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big span { font-size: 18px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.visa > .muted { margin: 8px 0 0; font-size: 15px; }

/* Part-to-whole bar: 2px surface gaps between segments, 4px rounded ends. */
.bar { display: flex; gap: 2px; height: 16px; margin: 20px 0 14px; border-radius: 4px; overflow: hidden; }
.seg { min-width: 6px; flex-basis: 0; cursor: default; outline: none; }
.seg:focus-visible { box-shadow: inset 0 0 0 2px var(--fg); }
.s1 { background: var(--s1); }
.s2 { background: var(--s2); }
.s3 { background: var(--s3); }
.s4 { background: var(--s4); }
.legend { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 44px; align-items: center; gap: 10px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.lg-label { font-weight: 550; }
.amt { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.amt .eur { color: var(--muted); }
.lg-val { display: flex; justify-content: flex-end; }
.lg-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.steps, .timeline { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 0; counter-reset: step; }
.steps li, .timeline li { position: relative; padding: 14px 0 14px 40px; border-top: 1px solid var(--line); counter-increment: step; }
.steps li::before, .timeline li::before {
  content: counter(step); position: absolute; left: 0; top: 13px;
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 700;
}
.row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.row b { font-weight: 650; }
.row .amt { margin-left: auto; }
.row .inr { font-weight: 700; }
.steps p, .timeline p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

.note { background: var(--surface-2); box-shadow: none; }
.note p { margin: 0; font-size: 15px; }
.note .note-title { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; font-weight: 650; }
.note-title svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.warn .note-title { color: var(--warn); }
.tag { display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 4px; background: var(--warn); color: var(--surface); font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; vertical-align: 1px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 9px 0; border-top: 1px solid var(--line); text-align: right; }
.table th:first-child { text-align: left; font-weight: 450; padding-right: 12px; }
.table thead th { border-top: 0; padding-top: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.table td + td, .table th + th { padding-left: 12px; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 2px solid var(--fg); }
.table td.muted { text-align: right; }
.card > .hint { margin-top: 12px; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--fg); font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, .yt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.big { min-height: 52px; padding: 14px 22px; font-size: 17px; }

.cta { border: 2px solid var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.cta h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.2; }
.cta p { margin: 0 0 16px; }
.cta .small { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.yt { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; font-weight: 600; }
.yt svg { width: 20px; height: 20px; }

/* Tooltip */
.tooltip {
  position: fixed; z-index: 20; max-width: 260px; padding: 8px 10px; border-radius: 8px;
  background: var(--fg); color: var(--bg); font-size: 13px; line-height: 1.35; pointer-events: none;
}
.tooltip b { display: block; }

/* Footer */
.notes { padding: 24px 0 96px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.notes h2 { margin: 0 0 8px; font-size: 16px; color: var(--fg); }
.notes p { margin: 0 0 12px; max-width: 760px; }
.notes ul { margin: 0 0 16px; padding-left: 18px; display: grid; gap: 4px; }
.disclaimer { font-size: 13px; }

/* Mobile summary bar */
.peek {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 10;
  display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-radius: 14px;
  background: var(--fg); color: var(--bg); text-decoration: none; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.peek[hidden] { display: none; }
.peek small { display: block; font-size: 11px; font-weight: 500; opacity: 0.75; }
.peek .go { margin-left: auto; font-size: 14px; }
@media (min-width: 960px) { .peek { display: none !important; } }

@media (max-width: 480px) {
  .checked { display: none; }
  .card { padding: 16px; border-radius: 14px; }
  .legend li { grid-template-columns: 12px 1fr auto; }
  .lg-pct { display: none; }
  .lg-val .amt { flex-direction: column; align-items: flex-end; gap: 0; }
  .actions .btn { flex: 1 1 100%; }
}

/* Print: a clean plan to hand to family */
@media print {
  :root { --bg: #fff; --surface: #fff; --shadow: none; }
  body { font-size: 12px; }
  .topbar, .controls, .actions, .cta, .peek, .tooltip, .fine { display: none !important; }
  .layout { display: block; }
  .hero { padding: 0 0 12px; }
  .lede { display: none; }
  .card { break-inside: avoid; margin-bottom: 12px; border-color: #ccc; }
  .results { display: block; }
  .summary { font-size: 14px; color: #000; margin-bottom: 12px; }
  .bar, .swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .notes { padding-bottom: 0; }
}

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