:root {
  --text: #f2f6fb;
  --muted: rgba(226, 234, 245, .72);
  --muted2: rgba(226, 234, 245, .62);
  --faint: rgba(226, 234, 245, .35);
  --card: rgba(255, 255, 255, .07);
  --card-b: rgba(255, 255, 255, .13);
  --soft: rgba(255, 255, 255, .05);
  --soft2: rgba(255, 255, 255, .08);
  --track: rgba(255, 255, 255, .1);
  --mint: #5ef2b4;
  --ice: #9ff6ff;
  --red: #e8474f;
  --gold: #f7cf73;
  --gold-text: #f7d98f;
  --neg: #ff8a90;
  --navy: #0a1633;
  --sheet: #0e1a3a;
  --pop: #16224a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 60% at 50% 0%, #12305a 0%, #0a1633 45%, #060b1c 100%) fixed, #060b1c;
  color: var(--text);
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; }

.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal;
  text-transform: none; white-space: nowrap; direction: ltr; display: inline-block;
  font-feature-settings: 'liga'; -webkit-font-feature-settings: 'liga'; user-select: none;
  font-variation-settings: 'FILL' 0;
}
.ms.fill { font-variation-settings: 'FILL' 1; }

#sky { position: fixed; inset: 0; display: block; pointer-events: none; z-index: 0; }
html { overflow-x: hidden; }
#app {
  position: relative; z-index: 1; max-width: 440px; margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 14px) 0 calc(env(safe-area-inset-bottom) + 116px);
}
#app.no-tab { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }

/* ---------- layout helpers ---------- */
.screen { display: flex; flex-direction: column; gap: 10px; }
.px { padding-left: 16px; padding-right: 16px; }
.mx { margin-left: 16px; margin-right: 16px; }
.col { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.gap2 { gap: 2px; } .gap3 { gap: 3px; } .gap4 { gap: 4px; } .gap5 { gap: 5px; } .gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.num { font-variant-numeric: tabular-nums; }
.b6 { font-weight: 600; } .b7 { font-weight: 700; }
.xs { font-size: 12px; } .sm { font-size: 13px; } .fs14 { font-size: 14px; } .fs15 { font-size: 15px; } .fs16 { font-size: 16px; }
.muted { color: var(--muted); } .muted2 { color: var(--muted2); } .faint { color: var(--faint); }
.mint { color: var(--mint); } .ice { color: var(--ice); } .gold { color: var(--gold); } .neg { color: var(--neg); }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }

