:root {
  --accent: #3182f6;
  --accent-deep: #1b64da;
  --accent-soft: #e8f3ff;
  --bg: #f2f4f6;
  --card: #ffffff;
  --text: #191f28;
  --text-2: #4e5968;
  --muted: #8b95a1;
  --line: #e5e8eb;
  --danger: #f04452;
  --income: #3182f6;
  --shadow: 0 2px 10px rgba(0, 0, 0, .05);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .14);
  --radius: 16px;
  --tabbar-h: 62px;
  --spring: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: #1a2c4a;
    --bg: #101214;
    --card: #1b1f24;
    --text: #e9ecef;
    --text-2: #b0b8c1;
    --muted: #6b7684;
    --line: #2a3038;
    --income: #5aa0ff;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --accent-soft: #1a2c4a;
    --bg: #101214;
    --card: #1b1f24;
    --text: #e9ecef;
    --text-2: #b0b8c1;
    --muted: #6b7684;
    --line: #2a3038;
    --income: #5aa0ff;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  letter-spacing: -.01em;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
code { background: var(--line); padding: 1px 6px; border-radius: 6px; }

/* ---- 눌림 피드백 (공통) ---- */
.pressable, .btn, .icon-btn, .chip, .fab, .tx-row, .todo-row, .event-row, .cal-cell, .tabbar a, .todo-check, .cat-item .icon-btn {
  transition: transform .12s var(--spring), background-color .15s, opacity .15s, box-shadow .15s;
}
.btn:active, .chip:active, .tx-row:active, .todo-row:active, .event-row:active, .cal-cell:active { transform: scale(.97); }
.fab:active { transform: scale(.92); }
.icon-btn:active, .todo-check:active, .tabbar a:active .tab-icon { transform: scale(.88); }

/* ---- 공통 컴포넌트 ---- */
.btn {
  border: 0; background: var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 18px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-deep); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { padding: 9px 14px; border-radius: 10px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1; }
.icon-btn {
  border: 0; background: transparent; padding: 8px 10px; border-radius: 10px;
  font-size: 18px; cursor: pointer; color: var(--text-2);
}
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"] {
  width: 100%; border: 0; background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 13px 14px; transition: box-shadow .15s, background-color .15s;
}
.sheet-panel input[type="text"], .sheet-panel input[type="date"], .sheet-panel input[type="time"],
.overlay input[type="text"] { background: var(--bg); }
input:focus { outline: 0; box-shadow: 0 0 0 2px var(--accent); background: var(--card); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; animation: shake .35s; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.placeholder { color: var(--muted); text-align: center; margin-top: 40vh; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; animation: fadeIn .3s both; }
.empty.small { padding: 24px 0; }
.retry { text-align: center; padding: 30px 0; color: var(--muted); }
.retry .btn { margin-top: 10px; }

/* ---- 스플래시: 집이 그 자리에서 커지며 화면을 채우고 사라진다 ---- */
#splash {
  position: fixed; inset: 0; z-index: 100; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
#splash .logo { width: 60px; height: 60px; fill: #fff; will-change: transform; }
#splash.out { animation: splashFade .45s ease .3s both; pointer-events: none; }
#splash.out .logo { animation: splashGrow .75s cubic-bezier(.55, 0, .85, .25) both; }
@keyframes splashGrow { to { transform: scale(60); } }
@keyframes splashFade { to { opacity: 0; visibility: hidden; } }

/* ---- 로그인 ---- */
.center-box {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 24px; max-width: 420px; margin: 0 auto; gap: 18px;
}
.center-box form { display: flex; flex-direction: column; gap: 12px; animation: riseIn .45s .1s var(--spring) both; }
.center-box label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.center-box input { background: var(--card); box-shadow: var(--shadow); }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; animation: riseIn .45s var(--spring) both; }
.brand svg { width: 64px; height: 64px; fill: var(--accent); }
.brand h1 { font-size: 24px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---- 상단바·탭바 ---- */
.topwrap { position: sticky; top: 0; z-index: 5; }
.topwrap .topbar { position: static; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px;
  padding: 14px 10px 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 22px; font-weight: 700; flex: 1; letter-spacing: -.02em; }
main { padding: 6px 16px calc(var(--tabbar-h) + 90px); }
.tab { animation: riseIn .32s var(--spring) both; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding-top: 6px; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; position: relative;
}
.tabbar a.active { color: var(--accent); font-weight: 700; }
.tabbar a::before {
  content: ""; position: absolute; top: 0; width: 22px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--accent); transform: scaleX(0); transition: transform .25s var(--spring);
}
.tabbar a.active::before { transform: scaleX(1); }
.tab-icon { display: block; height: 22px; transition: transform .2s var(--spring); }
.tab-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active .tab-icon { transform: translateY(-1px) scale(1.08); }

