:root {
  --bg: #FFF8EC;
  --surface: #FFFFFF;
  --surface-2: #FFF1DC;
  --text: #1F1A14;
  --muted: #7A6A58;
  --line: #EBDCC6;
  --accent: #FF7A1A;
  --accent-ink: #E2560B;
  --accent-soft: #FFE3CC;
  --plus: #0F8A5F;
  --minus: #D2402A;
  --shadow: 0 2px 10px rgba(80, 50, 10, .08);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130F; --surface: #221C16; --surface-2: #2C241C; --text: #F5ECDF; --muted: #B5A48E;
    --line: #3A3026; --accent: #FF8A33; --accent-ink: #FFA45C; --accent-soft: #3D2A1A;
    --plus: #43C795; --minus: #FF7A66; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130F; --surface: #221C16; --surface-2: #2C241C; --text: #F5ECDF; --muted: #B5A48E;
  --line: #3A3026; --accent: #FF8A33; --accent-ink: #FFA45C; --accent-soft: #3D2A1A;
  --plus: #43C795; --minus: #FF7A66; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 560px; margin: 0 auto; padding: 0 16px 120px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* 헤더 */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 0 8px; }
.top h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-top: 10px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* 카드·버튼 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.btn { border: 0; border-radius: 12px; padding: 12px 16px; min-height: 48px; font-weight: 700; cursor: pointer; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
a.btn { display: inline-block; text-decoration: none; color: inherit; }
.btn.sm { padding: 8px 12px; min-height: 44px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; padding: 10px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border-radius: 10px; cursor: pointer; font-size: 18px; }
.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 6;
  border: 0; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 800; padding: 16px 22px; box-shadow: 0 6px 20px rgba(255,122,26,.4); cursor: pointer; }

/* 폼 */
label.field { display: block; }
label.field > span, div.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 10px 16px; min-height: 44px; cursor: pointer; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 홈 */
.hero { padding: 40px 0 20px; }
.hero h1 { font-size: 30px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.5px; }
.hero p { margin: 0; color: var(--muted); }
.recent a { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); }

/* 요약 */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.summary .card { padding: 12px 14px; }
.summary b { display: block; font-size: 20px; }

/* 지출 목록 */
.day { margin-top: 18px; font-size: 13px; font-weight: 700; color: var(--muted); }
.exp { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.exp .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp .amt { text-align: right; font-weight: 800; white-space: nowrap; }
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

/* 정산 */
.xfer { display: flex; align-items: center; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.xfer .who { font-weight: 700; }
.xfer .amt { margin-left: auto; font-weight: 800; color: var(--accent-ink); font-size: 18px; }
.xfer .links { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; }
table.basis { width: 100%; border-collapse: collapse; font-size: 14px; }
table.basis th, table.basis td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
table.basis th:first-child, table.basis td:first-child { text-align: left; }
details summary { cursor: pointer; font-weight: 700; padding: 8px 0; }

/* 시트(모달) */
.scrim { position: fixed; inset: 0; background: rgba(20,12,4,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 14px; font-size: 20px; }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: 20px; } }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; }

/* ── P0 (2026-10-01) ── */
.tabs button { min-height: 44px; }
.steps { list-style: none; counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; margin: 0 0 16px; }
.steps li { counter-increment: s; background: var(--surface-2); border-radius: 12px; padding: 10px; font-size: 13px; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; margin-bottom: 4px; }
.steps b { display: block; }
.steps span { color: var(--muted); font-size: 12px; }
.invite { border: 2px solid var(--accent); background: var(--accent-soft); margin-top: 4px; }
.invite p { margin: 6px 0 12px; }
.joined { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.joined span { padding: 4px 10px; border-radius: 99px; background: var(--surface); color: var(--muted); }
.joined span.on { color: var(--plus); font-weight: 700; }
.seg { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { flex: 1; border: 0; background: transparent; min-height: 44px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.mode-note { margin: 8px 2px 12px; }
.xfer .hint { width: 100%; margin: 0; }
.xfer.done .who, .xfer.done .amt { color: var(--muted); text-decoration: line-through; }
.btn.send { background: var(--plus); color: #fff; }
.paid { color: var(--plus); font-weight: 800; align-self: center; margin-right: 4px; }
.celebrate { text-align: center; margin-bottom: 12px; border: 2px solid var(--plus); }
.celebrate b { font-size: 20px; }
.celebrate p { margin: 4px 0 0; }
.exp.transfer .t { font-weight: 600; color: var(--muted); }
#netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; display: flex; gap: 10px; align-items: center; justify-content: center;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--minus); color: #fff; font-size: 14px; font-weight: 600; text-align: center; }
#netbar[hidden] { display: none; }
#netbar .btn { background: #fff; color: var(--minus); }

/* ── P1-1 지출 입력 (2026-10-01) ── */
.amount-row { display: flex; gap: 8px; align-items: stretch; }
.input.amount { flex: 1; min-width: 0; font-size: 30px; font-weight: 800; padding: 10px 14px; letter-spacing: -.5px; }
.input.cur { width: 96px; font-weight: 700; }
.summary-line { margin: 0; line-height: 2.1; font-size: 16px; }
.link-btn { border: 0; background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; padding: 6px 10px; min-height: 36px;
  border-radius: 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.panel { padding: 12px; }
.panel > * + * { margin-top: 10px; }
.small-seg button { min-height: 40px; font-size: 14px; }
.part-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.part-row:last-child { border-bottom: 0; }
.step { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; font-weight: 800; cursor: pointer; }
.part-n { width: 24px; text-align: center; font-size: 18px; }
.part-amt { width: 88px; text-align: right; font-size: 13px; }
.exact-in { width: 130px; text-align: right; }
label.field.date-row { display: flex; align-items: center; gap: 10px; }
.date-row > span { margin: 0 !important; }
.date-row .input { width: auto; flex: 1; }
.fx { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.fx-row { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.fx-row .input { flex: 1; min-width: 0; padding: 8px 10px; }
.fx details { margin-top: 6px; }
.fx details summary { color: var(--accent-ink); font-weight: 700; padding: 6px 0; }
.fx p { margin: 6px 0 0; }
.link-btn { padding: 4px 6px; margin: 0 1px; }

/* ── P1 나머지 (2026-10-01) ── */
#toast { display: flex; gap: 12px; align-items: center; }
#toast.has-action { pointer-events: auto; }
#toast button { border: 0; background: transparent; color: var(--accent); font-weight: 800; font-size: 14px; padding: 6px 4px; min-height: 36px; cursor: pointer; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 8px 12px; min-height: 40px;
  font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.cat[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.cat-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; font-size: 18px; }
.cat-card b { display: block; margin-bottom: 8px; }
.cat-bar { display: grid; grid-template-columns: 76px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; font-size: 14px; }
.cat-bar .bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cat-bar .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.cat-amt { text-align: right; white-space: nowrap; font-weight: 700; }
.member { padding: 12px 0; border-bottom: 1px solid var(--line); }
.member.off .t { color: var(--muted); }
.member-ctl { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.step.sm { width: 36px; height: 36px; font-size: 16px; }
.chip.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.grow-end { margin-left: auto; }
.members:empty { display: none; }
.member-chip { display: inline-flex; align-items: center; gap: 4px; cursor: default; padding-right: 6px; }
.member-chip small { color: var(--accent-ink); font-weight: 800; }
.member-chip button { border: 0; background: transparent; font-size: 18px; line-height: 1; width: 28px; height: 28px; cursor: pointer; color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 900; font-size: 18px; letter-spacing: -.3px; }
.brand i { font-style: normal; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 16px; }
