/* DESIGN SYSTEM (from design/mockup.html, approved by Anu 2026-09-24; reference/anti-slop-design.md)
   VOICE: a calm friend who is good with money. Plain words, never scolds, never sells.
   FONTS: display = Bricolage Grotesque (the number, headings) · body = Instrument Sans (UI).
          Tabular figures wherever a number can change.
   COLOR: fog bg · paper surface · ink navy text + hero number · marigold = the stretch + money in.
          No red anywhere (R11). Short states use weight and words, in ink.
   SHAPE: 4px base unit, radius cap 6px (pills only on the 3 actions), hairline borders, no shadows.
   LAYOUT PRIMITIVE: one column: the number, then the stretch, then the list.
   DO NOT: Inter/Roboto/Geist, indigo/violet/emerald, gradients, glass, glows, red, 3-card grids, streaks. */

@font-face { font-family: "Bricolage Grotesque"; src: url(fonts/bricolage-grotesque.woff2) format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/instrument-sans.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --fog: #F1F3F6; --paper: #FFFFFF; --ink: #0F2340; --muted: #5A6780; --rule: #D8DEE8;
  --marigold: #F2B01E; --marigold-ink: #7A5000; --mist: #E4EBF5; --on-ink: #FFFFFF;
  --scrim: rgba(15, 35, 64, 0.28);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Instrument Sans", "Avenir Next", "Segoe UI", sans-serif;
  --r: 6px; --u: 4px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --fog: #0B1626; --paper: #12213A; --ink: #EEF2F8; --muted: #9AA7BD; --rule: #263857;
  --marigold: #F2B01E; --marigold-ink: #F5C451; --mist: #1A2B47; --on-ink: #0B1626;
  --scrim: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fog: #0B1626; --paper: #12213A; --ink: #EEF2F8; --muted: #9AA7BD; --rule: #263857;
    --marigold: #F2B01E; --marigold-ink: #F5C451; --mist: #1A2B47; --on-ink: #0B1626;
    --scrim: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fog); color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }
.num, .tab { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.app {
  max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) 0 0;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 0; font-size: 14px; color: var(--muted); min-height: 44px; }
.brand { font: 700 18px var(--display); color: var(--ink); letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 7px; }
.iconbtn { background: none; border: 0; padding: 10px; margin: -10px; color: var(--ink); min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r); }
.textbtn { background: none; border: 0; padding: 10px 0; color: var(--marigold-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--r); background: var(--mist); font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner b { font-weight: 600; }

/* ── The number ────────────────────────────────────────────────────────── */
.hero { padding: 22px 20px 4px; }
.hero .label { font-size: 15px; color: var(--muted); margin: 0 0 2px; }
.bignum { all: unset; cursor: pointer; display: block; font: 700 clamp(64px, 22vw, 96px)/0.95 var(--display); font-variation-settings: "opsz" 96; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.bignum sup { font-size: 0.42em; vertical-align: 0.95em; letter-spacing: 0; margin-right: 2px; font-weight: 600; }
.bignum .cents { font-size: 0.42em; letter-spacing: 0; font-weight: 600; color: var(--muted); }
.bignum:focus-visible { outline: 2px solid var(--marigold); outline-offset: 4px; border-radius: var(--r); }
.perday { margin: 10px 0 0; font-size: 16px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.perday b { font-weight: 600; }
.short-title { font: 700 clamp(36px, 11vw, 52px)/1.02 var(--display); letter-spacing: -0.025em; margin: 0; }
.short-why { font-size: 16px; margin: 10px 0 0; }

/* ── The stretch (signature) ───────────────────────────────────────────── */
.stretch { margin: 18px 20px 0; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 14px 14px 10px; }
.stretch h3 { margin: 0 0 8px; font: 600 14px var(--body); color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.stretch svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ── Lists ─────────────────────────────────────────────────────────────── */
.list { margin: 16px 20px 0; }
.list h4 { margin: 0 0 4px; font: 600 14px var(--body); color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 16px; min-height: 48px; }
.row:last-child { border-bottom: 0; }
.row .when { color: var(--muted); font-size: 14px; margin-left: 8px; }
.row .sub { display: block; color: var(--muted); font-size: 14px; }
button.row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--rule); text-align: left; padding-left: 0; padding-right: 0; }
.empty { color: var(--muted); font-size: 15px; padding: 8px 0; }

.nudge { margin: 14px 20px 0; padding: 14px; background: var(--paper); border: 1px solid var(--rule); border-left: 4px solid var(--marigold); border-radius: var(--r); }
.nudge p { margin: 0 0 10px; }
.nudge .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn { font: 600 16px var(--body); border-radius: var(--r); padding: 12px 16px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); min-height: 48px; }
.btn.primary { background: var(--ink); color: var(--on-ink); }
.btn.block { width: 100%; }
.btn.big { font-size: 17px; padding: 16px; min-height: 56px; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn.quiet { border-color: var(--rule); }

.actions { position: sticky; bottom: 0; margin-top: auto; padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--fog); border-top: 1px solid var(--rule); display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 8px; z-index: 5; }
.actions button { font: 600 16px var(--body); border-radius: 999px; padding: 14px 6px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); min-height: 52px; white-space: nowrap; }
.actions button.primary { background: var(--ink); color: var(--on-ink); }
@media (max-width: 340px) { .actions button { font-size: 14px; padding: 12px 4px; } }
.spacer { height: 20px; }

