/* 매달 — 벽 달력 한 장. 흰 종이, 남색 먹, 토요일 파랑·일요일 빨강, 했어요는 인주 도장. */
@font-face { font-family: 'SUIT'; font-weight: 100 900; font-display: swap; src: url('/fonts/SUIT-Variable.woff2') format('woff2-variations'); }

:root {
  --paper: #ffffff;
  --ink: #14213d;
  --mute: #4a5468;
  --rule: #d9dee7;
  --band: #eef1f5;
  --sat: #1d4e89;
  --sun: #c8102e;
  --today: #e0a526;
  --stamp: #b4372b;
  --ok: #2f6b4f;
  --focus: #1d4e89;
  /* 카테고리 진한 색(흰 바탕 4.5:1 이상) */
  --c-sub: #6b3fa0; --c-pay: #9a4410; --c-home: #4b6a2a; --c-sched: #1f5fa8; --c-work: #2b3a67;
  --c-fit: #1d6f42; --c-food: #7a5c00; --c-study: #74492a; --c-people: #a83467; --c-health: #0f6b64;
  --fs: 17px; --fs-small: 15px; --fs-big: 22px; --radius: 8px; --tap: 48px;
  color-scheme: light;
}
:root.large { --fs: 22px; --fs-small: 19px; --fs-big: 28px; --tap: 56px; }

* { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: 'SUIT', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 1rem; line-height: 1.55; font-feature-settings: 'tnum'; word-break: keep-all; overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.mute { color: var(--mute); }
.small { font-size: var(--fs-small); }
[hidden] { display: none !important; }

.app { max-width: 760px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---- 벽 달력 머리(이 앱의 얼굴) ---- */
.page { position: relative; margin: 14px 14px 0; border: 1px solid var(--rule); border-radius: 6px 6px 4px 4px; background: var(--paper); }
.page::before { content: ''; display: block; height: 22px; background: var(--band); border-bottom: 1px solid var(--rule); border-radius: 6px 6px 0 0; }
.page .rings { position: absolute; top: -7px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 22%; pointer-events: none; }
.page .rings i { width: 12px; height: 22px; border: 3px solid var(--mute); border-bottom: none; border-radius: 8px 8px 0 0; background: transparent; }
.page-head { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 10px 14px; padding: 10px 16px 14px; }
.month-num { font-size: clamp(56px, 16vw, 84px); font-weight: 850; line-height: .85; letter-spacing: -.04em; }
.month-meta { padding-bottom: 6px; }
.month-meta .y { font-weight: 700; color: var(--mute); }
.month-meta .t { font-weight: 800; font-size: clamp(19px, 5.4vw, var(--fs-big)); line-height: 1.25; margin: 0; }
.month-meta { min-width: 0; }
.head-actions { display: flex; gap: 4px; align-self: start; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); display: inline-grid; place-items: center; border: 1px solid transparent; background: none; border-radius: 10px; color: var(--ink); }
.icon-btn:hover { background: var(--band); }
.icon-btn svg { width: 24px; height: 24px; }
.money-line { border-top: 1px solid var(--rule); padding: 10px 16px 12px; display: grid; gap: 6px; }
.money-line .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.money-line strong { font-size: var(--fs-big); font-weight: 800; }
.bar { height: 10px; background: var(--band); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 6px; }

/* ---- 카테고리 칩 ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 48px; padding: 4px 14px 4px 8px; display: inline-flex; align-items: center; gap: 8px; border-radius: 999px;
  border: 1.5px solid var(--rule); background: var(--paper); font-weight: 700; color: var(--mute); position: relative; }
.chip[aria-pressed='true'] { border-color: var(--cc, var(--ink)); color: var(--ink); background: color-mix(in srgb, var(--cc, var(--ink)) 9%, white); }
.chip[aria-pressed='true']::after { content: '✓'; font-weight: 900; }
.chip .badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--stamp); color: #fff; font-size: 13px; display: inline-grid; place-items: center; }
.chip.all { padding-left: 14px; }
.glyph { width: 26px; height: 26px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; background: var(--cc, var(--ink));
  font-size: 14px; font-weight: 800; line-height: 1; }
.chip[aria-pressed='false'] .glyph { background: #fff; color: var(--cc); box-shadow: inset 0 0 0 1.5px var(--cc); }
.only-band { margin: 8px 14px 0; padding: 8px 12px; background: var(--band); border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.link-btn { background: none; border: none; color: var(--sat); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: var(--tap); padding: 0 6px; }

/* ---- 보기 탭 ---- */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); margin: 12px 14px 0; border-bottom: 1px solid var(--rule); }
.tab { min-height: var(--tap); background: none; border: none; border-bottom: 3px solid transparent; font-weight: 700; color: var(--mute); }
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--ink); }

