/* Tally — black and white, sea green primary, coral for money going out. */

:root {
  --bg: #F4F4F3; --card: #FFFFFF; --ink: #111111; --sub: #666666; --line: #EAEAEA;
  --soft: #F1F1F0; --dash: #D6D6D3;
  --green: #12A37A; --green-text: #0B7D5C; --green-tint: #E2F4EC;
  --coral: #E8573E; --coral-text: #C2452D; --coral-tint: #FCEAE5;
  --btn: #111111; --btn-text: #FFFFFF; --idle: #E2E2E0;
  --toast: #111111; --toast-text: #FFFFFF; --toast-soft: #262626; --toast-line: #444444;
  --scrim: rgba(0, 0, 0, 0.35);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0B0C; --card: #17171A; --ink: #F4F4F5; --sub: #A3A3AA; --line: #26262A;
    --soft: #232327; --dash: #34343A;
    --green: #1FB386; --green-text: #3DD3A1; --green-tint: #10291F;
    --coral: #F0674D; --coral-text: #FF9A85; --coral-tint: #2E1712;
    --btn: #F4F4F5; --btn-text: #111111; --idle: #34343A;
    --toast: #232327; --toast-text: #F4F4F5; --toast-soft: #2E2E33; --toast-line: #44444A;
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0B0C; --card: #17171A; --ink: #F4F4F5; --sub: #A3A3AA; --line: #26262A;
  --soft: #232327; --dash: #34343A;
  --green: #1FB386; --green-text: #3DD3A1; --green-tint: #10291F;
  --coral: #F0674D; --coral-text: #FF9A85; --coral-tint: #2E1712;
  --btn: #F4F4F5; --btn-text: #111111; --idle: #34343A;
  --toast: #232327; --toast-text: #F4F4F5; --toast-soft: #2E2E33; --toast-line: #44444A;
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; position: relative; }

