/* MyFinance · "Ledger" design system
   Warm paper, ink, one ochre accent. Big editorial numerals, hairline structure, motion only where it explains. */

:root {
  --paper: #F4F0E8;
  --surface: #FFFDF8;
  --sunk: #ECE6DA;
  --ink: #17150F;
  --ink-2: #5A544A;
  --ink-3: #908879;
  --hair: rgba(23, 21, 15, 0.09);
  --hair-2: rgba(23, 21, 15, 0.16);
  --accent: #B97A1C;
  --accent-soft: rgba(185, 122, 28, 0.14);
  --good: #2D7A57;
  --good-soft: rgba(45, 122, 87, 0.13);
  --bad: #B8432F;
  --bad-soft: rgba(184, 67, 47, 0.12);
  --shadow: 0 1px 0 rgba(23, 21, 15, 0.04), 0 12px 32px -18px rgba(23, 21, 15, 0.28);
  --shadow-lift: 0 2px 0 rgba(23, 21, 15, 0.04), 0 28px 60px -24px rgba(23, 21, 15, 0.42);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", -apple-system, "SF Pro Text", system-ui, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --safe-top: max(var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-content-safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --gutter: 20px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #121110;
  --surface: #1B1A17;
  --sunk: #23211D;
  --ink: #F2EEE5;
  --ink-2: #B9B2A5;
  --ink-3: #7F786C;
  --hair: rgba(242, 238, 229, 0.08);
  --hair-2: rgba(242, 238, 229, 0.15);
  --accent: #E0A548;
  --accent-soft: rgba(224, 165, 72, 0.16);
  --good: #5FB88D;
  --good-soft: rgba(95, 184, 141, 0.14);
  --bad: #E2735F;
  --bad-soft: rgba(226, 115, 95, 0.14);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 36px -20px rgba(0, 0, 0, 0.7);
  --shadow-lift: 0 2px 0 rgba(0, 0, 0, 0.3), 0 30px 64px -24px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  font-feature-settings: "ss01", "cv11";
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.press { transition: transform 160ms var(--ease-out), background-color 200ms ease; }
.press:active { transform: scale(0.97); }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) var(--gutter) calc(var(--safe-bottom) + 112px);
  min-height: 100dvh;
}

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; margin-bottom: 6px; }
.month { display: flex; align-items: center; gap: 2px; touch-action: pan-y; }
.month h1 { font: 400 26px/1 var(--serif); margin: 0 6px; min-width: 7.2ch; text-align: center; letter-spacing: -0.01em; }
.month h1 em { font-style: italic; color: var(--ink-3); font-size: 18px; margin-left: 4px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; color: var(--ink-2); }
.icon-btn:active { background: var(--sunk); }
.icon-btn svg { width: 20px; height: 20px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.pill-btn svg { width: 16px; height: 16px; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.sync-btn svg { transition: transform 300ms var(--ease-out); }
.sync-btn.syncing { color: var(--accent); }
.sync-btn.syncing svg { animation: spin 1100ms linear infinite; }

/* ---------- sync island ---------- */
.sync-island {
  position: fixed; top: calc(var(--safe-top) + 62px); left: 50%; z-index: 95; width: min(360px, calc(100vw - 24px));
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lift), inset 0 0 0 1px var(--hair);
  transform: translate(-50%, calc(-100% - 24px)); opacity: 0; touch-action: none;
  transition: transform 340ms var(--ease-drawer), opacity 200ms var(--ease-out);
}
.sync-island.on { transform: translate(-50%, 0); opacity: 1; }
.si-icon { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.si-icon svg { width: 20px; height: 20px; }
.si-icon .ring { animation: spin 900ms linear infinite; }
.si-icon .tick path { stroke-dasharray: 20; stroke-dashoffset: 20; animation: draw 360ms var(--ease-out) 60ms forwards; }
.sync-island[data-state="done"] .si-icon { background: var(--good-soft); color: var(--good); }
.sync-island[data-state="failed"] .si-icon { background: var(--bad-soft); color: var(--bad); }
.si-title { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.si-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.35; }
.si-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.si-steps li { font-size: 11px; color: var(--ink-3); }
.si-steps li i { display: block; height: 3px; border-radius: 3px; background: var(--hair-2); margin-bottom: 5px; overflow: hidden; position: relative; }
.si-steps li i::after { content: ""; position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: var(--accent); transition: transform 420ms var(--ease-out); }
.si-steps li.done i::after { transform: scaleX(1); }
.si-steps li.now i::after { transform: scaleX(0.4); animation: inch 1.2s var(--ease-in-out) infinite alternate; }
.si-steps li.fail i::after { transform: scaleX(1); background: var(--bad); }
.si-steps li.done span, .si-steps li.now span { color: var(--ink-2); }
.sync-island[data-state="done"] .si-steps li i::after { background: var(--good); }
@keyframes inch { from { transform: scaleX(0.15); } to { transform: scaleX(0.75); } }
.si-retry { font-size: 13px; font-weight: 600; color: var(--accent); padding: 8px 10px; border-radius: 12px; background: var(--accent-soft); }

/* ---------- hero ---------- */
.hero { padding: 18px 0 10px; }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.hero .big { font: 400 64px/0.95 var(--serif); letter-spacing: -0.03em; margin: 10px 0 6px; display: flex; align-items: baseline; gap: 10px; }
.hero .big small { font: 500 14px/1 var(--sans); letter-spacing: 0.04em; color: var(--ink-3); }
.hero .sub { font-size: 15px; color: var(--ink-2); }
.hero .sub b { color: var(--ink); font-weight: 600; }
.hero .cta { margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-weight: 500; font-size: 15px;
}
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair-2); }
.btn.small { height: 36px; padding: 0 14px; border-radius: 12px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }

