/* Numbers vs Narrative — system fonts only (no third-party requests: minors' privacy). */
:root {
  color-scheme: light;
  --paper: #f5f6f8; --panel: #ffffff; --ink: #15171c; --muted: #5c6270; --faint: #8b91a0; --line: #e3e6ec;
  --fact: #1f5f8b; --fact-soft: rgba(31, 95, 139, .10);
  --hype: #c2562c; --hype-soft: rgba(194, 86, 44, .10);
  --good: #2f7d6b; --ok: #6b7280; --warn: #b07a16; --crit: #b0402a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #111318; --panel: #1a1d24; --ink: #e8eaef; --muted: #a3a9b6; --faint: #7c8392; --line: #2b2f39;
    --fact: #6aa8d8; --fact-soft: rgba(106, 168, 216, .14);
    --hype: #ec8a5f; --hype-soft: rgba(236, 138, 95, .14);
    --good: #5cc0a6; --ok: #a3a9b6; --warn: #e0b257; --crit: #ef7d66;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 760px; margin: 0 auto; padding: env(safe-area-inset-top, 0px) max(18px, env(safe-area-inset-right, 0px)) 80px max(18px, env(safe-area-inset-left, 0px)); }
.mono { font-family: var(--mono); }
.num { color: var(--fact); } .nar { color: var(--hype); }

.top { text-align: center; padding: 40px 0 6px; }
.brand { font-family: var(--mono); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); margin: 0 0 12px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 6vw, 2.7rem); line-height: 1.08; margin: 0; }
h1 .vs { font-style: italic; color: var(--faint); font-size: .7em; }
.tag { color: var(--muted); margin: 12px 0 0; }

