:root {
  /* ---- 팔레트 (지정된 컬러 가이드) ---- */
  --mint: #eaf7f2;
  --pink: #fceef3;
  --sky: #eef7fd;
  --cream: #fff9e8;
  --lavender: #f5f0ff;
  --bg: #fcfcfa;

  --mint-strong: #74c9a8;
  --pink-strong: #ff9fb8;
  --sky-strong: #7bb8ee;
  --cream-strong: #e8b93c;
  --lavender-strong: #a68af0;

  --surface: #ffffff;
  --text: #3c3a45;
  --text-muted: #9b98a8;
  --text-faint: #c9c6d6;
  --border: #f1eff8;

  --income: #6fc2a4;
  --expense: #ff96ab;

  --radius-lg: 24px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-card: 0 10px 26px rgba(150, 140, 180, 0.09);
  --shadow-fab: 0 12px 26px rgba(255, 159, 184, 0.5);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

:focus-visible {
  outline: 2px solid var(--sky-strong);
  outline-offset: 2px;
  border-radius: 8px;
}

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

/* ================= 앱 셸 ================= */
.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.screen {
  padding: 22px 20px 108px;
  animation: fadeUp 0.32s cubic-bezier(.22,.9,.35,1);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  animation: cardIn 0.35s cubic-bezier(.22,.9,.35,1) backwards;
}

.screen > .card:nth-of-type(1) { animation-delay: .02s; }
.screen > .card:nth-of-type(2) { animation-delay: .06s; }
.screen > .card:nth-of-type(3) { animation-delay: .10s; }
.screen > .card:nth-of-type(4) { animation-delay: .14s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
}

.muted { color: var(--text-muted); font-size: 13px; }
.is-error { color: var(--expense) !important; }
.is-income { color: var(--income); }
.is-expense { color: var(--expense); }

/* ================= 하단 탭바 ================= */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -8px 20px rgba(150, 140, 180, 0.07);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 20px;
  border-radius: 16px;
  transition: color .18s ease, background .18s ease, transform .12s ease;
}

.bottom-nav__item.is-active {
  color: var(--mint-strong);
  background: var(--mint);
}

.bottom-nav__item:active { transform: scale(0.92); }

/* ================= FAB ================= */
.fab {
  position: fixed;
  right: max(20px, calc(50vw - 195px));
  bottom: 96px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffb3c6, var(--pink-strong));
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  z-index: 30;
  transition: transform .15s cubic-bezier(.22,.9,.35,1);
}

.fab:active { transform: scale(0.9); }

/* ================= 공용 리스트 아이템 ================= */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  margin-bottom: 6px;
  transition: transform .12s ease;
}

.list-item:active { transform: scale(0.98); }

.list-item__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sky);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.list-item__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  min-width: 0;
}

.list-item__info span { display: inline-flex; align-items: center; gap: 4px; }

.list-item__amount { font-size: 14px; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
}

/* ================= 버튼 / 폼 ================= */
.add-btn {
  width: 100%;
  padding: 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}

.add-btn--mint { background: var(--mint); color: var(--mint-strong); }

.btn {
  padding: 13px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  transition: transform .12s ease;
}
.btn:active { transform: scale(0.96); }
.btn--primary { background: var(--pink-strong); color: #fff; }
.btn--ghost { background: var(--border); color: var(--text-muted); }

.form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.form__label { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-top: 10px; }
.form__input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
}
.form__input:focus { border-color: var(--pink-strong); }
.form__input--amount { font-size: 20px; font-weight: 800; }
.form__textarea { resize: none; line-height: 1.5; font-family: inherit; min-height: 72px; }
.form__checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.form__actions { display: flex; gap: 10px; margin-top: 18px; }

.tab-group { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-group button {
  flex: 1;
  padding: 11px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  transition: background .15s ease, color .15s ease;
}
.tab-group--pastel button.is-active { background: var(--pink-strong); color: #fff; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 4px 0 4px;
}
.cat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 11px;
  color: var(--text-muted);
  border: 1.5px solid transparent;
  transition: transform .12s ease;
}
.cat-chip__icon { font-size: 19px; }
.cat-chip.is-selected {
  background: var(--pink);
  border-color: var(--pink-strong);
  color: var(--text);
  transform: scale(1.04);
}

/* ================= 모달(바텀시트) ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 58, 69, 0.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity .2s ease;
}
.modal-overlay.is-open { opacity: 1; }

.modal-sheet {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 86vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform .25s cubic-bezier(.22,.9,.35,1);
}
.modal-overlay.is-open .modal-sheet { transform: translateY(0); }

.modal-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-sheet__head strong { font-size: 16px; font-weight: 800; }
.modal-sheet__head button { color: var(--text-muted); }

/* ================= 토스트 ================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translate(-50%, 12px);
  background: rgba(60, 58, 69, 0.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
  max-width: 88vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ================= PIN 화면 ================= */
#pin-gate { max-width: 430px; margin: 0 auto; }

.pin-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: linear-gradient(180deg, var(--mint) 0%, var(--bg) 55%);
  text-align: center;
}
.pin-screen__logo { font-size: 44px; margin-bottom: 6px; }
.pin-screen h1 { font-size: 19px; font-weight: 800; margin: 4px 0 4px; }
.pin-screen .muted { margin-bottom: 26px; }