/* ── Setup / full-page steps ───────────────────────────────────────────── */
.q { padding: 28px 22px calc(22px + env(safe-area-inset-bottom, 0px)); flex: 1; display: flex; flex-direction: column; }
.step { font-size: 14px; color: var(--muted); }
.q h2, .page h2 { font: 700 clamp(28px, 8.5vw, 36px)/1.08 var(--display); letter-spacing: -0.02em; margin: 12px 0 20px; }
.choices { display: grid; gap: 10px; }
.choice { background: var(--paper); border: 1.5px solid var(--rule); border-radius: var(--r); padding: 16px; font-size: 17px; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; width: 100%; min-height: 56px; }
.choice[aria-pressed="true"], .choice.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice small { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 14px 0 0; }
.next { margin-top: auto; padding-top: 20px; }
.privacy { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--rule); background: var(--paper); border-radius: var(--r); padding: 10px 12px; min-height: 48px; font-size: 15px; text-align: center; line-height: 1.2; }
.chip small { display: block; color: var(--muted); font-size: 12px; }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.datechips { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }

.moneyfield { display: flex; align-items: baseline; gap: 2px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.moneyfield span { font: 700 clamp(36px, 11vw, 56px)/1 var(--display); color: var(--muted); }
.moneyfield input { border: 0; background: transparent; outline: none; width: 100%; font: 700 clamp(44px, 15vw, 64px)/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; padding: 0; min-width: 0; }
.moneyfield input::placeholder { color: var(--rule); }
.moneyfield.small span { font-size: 28px; }
.moneyfield.small input { font-size: 40px; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; background: var(--paper); border: 1.5px solid var(--rule); border-radius: var(--r); padding: 12px; min-height: 48px; font-size: 16px; }
.field input:focus, .field select:focus { border-color: var(--ink); outline: none; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.filedrop { display: block; border: 1.5px dashed var(--muted); border-radius: var(--r); padding: 14px; font-size: 15px; color: var(--muted); background: var(--mist); text-align: left; width: 100%; }
.filedrop b { color: var(--ink); }
.filedrop.over { border-color: var(--ink); }

/* ── Pages (bills, settings, history) ──────────────────────────────────── */
.page { padding: 8px 20px calc(28px + env(safe-area-inset-bottom, 0px)); flex: 1; }
.page .lead { color: var(--muted); margin: -8px 0 18px; }
.section { margin: 22px 0 0; }
.section h3 { font: 600 14px var(--body); color: var(--muted); margin: 0 0 6px; }
.card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 4px 14px; }
.menu .row { font-size: 17px; }

/* ── Sheets ────────────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 480px; margin: 0 auto;
  background: var(--paper); border-radius: var(--r) var(--r) 0 0; border-top: 1px solid var(--rule);
  padding: 14px 20px calc(22px + env(safe-area-inset-bottom, 0px)); max-height: 92vh; max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 720px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: var(--r); border: 1px solid var(--rule); }
}
.grab { width: 36px; height: 4px; background: var(--rule); border-radius: 2px; margin: 0 auto 12px; }
.sheet h3 { font: 700 23px/1.15 var(--display); margin: 0 0 12px; letter-spacing: -0.01em; }
.sheet .close { position: absolute; top: 8px; right: 10px; }
.sum { width: 100%; border-collapse: collapse; font-size: 16px; }
.sum td { padding: 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.sum td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.sum tr.total td { border-bottom: 0; border-top: 2px solid var(--ink); font-weight: 700; font-size: 18px; }
.sum .minus { color: var(--muted); }
.sum .item td { font-size: 14px; color: var(--muted); padding: 4px 0 4px 14px; border-bottom: 0; }
.sum button { all: unset; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.note { font-size: 14px; color: var(--muted); margin-top: 10px; }

.found { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; width: 100%; text-align: left; min-height: 60px; }
.found .what { flex: 1; min-width: 0; }
.found .what b { display: block; font-weight: 600; }
.found .what span { font-size: 14px; color: var(--muted); }
.toggle { width: 46px; height: 28px; border-radius: 14px; background: var(--rule); position: relative; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
[aria-checked="true"] > .toggle { background: var(--ink); }
[aria-checked="true"] > .toggle::after { left: 22px; }
:root[data-theme="dark"] [aria-checked="true"] > .toggle::after { background: var(--fog); }

.gap { font: 700 46px/1 var(--display); letter-spacing: -0.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.cause { background: var(--mist); border-radius: var(--r); padding: 12px 14px; margin-top: 12px; }
.cause b { display: block; margin-bottom: 2px; }
.inline-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.check { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--marigold); color: #0F2340; align-items: center; justify-content: center; font-weight: 700; margin-right: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--ink); color: var(--on-ink); border-radius: var(--r); padding: 10px 10px 10px 16px; display: flex; gap: 14px; align-items: center; font-size: 15px; max-width: calc(100vw - 32px); }
.toast { width: max-content; }
.toast.low { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.toast button { background: none; border: 0; color: var(--marigold); font-weight: 700; padding: 8px 10px; min-height: 40px; }

.table-wrap { overflow-x: auto; }
.map-table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.map-table td, .map-table th { border: 1px solid var(--rule); padding: 6px 8px; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; text-align: left; }

@media (min-width: 720px) {
  .app { max-width: 520px; }
  .hero { padding-top: 36px; }
}

@media (prefers-reduced-motion: no-preference) {
  .bignum { animation: settle .5s ease-out both; }
  @keyframes settle { from { transform: translateY(6px); } }   /* never from opacity 0: if the animation doesn't run, the number must still show */
  .sheet { animation: rise .2s ease-out both; }
  @media (min-width: 720px) { .sheet { animation: none; } }
  @keyframes rise { from { transform: translateY(24px); } }
}