/* ---------- month track (scrubbable) ---------- */
.track-wrap { position: relative; padding: 18px 0 8px; touch-action: none; user-select: none; }
.track { position: relative; height: 12px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.track .fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--ink); transform-origin: left; transition: width 600ms var(--ease-out); }
.track .fill.over { background: var(--bad); }
.track .fill.warn { background: var(--accent); }
.track .future { position: absolute; inset: 0 0 0 auto; background: repeating-linear-gradient(135deg, transparent 0 5px, var(--hair) 5px 6px); }
.track-pace { position: absolute; top: 12px; width: 2px; height: 24px; margin-left: -1px; background: var(--ink); border-radius: 2px; transition: left 600ms var(--ease-out); }
.track-pace::after { content: "today"; position: absolute; top: 26px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.track-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-top: 22px; }
.scrub-tip {
  position: absolute; top: -34px; transform: translateX(-50%); padding: 7px 10px; border-radius: 10px; background: var(--ink); color: var(--paper);
  font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 150ms ease; box-shadow: var(--shadow);
}
.scrub-tip.on { opacity: 1; }
.scrub-line { position: absolute; top: 12px; width: 1px; height: 24px; background: var(--accent); opacity: 0; pointer-events: none; }
.scrub-line.on { opacity: 1; }

/* ---------- sections ---------- */
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font: 400 24px/1.1 var(--serif); margin: 0; letter-spacing: -0.01em; }
.section-head .link { font-size: 13px; color: var(--ink-2); padding: 6px 0 6px 10px; }

/* ---------- sort stack peek ---------- */
.peek { position: relative; height: 112px; margin-top: 26px; touch-action: pan-y; }
.peek .layer {
  position: absolute; inset: 0; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 1px var(--hair);
  transition: transform 300ms var(--ease-out);
}
.peek .layer:nth-child(1) { transform: translateY(16px) scale(0.9); opacity: 0.5; }
.peek .layer:nth-child(2) { transform: translateY(8px) scale(0.95); opacity: 0.8; }
.peek .front { padding: 18px 18px 16px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; }
.peek .front:active { transform: scale(0.985); }
.peek .count { display: flex; align-items: baseline; gap: 8px; }
.peek .count b { font: 400 40px/1 var(--serif); }
.peek .count span { color: var(--ink-2); }
.peek .hint { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
.peek .hint .swipe { display: inline-block; width: 30px; height: 6px; border-radius: 3px; background: var(--sunk); position: relative; overflow: hidden; }
.peek .hint .swipe::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: 3px; background: var(--accent); animation: nudge 1.8s var(--ease-in-out) infinite; }
@keyframes nudge { 0%, 15% { transform: translateX(-100%); } 60%, 100% { transform: translateX(250%); } }
.peek .badge { position: absolute; right: 16px; top: 16px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.peek .badge svg { width: 20px; height: 20px; }

/* ---------- wallets ---------- */
.wallets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.wallet { padding: 14px 14px 12px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); min-width: 0; }
.wallet .name { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.wallet .name i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.wallet .bal { font: 400 28px/1.1 var(--serif); margin: 6px 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wallet .state { font-size: 12px; display: flex; align-items: center; gap: 5px; color: var(--ink-3); }
.wallet .state.ok { color: var(--good); }
.wallet .state.off { color: var(--accent); }
.wallet .state svg { width: 13px; height: 13px; }
.wallet.manual .state { color: var(--ink-3); }

/* ---------- category ledger ---------- */
.cats { display: flex; flex-direction: column; }
.cat { display: grid; grid-template-columns: 36px 1fr 88px; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--hair); text-align: left; width: 100%; }
.cat:last-child { border-bottom: 0; }
.glyph { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--c-soft, var(--sunk)); color: var(--c, var(--ink-2)); flex: none; }
.glyph svg { width: 19px; height: 19px; }
.glyph b { font-size: 13px; font-weight: 600; }
.cat .mid { min-width: 0; }
.cat .label { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat .bar { position: relative; height: 4px; border-radius: 2px; background: var(--sunk); margin-top: 7px; overflow: hidden; }
.cat .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; background: var(--c, var(--ink)); }
.cat .bar u { position: absolute; top: -2px; width: 2px; height: 8px; background: var(--ink); border-radius: 1px; text-decoration: none; }
.cat .right { text-align: right; }
.cat .amt { font-weight: 500; }
.cat .of { font-size: 12px; color: var(--ink-3); }
.cat .of.over { color: var(--bad); }
.cat .of.warn { color: var(--accent); }

