:root {
  --bg: #f8faf9;
  --card: #fff;
  --ink: #1c2420;
  --muted: #5e6b64;
  --line: #e3ebe6;
  --brand: #1b6b4a;
  --on-brand: #fff;
  --soft: #e7f3ec;
  --expense: #d64545;
  --income: #2f6fde;
  --shadow: 0 8px 28px rgba(27, 50, 40, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --card: #1c201e;
    --ink: #e8eeea;
    --muted: #a3b0a8;
    --line: #2c3330;
    --brand: #7fd3a8;
    --on-brand: #00391f;
    --soft: #163528;
    --expense: #ff8a80;
    --income: #8ab4f8;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
/* hidden 속성이 display 지정에 지지 않게 한다. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { min-height: 100%; }

.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 96px; }
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
}
h1 { font-size: 28px; margin: 8px 0 4px; }
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
}
textarea { min-height: 72px; resize: vertical; }
.primary, .ghost, .seg button, .chip, .nav button {
  border: 0;
  border-radius: 12px;
}
.primary {
  background: var(--brand);
  color: var(--on-brand);
  padding: 14px 16px;
  font-weight: 650;
}
.primary:disabled { opacity: 0.45; cursor: default; }
.ghost { background: transparent; color: var(--muted); padding: 8px; }
.seg { display: flex; gap: 6px; background: var(--soft); padding: 4px; border-radius: 14px; }
.seg button { flex: 1; background: transparent; padding: 10px; }
.seg button.on { background: var(--card); font-weight: 650; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.error { color: var(--expense); font-size: 14px; margin: 0; }
.top {
  display: flex; align-items: center; gap: 12px;
  max-width: 720px; margin: 0 auto; padding: 14px 16px 0;
}
.top h1 { font-size: 20px; margin: 0; }
.top .spacer { flex: 1; }
.month { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 12px; }
.month strong { font-size: 18px; }
.sums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.sum { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.sum span { display: block; color: var(--muted); font-size: 12px; }
.sum b { display: block; font-size: clamp(12px, 3.4vw, 15px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense { color: var(--expense); }
.income { color: var(--income); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); padding: 8px 12px; white-space: nowrap; }
.chip.on { background: var(--soft); border-color: transparent; font-weight: 650; }
.day { margin: 16px 0 6px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.row, .asset {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-bottom: 8px; width: 100%; text-align: left;
}
.emoji { font-size: 22px; width: 36px; text-align: center; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 650; }
.sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount { font-weight: 700; white-space: nowrap; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.nav button { background: transparent; padding: 10px 18px; color: var(--muted); }
.nav button.on { color: var(--ink); font-weight: 700; }
.fab {
  position: fixed; right: max(16px, calc(50% - 344px)); bottom: 76px;
  border: 0; border-radius: 999px; background: var(--brand); color: var(--on-brand);
  padding: 14px 18px; font-weight: 700; box-shadow: var(--shadow);
}
.sheet {
  position: fixed; inset: 0; background: var(--bg); z-index: 2; overflow: auto;
}
.sheet .wrap { padding-top: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
.pick {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 4px;
}
.pick.on { border-color: var(--brand); background: var(--soft); }
.pick:disabled { cursor: default; color: var(--muted); }
.pick.on:disabled { color: var(--ink); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); }
.empty { text-align: center; padding: 32px 8px; }
.group { margin-top: 18px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }

/* 설정·자산 편집(manage.js) */
.spacer { flex: 1; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.line { padding: 6px 0; border-top: 1px solid var(--line); }
.card.wide { width: 100%; padding: 18px 16px; }
.big { font-size: 22px; }
.code { font-size: 26px; letter-spacing: 2px; }
.outline {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; font-weight: 600;
}
.row.static { cursor: default; }
.row .plain { border: 0; background: transparent; text-align: left; padding: 0; font: inherit; color: inherit; }
.row.dim { opacity: 0.55; }
.wrap-chips { flex-wrap: wrap; overflow: visible; }
.danger { color: var(--expense); }
h2 { font-size: 15px; color: var(--muted); margin: 18px 0 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-title { font-size: 14px; color: var(--muted); }
.stack > .ghost:first-child { align-self: flex-start; }