main { padding: 6px 14px 20px; flex: 1; }
.section-title { font-size: var(--fs); font-weight: 800; margin: 18px 2px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.empty { padding: 18px; border: 1.5px dashed var(--rule); border-radius: var(--radius); color: var(--mute); }

/* ---- 항목 카드 ---- */
.card { display: grid; grid-template-columns: 30px 1fr auto; gap: 4px 12px; align-items: start; padding: 14px 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); position: relative; }
.card + .card { margin-top: 8px; }
.card .title { font-weight: 800; line-height: 1.3; background: none; border: none; padding: 0; text-align: left; min-height: 0; }
.card .title:hover { text-decoration: underline; }
.card .rule-line { color: var(--mute); font-size: var(--fs-small); }
.card .amount { font-weight: 800; }
.card .status { font-size: var(--fs-small); font-weight: 700; }
.card .status.overdue, .card .status.important { color: var(--stamp); }
.card .status.today { color: var(--ink); }
.card .actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cycle { grid-column: 2 / 3; height: 6px; background: var(--band); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.cycle > span { display: block; height: 100%; background: var(--mute); }
.cycle.near > span { background: var(--today); }
.cycle.over > span { background: var(--stamp); }
.done-btn { min-width: 88px; min-height: 56px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-weight: 800; }
.done-btn:active { transform: scale(.97); }
.more-btn { min-width: var(--tap); min-height: var(--tap); border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); font-weight: 700; }
.card.is-done { background: #fbfbfc; }
.card.is-done .done-btn { background: var(--paper); color: var(--ink); border-color: var(--rule); }
.stamp { position: absolute; right: 14px; bottom: 10px; width: 58px; height: 58px; border: 3px solid var(--stamp); border-radius: 50%; color: var(--stamp);
  display: grid; place-items: center; font-weight: 900; font-size: 17px; transform: rotate(-14deg); opacity: .9; pointer-events: none; }
.stamp.press { animation: press .32s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes press { from { transform: rotate(-14deg) scale(1.8); opacity: 0; } to { transform: rotate(-14deg) scale(1); opacity: .9; } }

/* 놓친 것 묶음 */
.missed { border: 1.5px solid var(--stamp); border-radius: var(--radius); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.missed strong { color: var(--stamp); }

/* ---- 하루 칸(레인) ---- */
.lanes { display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 16px 8px 2px; margin: 0 -14px; padding-left: 14px; }
.lane { scroll-snap-align: start; border-top: 4px solid var(--cc); background: var(--paper); }
.lane h3 { margin: 8px 0; display: flex; gap: 8px; align-items: center; font-size: var(--fs); }
@media (min-width: 720px) { .lanes { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); grid-auto-columns: auto; overflow: visible; margin: 0; padding: 0; } }

/* ---- 주 보기 ---- */
.week-day { border-top: 1px solid var(--rule); padding: 10px 0; }
.week-day h3 { margin: 0 0 6px; font-size: var(--fs); display: flex; gap: 10px; align-items: baseline; }
.week-day h3 .d { font-size: var(--fs-big); font-weight: 850; }
.wk-sat { color: var(--sat); } .wk-sun { color: var(--sun); text-decoration: underline; text-underline-offset: 4px; }
.week-row { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.week-row .t { flex: 1; font-weight: 700; }
.week-row.done .t { text-decoration: line-through; color: var(--mute); }

/* ---- 월 보기(벽 달력 격자) ---- */
.month-tools { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.seg button { min-height: var(--tap); padding: 0 14px; border: none; background: var(--paper); font-weight: 700; color: var(--mute); }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 2px solid var(--ink); }
.grid .wd { text-align: center; font-weight: 800; padding: 6px 0; font-size: var(--fs-small); border-bottom: 1px solid var(--rule); }
.cell { min-height: 74px; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); padding: 4px 3px; background: none; border-left: none; border-top: none; text-align: left; display: flex; flex-direction: column; gap: 3px; }
.cell:nth-child(7n + 7) { border-right: none; }
.cell .dn { font-weight: 850; font-size: 18px; line-height: 1; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; }
.cell.today .dn { box-shadow: inset 0 0 0 3px var(--today); }
.cell.other { opacity: .6; }
.cell .dots { display: flex; flex-wrap: wrap; gap: 2px; }
.cell .dots .glyph { width: 18px; height: 18px; font-size: 10px; }
.cell .more { font-size: 12px; font-weight: 800; color: var(--mute); }
.cell .won { font-size: 12px; font-weight: 800; }
.cell.heat-1 { background: color-mix(in srgb, var(--sat) 6%, white); } .cell.heat-2 { background: color-mix(in srgb, var(--sat) 14%, white); } .cell.heat-3 { background: color-mix(in srgb, var(--sat) 24%, white); }

/* ---- 돈 보기 ---- */
.big-money { font-size: clamp(34px, 9vw, 48px); font-weight: 850; letter-spacing: -.02em; line-height: 1.1; }
.cat-bars { display: grid; gap: 10px; }
.cat-bar { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; background: none; border: none; padding: 0; text-align: left; min-height: 40px; }
.cat-bar .track { height: 12px; background: var(--band); border-radius: 6px; overflow: hidden; grid-column: 2; }
.cat-bar .track span { display: block; height: 100%; background: var(--cc); }
.note { padding: 12px 14px; background: var(--band); border-radius: var(--radius); }

/* ---- 아래 입력 막대 ---- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--rule); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); z-index: 20; }
.dock-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; }
.dock input { flex: 1; min-height: 52px; border: 2px solid var(--ink); border-radius: 12px; padding: 0 14px; background: var(--paper); }
.dock .add { min-width: 52px; min-height: 52px; border-radius: 12px; border: 2px solid var(--ink); background: var(--ink); color: #fff; font-weight: 800; padding: 0 14px; }

/* ---- 시트(바텀 시트·대화상자) ---- */
dialog.sheet { border: none; padding: 0; width: min(760px, 100%); max-height: 92dvh; margin: auto auto 0; border-radius: 16px 16px 0 0; background: var(--paper); color: var(--ink); }
dialog.sheet::backdrop { background: rgb(20 33 61 / .45); }
@media (min-width: 760px) { dialog.sheet { margin: auto; border-radius: 16px; } }
.sheet-head { position: sticky; top: 0; background: var(--paper); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 8px 18px; border-bottom: 1px solid var(--rule); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: var(--fs-big); }
.sheet-body { padding: 14px 18px 24px; overflow: auto; }
.sheet-foot { position: sticky; bottom: 0; background: var(--paper); padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); display: flex; gap: 8px; }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); font-weight: 800; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.danger { border-color: var(--stamp); color: var(--stamp); }
.btn.wide { flex: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .field .lbl { font-weight: 800; }
.field input, .field select, .field textarea { min-height: var(--tap); border: 1.5px solid var(--mute); border-radius: 10px; padding: 8px 12px; background: var(--paper); width: 100%; }
.field textarea { min-height: 96px; }
.field .hint { font-size: var(--fs-small); color: var(--mute); }
.field .err { font-size: var(--fs-small); color: var(--stamp); font-weight: 700; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--rule); background: var(--paper); font-weight: 700; }
.choice[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.preview { border: 2px solid var(--ink); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 30px 1fr auto; gap: 4px 12px; margin: 12px 0; }
.preview .warn { grid-column: 1 / -1; color: var(--stamp); font-weight: 700; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.piece-when { text-decoration: underline 3px var(--sat); text-underline-offset: 4px; }
.piece-amount { text-decoration: underline 3px var(--ok); text-underline-offset: 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { min-height: 72px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper); text-align: left; padding: 10px 12px; display: flex; gap: 10px; align-items: center; font-weight: 800; }
.tile[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.tile .check { margin-left: auto; font-size: 20px; }
.list-row { display: grid; grid-template-columns: 30px 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); align-items: center; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 10px; }
.code-box { font-size: 22px; font-weight: 850; letter-spacing: .06em; padding: 14px; border: 2px dashed var(--ink); border-radius: 12px; text-align: center; word-break: break-all; }
.example-band { display: inline-block; background: var(--today); color: var(--ink); font-weight: 900; padding: 2px 10px; border-radius: 4px; transform: rotate(-3deg); }
.hero { padding: 28px 18px 8px; }
.hero h1 { font-size: clamp(30px, 8vw, 44px); line-height: 1.2; margin: 18px 0 10px; letter-spacing: -.02em; }
.diff-op { border: 1px solid var(--rule); border-left: 6px solid var(--mute); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 4px; }
.diff-op.add { border-left-color: var(--ok); } .diff-op.change { border-left-color: var(--sat); } .diff-op.archive { border-left-color: var(--mute); }
.diff-op.invalid { border-left-color: var(--stamp); }
.diff-op del { color: var(--stamp); } .diff-op ins { color: var(--ok); text-decoration: none; font-weight: 800; }

/* 되돌리기 띠 */
.snackbar { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(720px, calc(100% - 28px)); background: var(--ink); color: #fff;
  border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; z-index: 30; box-shadow: 0 6px 24px rgb(20 33 61 / .25); }
.snackbar .msg { flex: 1; }
.snackbar button { background: none; border: 2px solid #fff; color: #fff; border-radius: 10px; min-height: 44px; padding: 0 14px; font-weight: 800; }

.toast-err { background: var(--stamp); }
.offline { margin: 8px 14px 0; padding: 6px 12px; border-radius: var(--radius); background: var(--band); font-size: var(--fs-small); }

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

/* ---- v0.2: 아래 탭·넣기 버튼·카드 날짜 줄 ---- */
.app { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { min-height: 60px; background: none; border: none; font-weight: 800; color: var(--mute); font-size: var(--fs); }
.tabbar button[aria-current='page'] { color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }
.fab { position: fixed; right: max(16px, calc(50% - 364px)); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 21; min-height: 56px; padding: 0 22px; border-radius: 28px; border: none; background: var(--ink); color: #fff; font-weight: 900; font-size: var(--fs); box-shadow: 0 6px 18px rgb(20 33 61 / .28); }
.snackbar { bottom: calc(146px + env(safe-area-inset-bottom)); }
dialog .snackbar { position: sticky; bottom: 8px; left: auto; transform: none; width: 100%; margin-top: 12px; }
.money-btn { background: none; border: none; padding: 0; text-align: left; display: grid; color: var(--ink); min-height: var(--tap); }
.money-btn strong { font-size: var(--fs-big); font-weight: 850; }
.card .when { font-size: var(--fs); }
.card .when .status { font-weight: 700; color: var(--mute); }
.card .when .status.overdue { color: var(--stamp); }
.card .amount { font-weight: 800; margin-top: 2px; }
.section-title { font-size: var(--fs-big); }

/* ---- ⋯ 메뉴 흐름도: 지난번 → 이번 → 앞으로 ---- */
.flow { list-style: none; margin: 4px 0 0; padding: 0; }
.flow-node { position: relative; padding: 0 0 18px 30px; }
.flow-node::before { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--rule); }
.flow-node:last-child { padding-bottom: 4px; }
.flow-node:last-child::before { display: none; }
.flow-node.next::before { display: none; }
.flow-dot { position: absolute; left: 0; top: 12px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--mute); background: var(--paper); }
.flow-box { display: grid; gap: 6px; padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--radius); }
.flow-label { font-size: var(--fs-small); color: var(--mute); }
.flow-main { font-size: 1.05rem; }
.flow-node.past .flow-box { background: var(--band); border-color: transparent; }
.flow-node.past .flow-main { font-weight: 600; color: var(--mute); }
.flow-node.now .flow-dot { border-color: var(--sat); background: var(--sat); box-shadow: 0 0 0 4px #1d4e8926; }
.flow-node.now .flow-box { border: 2px solid var(--sat); }
.flow-node.now .flow-label { color: var(--sat); font-weight: 700; }
.flow-node.next .flow-dot { border-style: dashed; }
.flow-node.next .flow-box { border-style: dashed; }
.flow-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.flow-actions > span { grid-column: 1 / -1; }
.flow-actions > .btn:only-of-type { grid-column: 1 / -1; }
.flow-end { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule); }
.flow-end .btn { width: 100%; }

/* ---- 한 줄 입력 ---- */
input.oneline { width: 100%; min-height: 56px; font-size: 1.15rem; padding: 0 14px; border: 2px solid var(--ink); border-radius: 12px; }
.understood { margin-top: 12px; display: grid; gap: 10px; justify-items: start; }
.chips, .examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples { margin-top: 18px; }
.examples > span { width: 100%; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); font-size: var(--fs-small); }
button.chip { cursor: pointer; border-color: var(--mute); }
.chip.got { background: var(--band); border-color: transparent; font-weight: 700; }
.chip.got::before { content: '✓'; margin-right: 6px; color: var(--ok); }
.chip.need { border: 2px dashed var(--stamp); color: var(--stamp); font-weight: 700; }
.card-body { cursor: pointer; }
