:root {
  --bg: #fff5f8;
  --bg2: #fdeef3;
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --ink: #574659;
  --ink-soft: #9a8a9e;
  --line: #f3e3ea;
  --pink: #ff7fa3;
  --pink-deep: #e0578a;
  --pink-soft: #ffd6e0;
  --mint: #6fd3b5;
  --mint-soft: #d7f5ec;
  --peach: #ffb4a2;
  --lav: #b8a9ff;
  --lav-soft: #ece8ff;
  --yellow: #ffd46b;
  --danger: #ff5c7a;
  --radius: 24px;
  --shadow: 0 10px 30px -12px rgba(224, 87, 138, 0.28), 0 2px 6px rgba(224, 87, 138, 0.06);
  --shadow-lg: 0 20px 44px -16px rgba(224, 87, 138, 0.42);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --smooth: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  font-family: "Mali", "Leelawadee UI", "Tahoma", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--pink-soft); }

/* ---------- ฉากหลังลอยๆ ---------- */
.bg-deco { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(50px); opacity: .55; animation: drift 18s ease-in-out infinite alternate; }
.b1 { width: 340px; height: 340px; background: #ffc9da; top: -120px; left: -100px; }
.b2 { width: 300px; height: 300px; background: #cdf3e6; top: 30%; right: -140px; animation-duration: 22s; animation-delay: -6s; }
.b3 { width: 280px; height: 280px; background: #e6e0ff; bottom: -120px; left: 10%; animation-duration: 26s; animation-delay: -12s; }
@keyframes drift { to { transform: translate(40px, 60px) scale(1.15); } }
.float { position: absolute; bottom: -40px; color: #ffb3c8; font-size: 18px; opacity: 0; animation: rise 16s linear infinite; }
.f1 { left: 8%; } .f2 { left: 30%; animation-delay: -4s; font-size: 14px; color: #c9b8ff; }
.f3 { left: 55%; animation-delay: -9s; font-size: 22px; } .f4 { left: 78%; animation-delay: -2s; color: #9ee3cc; }
.f5 { left: 92%; animation-delay: -12s; font-size: 14px; }
@keyframes rise {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: .7; }
  90% { opacity: .5; }
  100% { transform: translateY(-110vh) rotate(40deg); opacity: 0; }
}

.app {
  position: relative; z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(112px + env(safe-area-inset-bottom));
}

/* ---------- top ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto; object-fit: cover;
  background: #fff; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--pink-soft), var(--shadow);
  animation: bob 4s ease-in-out infinite;
}
.brand-logo.gulp { animation: gulp .6s var(--spring); }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-3deg); } }
@keyframes gulp { 0% { transform: scale(1); } 30% { transform: scale(1.25) rotate(-8deg); } 60% { transform: scale(.92) rotate(4deg); } 100% { transform: scale(1); } }
h1 {
  font-size: 22px; margin: 0; line-height: 1.2;
  background: linear-gradient(90deg, #e0578a, #ff8fab, #f59e7a, #e0578a); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: flow 8s linear infinite;
}
@keyframes flow { to { background-position: 300% 0; } }
.hello { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.icon-btn {
  border: 0; background: var(--card); width: 44px; height: 44px; border-radius: 15px;
  box-shadow: var(--shadow); font-size: 20px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .25s var(--spring), box-shadow .25s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.small { width: 36px; height: 36px; font-size: 13px; color: var(--pink); border-radius: 12px; }

.month-switch {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 18px 0 14px; font-weight: 600; font-size: 17px;
}
.month-switch[hidden] + main { margin-top: 18px; }
.month-switch span { min-width: 150px; text-align: center; view-transition-name: month-label; }

/* ---------- views & cards ---------- */
main { view-transition-name: page; }
.view { display: none; }
.view.active { display: block; }

.card {
  position: relative;
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card.enter { animation: cardIn .6s var(--smooth) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }

.card-title {
  font-weight: 700; font-size: 16px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.link { border: 0; background: none; color: var(--pink); font-weight: 600; font-size: 14px; padding: 4px 8px; border-radius: 10px; transition: background .2s; }
.link:hover { background: var(--pink-soft); }
.muted { color: var(--ink-soft); font-size: 13px; margin: 0 0 10px; }
.tiny { font-size: 12px; }

/* hero */
.hero {
  overflow: hidden; text-align: center; padding: 24px 16px 20px; border: 0;
  background: linear-gradient(125deg, #ffb8cc, #ffcfbd 35%, #fff0c2 60%, #ffc6d8 85%, #ffb8cc);
  background-size: 300% 300%;
  animation: heroFlow 14s ease-in-out infinite;
  box-shadow: var(--shadow-lg);
}
.hero.enter { animation: cardIn .6s var(--smooth) both, heroFlow 14s ease-in-out infinite; }
@keyframes heroFlow { 50% { background-position: 100% 50%; } }
.hero > *:not(.hero-shine):not(.hero-spark) { position: relative; }
.hero-shine {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  transform: translateX(-120%); animation: shine 5s ease-in-out infinite 1.2s;
}
@keyframes shine { 0%, 60% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.hero-spark { position: absolute; color: #fff; opacity: .85; animation: twinkle 3s ease-in-out infinite; pointer-events: none; }
.s1 { top: 14px; left: 18px; font-size: 16px; }
.s2 { top: 20px; right: 22px; font-size: 14px; color: #ff8fab; animation-delay: -1s; }
.s3 { bottom: 16px; right: 38px; font-size: 18px; animation-delay: -2s; }
@keyframes twinkle { 50% { transform: scale(.5) rotate(45deg); opacity: .3; } }
.hero-label { font-size: 14px; opacity: .8; }
.hero-amount { font-size: 42px; font-weight: 700; margin: 2px 0 12px; color: #6b3d57; font-variant-numeric: tabular-nums; letter-spacing: -.5px; text-shadow: 0 2px 0 rgba(255,255,255,.5); }
.hero-amount.neg { color: var(--danger); }
.hero-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.72); border-radius: 999px; padding: 7px 14px; font-size: 13px; backdrop-filter: blur(6px); }
.pill b { font-variant-numeric: tabular-nums; }
.pill.in b { color: #25a07c; }
.pill.out b { color: #de4f6c; }
.budget-wrap { margin-top: 16px; text-align: left; }
.budget-text { font-size: 13px; margin-bottom: 6px; }

.bar { height: 12px; background: rgba(255,255,255,.7); border-radius: 999px; overflow: hidden; }
.card:not(.hero) .bar { background: var(--bg2); }
.bar-fill {
  height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #8fe3c8, var(--mint));
  transition: width .8s var(--smooth); animation: fillIn 1s var(--smooth) both .15s;
  position: relative; overflow: hidden;
}
.bar-fill::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  transform: translateX(-100%); animation: shimmer 2.6s ease-in-out infinite 1.2s;
}
@keyframes fillIn { from { width: 0; } }
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }
.bar-fill.warn { background: linear-gradient(90deg, #ffe39a, var(--yellow)); }
.bar-fill.over { background: linear-gradient(90deg, #ff8ea3, var(--danger)); }

/* ---------- donut ---------- */
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.donut-wrap svg { flex: 0 0 auto; overflow: visible; }
.donut-seg { animation: donutDraw .9s var(--smooth) both; animation-delay: calc(var(--i) * 90ms); transition: stroke-width .25s var(--spring); cursor: pointer; }
.donut-seg:hover { stroke-width: 34px; }
@keyframes donutDraw { from { stroke-dasharray: 0 400; } }
.donut-center { animation: popIn .6s var(--spring) both .35s; transform-origin: center; transform-box: fill-box; }
@keyframes popIn { from { opacity: 0; transform: scale(.4); } }
.legend { flex: 1 1 180px; display: grid; gap: 6px; min-width: 0; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 6px; border-radius: 10px; animation: slideIn .5s var(--smooth) both; animation-delay: calc(var(--i) * 60ms + 150ms); }
.legend-item:hover { background: var(--bg); }
.legend-item .dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.legend-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-item .pc { color: var(--ink-soft); font-size: 12px; min-width: 32px; text-align: right; }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } }

.empty { text-align: center; color: var(--ink-soft); padding: 18px 8px; font-size: 14px; }
.empty .big { font-size: 42px; display: block; margin-bottom: 6px; animation: bob 3s ease-in-out infinite; }

/* ---------- tx list ---------- */
.tx {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px dashed var(--line);
  cursor: pointer; border-radius: 14px; transition: background .2s, transform .25s var(--spring);
  animation: slideIn .45s var(--smooth) both; animation-delay: calc(var(--i, 0) * 40ms);
}
.tx:last-child { border-bottom: 0; }
.tx:hover { background: #fff7fa; transform: translateX(3px); }
.tx:active { transform: scale(.98); }
.tx-ic { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-size: 22px; flex: 0 0 auto; transition: transform .3s var(--spring); }
.tx:hover .tx-ic { transform: rotate(-8deg) scale(1.08); }
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; font-size: 15px; }
.tx-note { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amt { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-amt.income { color: #25a07c; }
.tx-amt.expense { color: #de4f6c; }
.day-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin: 0 6px 4px; font-weight: 600; }

.filters { display: grid; gap: 10px; }
input[type=search], input[type=text], input[type=number], input[type=date], input[type=month], input[type=password] {
  width: 100%; border: 2px solid var(--line); background: #fffafc; border-radius: 14px;
  padding: 10px 12px; outline: none; transition: border-color .2s, box-shadow .2s; min-width: 0;
}
input:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 127, 163, .15); }

.seg { position: relative; display: flex; background: var(--bg2); border-radius: 15px; padding: 4px; gap: 4px; }
.seg button { position: relative; z-index: 1; flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 11px; font-weight: 600; font-size: 14px; color: var(--ink-soft); transition: color .25s, background .25s, box-shadow .25s, transform .25s var(--spring); }
.seg button:active { transform: scale(.95); }
.seg button.on { background: var(--card-solid); color: var(--pink); box-shadow: 0 3px 10px rgba(255,127,163,.25); }
.seg.big button { padding: 11px; font-size: 15px; }
.seg.big button[data-t=income].on { color: #25a07c; }

/* ---------- analyze ---------- */
.mood { display: flex; gap: 14px; align-items: center; }
.mood .face { font-size: 58px; line-height: 1; animation: popIn .7s var(--spring) both .1s, bob 3.5s ease-in-out infinite 1s; }
.mood h3 { margin: 0 0 4px; font-size: 18px; }
.mood p { margin: 0; font-size: 14px; color: var(--ink-soft); }
.mood .rate { display: inline-block; font-size: 13px; margin-top: 8px; font-weight: 700; background: var(--pink-soft); color: var(--pink-deep); padding: 3px 10px; border-radius: 999px; }

.rule-row { margin-bottom: 14px; }
.rule-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; gap: 8px; }
.rule-top b { white-space: nowrap; }
.rule-row .bar { position: relative; overflow: visible; }
.rule-row .bar-fill { overflow: hidden; }
.rule-row .mark { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; opacity: .4; }

.insight {
  display: flex; gap: 10px; padding: 12px; border-radius: 18px; margin-bottom: 10px; background: var(--bg);
  animation: cardIn .55s var(--smooth) both; animation-delay: calc(var(--i, 0) * 80ms + 100ms);
  transition: transform .25s var(--spring);
}
.insight:hover { transform: translateY(-2px); }
.insight:last-child { margin-bottom: 0; }
.insight .ic { font-size: 26px; line-height: 1.2; }
.insight h4 { margin: 0 0 3px; font-size: 15px; }
.insight p { margin: 0; font-size: 13px; line-height: 1.6; }
.insight.bad { background: linear-gradient(135deg, #ffeef1, #fff5f6); }
.insight.warn { background: linear-gradient(135deg, #fff5d9, #fffaf0); }
.insight.good { background: linear-gradient(135deg, var(--mint-soft), #f0fbf7); }
.insight.info { background: linear-gradient(135deg, var(--lav-soft), #f6f4ff); }

.plan { display: grid; gap: 10px; }
.plan-item { display: flex; gap: 12px; align-items: center; background: var(--bg); padding: 12px; border-radius: 18px; animation: slideIn .5s var(--smooth) both; animation-delay: calc(var(--i, 0) * 80ms + 100ms); }
.plan-item .num { font-size: 24px; }
.plan-item .t { font-size: 13px; color: var(--ink-soft); }
.plan-item .v { font-weight: 700; font-size: 17px; }
.plan-item .s { font-size: 12px; color: var(--ink-soft); }

.trend-bar { transform-box: fill-box; transform-origin: bottom; animation: grow .8s var(--spring) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes grow { from { transform: scaleY(0); } }
.trend-legend { display: flex; gap: 14px; font-size: 12px; justify-content: center; margin-top: 6px; }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }

/* ---------- goals ---------- */
.goal { padding: 14px; background: var(--bg); border-radius: 20px; margin-bottom: 12px; animation: cardIn .55s var(--smooth) both; animation-delay: calc(var(--i, 0) * 90ms + 80ms); }
.goal:last-child { margin-bottom: 0; }
.goal-top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.goal-top .em { font-size: 28px; width: 50px; height: 50px; background: var(--card-solid); border-radius: 16px; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 4px 12px rgba(224,87,138,.12); }
.goal-top .nm { flex: 1; min-width: 0; }
.goal-top .nm b { display: block; font-size: 16px; }
.goal-top .nm small { color: var(--ink-soft); }
.goal .bar { background: var(--card-solid); height: 14px; }
.goal .bar-fill { background: linear-gradient(90deg, var(--pink), var(--peach)); }
.goal-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft); margin-top: 6px; gap: 8px; }
.goal-actions { display: flex; gap: 8px; margin-top: 10px; }
.goal-actions .btn { flex: 1; padding: 8px; font-size: 14px; }
.goal.done .bar-fill { background: linear-gradient(90deg, var(--mint), #a8e6cf); }
.goal.done .em { animation: bob 2.5s ease-in-out infinite; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(488px, calc(100% - 24px)); background: rgba(255,255,255,.78); border-radius: 26px;
  border: 1px solid rgba(255,255,255,.9);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 12px 34px -8px rgba(224, 87, 138, .32); display: flex; align-items: center; padding: 6px; z-index: 10;
  view-transition-name: bottom-nav;
}
.nav-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 0; width: 0; border-radius: 18px;
  background: linear-gradient(135deg, #ffe3ec, #fff0e8); box-shadow: inset 0 0 0 1px rgba(255,127,163,.18);
  transition: transform .5s var(--spring), width .5s var(--spring); z-index: 0;
}
.bottom-nav button { position: relative; z-index: 1; flex: 1; border: 0; background: none; font-size: 11px; color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 18px; transition: color .3s; }
.bottom-nav button span { font-size: 20px; filter: grayscale(.7); opacity: .8; transition: transform .45s var(--spring), filter .3s, opacity .3s; }
.bottom-nav button.on { color: var(--pink-deep); font-weight: 700; }
.bottom-nav button.on span { filter: none; opacity: 1; transform: translateY(-3px) scale(1.18); }
.bottom-nav .fab {
  flex: 0 0 60px; height: 60px; border-radius: 22px; margin: -30px 4px 0; font-size: 32px; color: #fff; padding: 0;
  background: linear-gradient(135deg, #ff7fa3, #ffab91); box-shadow: 0 10px 22px -4px rgba(255, 127, 163, .7);
  display: grid; place-items: center; transition: transform .35s var(--spring), box-shadow .3s;
  animation: fabPulse 3s ease-in-out infinite;
}
.bottom-nav .fab:hover { transform: translateY(-3px) rotate(90deg); }
.bottom-nav .fab:active { transform: scale(.88) rotate(90deg); }
@keyframes fabPulse { 0%, 100% { box-shadow: 0 10px 22px -4px rgba(255,127,163,.7), 0 0 0 0 rgba(255,127,163,.35); } 50% { box-shadow: 0 10px 22px -4px rgba(255,127,163,.7), 0 0 0 10px rgba(255,127,163,0); } }

/* ---------- sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(87, 70, 89, .32); z-index: 20;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .3s ease both;
}
.sheet-backdrop.closing { animation: fade .25s ease reverse both; }
.sheet-backdrop.closing .sheet { animation: sheetOut .25s ease-in both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  background: var(--card-solid); width: 100%; max-width: 520px; border-radius: 30px 30px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto;
  animation: sheetIn .5s var(--spring) both; display: grid; gap: 12px;
  box-shadow: 0 -10px 40px rgba(224,87,138,.2);
}
.sheet > * { animation: cardIn .45s var(--smooth) both; }
.sheet > *:nth-child(2) { animation-delay: .04s; } .sheet > *:nth-child(3) { animation-delay: .08s; }
.sheet > *:nth-child(4) { animation-delay: .12s; } .sheet > *:nth-child(5) { animation-delay: .16s; }
.sheet > *:nth-child(n+6) { animation-delay: .2s; }
@keyframes sheetIn { from { transform: translateY(100%); } }
@keyframes sheetOut { to { transform: translateY(100%); } }
.sheet-handle { width: 44px; height: 5px; background: var(--line); border-radius: 9px; margin: 0 auto 4px; }
.sheet h2 { margin: 0; font-size: 19px; text-align: center; }
.sheet label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.sheet label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.sheet label.check input { width: 18px; height: 18px; accent-color: var(--pink); }

.amount-field { display: flex !important; align-items: center; gap: 6px; background: linear-gradient(135deg, #fff0f5, #fff7f0); border-radius: 20px; padding: 6px 16px; transition: box-shadow .25s; }
.amount-field:focus-within { box-shadow: 0 0 0 3px var(--pink-soft); }
.amount-field span { font-size: 28px; color: var(--pink); font-weight: 700; }
.amount-field input { border: 0 !important; background: transparent !important; font-size: 32px; font-weight: 700; padding: 6px 0 !important; box-shadow: none !important; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.cat-grid button {
  border: 2px solid transparent; background: var(--bg); border-radius: 18px; padding: 8px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px;
  transition: transform .35s var(--spring), background .2s, border-color .2s;
  animation: popIn .4s var(--spring) both; animation-delay: calc(var(--i, 0) * 22ms + 120ms);
}
.cat-grid button span { font-size: 24px; transition: transform .4s var(--spring); }
.cat-grid button:hover span { transform: scale(1.15) rotate(-6deg); }
.cat-grid button.on { border-color: var(--pink); background: var(--pink-soft); transform: scale(1.06); }
.cat-grid button.on span { animation: wiggle .5s ease; }
@keyframes wiggle { 25% { transform: rotate(-14deg) scale(1.2); } 75% { transform: rotate(10deg) scale(1.2); } }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .w-emoji { max-width: 90px; }
.row2:has(.w-emoji) { grid-template-columns: 90px 1fr; }

.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.btn { position: relative; overflow: hidden; border: 0; border-radius: 15px; padding: 11px 18px; font-weight: 600; font-size: 15px; transition: transform .25s var(--spring), box-shadow .25s, filter .2s; }
.btn:active { transform: scale(.94); }
.btn.primary { background: linear-gradient(135deg, #ff7fa3, #ffa08e); color: #fff; box-shadow: 0 6px 16px -4px rgba(255,127,163,.6); }
.btn.primary:hover { box-shadow: 0 10px 22px -6px rgba(255,127,163,.75); filter: brightness(1.04); }
.btn.ghost { background: var(--bg2); }
.btn.ghost:hover { background: #fbe2ea; }
.btn.danger { color: var(--danger); }
.sheet-actions .danger { margin-right: auto; }
.settings-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.settings-tools .btn { font-size: 13px; padding: 10px 8px; text-align: center; }
.file-btn { display: block !important; color: var(--ink) !important; font-weight: 600 !important; font-size: 13px !important; cursor: pointer; }

/* ripple */
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.55); transform: scale(0); animation: ripple .6s ease-out forwards; pointer-events: none; }
.btn.ghost .ripple, .cat-grid .ripple, .who .ripple { background: rgba(255,127,163,.25); }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* ---------- account / sync ---------- */
.icon-btn.cloud { position: relative; }
.sync-dot { position: absolute; right: 6px; bottom: 6px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; background: transparent; transition: background .3s; }
.sync-dot.ok { background: var(--mint); }
.sync-dot.busy { background: var(--yellow); animation: blink 1s infinite; }
.sync-dot.err { background: var(--danger); }
@keyframes blink { 50% { opacity: .3; } }
.center { text-align: center; }
.account-card { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: 20px; padding: 14px; }
.account-card .avatar { font-size: 30px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--pink-soft); border-radius: 18px; }
.account-card b { font-size: 17px; }
.account-card .muted { margin: 2px 0 0; }

/* ---------- welcome (เลือกคน) ---------- */
.welcome {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(circle at 20% 10%, #ffd9e5, transparent 50%), radial-gradient(circle at 90% 80%, #daf6ec, transparent 45%), var(--bg);
}
.welcome.leaving { animation: welcomeOut .55s var(--smooth) forwards; }
@keyframes welcomeOut { to { opacity: 0; transform: scale(1.08); filter: blur(6px); } }
.welcome-box { width: 100%; max-width: 420px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.welcome-logo {
  width: min(220px, 60vw); height: auto; border-radius: 50%;
  filter: drop-shadow(0 16px 30px rgba(224,87,138,.3));
  animation: logoIn 1s var(--spring) both, bob 4s ease-in-out infinite 1s;
}
@keyframes logoIn { from { opacity: 0; transform: scale(.3) rotate(-25deg); } }
.welcome h2 { margin: 10px 0 0; font-size: 22px; color: var(--pink-deep); animation: cardIn .6s var(--smooth) both .35s; }
.welcome .muted { animation: cardIn .6s var(--smooth) both .45s; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; width: 100%; }
.who button {
  position: relative; overflow: hidden;
  border: 0; background: var(--card-solid); border-radius: 28px; padding: 22px 8px; box-shadow: var(--shadow);
  display: grid; gap: 6px; justify-items: center; font-size: 20px; font-weight: 700;
  transition: transform .35s var(--spring), box-shadow .3s;
  animation: popIn .6s var(--spring) both; animation-delay: calc(.55s + var(--i, 0) * .12s);
}
.who button span { font-size: 54px; width: 88px; height: 88px; display: grid; place-items: center; border-radius: 30px; transition: transform .45s var(--spring); }
.who button:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.who button:hover span { transform: rotate(-10deg) scale(1.08); }
.who button:active { transform: scale(.95); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); z-index: 60;
  background: rgba(107, 61, 87, .92); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(107,61,87,.3); max-width: calc(100% - 32px); text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: toastIn .55s var(--spring) both; transform: translateX(-50%);
}
@keyframes toastIn { from { transform: translate(-50%, -30px) scale(.8); opacity: 0; } }

/* ---------- เอฟเฟกต์เหรียญ / คอนเฟตti ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.fx-coin, .fx-bit { position: absolute; left: 0; top: 0; will-change: transform, opacity; }
.fx-coin { font-size: 28px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.15)); }
.fx-bit { width: 9px; height: 13px; border-radius: 2px; }

/* ---------- View Transitions (สลับหน้า / เดือน) ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(page) { animation: pageOut .28s var(--smooth) both; }
::view-transition-new(page) { animation: pageIn .45s var(--smooth) both; }
html[data-dir=back]::view-transition-old(page) { animation-name: pageOutBack; }
html[data-dir=back]::view-transition-new(page) { animation-name: pageInBack; }
@keyframes pageOut { to { opacity: 0; transform: translateX(-40px) scale(.98); } }
@keyframes pageIn { from { opacity: 0; transform: translateX(50px) scale(.98); } }
@keyframes pageOutBack { to { opacity: 0; transform: translateX(40px) scale(.98); } }
@keyframes pageInBack { from { opacity: 0; transform: translateX(-50px) scale(.98); } }
::view-transition-old(month-label) { animation: labelOut .25s ease both; }
::view-transition-new(month-label) { animation: labelIn .4s var(--spring) both; }
@keyframes labelOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes labelIn { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 380px) {
  .hero-amount { font-size: 34px; }
  .row2 { grid-template-columns: 1fr; }
  .row2:has(.w-emoji) { grid-template-columns: 70px 1fr; }
  h1 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important;
  }
  .float, .blob, .hero-shine { display: none; }
}