/* 한 칸 안에서 화면을 바꾸는 작은 탭 (가계부·식비·고정비 / 스케줄·할일) */
.subtabs {
  display: flex; gap: 6px; padding: 0 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.subtab {
  flex: 1; border: 0; border-radius: 999px; padding: 8px 4px; cursor: pointer;
  background: var(--card); color: var(--text-2); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); transition: transform .12s var(--spring), background-color .15s, color .15s;
}
.subtab:active { transform: scale(.96); }
.subtab.active { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(49, 130, 246, .3); }

/* ---- 가계부 ---- */
.range-row { display: flex; justify-content: center; margin: -6px 0 12px; }
.pill { border: 0; background: var(--card); color: var(--text-2); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.muted { color: var(--muted); }
.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 18px; margin: 4px 0 14px; letter-spacing: -.02em;
}
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.sum-item { background: var(--card); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.sum-label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.sum-item strong { display: block; font-size: 16px; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.income { color: var(--income); }
#cat-totals, #meal-cat-totals { margin-bottom: 14px; padding: 14px 16px; }
#cat-totals summary, #meal-cat-totals summary { cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 14px; list-style: none; display: flex; justify-content: space-between; }
#cat-totals summary::-webkit-details-marker, #meal-cat-totals summary::-webkit-details-marker { display: none; }
#cat-totals summary::after, #meal-cat-totals summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
#cat-totals[open] summary::after, #meal-cat-totals[open] summary::after { transform: rotate(180deg); }
#cat-totals-list, #meal-cat-list { margin-top: 10px; }
#cat-totals-list li, #meal-cat-list li { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }

.date-head { color: var(--muted); font-size: 13px; font-weight: 600; margin: 16px 0 8px 4px; }
.tx-row, .todo-row, .event-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 14px; margin-bottom: 8px; cursor: pointer;
  animation: riseIn .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 35ms);
}
.tx-row:active, .todo-row:active, .event-row:active { background: var(--accent-soft); }
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; }
.tx-memo, .todo-due, .event-memo { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}

.fab {
  position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 8px 20px rgba(49, 130, 246, .42); cursor: pointer; z-index: 4;
  animation: popIn .4s .15s var(--spring) both;
}

