/* ==========================================================
   꿈과 희망 — Design System
   ========================================================== */
:root {
  /* color tokens (fixed by brand spec) */
  --bg: #FAF3EF;
  --card: #FFFFFF;
  --accent: #F05A28;
  --text: #2C2927;
  --text-sub: #79685F;
  --border: #E8DCD5;

  /* derived tokens — tints of the same palette, no extra hues */
  --accent-soft: #FDEDE6;
  --accent-press: #D94A1C;
  --line-soft: #F1E8E2;
  --muted-fill: #F5ECE7;
  --text-faint: #A8978E;
  --neutral-bar: #C9B6AB;
  --success: #3C7A5A;      /* used only for tiny "완료" check */
  --danger: #C2410C;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-card: 0 1px 2px rgba(44, 41, 39, .04), 0 6px 20px rgba(121, 104, 95, .07);
  --shadow-float: 0 8px 28px rgba(121, 104, 95, .16);

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.won { font-size: .72em; font-weight: 600; margin-left: 2px; letter-spacing: 0; }

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

/* ---------- screen transitions ---------- */
.screen { animation: screenIn .38s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .char-btn, .bar-fill { animation: none !important; transition: none !important; } }

/* ==========================================================
   1. Character select (entry)
   ========================================================== */
.entry {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(28px + var(--safe-t)) 20px calc(20px + var(--safe-b));
}
.entry-top { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-top: 8px; }

.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo-mark { width: 26px; height: 26px; flex: none; }
.logo-word { font-size: 30px; font-weight: 800; letter-spacing: -0.05em; color: var(--text); }
.logo.sm .logo-mark { width: 18px; height: 18px; }
.logo.sm .logo-word { font-size: 18px; letter-spacing: -0.04em; }

.couple { width: min(270px, 74vw); margin: 22px 0 6px; }
.couple svg { display: block; width: 100%; height: auto; overflow: visible; }

.tagline { margin: 6px 0 0; font-size: 16px; color: var(--text-sub); font-weight: 500; letter-spacing: -0.02em; }

.entry-bottom { padding-top: 24px; }
.entry-q { text-align: center; font-size: 14px; color: var(--text-sub); margin: 0 0 12px; font-weight: 500; }
.char-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.char-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 10px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
  min-height: 176px;
}
.char-btn:active { transform: scale(.97); }
@media (hover: hover) { .char-btn:hover { border-color: var(--accent); } }
.char-btn.picked { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-card); }
.char-face { width: 96px; height: 104px; }
.char-face svg { width: 100%; height: 100%; display: block; }
.char-name { font-size: 19px; font-weight: 700; letter-spacing: -0.03em; }
.char-go { font-size: 12.5px; color: var(--text-sub); display: inline-flex; align-items: center; gap: 3px; }

.notice {
  margin: 16px 0 0;
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12px; line-height: 1.55; color: var(--text-sub);
  background: rgba(255, 255, 255, .55);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.notice svg { flex: none; margin-top: 2px; }

/* ==========================================================
   2. Shell: header + bottom nav
   ========================================================== */
.shell { padding: calc(8px + var(--safe-t)) 16px calc(var(--nav-h) + 28px + var(--safe-b)); }

.topbar { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.topbar-left { display: flex; flex-direction: column; }
.topbar-month { font-size: 12.5px; color: var(--text-sub); font-weight: 500; margin-top: 1px; }
.me-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  min-height: 44px;
}
.me-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--muted-fill); overflow: hidden; display: grid; place-items: center; }
.me-avatar svg, .income-avatar svg { width: 100%; height: 100%; display: block; }
.me-name { font-size: 14px; font-weight: 600; }

.sample-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-sub);
  background: var(--muted-fill);
  border-radius: 999px; padding: 6px 12px; margin: 4px 0 14px;
  width: fit-content;
}
.sample-chip b { color: var(--text); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.nav-inner { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.nav-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--text-faint); font-weight: 500; }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* ==========================================================
   3. Cards & dashboard
   ========================================================== */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 12px;
}
.card-label { font-size: 13.5px; color: var(--text-sub); font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head .meta { font-size: 12.5px; color: var(--text-sub); }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-sub); margin: 22px 4px 10px; letter-spacing: -0.01em; }

/* hero: 생활비 통장 잔액 */
.hero { padding: 22px 20px 18px; }
.hero-amount { font-size: 34px; font-weight: 800; letter-spacing: -0.04em; margin: 4px 0 2px; line-height: 1.2; }
.hero-amount .won { font-size: 22px; font-weight: 700; }
.hero-sub { font-size: 12.5px; color: var(--text-sub); }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; color: var(--text-sub);
  background: var(--muted-fill); border-radius: 6px; padding: 3px 7px; line-height: 1.3;
}
.tag.accent { color: var(--accent); background: var(--accent-soft); }

