@font-face { font-family: 'Bricolage'; src: url('/static/fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 400 800; font-stretch: 75% 100%; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('/static/fonts/figtree.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

/* ───────── tokens: light (default) ───────── */
:root {
  color-scheme: light;
  --bg: #eef1f6;
  --surface: #ffffff;          /* content layer: solid (HIG: no glass on content) */
  --surface-2: #f4f6fa;
  --ink: #141b33;
  --muted: #5b6480;
  --line: #e0e4ee;
  --accent: #4b3fd1;
  --accent-ink: #ffffff;
  --spent: #b42318;
  --got: #117a4b;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b00;
  --stamp: #4b3fd1;
  --orb-1: #b9b3ff; --orb-2: #ffd79a; --orb-3: #9fe3c8;
  --glass-tint: rgb(255 255 255 / .62);
  --glass-rim: rgb(255 255 255 / .9);
  --glass-edge: rgb(20 27 51 / .08);
  --glass-shadow: 0 10px 34px -10px rgb(20 27 51 / .22);
  --glass-blur: blur(22px) saturate(180%);
  --card-shadow: 0 1px 0 rgb(20 27 51 / .04), 0 8px 24px -14px rgb(20 27 51 / .22);
  --tabbar-h: 68px;
  --side-w: 248px;
}
/* ───────── dark: explicit choice, or system when no choice ───────── */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f1c; --surface: #151b2e; --surface-2: #1b2238; --ink: #edf0f8; --muted: #a0a9c2; --line: #28304a;
  --accent: #8d85ff; --accent-ink: #0b0f1c; --spent: #ff8a7a; --got: #62d6a0;
  --warn-bg: #3a2a12; --warn-ink: #ffd08c; --stamp: #8d85ff;
  --orb-1: #3a2f9e; --orb-2: #6b4412; --orb-3: #0f5a44;
  --glass-tint: rgb(24 30 48 / .6); --glass-rim: rgb(255 255 255 / .12); --glass-edge: rgb(255 255 255 / .08);
  --glass-shadow: 0 12px 36px -10px rgb(0 0 0 / .6);
  --card-shadow: 0 1px 0 rgb(0 0 0 / .3), 0 10px 28px -16px rgb(0 0 0 / .7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f1c; --surface: #151b2e; --surface-2: #1b2238; --ink: #edf0f8; --muted: #a0a9c2; --line: #28304a;
    --accent: #8d85ff; --accent-ink: #0b0f1c; --spent: #ff8a7a; --got: #62d6a0;
    --warn-bg: #3a2a12; --warn-ink: #ffd08c; --stamp: #8d85ff;
    --orb-1: #3a2f9e; --orb-2: #6b4412; --orb-3: #0f5a44;
    --glass-tint: rgb(24 30 48 / .6); --glass-rim: rgb(255 255 255 / .12); --glass-edge: rgb(255 255 255 / .08);
    --glass-shadow: 0 12px 36px -10px rgb(0 0 0 / .6);
    --card-shadow: 0 1px 0 rgb(0 0 0 / .3), 0 10px 28px -16px rgb(0 0 0 / .7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); min-height: 100dvh;
  font: 16px/1.5 'Figtree', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
/* soft colour glows behind everything, so the glass has something to refract (one fixed layer; cheap) */
body::before {
  content: ''; position: fixed; inset: -20vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 12% 8%, color-mix(in srgb, var(--orb-1) 55%, transparent), transparent 70%),
    radial-gradient(34vmax 34vmax at 92% 18%, color-mix(in srgb, var(--orb-2) 45%, transparent), transparent 70%),
    radial-gradient(40vmax 40vmax at 70% 96%, color-mix(in srgb, var(--orb-3) 40%, transparent), transparent 70%);
  filter: blur(8px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ───────── glass: ONLY the navigation/controls layer ───────── */
.glass {
  background: var(--glass-tint);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-rim), var(--glass-shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--surface); }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); border-color: var(--muted); }
}
:root[data-surfaces="solid"] .glass { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
:root[data-surfaces="solid"] body::before { display: none; }

/* ───────── frame ───────── */
.app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.top.glass { border-radius: 0 0 20px 20px; border-top: 0; }
.brand { font-family: 'Bricolage', sans-serif; font-weight: 750; font-size: 20px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.logo { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); border-radius: 999px; padding: 6px 11px; text-decoration: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--got); box-shadow: 0 0 0 3px color-mix(in srgb, var(--got) 22%, transparent); }
.dot.bad { background: var(--spent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--spent) 22%, transparent); }
h1 { font-family: 'Bricolage', sans-serif; font-weight: 720; font-size: 30px; line-height: 1.12; letter-spacing: -.025em; margin: 14px 0 6px; }
h2 { font-family: 'Bricolage', sans-serif; font-weight: 650; font-size: 19px; margin: 26px 0 10px; }
p { margin: 0 0 10px; }
.lede { color: var(--muted); margin-bottom: 18px; }
.muted { color: var(--muted); font-size: 14px; }

