/* Level Up — playful, outlined "sticker" cards with hard offset shadows.
   Phone-first single column; two columns from 900px. */
:root {
  --ground: #F2EFFF;
  --ink: #1A1530;
  --muted: #514A6B;
  --paper: #FFFFFF;
  --soft: #ECE8FA;
  --sun: #FFC83D;
  --coral: #FF6F59;
  --sky: #3FA9F5;
  --lime: #A6E22E;
  --lilac: #B9A8FF;
  --done: #E7F8C8;
  --good: #1F7A3A;
  --bad: #B3261E;
  --display: 'Bricolage Grotesque', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --line: 2px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
/* 16px minimum: iPhone Safari zooms into any focused field smaller than that. */
input, select, textarea { font-size: 16px; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.fl { fill: var(--coral); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }

/* Type */
.display { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; margin: 0; letter-spacing: -0.01em; }
.h2 { font-family: var(--display); font-weight: 800; font-size: 24px; margin: 0; text-wrap: balance; }
.h3 { font-family: var(--display); font-weight: 800; font-size: 20px; margin: 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.error { color: var(--bad); font-weight: 500; margin: 0; }
.note { margin: 4px 0 0; }

/* Layout */
.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(100px + env(safe-area-inset-bottom, 0px));
}
.tab { padding-top: 14px; }
.cols, .col { display: flex; flex-direction: column; gap: 22px; }
.col { min-width: 0; }
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 28px; }
}
.block { display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.sync { font-size: 12px; color: var(--muted); }

/* Cards */
.card { background: var(--paper); border: var(--line); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-sun { background: var(--sun); box-shadow: var(--shadow); }
.card-sky { background: var(--sky); }
.card-lime { background: var(--lime); box-shadow: var(--shadow); }

.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--paper); border: var(--line); border-radius: 999px; padding: 3px 12px 3px 8px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-sm); }
.chip { font-size: 12px; font-weight: 700; background: var(--paper); border: var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }

/* Buttons & inputs */
.btn { border: var(--line); border-radius: 999px; padding: 10px 18px; font-weight: 700; background: var(--paper); box-shadow: var(--shadow-sm); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn-sun { background: var(--sun); }
.btn-coral { background: var(--coral); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-danger { background: var(--paper); color: var(--bad); border-color: var(--bad); box-shadow: none; }
.btn-small { padding: 6px 14px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; border-radius: 12px; border: var(--line); background: var(--paper); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.icon-btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }

input, select { border: var(--line); border-radius: 14px; background: var(--paper); padding: 10px 12px; min-height: 44px; width: 100%; }
label { font-weight: 700; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.add-row select { width: auto; }
@media (max-width: 420px) {
  .add-row { grid-template-columns: minmax(0, 1fr) auto; }
  .add-row input { grid-column: 1 / -1; }
  .add-row select { width: 100%; }
}

.seg { display: flex; background: var(--paper); border: var(--line); border-radius: 999px; padding: 2px; box-shadow: var(--shadow-sm); }
.seg button { border: 0; border-radius: 999px; padding: 4px 12px; font-weight: 700; background: transparent; min-height: 30px; }
.seg button[aria-pressed="true"] { background: var(--sun); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--paper); border: var(--line); border-radius: 16px; padding: 10px 10px 10px 12px; }
.row.is-done { background: var(--done); }
.row.is-done .row-text { text-decoration: line-through; color: var(--muted); }
.row-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-sub { display: block; font-size: 12px; color: var(--muted); }
.check { width: 30px; height: 30px; flex: none; border-radius: 10px; border: var(--line); background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 0; }
.check svg { visibility: hidden; }
.check[aria-pressed="true"] { background: var(--lime); }
.check[aria-pressed="true"] svg { visibility: visible; }
.check .ck { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.empty { border: 2px dashed var(--muted); border-radius: 16px; padding: 14px; color: var(--muted); text-align: center; }

/* Level card */
.level-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.meter { height: 16px; background: var(--paper); border: var(--line); border-radius: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--coral); border-right: var(--line); transition: width .4s ease; }
.meter.sun > i { background: var(--sun); }
.meter.thin { height: 12px; background: var(--soft); }

/* Dreams */
.dream-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dream { text-align: left; background: var(--paper); border: var(--line); border-radius: 20px; box-shadow: 3px 3px 0 var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.dream:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.dream-title { font-family: var(--display); font-weight: 800; font-size: 17px; line-height: 1.15; overflow-wrap: anywhere; }
.dream-meta { font-size: 12px; color: var(--muted); line-height: 1.35; }
.dream-new { border-style: dashed; box-shadow: none; background: transparent; align-items: center; justify-content: center; min-height: 120px; font-weight: 700; color: var(--muted); }
.ring { width: 70px; height: 70px; border-radius: 50%; border: var(--line); display: flex; align-items: center; justify-content: center; flex: none; }
.ring > span { width: 46px; height: 46px; border-radius: 50%; border: var(--line); background: var(--paper); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 15px; }
.unlocked { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; background: var(--sun); border: var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; }

/* Habits */
.habits { display: flex; flex-direction: column; gap: 10px; }
.habit { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; row-gap: 6px; padding-top: 4px; }
.habit-streak { display: flex; align-items: center; gap: 2px; font-family: var(--display); font-weight: 800; font-size: 18px; }
.habit-name { min-width: 0; font-weight: 700; background: none; border: 0; padding: 4px 0; text-align: left; overflow-wrap: anywhere; text-decoration: underline dotted 1.5px; text-underline-offset: 4px; }
.habit-days, .habit-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.habit-week { grid-column: 1 / -1; }
.habit-days { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; }
.day { height: 32px; border-radius: 9px; border: var(--line); background: var(--paper); padding: 0; font-size: 11px; font-weight: 700; color: var(--ink); }
.day.today { box-shadow: 0 0 0 2px var(--sun); }
.heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.heat i { border-radius: 3px; background: var(--soft); }

/* Week bars */
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: end; height: 120px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 12px; font-weight: 700; }
.bar i { display: block; width: 100%; border: var(--line); border-radius: 8px; background: var(--paper); min-height: 10px; }
.bar.best i { background: var(--sun); }
.bar.zero i { background: #9FD2FA; }

/* Assets */
.treasure-total { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; overflow-wrap: anywhere; }
.goal-box { background: var(--paper); border: var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.goal-box-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.chest { flex-direction: row; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 120px; height: 120px; flex: none; border-radius: 50%; border: var(--line); display: flex; align-items: center; justify-content: center; }
.donut > span { width: 64px; height: 64px; border-radius: 50%; border: var(--line); background: var(--paper); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 20px; }
.legend { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; font-size: 14px; font-weight: 500; }
.legend span { display: flex; align-items: center; gap: 8px; }
.sw { width: 14px; height: 14px; border-radius: 4px; border: var(--line); flex: none; }
.asset-sym { width: 40px; height: 40px; flex: none; border-radius: 12px; border: var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 800; font-size: 15px; }
.asset-value { font-family: var(--display); font-weight: 800; font-size: 16px; text-align: right; }
.row-btn { width: 100%; text-align: left; font: inherit; color: inherit; }
.rate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rate { border: var(--line); border-radius: 14px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.rate.gold { grid-column: 1 / -1; background: #FFF1C7; }
.rate b { font-family: var(--display); font-weight: 800; font-size: 16px; }
.rate-val { display: flex; flex-direction: column; align-items: flex-end; }
.up { color: var(--good); font-size: 11px; font-weight: 700; }
.down { color: var(--bad); font-size: 11px; font-weight: 700; }

/* Purchases */
.pnl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.pnl-tile { border: var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.pnl-tile b { font-family: var(--display); font-weight: 800; font-size: 20px; }
.pnl-tile .big-good { color: var(--good); }
.pnl-tile .big-bad { color: var(--bad); }
.prow { padding: 8px 10px 8px 12px; border-radius: 14px; }
.prow .asset-sym { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.prow .asset-value { font-size: 14px; }

/* Rate history */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: var(--line); border-radius: 999px; background: var(--paper); padding: 5px 12px; font-weight: 700; font-size: 13px; min-height: 32px; }
.chip-btn[aria-pressed="true"] { background: var(--sun); box-shadow: var(--shadow-sm); }
.rate-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.rate-stats b { font-family: var(--display); font-weight: 800; font-size: 26px; }
.chart-wrap { position: relative; touch-action: pan-y; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-wrap .ln { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-wrap .ar { fill: var(--sky); fill-opacity: .18; }
.chart-wrap .gr { stroke: var(--soft); stroke-width: 1.5; }
.chart-wrap .avg { stroke: var(--coral); stroke-width: 2; stroke-dasharray: 6 5; }
.chart-wrap .cursor { stroke: var(--muted); stroke-width: 1.5; }
.chart-wrap text { font-family: var(--body); font-size: 10.5px; fill: var(--muted); font-weight: 700; }
.chart-wrap .avg-label { fill: var(--bad); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.chart-tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: var(--paper); border-radius: 10px; padding: 6px 10px; font-size: 12px; line-height: 1.35; white-space: nowrap; pointer-events: none; z-index: 2; }
.nw .ar { fill: var(--lime); fill-opacity: .55; }
.chart-wrap .ln2 { fill: none; stroke: var(--sky); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.mk.area { border-radius: 4px; background: var(--lime); }
.mk.full { width: 18px; height: 0; border: 0; border-top: 3px solid var(--sky); border-radius: 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mk { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; display: inline-block; }
.mk.buy { background: var(--lime); }
.mk.sell { background: var(--coral); border-radius: 3px; }
.mk.avg { width: 18px; height: 0; border: 0; border-top: 2px dashed var(--coral); border-radius: 0; }
.tag-sell { font-size: 11px; font-weight: 700; background: var(--coral); border: var(--line); border-radius: 999px; padding: 0 7px; margin-left: 6px; }
.seg-wide { box-shadow: none; }
.seg-wide button { flex: 1; min-height: 40px; font-size: 15px; }

/* Nav */
.nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  width: min(440px, calc(100% - 32px));
  display: flex; gap: 8px; background: var(--ink); border-radius: 22px; padding: 6px; z-index: 10;
}
.nav button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 0; border-radius: 16px; color: var(--paper); font-weight: 700; font-size: 15px; background: transparent; border: 0; }
.nav button[aria-current="page"] { background: var(--sun); color: var(--ink); }
.nav button[data-tab="assets"][aria-current="page"] { background: var(--lime); }
.nav button[data-tab="spend"][aria-current="page"] { background: var(--coral); }

/* Sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(26, 21, 48, .45); }
.sheet { position: relative; width: min(560px, 100%); max-height: 88vh; overflow-y: auto; border-radius: 24px 24px 0 0; border-bottom: 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 600px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 24px; border-bottom: var(--line); box-shadow: var(--shadow); } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #FFE3DE; border: var(--line); border-radius: 14px; padding: 10px 12px; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: min(380px, 100%); box-shadow: var(--shadow); background: var(--sun); }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); border-radius: 14px; padding: 10px 16px; font-weight: 500; z-index: 30; max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ===================== Motion ===================== */
@property --p { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
:root { --spring: cubic-bezier(.34, 1.56, .64, 1); --ease-out: cubic-bezier(.22, 1, .36, 1); }

/* Ring progress uses custom properties so it can animate */
.ring, .donut { transition: transform .25s var(--spring); }
.ring { background: conic-gradient(var(--c, var(--sun)) var(--p), var(--soft) 0); }

/* Hover lift / press-in for everything tappable */
.btn, .dream, .row-btn, .chip-btn, .check, .day, .icon-btn, .seg button, .badge, .habit-name {
  transition: transform .18s var(--spring), box-shadow .18s var(--spring), background-color .2s, color .2s;
}
@media (hover: hover) {
  .btn:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
  .btn-ghost:hover, .btn-danger:hover { box-shadow: none; transform: translateY(-1px); }
  .dream:hover { transform: translate(-3px, -3px) rotate(-.6deg); box-shadow: 6px 6px 0 var(--ink); }
  .dream:hover .ring { transform: rotate(-8deg) scale(1.06); }
  .dream-new:hover { transform: none; box-shadow: none; border-color: var(--ink); color: var(--ink); animation: wiggle .5s ease; }
  .row-btn:hover { transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); }
  .chip-btn:hover { transform: translateY(-2px); }
  .check:hover, .day:hover { transform: scale(1.08); }
  .icon-btn:hover { transform: rotate(-8deg) scale(1.08); color: var(--bad); }
  .badge:hover { transform: translateY(-2px) rotate(-2deg); }
  .habit-name:hover { color: #4B3FA0; }
  .pill:hover svg { animation: flicker .5s ease-in-out 2; }
}
.btn:active, .row-btn:active, .chip-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); transition-duration: .06s; }
.dream:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); transition-duration: .06s; }
.check:active, .day:active { transform: scale(.88); transition-duration: .06s; }

/* Tab entrance: cards fly in one after another */
.tab.enter .col > * { animation: rise .55s var(--ease-out) both; }
.tab.enter .col > *:nth-child(2) { animation-delay: .06s; }
.tab.enter .col > *:nth-child(3) { animation-delay: .12s; }
.tab.enter .col > *:nth-child(4) { animation-delay: .18s; }
.tab.enter .col:nth-child(2) > * { animation-delay: .1s; }
.tab.enter .col:nth-child(2) > *:nth-child(2) { animation-delay: .16s; }
.tab.enter .col:nth-child(2) > *:nth-child(3) { animation-delay: .22s; }
.tab.enter.from-right .col > * { animation-name: slide-left; }
.tab.enter.from-left .col > * { animation-name: slide-right; }
.tab.enter .ring { animation: ring-fill 1s var(--ease-out) .25s both; }
.tab.enter .dream { animation: pop-in .45s var(--spring) both; }
.tab.enter .dream:nth-child(2) { animation-delay: .07s; }
.tab.enter .dream:nth-child(3) { animation-delay: .14s; }
.tab.enter .dream:nth-child(4) { animation-delay: .21s; }
.tab.enter .dream:nth-child(n+5) { animation-delay: .28s; }
.tab.enter .bar i { animation: grow .6s var(--spring) both; transform-origin: bottom; }
.tab.enter .bar:nth-child(2) i { animation-delay: .04s; } .tab.enter .bar:nth-child(3) i { animation-delay: .08s; }
.tab.enter .bar:nth-child(4) i { animation-delay: .12s; } .tab.enter .bar:nth-child(5) i { animation-delay: .16s; }
.tab.enter .bar:nth-child(6) i { animation-delay: .2s; } .tab.enter .bar:nth-child(7) i { animation-delay: .24s; }
.tab.enter .donut { animation: spin-in .9s var(--spring) .15s both; }
.tab.enter .list > li { animation: rise .4s var(--ease-out) both; }
.tab.enter .list > li:nth-child(2) { animation-delay: .04s; } .tab.enter .list > li:nth-child(3) { animation-delay: .08s; }
.tab.enter .list > li:nth-child(4) { animation-delay: .12s; } .tab.enter .list > li:nth-child(n+5) { animation-delay: .16s; }

/* Meters slide to their new value */
.meter > i { transition: width .7s var(--spring); }

/* Just-toggled feedback */
.check.pop, .day.pop { animation: check-pop .45s var(--spring); }
.check.pop .ck { stroke-dasharray: 24; animation: draw-check .35s ease-out .05s both; }
.row.pop-row { animation: row-done .5s var(--ease-out); }
.row.new-row { animation: slide-in-row .45s var(--spring); }

/* Living flames on active streaks */
.flame-live .fl { transform-origin: 50% 90%; transform-box: fill-box; animation: flicker 1.8s ease-in-out infinite; }
.habit:nth-child(2) .flame-live .fl { animation-delay: -.6s; }
.habit:nth-child(3) .flame-live .fl { animation-delay: -1.1s; }

/* Floating "+XP" */
.xp-float { position: fixed; z-index: 40; pointer-events: none; font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--ink); background: var(--sun); border: var(--line); border-radius: 999px; padding: 2px 10px; box-shadow: var(--shadow-sm); animation: float-up 1s var(--ease-out) forwards; }

/* Level card celebrates */
.level.level-up { animation: level-up .8s var(--spring); }

/* Sheet & toast */
.sheet-backdrop { animation: fade .2s ease-out; }
.sheet { animation: sheet-up .35s var(--spring); }
@media (min-width: 600px) { .sheet { animation: sheet-pop .3s var(--spring); } }
.toast:not([hidden]) { animation: toast-in .35s var(--spring); }
.login-card { animation: pop-in .6s var(--spring) both; }

/* Nav: sliding highlight */
.nav { overflow: hidden; }
.nav-ind { position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 28px) / 3); border-radius: 16px; background: var(--sun); transition: transform .45s var(--spring), background-color .3s; }
.nav[data-active="assets"] .nav-ind { transform: translateX(calc(100% + 8px)); background: var(--lime); }
.nav[data-active="spend"] .nav-ind { transform: translateX(calc(200% + 16px)); background: var(--coral); }
.nav button, .nav button[aria-current="page"], .nav button[data-tab="assets"][aria-current="page"], .nav button[data-tab="spend"][aria-current="page"] { position: relative; z-index: 1; background: transparent; transition: color .3s, transform .18s var(--spring); }
.nav button[aria-current="page"] { color: var(--ink); }
.nav button:active { transform: scale(.94); }
@media (hover: hover) { .nav button:not([aria-current]):hover svg { animation: wiggle .45s ease; } }

/* Chart draws itself */
.chart-wrap.draw .ln { animation: draw-line 1.1s var(--ease-out) both; }
.chart-wrap.draw .ar { animation: fade .8s ease-out .4s both; }
.chart-wrap.draw .mkp { animation: pop-in .35s var(--spring) both; }
.chart-wrap.draw .avg { animation: fade .5s ease-out .9s both; }
.chart-tip:not([hidden]) { animation: fade .12s ease-out; }

/* Keyframes */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes slide-left { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes slide-right { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.8); } 100% { opacity: 1; transform: none; } }
@keyframes ring-fill { from { --p: 0deg; } }
@keyframes grow { from { transform: scaleY(0); } to { transform: none; } }
@keyframes spin-in { from { transform: rotate(-200deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes check-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.25) rotate(-6deg); } 100% { transform: none; } }
@keyframes draw-check { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes row-done { 0% { transform: none; } 35% { transform: scale(1.03) rotate(-.5deg); } 100% { transform: none; } }
@keyframes slide-in-row { from { opacity: 0; transform: translateY(-10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(0); } 25% { transform: scale(1.08, .94) rotate(-4deg); } 50% { transform: scale(.95, 1.07) rotate(3deg); } 75% { transform: scale(1.05, .97) rotate(-2deg); } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
@keyframes level-up { 0% { transform: none; } 30% { transform: scale(1.04) rotate(-1.5deg); } 60% { transform: scale(.99) rotate(1deg); } 100% { transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-pop { from { opacity: 0; transform: translateY(20px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 20px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes draw-line { from { stroke-dashoffset: var(--len, 1000); } to { stroke-dashoffset: 0; } }


/* Daily quests */
.repeat-toggle { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 14px; color: var(--muted); }
.repeat-toggle input { width: 20px; height: 20px; min-height: 0; padding: 0; margin: 0; accent-color: var(--ink); }

/* Tonight's pick */
.card-lilac { background: var(--lilac); box-shadow: var(--shadow); }
.movie { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px 14px; align-items: start; }
.poster { width: 96px; aspect-ratio: 2 / 3; object-fit: cover; border: var(--line); border-radius: 12px; background: var(--paper); display: block; }
.poster-tile { display: flex; align-items: flex-end; padding: 8px; background: var(--sun); font-family: var(--display); font-weight: 800; font-size: 14px; line-height: 1.1; overflow-wrap: anywhere; }
.movie-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.movie-info .h3 { overflow-wrap: anywhere; }
.movie-line { margin: 0; }
.movie-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; }
.link { color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.movie-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.saved { display: flex; flex-direction: column; gap: 6px; }
.saved:empty { display: none; }

/* Screen time */
.screen-body { display: flex; flex-direction: column; gap: 12px; }
.screen-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.screen-now b { font-family: var(--display); font-weight: 800; font-size: 32px; line-height: 1; }
.screen-change { margin: 0; font-size: 13px; font-weight: 700; }
.screen-change.good { color: var(--good); }
.screen-change.bad { color: var(--bad); }
.screen-bars { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.screen-bars .bar { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-size: 12px; font-weight: 700; }
.screen-bars .bar.hit i { background: var(--lime); }
.screen-goal { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.kit { background: var(--sun); border: var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; box-shadow: var(--shadow-sm); }

/* Spending */
.spend-add { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 420px) { .spend-add { grid-template-columns: minmax(0, 1fr) auto; } .spend-add input { grid-column: auto; } }
.spend-body { display: flex; flex-direction: column; gap: 12px; }
.spend-top { display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; }
.spend-top > div { display: flex; flex-direction: column; gap: 2px; }
.spend-top b { font-family: var(--display); font-weight: 800; font-size: 20px; }
.spend-top b.spend-total { font-size: 32px; line-height: 1; }
.spend-stack { display: flex; height: 16px; border: var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); }
.spend-stack i { display: block; height: 100%; border-right: 2px solid var(--ink); }
.spend-stack i:last-child { border-right: 0; }
.spend-cats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.spend-cats li { display: grid; grid-template-columns: minmax(0, 1fr) auto 40px; gap: 10px; align-items: baseline; }
.spend-cats li > span:last-child { text-align: right; }
.spend-ic { width: 36px; height: 36px; flex: none; border: var(--line); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; }

/* Spending tab */
.nav button { font-size: 14px; gap: 5px; min-width: 0; }
.card-coral { background: var(--coral); box-shadow: var(--shadow); }
.spend-hero { gap: 10px; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav .icon-btn { font-size: 22px; font-weight: 700; line-height: 1; background: var(--paper); }
.month-nav .icon-btn:disabled { opacity: .35; cursor: default; }
.spend-hero .spend-stack { background: var(--paper); }
.spend-days { display: grid; gap: 2px; align-items: end; height: 110px; }
.spend-days i { display: block; background: var(--coral); border: 1.5px solid var(--ink); border-radius: 4px 4px 2px 2px; min-height: 3px; }
.spend-days i.today { background: var(--sun); }
.spend-days i.future { border-style: dashed; background: transparent; }
.spend-days-axis { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--muted); }
.spend-list { display: flex; flex-direction: column; gap: 16px; }
.day-group { display: flex; flex-direction: column; gap: 8px; }
.day-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 0 4px; }

/* Spending balance */
.spend-balance { gap: 8px; }
.bal-total { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; }
.bal-total.neg { color: var(--bad); }
.bal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.top-row { background: var(--done); }
.top-amt { color: var(--good); }
.top-amt.neg { color: var(--bad); }