/* ---------- heat calendar (scrubbable) ---------- */
.heat { position: relative; touch-action: none; user-select: none; }
.heat .dow, .heat .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.heat .dow span { font-size: 11px; color: var(--ink-3); text-align: center; padding-bottom: 6px; }
.heat .cell {
  aspect-ratio: 1; border-radius: 10px; background: var(--sunk); position: relative; display: grid; place-items: center;
  font-size: 11px; color: var(--ink-3); transition: transform 160ms var(--ease-out), box-shadow 160ms ease;
}
.heat .cell.has { color: var(--ink); background: color-mix(in oklab, var(--accent) calc(var(--v, 0) * 88%), var(--sunk)); }
.heat .cell.hot { color: var(--paper); }
.heat .cell.today { box-shadow: inset 0 0 0 1.5px var(--ink); }
.heat .cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--hair); }
.heat .cell.blank { background: transparent; }
.heat .cell.on { transform: scale(1.16); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.4); z-index: 2; }
.heat .tip { position: absolute; padding: 8px 11px; border-radius: 11px; background: var(--ink); color: var(--paper); font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transform: translate(-50%, -8px); transition: opacity 120ms ease; z-index: 3; box-shadow: var(--shadow); }
.heat .tip.on { opacity: 1; }
.heat .tip b { font-weight: 600; }