.hero-split { display: grid; grid-template-columns: 1fr 1fr; margin-top: 16px; border-top: 1px solid var(--line-soft); }
.hero-split > div { padding-top: 14px; }
.hero-split > div + div { padding-left: 16px; border-left: 1px solid var(--line-soft); }
.mini-label { font-size: 12px; color: var(--text-sub); }
.mini-val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.mini-val.accent { color: var(--accent); }

/* deposits */
.dep-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--muted-fill); overflow: hidden; display: flex; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s cubic-bezier(.2, .8, .2, 1); }
.bar-fill.neutral { background: var(--neutral-bar); }
.bar.stack .bar-fill { border-radius: 0; }
.bar.stack .bar-fill:first-child { border-radius: 99px 0 0 99px; }
.dep-progress .pct { font-size: 12.5px; color: var(--text-sub); min-width: 36px; text-align: right; }

.dep-list { list-style: none; margin: 10px 0 0; padding: 0; }
.dep-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.dep-item:first-child { border-top: 0; }
.dep-main { flex: 1; min-width: 0; }
.dep-name { font-size: 15px; font-weight: 600; }
.dep-from { font-size: 12.5px; color: var(--text-sub); }
.dep-amt { font-size: 15px; font-weight: 700; text-align: right; }
.dep-amt.done { color: var(--text-faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.check {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px;
}
.check span {
  width: 26px; height: 26px; border-radius: 50%; border: 1.8px solid var(--border);
  display: grid; place-items: center; transition: all .15s ease; background: #fff;
}
.check[aria-pressed="true"] span { background: var(--accent); border-color: var(--accent); }
.check svg { opacity: 0; transition: opacity .15s; }
.check[aria-pressed="true"] svg { opacity: 1; }

/* settlement */
.settle { position: relative; overflow: hidden; }
.settle-amount { font-size: 30px; font-weight: 800; color: var(--accent); letter-spacing: -0.04em; margin: 2px 0 2px; line-height: 1.2; }
.settle-amount .won { font-size: 20px; }
.settle-meta { font-size: 12.5px; color: var(--text-sub); }
.settle-row { display: flex; gap: 8px; margin-top: 16px; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: var(--muted-fill); color: var(--text); }
.btn-block { flex: 1; }

/* budget */
.budget-legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12.5px; color: var(--text-sub); flex-wrap: wrap; }
.budget-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.budget-legend b { color: var(--text); font-weight: 600; margin-left: 4px; }
.budget-remain { font-size: 24px; font-weight: 800; letter-spacing: -0.04em; margin: 2px 0 12px; }
.budget-remain .won { font-size: 16px; }
.hint {
  margin-top: 14px; font-size: 12px; color: var(--text-sub);
  display: flex; gap: 6px; align-items: flex-start;
  padding-top: 12px; border-top: 1px solid var(--line-soft);
}

/* income */
.income-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.income-row + .income-row { border-top: 1px solid var(--line-soft); }
.income-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--muted-fill); overflow: hidden; display: grid; place-items: center; flex: none; }

.income-main { flex: 1; }
.income-who { font-size: 14.5px; font-weight: 600; }
.income-when { font-size: 12.5px; color: var(--text-sub); }
.income-amt { text-align: right; font-weight: 700; font-size: 15px; }
.income-amt small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-sub); }
.income-amt.pending { color: var(--text-faint); }
.income-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line-soft); font-size: 13px; color: var(--text-sub); }
.income-total b { font-size: 16px; color: var(--text); }

/* savings / assets pair */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.pair .card { margin-bottom: 0; padding: 16px; }
.stat-val { font-size: 19px; font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; }
.stat-val .won { font-size: 13px; }
.stat-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.ring-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

/* recent tx */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.tx + .tx, .tx-list > li + li { border-top: 1px solid var(--line-soft); }
.tx-ico { width: 38px; height: 38px; border-radius: 12px; background: var(--muted-fill); display: grid; place-items: center; flex: none; color: var(--text-sub); }
.tx-main { flex: 1; min-width: 0; }
.tx-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--text-sub); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx-amt { font-size: 15px; font-weight: 700; text-align: right; white-space: nowrap; }
.tx-amt.plus { color: var(--accent); }
.tx-amt.move { color: var(--text-sub); font-weight: 600; }
.link-more { width: 100%; min-height: 44px; margin-top: 6px; font-size: 13.5px; color: var(--text-sub); font-weight: 600; border-radius: 12px; background: var(--muted-fill); }