/* ───────── navigation: floating glass tab bar (phone) → glass sidebar (laptop) ───────── */
.tabbar { position: fixed; z-index: 10; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); border-radius: 26px; }
.tabbar nav { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabbar-h); padding: 6px; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted);
  font-size: 12px; font-weight: 650; position: relative; border-radius: 20px; min-height: 44px; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--spent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.side-only { display: none; }

/* ───────── content layer (solid) ───────── */
.panel { background: var(--surface); border-radius: 18px; box-shadow: var(--card-shadow); padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.panel.warn { background: var(--warn-bg); color: var(--warn-ink); box-shadow: none; border-color: transparent; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.empty { text-align: center; padding: 36px 16px; }
.empty .big { font-family: 'Bricolage', sans-serif; font-size: 44px; color: var(--got); }

/* the slip */
.progress { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 10px; }
.slip { position: relative; background: var(--surface); border-radius: 22px; box-shadow: var(--card-shadow); border: 1px solid var(--line);
  padding: 22px 18px 18px; overflow: clip; /* clip, not hidden: hidden would break the sticky Save bar */ }
.slip::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px;
  background: radial-gradient(circle at 8px -2px, var(--bg) 6px, transparent 6.5px) 0 0 / 16px 8px repeat-x; }
.verb { font-size: 15px; color: var(--muted); }
.amount { font-family: 'Bricolage', sans-serif; font-weight: 780; font-size: 50px; line-height: 1.05; letter-spacing: -.035em; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.amount.spent { color: var(--spent); } .amount.got { color: var(--got); }
.payee { font-size: 20px; font-weight: 680; overflow-wrap: anywhere; }
.payee.unknown { color: var(--muted); font-weight: 500; font-style: italic; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fact { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 3px 9px; }
.hintline { margin-top: 14px; font-size: 14px; color: var(--muted); }
.field-label { display: block; font-weight: 650; font-size: 15px; margin: 18px 0 8px; }
.cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cat { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 12px; text-align: left; background: var(--surface-2);
  border: 2px solid transparent; border-radius: 14px; font-size: 15px; font-weight: 560; transition: border-color .12s, background .12s; }
.cat .sw { flex: none; width: 14px; height: 22px; border-radius: 4px; background: var(--note, #9aa3bd); }
.cat.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.cat.more { justify-content: center; color: var(--accent); font-weight: 650; }
.kinds { display: flex; gap: 6px; flex-wrap: wrap; }
.kind { min-height: 42px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; }
.kind.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.note-row { display: flex; gap: 8px; }
.note-row input, input[type=password], input[type=text].plain, input[type=search] { flex: 1; min-width: 0; width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); font-size: 16px; }
.mic { flex: none; width: 50px; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; }
.mic.live { background: var(--spent); color: #fff; border-color: var(--spent); }
.tip { font-size: 13px; color: var(--muted); margin-top: 6px; }
.remember { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; color: var(--muted); }
.remember input { width: 20px; height: 20px; accent-color: var(--accent); }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { min-height: 52px; padding: 0 20px; border-radius: 16px; border: 0; font-weight: 700; font-size: 16px; display: inline-grid; place-items: center; text-decoration: none; }
.btn.primary { flex: 1; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent); }
.btn.primary:disabled { opacity: .45; box-shadow: none; }
.btn.quiet { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.actions.sticky { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 5; margin: 18px -8px -8px; padding: 8px; border-radius: 20px; }
.stamp { position: absolute; right: 18px; top: 24px; width: 96px; height: 96px; border-radius: 50%; border: 4px double var(--stamp); color: var(--stamp);
  display: grid; place-items: center; font-family: 'Bricolage', sans-serif; font-weight: 800; font-size: 20px; transform: rotate(-14deg); opacity: 0; pointer-events: none; }
.slip.done .stamp { animation: stamp .42s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes stamp { from { opacity: 0; transform: rotate(-14deg) scale(1.9); } to { opacity: .9; transform: rotate(-14deg) scale(1); } }

/* queue (laptop left pane) */
.queue { display: none; }
.q-item { display: flex; width: 100%; justify-content: space-between; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 12px;
  background: none; border: 1px solid transparent; }
.q-item.on { background: var(--surface); border-color: var(--line); box-shadow: var(--card-shadow); }
.q-item .q-who { font-weight: 620; overflow-wrap: anywhere; }
.kbd { font: 12px ui-monospace, monospace; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); }

/* spending */
.month { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.month button { width: 44px; height: 44px; border-radius: 14px; font-size: 18px; }
.month strong { font-family: 'Bricolage', sans-serif; font-size: 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat .v { font-family: 'Bricolage', sans-serif; font-weight: 760; font-size: 26px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.hero { grid-column: 1 / -1; }
.stat.hero .v { font-size: 42px; }
.total { font-family: 'Bricolage', sans-serif; font-weight: 780; font-size: 40px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; margin: 8px 0 4px; }
.bar i { display: block; height: 100%; border-radius: 5px; background: var(--note, var(--accent)); }
.cat-line { display: flex; align-items: center; gap: 10px; }
.cat-line .sw { width: 12px; height: 20px; border-radius: 3px; background: var(--note, #9aa3bd); flex: none; }
.cat-line .name { flex: 1; font-weight: 620; }
.cat-line .amt, .num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.num.got { color: var(--got); }
.cat-open { display: block; color: inherit; text-decoration: none; }
.cat-card.on { outline: 2px solid var(--accent); }
.see { font-size: 14px; font-weight: 650; color: var(--accent); }
.whatif input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }
.saving { font-size: 14px; color: var(--got); font-weight: 600; }
.backlink { display: inline-block; padding: 8px 0; color: var(--accent); font-weight: 650; text-decoration: none; }
.cat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cat-head h1 { margin: 0; }
.sw.big { width: 18px; height: 34px; border-radius: 4px; background: var(--note); flex: none; }
.txn-row { display: flex; width: 100%; gap: 12px; justify-content: space-between; align-items: flex-start; text-align: left; background: none; border: 0; padding: 2px 0; }
.txn-main { min-width: 0; }
.txn-payee { font-weight: 650; overflow-wrap: anywhere; }
.txn-note { font-size: 15px; margin: 2px 0; overflow-wrap: anywhere; }
.txn-note.none { color: var(--accent); font-size: 14px; }

/* intro */
.steps { list-style: none; counter-reset: s; padding: 0; margin: 18px 0; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 40px 1fr; gap: 12px; margin-bottom: 18px; }
.steps li::before { content: counter(s); width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: 'Bricolage', sans-serif; font-weight: 800; font-size: 18px; }
.steps strong { display: block; font-size: 17px; }

/* appearance control */
.seg { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 10px; background: none; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--card-shadow); }
.switch { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: var(--surface-2); padding: 10px; border-radius: 10px; max-height: 50vh; overflow: auto; }
.stack > * + * { margin-top: 10px; }
details summary { cursor: pointer; }

/* ═════════ tablet: icon rail ═════════ */
@media (min-width: 768px) {
  .app { max-width: none; margin: 0 0 0 96px; padding: 0 32px 48px; }
  .top { margin: 0 -32px; padding: 14px 32px; }
  .top .brand { visibility: hidden; }
  .tabbar { top: 12px; bottom: 12px; left: 12px; right: auto; width: 72px; border-radius: 24px; }
  .tabbar nav { height: 100%; grid-template-columns: 1fr; grid-auto-rows: 64px; align-content: start; padding: 10px 6px; gap: 6px; }
  .tab { font-size: 11px; }
  .actions.sticky { bottom: 16px; }
}
/* ═════════ laptop: glass sidebar + two panes ═════════ */
@media (min-width: 1100px) {
  .app { margin-left: calc(var(--side-w) + 24px); padding: 0 40px 56px; }
  .top { display: none; }
  .tabbar { width: var(--side-w); padding: 0; }
  .tabbar nav { grid-auto-rows: auto; padding: 18px 14px; gap: 4px; display: flex; flex-direction: column; }
  .side-only { display: block; }
  .tabbar .brand { padding: 4px 10px 18px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; font-size: 15px; min-height: 46px; }
  .badge { position: static; margin-left: auto; }
  .side-foot { margin-top: auto; padding: 12px 8px 4px; display: grid; gap: 12px; }
  .side-foot .health { justify-self: start; }
  h1 { font-size: 34px; margin-top: 28px; }
  .two-pane { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 28px; align-items: start; }
  .two-pane > .pane-left { position: sticky; top: 24px; max-height: calc(100dvh - 48px); overflow: auto; padding: 4px; }
  .queue { display: block; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat.hero { grid-column: auto; }
  .stat.hero .v { font-size: 30px; }
  .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spend-grid { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr); gap: 28px; align-items: start; }
  .spend-grid > .pane-right { position: sticky; top: 24px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .slip.done .stamp { opacity: .9; } }
.month button { background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--card-shadow); }
@media (min-width: 1100px) { .tabbar .brand.side-only { display: flex; } .tabbar .side-foot.side-only { display: grid; } }