.pin-dots { display: flex; gap: 16px; margin-bottom: 34px; }
.pin-dots.is-shake { animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--pink-strong);
  background: transparent;
  transition: background .15s ease;
}
.pin-dot.is-filled { background: var(--pink-strong); }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  width: 100%;
  max-width: 280px;
}
.pin-keypad button {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  transition: transform .1s ease, background .1s ease;
}
.pin-keypad button:active { transform: scale(0.92); background: var(--pink); }
.pin-keypad span { }

.pin-skip {
  margin-top: 26px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
}

/* ================= 홈 ================= */
.home__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.home__logo { font-size: 22px; }
.home__brand strong { font-size: 19px; font-weight: 800; }

.home__summary {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  background: linear-gradient(150deg, var(--pink) 0%, var(--sky) 100%);
}
.home__summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  flex: 1;
}
.home__summary-item strong { font-size: 16px; }

.home__budget { margin-bottom: 16px; }
.home__budget-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.home__budget-head strong { flex: 1; font-size: 17px; }
.home__budget-edit { font-size: 13px; }
.home__budget-track {
  height: 9px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 8px;
}
.home__budget-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--mint-strong), #a4e3c9);
}
.home__budget-foot {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.home__section { margin-bottom: 20px; }
.home__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.home__more { font-size: 12px; color: var(--text-muted); font-weight: 700; }

.goal-list { display: flex; flex-direction: column; gap: 10px; }
.goal-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  transition: transform .12s ease;
}
.goal-card:active { transform: scale(0.98); }
.goal-card__head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
.goal-card__pct { color: var(--lavender-strong); font-weight: 800; }
.goal-card__track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 8px; }
.goal-card__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #c8b6ff, var(--lavender-strong)); }
.goal-card__foot { display: flex; gap: 4px; font-size: 12px; }

.home__recent-list { display: flex; flex-direction: column; }

.home__quote {
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 24px 0 8px;
  line-height: 1.6;
}

.goal-detail { background: var(--lavender); border-radius: var(--radius-md); padding: 16px; margin-bottom: 4px; }
.goal-detail__amount { display: block; font-size: 20px; font-weight: 800; }

/* ================= 가계부 ================= */
.ledger__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ledger__header h1 { font-size: 19px; font-weight: 800; margin: 0; }
.ledger__excel {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mint-strong);
  background: var(--mint);
  padding: 7px 12px;
  border-radius: 999px;
}

.ledger__month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 700;
}
.ledger__month-nav button {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.ledger__summary {
  display: flex;
  gap: 20px;
  margin-bottom: 14px;
}
.ledger__summary > div { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ledger__summary strong { font-size: 16px; }

.ledger__search-row { margin-bottom: 10px; }
.ledger__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 999px;
  padding: 11px 16px;
  box-shadow: var(--shadow-card);
  color: var(--text-faint);
}
.ledger__search input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.ledger__filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.chip {
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-size: 12.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chip.is-active { background: var(--pink-strong); color: #fff; box-shadow: none; }

.ledger__day-group { margin-bottom: 16px; }
.ledger__day-label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin: 0 0 6px 4px; }

/* ================= 통계 ================= */
.stats-page__header h1 { font-size: 19px; font-weight: 800; margin: 0 0 16px; }
.stats-page__card { margin-bottom: 16px; }

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
  font-size: 15px;
}
.calendar-nav button {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg);
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.calendar-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 12.5px;
}
.calendar-cell.is-muted { color: var(--text-faint); }
.calendar-cell.is-today { background: var(--sky); color: var(--sky-strong); font-weight: 700; }
.calendar-cell.is-selected { background: var(--pink-strong); color: #fff; font-weight: 700; }
.calendar-dot {
  position: absolute;
  bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--expense);
}
.calendar-dot--static { position: static; display: inline-block; }
.calendar-legend {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 10px;
}

.stats-page__chart-row { display: flex; align-items: center; gap: 18px; }

.donut { position: relative; border-radius: 50%; flex-shrink: 0; }
.donut::after { content: ''; position: absolute; inset: 24%; background: var(--surface); border-radius: 50%; }
.donut__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1; text-align: center;
}

.legend { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.legend__item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend__name { flex: 1; }

.stats-page__bars { display: flex; flex-direction: column; gap: 14px; }
.stats-page__bar-row { display: flex; align-items: center; gap: 10px; }
.stats-page__bar-label { width: 30px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.stats-page__bar-pair { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.stats-page__bar-track { height: 7px; border-radius: 999px; background: var(--border); overflow: hidden; }
.stats-page__bar-fill { height: 100%; border-radius: 999px; }
.stats-page__bar-fill.is-income { background: var(--income); }
.stats-page__bar-fill.is-expense { background: var(--expense); }
.stats-page__bar-legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--text-muted); }
.stats-page__bar-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.stats-page__bar-legend .dot.is-income { background: var(--income); }
.stats-page__bar-legend .dot.is-expense { background: var(--expense); }

.top5-list { display: flex; flex-direction: column; gap: 10px; }
.top5-list li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.top5-rank {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--cream);
  color: var(--cream-strong);
  font-size: 11px; font-weight: 800;
  flex-shrink: 0;
}
.top5-icon { font-size: 16px; }
.top5-name { flex: 1; }