.screen {
  padding: calc(20px + var(--safe-top)) 20px calc(104px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.screen.no-tabs { padding-bottom: calc(32px + var(--safe-bottom)); }

/* ---------- text */
.eyebrow { font-size: 13px; color: var(--sub); }
.title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.6px; }
.big { font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.muted { color: var(--sub); }
.small { font-size: 13px; }
.green-text { color: var(--green-text); }
.coral-text { color: var(--coral-text); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- cards */
.card { background: var(--card); border-radius: 24px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.tight { gap: 6px; }
.card.coral { background: var(--coral-tint); }
.card.green { background: var(--green-tint); }
.card.dashed { background: transparent; border: 1.5px dashed var(--dash); align-items: center; text-align: center; gap: 6px; padding: 22px 18px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-title { font-size: 15px; font-weight: 600; }
.link { font-size: 13px; font-weight: 600; color: var(--green-text); background: none; border: none; padding: 4px 0; }
a.card { color: var(--ink); }
.row-link { display: flex; align-items: center; justify-content: space-between; }
.chev { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--ink); font-size: 13px; }

/* ---------- buttons */
.btn { display: block; width: 100%; text-align: center; background: var(--btn); color: var(--btn-text); border: none; font-size: 16px; font-weight: 600; padding: 15px 0; border-radius: 999px; }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.text { background: transparent; color: var(--sub); font-weight: 500; }
.btn.danger { background: transparent; color: var(--coral-text); }
.btn[aria-busy="true"] { opacity: 0.6; }
.pill-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn.green { background: var(--green); color: #fff; }

/* ---------- inputs */
.field { width: 100%; border: none; outline: none; background: var(--soft); border-radius: 16px; padding: 14px 16px; font-size: 16px; }
.field:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.field-label { font-size: 12px; color: var(--sub); }
.box { background: var(--soft); border-radius: 18px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.box input { border: none; outline: none; background: transparent; font-size: 20px; font-weight: 700; padding: 0; width: 100%; }

/* ---------- quick add */
.quick { scroll-margin-top: calc(12px + var(--safe-top)); }
.quick-bar { display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: 999px; padding: 6px 6px 6px 18px; }
.quick-bar input { flex: 1; min-width: 0; border: none; background: transparent; font-size: 17px; outline: none; padding: 8px 0; }
.quick-bar:focus-within { box-shadow: inset 0 0 0 1.5px var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--soft); border: none; display: inline-flex; align-items: center; gap: 4px; }
.chip.green { background: var(--green-tint); color: var(--green-text); }
.chip.quiet { font-weight: 500; color: var(--sub); }
.chip.warn { background: var(--coral-tint); color: var(--coral-text); }
.hint { font-size: 13px; color: var(--sub); line-height: 1.5; }
.mic.listening { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* ---------- category bar */
.stack-bar { display: flex; height: 10px; gap: 3px; border-radius: 999px; overflow: hidden; }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.legend .name { color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend .val { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- lists */
.list { background: var(--card); border-radius: 20px; padding: 0 14px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; width: 100%; background: none; border: none; text-align: left; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.list-icon { width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; }
.list-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.list-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: 13px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-amt { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-label { font-size: 13px; font-weight: 600; color: var(--sub); padding: 6px 4px 0; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 15px; width: 100%; background: none; border-left: none; border-right: none; border-top: none; text-align: left; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--sub); }
.kv .v { font-weight: 600; text-align: right; }

/* ---------- month switcher, bars */
.switcher { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 999px; padding: 4px; }
.switcher .mid { display: flex; flex-direction: column; align-items: center; }
.bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; height: 150px; margin-top: 10px; }
.bars button { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; background: none; border: none; padding: 0; }
.bars .bar { width: 100%; max-width: 36px; border-radius: 10px; background: var(--idle); min-height: 4px; position: relative; overflow: hidden; }
.bars .bar.on { background: var(--coral); }
.bars .bar.partial::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255,255,255,0.28) 5px 8px); }
.bars .lbl { font-size: 12px; color: var(--sub); }
.bars .on + .lbl { color: var(--ink); font-weight: 600; }
.progress { height: 6px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--ink); }

/* ---------- segmented */
.seg { display: flex; background: var(--soft); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: none; background: transparent; border-radius: 999px; padding: 9px 0; font-size: 14px; font-weight: 500; color: var(--sub); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; }

/* ---------- category grid */
.cat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cat { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 16px; font-size: 13px; font-weight: 500; background: var(--soft); border: 1.5px solid transparent; min-width: 0; text-align: left; }
.cat span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat[aria-pressed="true"] { background: var(--green-tint); color: var(--green-text); border-color: var(--green); }
.cat.new { border-style: dashed; border-color: var(--dash); background: transparent; }

/* ---------- options (questions) */
.option { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border-radius: 18px; padding: 14px; background: var(--soft); border: 1.5px solid transparent; }
.option .radio { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--dash); }
.option[aria-pressed="true"] { background: var(--green-tint); border-color: var(--green); }
.option[aria-pressed="true"] .radio { border: 6px solid var(--green); background: var(--card); }

/* ---------- tab bar */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 520px;
  background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + var(--safe-bottom)); z-index: 10;
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--sub); min-width: 64px; padding: 2px 0; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---------- sheets */
.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease-out; }
.sheet {
  width: 100%; max-width: 520px; max-height: calc(100dvh - 40px - var(--safe-top)); overflow-y: auto;
  background: var(--card); border-radius: 32px 32px 0 0; padding: 12px 20px calc(24px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 16px; animation: rise 0.22s cubic-bezier(.2,.8,.2,1);
}
.grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--dash); align-self: center; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0.6; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-bottom));
  width: calc(100% - 24px); max-width: 496px; background: var(--toast); color: var(--toast-text);
  border-radius: 24px; padding: 14px 16px; z-index: 20; display: flex; flex-direction: column; gap: 12px;
  animation: rise 0.22s cubic-bezier(.2,.8,.2,1);
}
.toast-row { display: flex; align-items: center; gap: 10px; }
.toast-row .msg { flex: 1; font-size: 15px; font-weight: 600; }
.toast .tick { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; }
.toast .note { display: flex; gap: 10px; align-items: flex-start; background: var(--toast-soft); border-radius: 16px; padding: 12px; font-size: 14px; line-height: 1.45; }
.toast .actions { display: flex; gap: 8px; }
.toast .actions button { flex: 1; border-radius: 999px; padding: 12px 0; font-size: 14px; font-weight: 600; border: 1px solid var(--toast-line); background: transparent; color: var(--toast-text); }
.toast .actions button.primary { background: var(--toast-text); color: var(--toast); border-color: var(--toast-text); }
.toast .undo { background: none; border: none; color: var(--toast-text); font-weight: 600; font-size: 14px; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- onboarding & celebrations */
.center { align-items: center; text-align: center; }
.hero-title { font-size: 32px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.15; }
.lead { font-size: 16px; line-height: 1.5; color: var(--sub); }
.gullak-wrap { width: 220px; height: 220px; display: flex; align-items: center; justify-content: center; position: relative; }
.gullak { width: 170px; height: 170px; }
.gullak.wobble { animation: wobble 1.2s ease-in-out 2; transform-origin: 50% 90%; }
.gullak.shake { animation: shake 0.5s ease-in-out 3; }
.coin { position: absolute; top: 0; left: 50%; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; background: #F2C14E; border: 2px solid #D39B22; opacity: 0; }
.coins .coin { animation: drop 1.4s ease-in infinite; }
.coins .coin:nth-child(2) { animation-delay: 0.45s; margin-left: -4px; }
.coins .coin:nth-child(3) { animation-delay: 0.9s; margin-left: -20px; }
@keyframes drop { 0% { transform: translateY(-20px); opacity: 0; } 15% { opacity: 1; } 70% { transform: translateY(70px); opacity: 1; } 80%, 100% { transform: translateY(78px); opacity: 0; } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-4deg); } 80% { transform: rotate(2deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.streak { display: flex; gap: 8px; justify-content: center; }
.streak span { width: 36px; height: 36px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

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