.card {
  border-radius: 26px; background: var(--card); border: 1px solid var(--card-b);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.panel { padding: 14px 16px; border-radius: 22px; background: var(--card); border: 1px solid var(--card-b); display: flex; flex-direction: column; gap: 10px; }
.panel.ice-panel { background: rgba(159, 246, 255, .07); border-color: rgba(159, 246, 255, .22); }
.tile { padding: 10px 14px; border-radius: 16px; background: rgba(255, 255, 255, .06); }
.tile.good { background: rgba(94, 242, 180, .1); }
.tile .v { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .k { font-size: 12px; color: var(--muted); }

.btn-round {
  width: 44px; height: 44px; border-radius: 22px; background: var(--soft2); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 22px; position: relative;
}
.btn-round.lg { width: 46px; height: 46px; border-radius: 23px; border: 1px solid rgba(255, 255, 255, .14); }
.btn-round.red { background: var(--red); font-size: 26px; }
.btn-round .dot { position: absolute; top: 10px; right: 11px; width: 8px; height: 8px; border-radius: 4px; background: #ff6b72; }
.btn-primary {
  height: 54px; border-radius: 18px; background: var(--red); box-shadow: 0 8px 24px rgba(232, 71, 79, .4);
  display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 17px; font-weight: 600; color: #fff; width: 100%;
}
.btn-primary:disabled { background: rgba(255, 255, 255, .12); box-shadow: none; color: var(--faint); cursor: default; }
.btn-primary.sm { height: 48px; border-radius: 16px; font-size: 15px; box-shadow: none; }
.btn-ghost {
  height: 48px; border-radius: 16px; background: rgba(255, 255, 255, .09);
  display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; font-weight: 600; width: 100%;
}
.btn-text { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14.5px; color: var(--muted); width: 100%; }
.btn-text.danger { color: var(--neg); }
.link { color: var(--mint); font-size: 13px; min-height: 32px; display: inline-flex; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.gold { background: rgba(247, 207, 115, .16); color: var(--gold); }

.bar { position: relative; border-radius: 5px; background: var(--track); }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; max-width: 100%; }
.bar > b { position: absolute; top: -4px; width: 2px; height: calc(100% + 8px); border-radius: 1px; background: #fff; transform: translateX(-1px); }

.cic { display: flex; align-items: center; justify-content: center; flex: none; }

.sec-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 24px 0; }
.sec-head > span:first-child { font-size: 16px; font-weight: 600; }

.list { display: flex; flex-direction: column; gap: 6px; }
.cat-row, .tx-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 18px; background: var(--soft); width: 100%;
}
.tx-row { padding: 10px 14px; }
.tx-row .amt { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 18px; border-radius: 18px; background: var(--soft); color: var(--muted); font-size: 13.5px; text-align: center; line-height: 1.5; }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; font-size: 13px; line-height: 1.45; }
.note .ms { font-size: 19px; }
.note.warn { background: rgba(247, 207, 115, .12); color: var(--gold-text); }
.note.ok { background: rgba(94, 242, 180, .1); color: var(--mint); }
.note.bad { background: rgba(255, 138, 144, .12); color: var(--neg); }

/* ---------- headers ---------- */
.home-head { display: flex; justify-content: space-between; align-items: center; padding: 0 22px; }
.logo { position: relative; display: flex; align-items: flex-end; gap: 8px; padding-top: 4px; }
.logo .word { position: relative; }
.logo .t {
  font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic; font-weight: 700; font-size: 40px;
  line-height: 1.1; letter-spacing: .3px; white-space: nowrap;
}
.logo .t.rim { position: absolute; left: 0; top: -3px; color: #fff; text-shadow: 0 -1px 0 #fff, 1px -1px 0 #fff, -1px -1px 0 #fff, 0 1px 2px rgba(90, 130, 190, .6); pointer-events: none; }
.logo .t.gold {
  position: relative; display: block;
  background: linear-gradient(180deg, #fff4d6 0%, #f3d58c 38%, #c9963f 62%, #f7dc95 82%, #a8772c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .4));
}
.logo .cap { position: absolute; height: 6px; border-radius: 50% 50% 45% 45%; background: radial-gradient(circle at 40% 30%, #fff 0 55%, #e3efff 100%); box-shadow: 0 1px 2px rgba(90, 130, 190, .55); pointer-events: none; }
.logo .star { display: flex; flex-direction: column; align-items: center; padding-bottom: 9px; }
.logo .star .ms { font-size: 20px; color: #f7dc95; filter: drop-shadow(0 0 6px rgba(247, 207, 115, .7)); }
.logo .star i { width: 1px; height: 10px; background: linear-gradient(#f7dc95, rgba(247, 220, 149, 0)); }

.page-head { display: flex; justify-content: space-between; align-items: center; padding: 0 22px; gap: 10px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.3; }
.sub-head { display: flex; justify-content: space-between; align-items: center; padding: 0 16px; gap: 10px; }
.sub-head .title { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ---------- 3D scene ---------- */
.scene-box { position: relative; }
.scene-slot { position: absolute; inset: 0; }
.scene-slot canvas { width: 100%; height: 100%; display: block; }
.bubble {
  position: absolute; top: 0; right: 8px; max-width: 62%; padding: 6px 11px; border-radius: 14px 14px 4px 14px;
  background: rgba(255, 255, 255, .92); color: #16203a; font-size: 12.5px; line-height: 1.4; font-weight: 500; z-index: 2;
}
.scene-chip {
  position: absolute; left: 14px; bottom: 6px; display: flex; gap: 6px; align-items: center; padding: 6px 11px; min-height: 32px;
  border-radius: 14px; background: rgba(6, 11, 28, .6); border: 1px solid rgba(255, 255, 255, .14); font-size: 12px; z-index: 2;
}
.scene-chip.ice-b { border-color: rgba(159, 246, 255, .3); font-size: 12.5px; }

/* ---------- home ---------- */
.safe { padding: 14px 18px; display: flex; flex-direction: column; gap: 9px; }
.big46 { font-size: 46px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.roll-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; text-align: left;
  background: rgba(159, 246, 255, .1); border: 1px solid rgba(159, 246, 255, .3);
}

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: min(412px, calc(100% - 28px)); height: 70px; border-radius: 35px;
  background: rgba(14, 22, 48, .78); border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  display: flex; align-items: center; justify-content: space-around; z-index: 20; font-size: 11px; color: var(--muted2);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 56px; min-height: 52px; }
.tab .ms { font-size: 24px; }
.tab.on { color: var(--mint); }
.tab.on .ms { font-variation-settings: 'FILL' 1; }
.tab-add { width: 54px; height: 54px; border-radius: 27px; background: var(--red); box-shadow: 0 6px 22px rgba(232, 71, 79, .55); display: flex; align-items: center; justify-content: center; color: #fff; }
.tab-add .ms { font-size: 30px; }

/* ---------- add transaction ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 16px; background: var(--card); height: 44px; }
.seg button { display: flex; align-items: center; justify-content: center; border-radius: 12px; font-size: 15px; font-weight: 600; color: var(--muted); }
.seg button.on-exp { background: var(--red); color: #fff; }
.seg button.on-inc { background: #2fbf8a; color: #fff; }
.amount-big { font-size: 58px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -1px; text-align: center; padding: 4px 0; overflow-wrap: anywhere; }
.field {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 14px;
  background: var(--card); border: 1px solid rgba(255, 255, 255, .1); font-size: 14px; color: rgba(226, 234, 245, .8);
}
.field input, .field select { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; color: var(--text); height: 42px; }
.field input::placeholder { color: var(--faint); }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-btn {
  height: 68px; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: var(--soft); border: 1.5px solid transparent; padding: 0 2px;
}
.cat-btn .ms { font-size: 23px; }
.cat-btn span:last-child { font-size: 11.5px; line-height: 1.2; text-align: center; }
.hint { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 14px; background: rgba(94, 242, 180, .1); font-size: 13px; line-height: 1.35; }
.hint .ms { font-size: 18px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.key { height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 500; background: rgba(255, 255, 255, .06); }
.key:active { background: rgba(255, 255, 255, .16); }
.date-chip { position: relative; display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--soft2); font-size: 13px; }
.date-chip .ms { font-size: 17px; }
.date-chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* ---------- planner ---------- */
.plan-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 18px; background: var(--soft); }
.plan-row.sav { padding: 10px 12px; background: rgba(94, 242, 180, .1); border: 1px solid rgba(94, 242, 180, .25); }
.money {
  width: 112px; padding: 8px 12px; border-radius: 12px; background: var(--soft2); border: 1px solid transparent;
  font-size: 16px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; outline: none;
}
.money:focus { border-color: var(--mint); background: rgba(94, 242, 180, .08); }
.money.big { width: 100%; font-size: 34px; font-weight: 700; padding: 0; background: none; text-align: left; border-radius: 8px; }
.money.big:focus { background: rgba(94, 242, 180, .06); }
.dd-btn { display: flex; align-items: center; gap: 4px; align-self: flex-start; padding: 3px 6px 3px 10px; min-height: 30px; border-radius: 10px; background: rgba(6, 11, 28, .55); font-size: 12.5px; font-weight: 600; }
.dd-btn .ms { font-size: 18px; }
.dd-backdrop { position: fixed; inset: 0; z-index: 4; }
.dd-panel {
  position: absolute; top: calc(100% - 6px); left: 56px; right: 12px; padding: 6px; border-radius: 18px; z-index: 5;
  background: var(--pop); border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column; gap: 2px;
}
.dd-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border-radius: 12px; width: 100%; }
.dd-item.on { background: rgba(94, 242, 180, .1); }
.dd-item.add { color: var(--mint); font-size: 13px; min-height: 44px; }
.x-btn { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: rgba(255, 138, 144, .14); color: var(--neg); flex: none; }
.alloc-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--track); }
.pay-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: rgba(247, 207, 115, .1); border: 1px solid rgba(247, 207, 115, .22); text-align: left; }

/* ---------- goals ---------- */
.goal-card { border-radius: 28px; overflow: hidden; }
.goal-cover { height: 116px; position: relative; display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 18px; overflow: hidden; }
.goal-cover .bg-ic { position: absolute; right: -10px; top: -18px; font-size: 130px; opacity: .14; }
.goal-cover .name { font-size: 24px; font-weight: 700; letter-spacing: 2px; line-height: 1.2; }
.goal-chip { padding: 5px 10px; border-radius: 12px; background: rgba(6, 11, 28, .6); font-size: 13px; font-weight: 600; flex: none; }
.knob { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 11px; background: var(--ice); border: 3px solid var(--navy); }
.goal-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: rgba(255, 255, 255, .06); width: 100%; text-align: left; }

/* ---------- forest ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.day > span:first-child { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 19px; }
.day.done > span:first-child { background: var(--ice); color: var(--navy); }
.day.today > span:first-child { border: 2px solid var(--ice); color: var(--ice); }
.day.future > span:first-child, .day.miss > span:first-child { background: rgba(255, 255, 255, .06); color: var(--faint); }
.day > span:last-child { font-size: 11.5px; color: rgba(226, 234, 245, .7); }
.orn-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.orn { aspect-ratio: 1; border-radius: 50%; }
.orn.locked { background: rgba(255, 255, 255, .05); border: 1.5px dashed rgba(255, 255, 255, .22); display: flex; align-items: center; justify-content: center; font-size: 14px; color: rgba(226, 234, 245, .4); }
.evo { position: relative; display: flex; }
.evo .line { position: absolute; left: 12.5%; right: 12.5%; top: 25px; height: 3px; border-radius: 2px; background: var(--track); }
.evo .line i { display: block; height: 100%; background: var(--ice); }
.evo-node { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; position: relative; }
.evo-node > span:first-child { width: 52px; height: 52px; border-radius: 26px; display: flex; align-items: center; justify-content: center; font-size: 26px; }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 16, .6); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet {
  width: 100%; max-width: 440px; max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain;
  border-radius: 36px 36px 0 0; background: var(--sheet); border-top: 1px solid rgba(255, 255, 255, .14);
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 18px); display: flex; flex-direction: column; gap: 12px;
  animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet .handle { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); flex: none; }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 700; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.roll-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 14px; border-radius: 18px; width: 100%; text-align: left; }
.chip-btn { height: 40px; padding: 0 14px; border-radius: 20px; display: flex; align-items: center; font-size: 13.5px; font-weight: 600; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06); }
.chip-btn.on { background: var(--ice); color: var(--navy); border-color: var(--ice); }
.swatch { width: 36px; height: 36px; border-radius: 18px; border: 3px solid transparent; }
.swatch.on { border-color: #fff; }
.icon-pick { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--soft2); font-size: 22px; border: 1.5px solid transparent; }
.icon-pick.on { border-color: var(--mint); color: var(--mint); }
.lbl { font-size: 13px; color: var(--muted); padding: 0 4px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--mint); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
input[type=range] { width: 100%; accent-color: var(--mint); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 100px); transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 14px; background: rgba(255, 255, 255, .95); color: #16203a; font-size: 14px; font-weight: 500; animation: up .2s; max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-wrap, .toast { animation: none; }
}