/* ---------- entries ---------- */
.day-group { margin-top: 6px; }
.more-days { width: 100%; margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 6px; position: sticky; top: 0; background: var(--paper); z-index: 1; }
.day-head .d { font: 400 19px/1 var(--serif); }
.day-head .d em { font-style: italic; color: var(--ink-3); font-size: 15px; margin-left: 6px; }
.day-head .t { font-size: 13px; color: var(--ink-2); }
.entry { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 9px 0; }
.entry .who { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .meta { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.entry .meta .auto { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.entry .amt { font-weight: 500; text-align: right; white-space: nowrap; }
.entry .amt.in { color: var(--good); }
.entry .amt.xfer { color: var(--ink-3); }

/* ---------- floating ask ---------- */
.ask-dock { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 16px); display: flex; justify-content: center; pointer-events: none; z-index: 20; transition: transform 320ms var(--ease-out), opacity 220ms ease; }
.ask-dock.away { transform: translateY(140%); opacity: 0; }
.ask-pill {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 20px 0 16px; border-radius: 999px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lift); font-weight: 500;
  transition: transform 200ms var(--ease-out);
}
.ask-pill:active { transform: scale(0.96); }
.ask-pill .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #17150F; }
.ask-pill .dot svg { width: 15px; height: 15px; }

/* ---------- layer: overlays, sheets ---------- */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.scrim { position: fixed; inset: 0; background: rgba(10, 9, 7, 0.38); opacity: 0; transition: opacity 260ms ease; pointer-events: auto; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--paper); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lift); pointer-events: auto;
  transform: translateY(100%); transition: transform 420ms var(--ease-drawer); padding-bottom: var(--safe-bottom);
}
.sheet.on { transform: translateY(0); }
.sheet .grip { padding: 10px 0 4px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet .grip i { width: 40px; height: 5px; border-radius: 3px; background: var(--hair-2); }
.sheet .sheet-head { padding: 6px var(--gutter) 10px; display: flex; align-items: baseline; justify-content: space-between; }
.sheet .sheet-head h3 { margin: 0; font: 400 26px/1.1 var(--serif); }
.sheet .body { overflow-y: auto; padding: 0 var(--gutter) 20px; overscroll-behavior: contain; }

/* ---------- sort mode ---------- */
.sort {
  position: fixed; inset: 0; background: var(--paper); pointer-events: auto; display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 10px) var(--gutter) calc(var(--safe-bottom) + 16px);
  opacity: 0; transform: scale(0.985); transition: opacity 220ms ease, transform 280ms var(--ease-out);
}
.sort.on { opacity: 1; transform: none; }
.sort .bar { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.sort .progress { display: flex; gap: 4px; }
.sort .progress i { width: 18px; height: 4px; border-radius: 2px; background: var(--sunk); transition: background-color 200ms ease; }
.sort .progress i.done { background: var(--ink); }
.stage { position: relative; flex: 1; display: grid; place-items: center; min-height: 0; }
.card {
  position: absolute; width: min(100%, 360px); min-height: 340px; max-height: 58dvh; border-radius: 28px; background: var(--surface);
  box-shadow: var(--shadow-lift), inset 0 0 0 1px var(--hair); padding: 22px; display: flex; flex-direction: column; touch-action: none; user-select: none;
  will-change: transform; transition: transform 380ms var(--ease-out), opacity 300ms ease;
}
.card.dragging { transition: none; cursor: grabbing; }
.card.behind { pointer-events: none; }
.card .c-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-3); }
.card .c-amt { font: 400 76px/0.95 var(--serif); letter-spacing: -0.035em; margin: 34px 0 6px; }
.card .c-amt small { font: 500 15px var(--sans); color: var(--ink-3); letter-spacing: 0.04em; margin-left: 6px; }
.card .c-who { font-size: 20px; font-weight: 500; margin-bottom: 4px; }
.card .c-note { color: var(--ink-2); font-size: 14px; }
.card .c-why { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.card .c-guess { margin-top: 18px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--sunk); }
.card .c-guess .q { font-size: 12px; color: var(--ink-3); }
.card .c-guess .g { font-weight: 500; }
.card .stamp {
  position: absolute; top: 24px; padding: 6px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; letter-spacing: 0.02em;
  opacity: 0; transform: scale(0.92); transition: none;
}
.card .stamp.yes { right: 22px; color: var(--good); box-shadow: inset 0 0 0 2px var(--good); background: var(--good-soft); }
.card .stamp.no { left: 22px; color: var(--ink-2); box-shadow: inset 0 0 0 2px var(--hair-2); background: var(--surface); }
.dock { position: relative; height: 150px; margin-top: 8px; }
.chip {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; text-align: center;
  font-size: 11.5px; color: var(--ink-2); line-height: 1.15; transition: transform 220ms var(--ease-out);
}
.chip .glyph { width: 52px; height: 52px; border-radius: 18px; box-shadow: inset 0 0 0 1px var(--hair); transition: transform 220ms var(--ease-out), box-shadow 200ms ease; }
.chip .glyph svg { width: 23px; height: 23px; }
.chip.hot .glyph { transform: scale(1.22); box-shadow: 0 0 0 3px var(--c, var(--ink)), 0 10px 24px -8px var(--c, var(--ink)); }
.chip.hot { color: var(--ink); }
.chip.more .glyph { background: var(--surface); color: var(--ink-2); }
.sort .actions { display: flex; justify-content: space-between; gap: 10px; }
.sort .actions .btn { flex: 1; }
.done-state { text-align: center; display: grid; justify-items: center; gap: 12px; }
.done-state .mark { width: 76px; height: 76px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; }
.done-state .mark svg { width: 36px; height: 36px; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 520ms var(--ease-out) 120ms forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-state h3 { font: 400 32px/1 var(--serif); margin: 6px 0 0; }

/* ---------- category grid (picker) ---------- */
.picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; padding-top: 6px; }
.picker button { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 11.5px; line-height: 1.15; color: var(--ink-2); text-align: center; }
.picker .glyph { width: 50px; height: 50px; border-radius: 16px; }
.picker .glyph svg { width: 22px; height: 22px; }