/* ---------- placeholder (not-yet-built) screens ---------- */
.empty { text-align: center; padding: 44px 24px 36px; }
.empty-ill { width: 92px; height: 100px; margin: 0 auto 14px; opacity: .9; }
.empty h2 { font-size: 18px; margin: 0 0 6px; letter-spacing: -0.03em; }
.empty p { margin: 0 auto; color: var(--text-sub); font-size: 14px; max-width: 280px; }
.empty .stage { display: inline-block; margin-top: 14px; }
.plan-list { list-style: none; padding: 0; margin: 0; }
.plan-list li { padding: 12px 0; border-top: 1px solid var(--line-soft); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.plan-list li:first-child { border-top: 0; }
.plan-list li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--border); margin-top: 8px; flex: none; }

/* ---------- user sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(44, 41, 39, .32); z-index: 40; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 480px; margin: 0 auto;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + var(--safe-b));
  animation: sheetUp .28s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 16px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.03em; }
.sheet p { margin: 0 0 16px; font-size: 13px; color: var(--text-sub); }
.sheet-actions { display: grid; gap: 8px; }
.sheet-actions .btn { width: 100%; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--safe-b)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: #fff; font-size: 13.5px; font-weight: 500;
  padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-float);
  transition: all .25s ease; max-width: calc(100vw - 32px); width: max-content;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================
   2단계: 상태 화면 · 로그인 · 폼 · 설정
   ========================================================== */
body.no-scroll { overflow: hidden; }

.center-screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); gap: 6px;
}
.center-screen h2 { margin: 6px 0 2px; font-size: 19px; letter-spacing: -0.03em; }
.center-screen p { margin: 0 0 14px; color: var(--text-sub); font-size: 14px; max-width: 320px; }
.state-ill { width: 96px; height: 104px; }
.missing-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.missing-list code { font-size: 13px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }

.loader-dots { display: inline-flex; gap: 6px; margin-bottom: 8px; }
.loader-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: dot 1s infinite ease-in-out both; }
.loader-dots i:nth-child(2) { animation-delay: .15s; }
.loader-dots i:nth-child(3) { animation-delay: .3s; }
.loader-dots.sm i { width: 6px; height: 6px; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: none; } }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-notice {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  font-size: 13px; line-height: 1.5; border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 12px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.auth-notice svg { flex: none; margin-top: 1px; }
.auth-notice.ok svg { color: var(--success); }
.auth-notice.warn, .auth-notice.error { border-color: #F3C7B5; background: var(--accent-soft); }
.auth-notice.error svg, .auth-notice.warn svg { color: var(--danger); }

.char-btn { position: relative; }
.char-btn.mine { border-color: var(--accent); }
.char-badge {
  position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 7px;
}
.char-btn:disabled { opacity: 1; }

.login-sheet { text-align: center; }
.login-face { width: 64px; height: 64px; border-radius: 50%; background: var(--muted-fill); overflow: hidden; margin: 0 auto 10px; }
.login-face svg { width: 100%; height: 100%; display: block; }
.gbtn { min-height: 52px; display: flex; justify-content: center; align-items: center; flex-direction: column; gap: 8px; margin: 4px 0 10px; }
.fine { font-size: 12px !important; color: var(--text-faint) !important; margin: 0 !important; }

.status-chip { font-size: 12px; font-weight: 600; color: var(--text-sub); background: var(--muted-fill); border-radius: 8px; padding: 5px 9px; flex: none; }
.status-chip.ok { color: var(--success); background: #E9F2EC; }
.empty-inline { font-size: 13.5px; color: var(--text-sub); margin: 4px 0 12px; }
.budget-remain.over { color: var(--danger); }
.bar-fill.faint { background: var(--border); }

.btn-sm { min-height: 40px; padding: 0 14px; font-size: 13.5px; border-radius: 12px; }
.btn-danger { background: #FBE4DC; color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn .spinner { margin-right: 2px; }

/* form */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-sub); }
.field-hint { font-size: 12px; color: var(--text-faint); }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1.5px solid var(--border); border-radius: 12px; outline: none; appearance: none; -webkit-appearance: none;
}
.input:focus { border-color: var(--accent); }
.input.invalid { border-color: var(--danger); }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2379685F' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input[type="date"].input { line-height: 46px; }
.money-wrap { position: relative; }
.money-wrap .input { padding-right: 36px; text-align: right; font-weight: 600; }
.money-unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-sub); font-size: 14px; pointer-events: none; }
.money-wrap.signed .input { padding-left: 50px; }
.sign-btn {
  position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 38px; border-radius: 9px; background: var(--muted-fill);
  font-size: 18px; font-weight: 700; color: var(--text-sub); line-height: 1;
}
.sign-btn[aria-pressed="true"] { color: var(--danger); background: #FBE4DC; }

/* 모바일 터치: 더블탭 확대 지연 제거, 가로 넘침 방지 */
button, a, input, select, label { touch-action: manipulation; }
html, body { overflow-x: hidden; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--muted-fill); border-radius: 12px; padding: 3px; gap: 3px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-sub); }
.seg-opt input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(44, 41, 39, .1); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin-bottom: 14px; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 1px; flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
/* 휴대폰(갤럭시 360~412px, 아이폰 375~430px)에서는 큰 금액이 잘리지 않도록 한 줄에 하나씩 */
@media (max-width: 440px) { .grid-2 { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-size: 13px; margin: -4px 0 12px; display: flex; gap: 6px; }

/* sheet with forms */
.sheet { max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-body h3 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.03em; }
.sheet-body > p { margin: 0 0 16px; font-size: 13px; color: var(--text-sub); }

/* setup wizard */
.setup { padding: calc(12px + var(--safe-t)) 16px calc(110px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.setup-top { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.setup-progress { display: flex; gap: 4px; margin: 6px 0 18px; }
.setup-progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.setup-progress i.on { background: var(--accent); }
.setup-step { font-size: 12.5px; color: var(--accent); font-weight: 700; }
.setup h1 { font-size: 22px; letter-spacing: -0.04em; margin: 2px 0 6px; }
.setup .lead { color: var(--text-sub); font-size: 14px; margin: 0 0 18px; }
.setup-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(250, 243, 239, .94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + var(--safe-b));
}
.setup-foot-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.item-card { background: var(--card); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 16px 16px 4px; margin-bottom: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.item-title { font-size: 15px; font-weight: 700; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text-sub); flex: none; }
.icon-btn:active { background: var(--muted-fill); }
.add-btn {
  width: 100%; min-height: 52px; border: 1.5px dashed var(--border); border-radius: var(--radius-md);
  color: var(--text-sub); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 12px;
}
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 14px; }
.review-list li:first-child { border-top: 0; }
.review-list .sub { color: var(--text-sub); font-size: 12.5px; }

/* settings */
.page-head { display: flex; align-items: center; gap: 4px; margin: 2px 0 12px; }
.page-head h2 { font-size: 19px; letter-spacing: -0.03em; margin: 0; }
.menu { list-style: none; margin: 0; padding: 0; }
.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 0; text-align: left;
  border-top: 1px solid var(--line-soft);
}
.menu li:first-child .menu-row { border-top: 0; }
.menu-ico { width: 36px; height: 36px; border-radius: 11px; background: var(--muted-fill); display: grid; place-items: center; color: var(--text-sub); flex: none; }
.menu-ico { overflow: hidden; }
.menu-ico svg:not([width]) { width: 100%; height: 100%; }
.menu-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-title { font-size: 15px; font-weight: 600; }
.menu-sub { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-val { font-size: 14px; font-weight: 700; white-space: nowrap; }
.menu-row .chev { color: var(--text-faint); flex: none; }
.menu-row.inactive .menu-title { color: var(--text-faint); }
.profile { display: flex; align-items: center; gap: 12px; }
.profile .me-avatar { width: 48px; height: 48px; }
.log-diff { font-size: 12.5px; background: var(--muted-fill); border-radius: 10px; padding: 10px 12px; margin-top: 8px; word-break: break-all; }
.log-diff div + div { margin-top: 4px; }
.log-diff del { color: var(--text-faint); }

/* ---------- 3단계: 기록하기 · 거래내역 · 월급 · 입금 ---------- */
.fab {
  position: fixed; z-index: 25; right: max(16px, calc(50% - 240px + 16px));
  bottom: calc(var(--nav-h) + 16px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(240, 90, 40, .35);
  transition: transform .12s ease;
}
.fab:active { transform: scale(.94); }
@media (min-width: 900px) { .fab { right: calc(50% - 490px + 16px); } }

button.income-row, button.tx-btn { width: 100%; text-align: left; border-radius: 10px; }
button.income-row:active, button.tx-btn:active { background: var(--muted-fill); }
.income-row .income-main, .income-row .income-amt, .tx-btn .tx-main { display: flex; flex-direction: column; }
.income-amt { display: flex; flex-direction: column; align-items: flex-end; }
.tx-btn .tx-name { display: block; }
.tx-btn .tx-amt { display: flex; flex-direction: column; align-items: flex-end; }
.tx-by { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.tx-btn.is-deleted { opacity: .55; }
.tx-btn.is-deleted .tx-name { text-decoration: line-through; }
.dep-amt { display: flex; flex-direction: column; align-items: flex-end; }
.dep-part { font-size: 11.5px; font-weight: 600; color: var(--accent); }
.check span.half { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, #fff 50%); }
.check span.half svg { opacity: 0; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.month-nav h2 { font-size: 18px; margin: 0; letter-spacing: -0.03em; }
.sum-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 20px; }
.sum-card > div { display: flex; flex-direction: column; gap: 2px; }
.sum-card b { font-size: 18px; letter-spacing: -0.03em; }
.plus-c { color: var(--accent); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-sub); background: var(--card); border: 1px solid var(--border); }
.chip[aria-selected="true"] { color: #fff; background: var(--text); border-color: var(--text); }
.day-card { padding: 12px 16px 6px; }
.day-head { font-size: 12.5px; font-weight: 700; color: var(--text-sub); margin-bottom: 2px; }
.amount-big .money-wrap .input { font-size: 22px; min-height: 56px; }
.sub-h { font-size: 13px; color: var(--text-sub); margin: 16px 0 4px; }
.shell[data-tab="tx"], .shell[data-tab="home"] { padding-bottom: calc(var(--nav-h) + 96px + var(--safe-b)); }

/* ---------- 4단계: 카드 정산 ---------- */
.add-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.add-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 14px 6px; border-radius: 14px; background: var(--muted-fill); color: var(--text); min-height: 96px;
}
.add-tile b { font-size: 13px; }
.add-tile span { font-size: 11px; color: var(--text-sub); }
.add-tile svg { color: var(--accent); }
.add-tile:disabled { opacity: .5; }
.add-tile:disabled svg { color: var(--text-faint); }
.cl-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.cl-list { list-style: none; margin: 0; padding: 0; }
.cl-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.cl-list .cl-row:first-child { border-top: 0; }
.cl-check { position: relative; width: 36px; height: 36px; flex: none; display: grid; place-items: center; }
.cl-check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.cl-check span { width: 24px; height: 24px; border-radius: 7px; border: 1.8px solid var(--border); background: #fff; }
.cl-check input:checked + span { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center/16px no-repeat; border-color: var(--accent); }
.cl-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.cl-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-meta { font-size: 12px; color: var(--text-sub); }
.cl-amt { font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.btn-xs { min-height: 34px; padding: 0 10px; font-size: 12px; border-radius: 10px; flex: none; }
.sel-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); z-index: 24;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(121, 104, 95, .08);
}
.sel-bar-inner { max-width: 480px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.settle-sum { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 16px; font-size: 14px; color: var(--text-sub); }
.settle-sum .num { font-size: 24px; font-weight: 800; color: var(--accent); }
.paste-area { min-height: 180px; padding: 12px 14px; line-height: 1.5; font-size: 15px; resize: vertical; }
.review-rows { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.rv { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: #fff; }
.rv.off { opacity: .55; }
.rv-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.rv-top input { width: 20px; height: 20px; accent-color: var(--accent); }
.rv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.rv-grid .input { min-height: 44px; font-size: 15px; }
@media (max-width: 440px) { .rv-grid { grid-template-columns: 1fr; } }
.shell[data-tab="card"] { padding-bottom: calc(var(--nav-h) + 90px + var(--safe-b)); }

/* import */
.preview-list { list-style: none; margin: 0; padding: 0; }
.preview-list li { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 13.5px; }
.preview-list li:first-child { border-top: 0; }
.preview-list .pv-main { flex: 1; min-width: 0; }
.preview-list .pv-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-list .pv-meta { font-size: 12px; color: var(--text-sub); }
.preview-list .pv-err { font-size: 12px; color: var(--danger); }
.preview-list .pv-amt { font-weight: 700; white-space: nowrap; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag.danger { color: var(--danger); background: #FBE4DC; }
.tag.ok { color: var(--success); background: #E9F2EC; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ==========================================================
   Desktop: keep mobile density, use the width for 2 columns
   ========================================================== */
@media (min-width: 900px) {
  .app.wide { max-width: 980px; }
  .dash-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 0 20px; align-items: start; }
  .entry { max-width: 440px; margin: 0 auto; }
  .nav-inner { max-width: 520px; }
}