/* ---- 스켈레톤 ---- */
.skel { height: 58px; border-radius: var(--radius); margin-bottom: 8px;
  background: linear-gradient(90deg, var(--card) 25%, var(--line) 50%, var(--card) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }

/* ---- 시트 ---- */
/* 시트는 오버레이(여행 상세·설정, z-index 30) 위에 떠야 한다 — 상세에서 일정 시트를 연다 */
.sheet { position: fixed; inset: 0; z-index: 35; pointer-events: none; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .45);
  opacity: 0; transition: opacity .25s;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 24px 24px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .38s var(--spring);
  max-height: 92dvh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.sheet-panel::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet.open { pointer-events: auto; }
.sheet.open .sheet-backdrop { opacity: 1; }
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet form { display: flex; flex-direction: column; gap: 14px; }

.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; position: relative; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span {
  display: block; text-align: center; padding: 9px; border-radius: 9px; color: var(--muted); cursor: pointer; font-weight: 500;
  transition: background-color .2s, color .2s, box-shadow .2s, transform .12s var(--spring);
}
.seg span:active { transform: scale(.96); }
.seg input:checked + span { background: var(--card); color: var(--text); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.amount-field { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.amount-field .won { font-size: 24px; color: var(--muted); font-weight: 600; }
.sheet-panel .amount-field input { font-size: 32px; font-weight: 800; background: transparent; border-radius: 0; padding: 4px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.sheet-panel .amount-field input:focus { box-shadow: none; background: transparent; }
.field-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 0; background: var(--bg); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text-2);
}
.chip.selected { background: var(--accent); color: #fff; font-weight: 600; }
.chip.add { color: var(--muted); border: 1.5px dashed var(--line); background: transparent; }
.actions { margin-top: 4px; }

/* ---- 설정 ---- */
.overlay { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; animation: slideInRight .32s var(--spring) both; }
.settings-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 40px; }
.cat-group { margin-top: 6px; }
.cat-group h3 { font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.cat-item { display: flex; align-items: center; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.cat-item .name { flex: 1; cursor: pointer; font-weight: 500; }
.cat-item .icon-btn { font-size: 14px; padding: 6px 8px; }
.cat-item .icon-btn.del { color: var(--danger); }

/* ---- 토스트 ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 28px);
  transform: translate(-50%, 24px) scale(.96);
  background: #191f28; color: #fff; padding: 12px 18px; border-radius: 14px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s var(--spring); z-index: 40;
  font-size: 14px; font-weight: 500; max-width: 90vw; box-shadow: var(--shadow-lg);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #toast { background: #e9ecef; color: #191f28; } }
:root[data-theme="dark"] #toast { background: #e9ecef; color: #191f28; }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---- 할일 ---- */
.quick { margin-bottom: 14px; }
.quick input { background: var(--card); box-shadow: var(--shadow); }
.todo-check {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); background: transparent; color: #fff;
  font-size: 15px; line-height: 1; padding: 0; cursor: pointer;
}
.todo-row.done .todo-check { background: var(--accent); border-color: var(--accent); animation: pop .35s var(--spring); }
.todo-main { flex: 1; min-width: 0; }
.todo-title { word-break: break-word; font-weight: 500; }
.todo-row.done .todo-title { color: var(--muted); text-decoration: line-through; font-weight: 400; }
.todo-due.overdue { color: var(--danger); font-weight: 600; }

/* ---- 스케줄 ---- */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 6px; font-weight: 500; }
.cal-head .sun { color: var(--danger); } .cal-head .sat { color: var(--income); }
.cal-grid { gap: 2px; background: var(--card); border-radius: var(--radius); padding: 8px 6px; box-shadow: var(--shadow); }
.cal-cell {
  border: 0; background: transparent; border-radius: 12px;
  padding: 5px 0 3px; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text); position: relative;
}
.cal-cell.dim { color: var(--muted); opacity: .4; }
.cal-cell.today span { color: var(--accent); font-weight: 800; }
.cal-cell.selected { background: var(--accent); color: #fff; animation: pop .3s var(--spring); }
.cal-cell.selected span { color: #fff; }
.cal-cell.selected .dots i { background: #fff !important; }
.cal-cell .dots { display: flex; gap: 3px; height: 6px; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; display: block; }
.day-label { margin: 18px 0 10px 4px; font-size: 15px; font-weight: 700; color: var(--text); }
.event-time { width: 46px; flex: none; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.event-time.allday { color: var(--muted); font-size: 12px; font-weight: 600; }
.event-main { flex: 1; min-width: 0; }
.event-title { font-weight: 500; }
#event-time { flex: 0 0 auto; width: auto; }

/* ---- 애니메이션 ---- */
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.08); } 100% { transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---- 고정비 ---- */
.fixed-total { text-align: center; padding: 22px 16px; margin-bottom: 14px; }
.fixed-total .sum-label { font-size: 13px; }
.fixed-total strong { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.by-owner { list-style: none; margin: 14px 0 0; padding: 12px 4px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-around; }
.by-owner li { text-align: center; }
.by-owner .who { display: block; font-size: 12px; color: var(--muted); }
.by-owner .amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.group-head { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: 13px; font-weight: 600; margin: 16px 4px 8px; }
.group-head .sub, .day-head .sub { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.list-head { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); margin: 6px 4px 10px; }
.list-head .count { color: var(--muted); font-weight: 500; }
.list-head .btn { margin-left: auto; }
#todo-done { margin-top: 20px; }
.version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---- 홈 ---- */
.home-card { margin-bottom: 10px; cursor: pointer; animation: riseIn .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 50ms); }
.card.home-card { display: flex; gap: 14px; align-items: flex-start; }
.card.home-card:active { background: var(--accent-soft); }
.home-body { flex: 1; min-width: 0; }
.home-card h2 { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--text); font-size: 15px; font-weight: 700; }
.home-card h2 .count { color: var(--accent); }
.home-card .big { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.home-sub { color: var(--muted); font-size: 13px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.home-empty { color: var(--muted); font-size: 14px; margin: 0; }
.home-list { list-style: none; margin: 0; padding: 0; }
.home-list li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.home-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-list .ev-time { width: 42px; flex: none; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.home-list .ev-time.allday { color: var(--muted); font-size: 11px; font-weight: 600; }
.home-list .ring { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.home-list .due { font-size: 12px; color: var(--muted); }
.home-list .due.overdue { color: var(--danger); font-weight: 600; }
.home-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.tile { width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center; }
.tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile.violet { background: #ede9fe; color: #7c3aed; }
.tile.green  { background: #d1fae5; color: #059669; }
.tile.orange { background: #ffedd5; color: #ea580c; }
:root[data-theme="dark"] .tile.violet { background: #2e2350; color: #c4b5fd; }
:root[data-theme="dark"] .tile.green  { background: #123528; color: #6ee7b7; }
:root[data-theme="dark"] .tile.orange { background: #3d2410; color: #fdba74; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tile.violet { background: #2e2350; color: #c4b5fd; }
  :root:not([data-theme="light"]) .tile.green  { background: #123528; color: #6ee7b7; }
  :root:not([data-theme="light"]) .tile.orange { background: #3d2410; color: #fdba74; }
}

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #3182f6 0%, #5b6cf6 55%, #7c5cf6 100%);
  color: #fff; border-radius: 22px; padding: 20px 20px 18px; margin: 2px 0 14px;
  box-shadow: 0 10px 28px rgba(59, 110, 246, .32);
}
.hero::before { content: ""; position: absolute; right: -40px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.10); }
.hero::after  { content: ""; position: absolute; right: 30px; bottom: -80px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.07); }
.hero > * { position: relative; }
.hero:active { transform: scale(.985); }
.hero-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; opacity: .95; }
.hero-date { font-weight: 500; opacity: .85; }
.hero-label { margin-top: 18px; font-size: 13px; opacity: .85; font-weight: 500; }
.hero-amount { font-size: 38px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-amount small { font-size: 18px; font-weight: 700; margin-left: 3px; opacity: .9; }
.hero-sub { margin-top: 8px; font-size: 13px; opacity: .9; font-variant-numeric: tabular-nums; }
.hero-compare { display: inline-block; margin-top: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 13px; font-weight: 600; backdrop-filter: blur(4px); }

.tile.sky { background: #e0f2fe; color: #0284c7; font-size: 22px; }
:root[data-theme="dark"] .tile.sky { background: #0c2a3d; color: #7dd3fc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile.sky { background: #0c2a3d; color: #7dd3fc; } }
.weather { cursor: default; }
.weather:active { background: var(--card); }
.weather .place { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.weather-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.weather-main strong { font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.weather-main > span:first-of-type { font-weight: 600; }
.grades { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.grade { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.grade.good  { background: #d1fae5; color: #047857; }
.grade.fair  { background: #e0f2fe; color: #0369a1; }
.grade.bad   { background: #ffedd5; color: #c2410c; }
.grade.worst { background: #fee2e2; color: #b91c1c; }

.tile.pink { background: #fce7f3; color: #db2777; font-size: 22px; }
:root[data-theme="dark"] .tile.pink { background: #3f1d2e; color: #f9a8d4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile.pink { background: #3f1d2e; color: #f9a8d4; } }
.dday { cursor: default; }
.dday:active { background: var(--card); }
.dday-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dday-main strong { font-size: 26px; font-weight: 800; letter-spacing: -.03em; color: #db2777; font-variant-numeric: tabular-nums; }
.dday.today { background: linear-gradient(135deg, #fdf2f8, #fce7f3); }
:root[data-theme="dark"] .dday.today { background: linear-gradient(135deg, #2a1622, #3f1d2e); }
.anniv-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.cat-item small { color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ---- 월별 비교 ---- */
.chart-card { margin-bottom: 10px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 18px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 40px; border-radius: 6px 6px 3px 3px; background: var(--accent-soft); height: calc(var(--h) * 1%); min-height: 3px; transition: height .5s var(--spring); position: relative; }
.bar.cur i { background: var(--accent); }
.bar .val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 3px; white-space: nowrap; }
.bar.cur .val { color: var(--accent); font-weight: 700; }
.bar .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar.cur .lbl { color: var(--text); font-weight: 600; }

/* ---- 식비 ---- */
.day-card { padding: 4px 14px 10px; margin-bottom: 10px; }
.day-head { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 10px 0 6px; }
.meal-row { margin-bottom: 6px; padding: 10px 12px; box-shadow: none; background: var(--bg); }
.meal-row:last-child { margin-bottom: 0; }
.meal-row.empty-slot { background: transparent; border: 1.5px dashed var(--line); }
.meal-slot { width: 50px; flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.slot-name { font-weight: 700; font-size: 13px; color: var(--text-2); }
.meal-row.empty-slot .slot-name { color: var(--muted); font-weight: 600; }
.meal-row { align-items: flex-start; }
.meal-row.empty-slot { align-items: center; }
.meal-head { display: flex; align-items: baseline; gap: 6px; }
/* 메뉴는 가장 잘 보여야 하지만 두 줄까지만. 뱃지는 밀리지 않게 고정. */
.meal-head .tx-cat { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meal-head .tag { flex: none; }
/* keep-all 이 없으면 한글이 '양 파' 처럼 단어 중간에서 잘린다. */
/* 뱃지는 왼쪽에 고정, 품목은 오른쪽에 한 줄씩 쌓여 열이 맞는다 */
.meal-buy { display: flex; align-items: flex-start; gap: 6px; margin-top: 5px; }
.meal-buy .tag { margin-left: 0; flex: none; }
.buy-items { display: flex; flex-direction: column; flex: 1; min-width: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }
/* 이름은 줄지 않게 자르고 가격은 오른쪽에 붙여 열을 맞춘다 */
.buy-item { display: flex; gap: 8px; }
.buy-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.buy-item .pr { flex: none; font-variant-numeric: tabular-nums; }
.buy-items .shop { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.who { margin-left: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-head .tx-amount { flex: none; font-size: 17px; }
.tag { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }
.slot-add { flex: none; width: 24px; text-align: center; font-size: 15px; color: var(--muted); padding: 0; }

/* 식비 시트: '쓴 돈' 세트(어떻게) 안에 품목 줄이 여러 개 */
.meal-set { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.meal-set .set-items { display: flex; flex-direction: column; gap: 8px; }
.meal-set input[readonly] { color: var(--muted); }
.meal-set .row > input.price { flex: 0 0 96px; text-align: right; font-variant-numeric: tabular-nums; }
.meal-set .set-sum { margin-left: auto; font-variant-numeric: tabular-nums; }
#meal-total { font-size: 13px; }

/* 이름이 길어도 칸이 밖으로 밀려나지 않게 (할일·일정·고정비의 기존 seg 에도 적용된다) */
.seg label { min-width: 0; }
.seg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 사 둔 것 (담아 두고 식비에서 꺼내 쓰는 품목) ---- */
/* 탭 목록: 식비 주간 목록처럼 카테고리별 카드(day-card) 안에 품목 줄이 쌓인다 */
#tab-pantry .fixed-total strong { font-size: 34px; }
#tab-pantry .fixed-total .hint { margin-top: 8px; }
#pantry-list .day-head .sub { color: var(--muted); font-variant-numeric: tabular-nums; }
.pantry-row { margin-bottom: 6px; padding: 10px 12px; box-shadow: none; background: var(--bg); gap: 10px; align-items: center; }
.pantry-row:last-child { margin-bottom: 0; }
.pantry-row .tag.how { margin-left: 0; flex: none; font-variant-numeric: tabular-nums; }
.pantry-row .tx-memo { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pantry-row .tx-amount { font-size: 15px; }
.pantry-row.done { opacity: .55; }
.pantry-row.done .tx-cat { text-decoration: line-through; }

/* 남김 ↔ 다 씀 토글. 목록에서도 세트 안에서도 같은 모양이다. */
.chip.mini {
  flex: none; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 0; background: var(--line); color: var(--text-2); cursor: pointer;
}
.chip.mini.selected { background: var(--accent); color: #fff; }

/* 세트 안에서 사 둔 것을 꺼내는 드롭다운 */
.meal-set select {
  width: 100%; border: 0; background: var(--bg); color: var(--text-2);
  border-radius: 12px; padding: 12px 14px; font: inherit; letter-spacing: inherit;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.meal-set select:focus { outline: 0; box-shadow: 0 0 0 2px var(--accent); }

/* 사 둔 것에서 꺼낸 품목 줄: 칸이 아니라 읽기용이라 글자로만 놓는다 */
/* 담기 시트의 줄: 이름은 한 줄 통째로, 가격은 그 아래 (읽은 품목 이름을 끝까지 보고 고칠 수 있게) */
/* 이름과 그 아래 가격이 한 덩어리로 보이게: 안쪽은 붙이고 줄과 줄 사이는 띄운다 */
.row.stacked { flex-wrap: wrap; row-gap: 4px; margin-bottom: 8px; }
.row.stacked:last-child { margin-bottom: 0; }
.row.stacked > [data-role="name"] { flex: 1 1 100%; }
.row.stacked > .price { flex: 0 0 110px; }
.row > input.qty { flex: 0 0 66px; text-align: center; }

/* 읽은 글 보기 — 엉뚱하게 읽혔을 때 무엇을 봤는지 눈으로 확인한다 */
#pantry-shot-raw summary { color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 0; }
#pantry-shot-text {
  margin: 4px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px;
  max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-size: 12px; line-height: 1.6; color: var(--text-2); user-select: text; -webkit-user-select: text;
}

.pantry-line { background: var(--bg); border-radius: 12px; padding: 9px 12px; }
.pantry-line .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pantry-line .pr { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pantry-line .icon-btn { flex: none; padding: 4px 6px; font-size: 14px; }


/* ---- 여행 ---- */
.travel-sum { margin-bottom: 12px; }
.travel-head { display: flex; justify-content: space-between; align-items: baseline; }
.travel-count { display: flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.travel-count strong { font-size: 24px; font-weight: 800; letter-spacing: -.03em; color: var(--accent); }
.travel-count span { font-size: 13px; color: var(--muted); }
.bar-track { height: 8px; border-radius: 999px; background: var(--bg); margin-top: 10px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .5s var(--spring); }

.map-wrap {
  position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  height: 58vh; min-height: 320px; overflow: hidden; touch-action: none; margin-bottom: 12px;
}
#korea-map { width: 100%; height: 100%; display: block; }
#map-layer path {
  fill: var(--line); stroke: var(--card); stroke-width: 1.4; vector-effect: non-scaling-stroke;
  cursor: pointer; transition: fill .25s;
}
/* 직접 칠한 곳은 연하게, 여행 기록이 있는 곳은 진하게 */
#map-layer path.been { fill: color-mix(in srgb, var(--accent) 42%, var(--line)); }
#map-layer path.trip { fill: var(--accent); }
/* 지역 이름표 — 확대하면 작은 곳까지 나온다 (크기는 travel.js 가 배율에 맞춰 잡는다) */
#map-labels { pointer-events: none; stroke: var(--card); paint-order: stroke; stroke-linejoin: round; }
#map-labels text { fill: var(--text-2); text-anchor: middle; dominant-baseline: central; font-weight: 600; }
#map-labels text.on { fill: var(--text); }
.map-tools {
  position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 2px;
  background: color-mix(in srgb, var(--card) 88%, transparent); border: 1px solid var(--line);
  border-radius: 12px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.map-tools .icon-btn { padding: 7px 10px; font-size: 16px; }
.map-wrap.zoomed { cursor: grab; }

#travel-sido-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
#travel-sido-list li.zero { color: var(--muted); }
#travel-sido-list .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; width: 46px; text-align: right; }
.mini-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.mini-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ---- 여행 계획 ---- */
.legend { display: flex; gap: 14px; justify-content: center; margin: -4px 0 12px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; display: block; }
.legend .sw.trip { background: var(--accent); }
.legend .sw.been { background: color-mix(in srgb, var(--accent) 42%, var(--line)); }

.trip-card { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; cursor: pointer;
  animation: riseIn .35s var(--spring) both; animation-delay: calc(var(--i, 0) * 35ms); }
.trip-card:active { background: var(--accent-soft); }
.trip-card.small { padding: 12px 14px; }
.trip-main { flex: 1; min-width: 0; }
.trip-title { font-weight: 700; letter-spacing: -.02em; }
.trip-where { color: var(--text-2); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-when { color: var(--muted); font-size: 13px; margin-top: 2px; }
.trip-dday { flex: none; padding-top: 2px; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.trip-dday.upcoming { color: var(--accent); }
.trip-dday.ongoing { color: #db2777; }
.trip-dday.big { padding-top: 0; font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 4px; }

#sheet-region .sheet-panel { display: flex; flex-direction: column; gap: 12px; }
.region-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.region-head h2 { font-size: 20px; color: var(--text); font-weight: 700; margin: 0; letter-spacing: -.02em; }
#region-trips { max-height: 40vh; overflow-y: auto; }
#region-trips .list-head { margin-top: 6px; }

.trip-head .trip-when { font-size: 14px; color: var(--text-2); }
.chips.read { margin-top: 10px; }
.chips.read .chip { background: var(--bg); color: var(--text-2); cursor: default; }
.trip-memo { margin: 10px 0 0; color: var(--text-2); white-space: pre-wrap; }
.chip small { color: var(--muted); font-weight: 400; margin-left: 3px; }
#trip-region-results { max-height: 30vh; overflow-y: auto; }
.item-row { margin-bottom: 6px; box-shadow: none; background: var(--bg); }
.item-row:last-child { margin-bottom: 0; }
.item-row .icon-btn.del { color: var(--muted); font-size: 14px; }
.item-list { margin-top: 10px; }
.trip-spend { display: flex; align-items: baseline; gap: 4px; }
.trip-spend strong { font-size: 24px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.trip-spend span { color: var(--muted); font-size: 14px; }


/* 여행 상세의 일차별 일정 */
.plans h2 .count { color: var(--accent); }
.plan-day { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.plan-day:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.plan-day.today .day-head { color: var(--accent); }
.plan-row { background: var(--bg); box-shadow: none; margin-bottom: 6px; padding: 11px 12px; }
.plan-add {
  width: 100%; border: 1.5px dashed var(--line); background: transparent; color: var(--muted);
  border-radius: 12px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .12s var(--spring), background-color .15s;
}
.plan-add:active { transform: scale(.98); background: var(--accent-soft); }
#plan-days .chip small { color: inherit; opacity: .65; }

/* 여행 준비 — 떠나기 전에 결제한 것 (항공권·숙소). 일차 칸과 구분되게 살짝 눕혀 둔다. */
.plan-day.prep { background: var(--bg); border: 0; border-radius: 14px; padding: 10px 12px; margin-bottom: 14px; }
.plan-day.prep .day-head { padding-top: 0; }
.plan-day.prep .day-head small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.plan-day.prep .plan-row { background: var(--card); }
.plan-row .when { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 접었다 펴는 카드 (여행 상세의 준비물) */
.fold { padding: 14px 16px; }
.fold > summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▾"; color: var(--muted); transition: transform .2s; }
.fold[open] > summary { margin-bottom: 12px; }
.fold[open] > summary::after { transform: rotate(180deg); }

/* 준비물 대분류 머리 (여행 상세 안에서는 조금 작게) */
.fold .group-head { margin: 14px 2px 6px; }
.fold .group-head:first-of-type { margin-top: 2px; }
#packing-list .group-head { margin: 18px 2px 8px; }
#packing-list .item-row { padding: 9px 8px 9px 14px; margin-bottom: 6px; }
#packing-list .item-row .icon-btn { font-size: 13px; padding: 6px 8px; color: var(--muted); }

/* 일정 시트의 지출 줄 (분류 + 금액) */
.cost-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cost-row select {
  flex: 0 0 42%; border: 0; background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 13px 10px; font: inherit;
}
.cost-row .cost-amount { flex: 1; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cost-row .icon-btn.del { color: var(--muted); font-size: 14px; padding: 6px 4px; }
.cost-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cost-tags .tag { margin-left: 0; font-variant-numeric: tabular-nums; }