.step { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-top: 18px; }
.step h2 { font-size: 1.1rem; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.stepn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: .9rem; font-family: var(--mono); }
.lede { margin: 0 0 14px; color: var(--muted); }
.field { display: grid; gap: 6px; }
.field label { font-size: .85rem; font-weight: 600; }
input { font: inherit; font-size: 1.05rem; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); width: 100%; font-variant-numeric: tabular-nums; }
input:focus { outline: none; border-color: var(--fact); }
.help { margin: 2px 0 0; font-size: .85rem; color: var(--faint); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .grid3 { grid-template-columns: 1fr; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
button { font: inherit; font-weight: 600; border-radius: 12px; padding: 12px 20px; cursor: pointer; border: 2px solid transparent; }
button.primary { background: var(--ink); color: var(--paper); }
button.secondary { background: transparent; color: var(--ink); border-color: var(--warn); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--fact); outline-offset: 2px; }
.msg { border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: .92rem; }
.msg.err { background: var(--hype-soft); color: var(--crit); }
.msg.warn { background: rgba(176, 122, 22, .12); color: var(--warn); }

#results { margin-top: 22px; display: grid; gap: 16px; }
.verdict { border-radius: 20px; padding: 26px 22px; text-align: center; border: 1px solid var(--line); background: var(--panel); }
.verdict.good { background: var(--fact-soft); }
.verdict.mid { background: linear-gradient(135deg, var(--fact-soft), var(--hype-soft)); }
.verdict.crit { background: var(--hype-soft); }
.verdict .tkr { font-family: var(--mono); font-size: .8rem; letter-spacing: .08em; color: var(--muted); margin: 0 0 4px; }
.verdict h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.5rem, 5vw, 1.9rem); margin: 2px 0 8px; text-wrap: balance; }
.verdict p { margin: 0 auto; max-width: 48ch; }
.scores { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.scores b { color: var(--ink); font-variant-numeric: tabular-nums; }
.echo { margin: 0; text-align: center; color: var(--muted); font-size: .95rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.card h3 { font-size: 1rem; margin: 0 0 12px; text-wrap: balance; }
.cite { font-family: var(--mono); font-size: .72rem; font-weight: 400; color: var(--faint); margin-left: 6px; }
.radar-wrap { max-width: 420px; margin: 0 auto; }
#radar text { fill: var(--muted); font-size: 12px; font-family: var(--sans); }
#radar .grid { fill: none; stroke: var(--line); }
#radar .fact { fill: var(--fact-soft); stroke: var(--fact); stroke-width: 2; }
#radar .hype { fill: var(--hype-soft); stroke: var(--hype); stroke-width: 2; stroke-dasharray: 5 4; }
.legend { display: flex; justify-content: center; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.sw.f { background: var(--fact); } .sw.h { background: var(--hype); margin-left: 10px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
td, th { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; font-size: .8rem; color: var(--muted); }
td.n { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gapbar { height: 6px; border-radius: 3px; background: var(--hype); }
.note { color: var(--muted); font-size: .85rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; border-radius: 999px; padding: 1px 8px; border: 1.5px solid currentColor; white-space: nowrap; }
.s-good { color: var(--good); } .s-ok { color: var(--ok); } .s-watch { color: var(--warn); } .s-bad { color: var(--crit); } .s-info, .s-na { color: var(--faint); }

.meter { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--fact-soft), var(--hype-soft)); border: 1px solid var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--hype); border-radius: 7px; width: 0; }
@media (prefers-reduced-motion: no-preference) { .meter-fill { transition: width .5s ease; } }
.parts { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: .9rem; display: grid; gap: 3px; }

.filter { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.filter li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.filter .why { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.choice { display: inline-flex; gap: 6px; }
.choice button { padding: 3px 10px; font-size: .8rem; border: 1.5px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; }
.choice button[aria-pressed="true"] { border-color: var(--fact); color: var(--fact); }

.statements { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 620px) { .statements { grid-template-columns: 1fr; } }
.stmt { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stmt h4 { margin: 0 0 2px; font-size: .9rem; }
.stmt .vibe { margin: 0 0 8px; font-size: .78rem; color: var(--faint); }
.stmt dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: .88rem; }
.stmt dt { color: var(--muted); } .stmt dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; align-items: end; height: 140px; margin-top: 6px; }
.bar { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; font-size: .75rem; }
.bar .v { font-family: var(--mono); color: var(--ink); }
.bar .col { align-self: end; background: var(--fact); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar .col.neg { background: var(--crit); }
.bar .y { color: var(--faint); font-family: var(--mono); }

.source { font-size: .85rem; color: var(--muted); }
.source p { margin: 0 0 6px; }
.foot { margin-top: 30px; text-align: center; font-size: .8rem; color: var(--faint); }
.foot p { margin: 4px 0; }
[hidden] { display: none !important; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 6px; justify-content: center; margin-top: 22px; flex-wrap: wrap; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); padding: 8px 0; }
.tab { text-decoration: none; color: var(--muted); font-weight: 600; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); }
.tab[aria-current="page"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.view { display: grid; gap: 16px; }
.view > .step:first-child { margin-top: 6px; }
.center { justify-content: center; }

/* ---- shared bits for portfolio + money ---- */
textarea { font: inherit; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); width: 100%; resize: vertical; }
textarea:focus { outline: none; border-color: var(--fact); }
.field + .field, .grid3 + .field { margin-top: 12px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: .92rem; }
.check input { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.kpis > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; }
.kpis .k { font-size: .78rem; color: var(--muted); }
.kpis b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.up { color: var(--good); } .down { color: var(--crit); }
.alloc { display: flex; height: 14px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.seg { height: 100%; background: hsl(calc(205 + var(--i) * 47) 55% 48%); }
.seg.cash, .dot.cash { background: var(--line); }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; background: hsl(calc(205 + var(--i) * 47) 55% 48%); }
.scroll { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.journal li { display: block; }
.journal p { margin: 4px 0 0; }
button.link { background: none; border: none; padding: 0; color: var(--fact); text-decoration: underline; font-weight: 600; cursor: pointer; }
label.link { color: var(--fact); text-decoration: underline; font-weight: 600; cursor: pointer; }
button.small { padding: 5px 12px; font-size: .85rem; }
.danger-btn { background: var(--crit); color: #fff; padding: 6px 12px; }
.card.danger { border-style: dashed; }
.risk { margin-top: 14px; }
.risk p { margin: 0 0 8px; }
.sub { font-size: .95rem; margin: 10px 0 8px; }
.budget { display: grid; gap: 10px; }
.brow { display: grid; grid-template-columns: minmax(110px, 1.2fr) 2fr auto; gap: 10px; align-items: center; font-size: .9rem; }
@media (max-width: 520px) { .brow { grid-template-columns: 1fr; gap: 4px; } }
.btrack { position: relative; height: 12px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); }
.bfill { height: 100%; border-radius: 6px; background: var(--fact); }
.btarget { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.meter.shield { background: var(--paper); }
.meter.shield .meter-fill { background: var(--good); }
.kinds { flex-wrap: wrap; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day { font-size: .78rem; padding: 4px 9px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--muted); }
.day.on { border-color: var(--good); color: var(--good); font-weight: 700; }
.day.today { outline: 2px solid var(--fact); outline-offset: 1px; }
.big { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 10px 0 4px; }
.big.small { font-size: .95rem; margin: 8px 0 0; }
.big .note { font-size: .85rem; font-weight: 400; display: block; }
.checkin { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: .9rem; opacity: 0; pointer-events: none; max-width: min(92vw, 480px); text-align: center; z-index: 20; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: no-preference) { #toast { transition: opacity .2s, transform .2s; } }
.backup { margin-top: 10px; }

.view > *, #results > * { min-width: 0; }