/* ---------- budgets ---------- */
.screen { opacity: 0; transform: translateY(8px); transition: opacity 240ms ease, transform 300ms var(--ease-out); }
.screen.on { opacity: 1; transform: none; }
.budget-total { padding: 8px 0 18px; border-bottom: 1px solid var(--hair); }
.budget-total .big { font: 400 54px/1 var(--serif); letter-spacing: -0.03em; margin: 8px 0 4px; }
.budget-row { position: relative; overflow: hidden; border-bottom: 1px solid var(--hair); }
.budget-row .slide { position: relative; background: var(--paper); padding: 14px 0 16px; touch-action: pan-y; transition: transform 300ms var(--ease-out); }
.budget-row .slide.dragging { transition: none; }
.budget-row .remove { position: absolute; inset: 0 0 0 auto; width: 96px; display: grid; place-items: center; background: var(--bad); color: #fff; font-weight: 500; font-size: 14px; }
.b-head { display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; }
.b-head .label { font-weight: 500; }
.b-head .spent { font-size: 12.5px; color: var(--ink-3); }
.b-amt { font-weight: 600; font-size: 17px; padding: 4px 8px; margin-right: -8px; border-radius: 10px; }
.b-amt:active { background: var(--sunk); }
.tank { position: relative; height: 34px; margin-top: 12px; border-radius: 12px; background: var(--sunk); touch-action: none; }
.tank .spentfill { position: absolute; inset: 0 auto 0 0; border-radius: 12px; background: var(--c-soft); }
.tank .cap { position: absolute; inset: 0 auto 0 0; border-radius: 12px; box-shadow: inset 0 0 0 1.5px var(--c); transition: width 200ms var(--ease-out); }
.tank.dragging .cap { transition: none; }
.tank .handle {
  position: absolute; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 10px; background: var(--surface);
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.3), inset 0 0 0 1px var(--hair-2); display: grid; place-items: center; transition: left 200ms var(--ease-out), transform 160ms var(--ease-out);
}
.tank.dragging .handle { transition: none; transform: scale(1.12); }
.tank .handle i { width: 2px; height: 12px; border-radius: 1px; background: var(--ink-3); box-shadow: 4px 0 0 var(--ink-3), -4px 0 0 var(--ink-3); }
.tank .ghost { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--ink-3); opacity: 0.6; border-radius: 1px; }
.tank .over-mark { position: absolute; inset: 0 0 0 auto; border-radius: 0 12px 12px 0; background: repeating-linear-gradient(135deg, var(--bad-soft) 0 6px, transparent 6px 12px); }
.budget-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.budget-input { width: 110px; text-align: right; font-weight: 600; font-size: 17px; border: 0; border-radius: 10px; padding: 6px 8px; background: var(--sunk); outline: none; }

/* ---------- ask ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button { padding: 9px 13px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); font-size: 13.5px; color: var(--ink-2); text-align: left; }
.thread { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.msg.me { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); border-bottom-left-radius: 6px; }
.msg.ai .typing { display: inline-flex; gap: 4px; }
.msg.ai .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: blink 1.1s ease-in-out infinite; }
.msg.ai .typing i:nth-child(2) { animation-delay: 0.15s; }
.msg.ai .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.composer { display: flex; gap: 8px; padding: 10px var(--gutter) 6px; border-top: 1px solid var(--hair); background: var(--paper); }
.composer input { flex: 1; height: 46px; border: 0; border-radius: 14px; padding: 0 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair); outline: none; font-size: 16px; }
.composer input:focus { box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.composer .send { width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: var(--paper); display: grid; place-items: center; }
.composer .send svg { width: 20px; height: 20px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 84px); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); padding: 12px 14px 12px 16px; border-radius: 16px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lift); font-size: 14px; touch-action: pan-y;
  transition: opacity 260ms ease, transform 320ms var(--ease-out);
}
.toast button { color: var(--accent); font-weight: 600; padding: 2px 4px; }
@starting-style { .toast { opacity: 0; transform: translateY(14px) scale(0.98); } }
.toast.out { opacity: 0; transform: translateY(14px) scale(0.98); transition-duration: 180ms; }

/* ---------- states ---------- */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--sunk) 0%, color-mix(in oklab, var(--sunk), var(--surface) 55%) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { padding: 40px 0; text-align: center; color: var(--ink-3); }
.gate { min-height: 80dvh; display: grid; place-items: center; text-align: center; }
.gate h1 { font: 400 40px/1 var(--serif); margin: 0 0 10px; }
.pull { height: 0; display: grid; place-items: center; overflow: visible; color: var(--ink-3); opacity: 0; pointer-events: none; }
.pull svg { width: 22px; height: 22px; transition: transform 200ms var(--ease-out); }
.pull { position: relative; }
.pull-inner { position: absolute; left: 50%; top: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; transform: translate(-50%, -40px); }
.pull-label { font-size: 12px; font-weight: 500; color: var(--ink-3); white-space: nowrap; min-height: 15px; transition: color 160ms ease; }
.pull.to-sync { color: var(--accent); }
.pull.to-sync .pull-label { color: var(--accent); }
.pull.spin svg { animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stagger > * { animation: rise 420ms var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(n + 6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--sunk); }
  .chips button:hover { color: var(--ink); }
}

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