:root {
  --paper: #f7f4ee; --card: #ffffff; --card-soft: #f1ece2;
  --ink: #211e1a; --ink-soft: #6f675c; --ink-faint: #9a9082;
  --line: #ede7dc; --income: #2e7d5b;
  --danger: #b3452f; --danger-soft: #fbe9e4;
  --on-primary: #ffffff;
  --primary: #1f6f5c; --primary-soft: #dcebe4;
  --accent: #c96a3e; --accent-soft: #fbe8de;
  --hero-a: #1f6f5c; --hero-b: #2f8a70;
}
body[data-theme="forest"] { --primary: #1f6f5c; --primary-soft: #dcebe4; --hero-a: #1f6f5c; --hero-b: #2f8a70; }
body[data-theme="indigo"] { --primary: #3a5a8c; --primary-soft: #e2e9f5; --hero-a: #3a5a8c; --hero-b: #5677a8; }
body[data-theme="clay"] { --primary: #a85b3f; --primary-soft: #f6e6dd; --hero-a: #a85b3f; --hero-b: #c07a59; }
body[data-theme="plum"] { --primary: #6b5b95; --primary-soft: #ece8f5; --hero-a: #6b5b95; --hero-b: #8676ae; }
body[data-theme="mist"] { --primary: #4a6e7e; --primary-soft: #e1edf1; --hero-a: #4a6e7e; --hero-b: #6b8f9e; }
body[data-dark="1"] {
  --paper: #14120e; --card: #1e1b16; --card-soft: #2a2620;
  --ink: #efe9dd; --ink-soft: #b9b0a2; --ink-faint: #8e8578;
  --line: #332e27; --income: #6fc49a; --on-primary: #0b2b23;
  --danger: #e08a76; --danger-soft: #3a211b;
  --primary: #6fbfa8; --primary-soft: #1c332c;
}
body[data-dark="1"][data-theme="indigo"] { --primary: #93b4e0; --primary-soft: #1c2736; --on-primary: #0d1a2a; --hero-a: #4a6a98; --hero-b: #6d8cb8; }
body[data-dark="1"][data-theme="clay"] { --primary: #e09a78; --primary-soft: #3a241b; --on-primary: #2a160c; --hero-a: #b8694a; --hero-b: #d08a68; }
body[data-dark="1"][data-theme="plum"] { --primary: #b4a3d8; --primary-soft: #2a2338; --on-primary: #1b1426; --hero-a: #7b6aa8; --hero-b: #9a8bc4; }
body[data-dark="1"][data-theme="mist"] { --primary: #8fb6c4; --primary-soft: #1c2b30; --on-primary: #0c1d22; --hero-a: #557b8a; --hero-b: #7499a8; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 20% 0%, #e9efe9 0%, #f3efe8 45%, #efeae1 100%);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
}
body[data-dark="1"] { background: radial-gradient(1000px 600px at 20% 0%, #1a231e 0%, #14120e 60%); }
.stage { display: flex; min-height: 100%; align-items: center; justify-content: center; gap: 56px; padding: 34px 28px; }
.intro { width: 330px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 54px; height: 54px; border-radius: 16px; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-size: 26px; font-weight: 600; box-shadow: 0 10px 24px rgba(31,111,92,.25);
}
.brand h1 { font-size: 24px; margin: 0; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 12px; }
.lead { margin: 22px 0 18px; color: #4b453b; font-size: 14px; line-height: 1.75; }
.features { margin: 0; padding: 0 0 0 18px; color: #4b453b; font-size: 13px; line-height: 2; }
.features li::marker { color: var(--primary); }
.install-tip { margin-top: 20px; padding: 13px 15px; border-radius: 14px; background: rgba(255,255,255,.62); border: 1px solid #e4ded2; font-size: 12px; color: #5a5348; display: grid; gap: 4px; }
.install-tip b { color: var(--primary); }
.foot { margin-top: 16px; color: #958c7d; font-size: 11px; }
.stage-main { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.phone { width: 410px; height: 864px; border-radius: 48px; background: #1d1a16; padding: 10px; box-shadow: 0 30px 70px rgba(30,26,20,.28); }
.phone-screen { position: relative; width: 390px; height: 844px; border-radius: 40px; background: var(--paper); overflow: hidden; display: flex; flex-direction: column; }
.statusbar { height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; font-size: 13px; font-weight: 600; color: var(--ink); }
.status-icons { display: flex; gap: 4px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); display: inline-block; }
#screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tabbar { flex: 0 0 74px; display: flex; border-top: 1px solid var(--line); background: var(--card); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
.tab { flex: 1; border: 0; background: transparent; color: var(--ink-faint); display: grid; place-items: center; gap: 2px; font-size: 10px; padding: 8px 0 4px; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--primary); }
.stage-note { color: #8b8375; font-size: 11px; margin: 0; }
#overlay-root { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
#overlay-root > * { pointer-events: auto; }
#toast { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(8px); background: rgba(33,30,26,.9); color: #fff; font-size: 12px; padding: 8px 14px; border-radius: 999px; opacity: 0; transition: .22s; pointer-events: none; z-index: 60; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 对话 */
.page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.page-head { padding: 6px 18px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 0; color: var(--ink-faint); font-size: 11px; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 6px 18px 10px; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: 20px; font-weight: 600; flex: 0 0 44px; }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 16px; }
.chat-head .who span { display: block; color: var(--ink-faint); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-meta { display: flex; gap: 6px; padding: 0 18px 8px; flex-wrap: wrap; }
.pill { font-size: 10px; padding: 3px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; }
.pill.green { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.pill.orange { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 10px; display: flex; flex-direction: column; gap: 9px; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.mini { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: 11px; flex: 0 0 22px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 16px; background: var(--card); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; box-shadow: 0 2px 8px rgba(33,30,26,.04); }
.msg.user .bubble { background: var(--primary); color: var(--on-primary); }
.chat-tip { align-self: center; font-size: 10.5px; color: var(--ink-faint); background: var(--card-soft); padding: 4px 12px; border-radius: 999px; }
.typing { color: var(--ink-faint); }
.composer { flex: 0 0 auto; padding: 8px 14px 10px; border-top: 1px solid var(--line); background: var(--paper); }
.mode-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.mode-btn { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 11px; font-weight: 600; background: var(--primary); color: var(--on-primary); }
.mode-btn.chat { background: var(--card-soft); color: var(--ink-soft); }
.mode-hint { font-size: 10px; color: var(--ink-faint); }
.chips { display: flex; gap: 6px; margin-bottom: 7px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); border-radius: 999px; padding: 5px 10px; font-size: 11px; }
.composer-box { display: flex; gap: 8px; align-items: flex-end; }
.composer-box textarea { flex: 1; resize: none; border: 0; border-radius: 16px; background: var(--card); padding: 11px 13px; font: inherit; font-size: 13.5px; color: var(--ink); min-height: 44px; max-height: 120px; outline: none; }
.send-btn { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.send-btn svg { width: 20px; height: 20px; }

/* 草稿 / 结构化卡 */
.draft { background: var(--card); border-radius: 18px; border: 1px solid var(--line); padding: 12px; box-shadow: 0 10px 26px rgba(33,30,26,.06); }
.draft-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.draft-title { font-size: 11px; color: var(--accent); font-weight: 600; }
.draft-time { font-size: 10px; color: var(--ink-faint); }
.draft-row { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.draft-row:last-of-type { border-bottom: 0; }
.dot-cat { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; flex: 0 0 30px; }
.dr-main { flex: 1; min-width: 0; }
.dr-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dr-sub { font-size: 10px; color: var(--ink-faint); }
.dr-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dr-amt.income { color: var(--income); }
.dr-del { border: 0; background: transparent; color: var(--ink-faint); padding: 0 2px; font-size: 14px; }
.draft-total { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); padding: 8px 0; border-top: 1px solid var(--line); }
.draft-actions { display: flex; gap: 8px; }
.btn { border: 0; border-radius: 12px; padding: 10px 14px; font: inherit; font-size: 12.5px; font-weight: 600; background: var(--card-soft); color: var(--ink); }
.btn.primary { flex: 1; background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn:disabled { opacity: .45; }
.share-row { background: var(--accent-soft); border-radius: 12px; padding: 9px 10px; margin: 8px 0; font-size: 11px; color: var(--accent); }
.share-row.done { background: var(--primary-soft); color: var(--primary); }
.share-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.share-chip { border: 1px solid rgba(201,106,62,.3); background: var(--card); color: var(--accent); border-radius: 999px; padding: 4px 9px; font-size: 10.5px; }
.warn-line { font-size: 10.5px; color: var(--accent); margin-top: 6px; text-align: center; }
.multi-tag { font-size: 9px; background: var(--accent-soft); color: var(--accent); padding: 1px 4px; border-radius: 4px; margin-left: 4px; }

/* 流水 */
.bills-hero { margin: 4px 18px 10px; padding: 16px; border-radius: 22px; color: var(--on-primary); background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); }
.bills-hero .label { font-size: 11px; opacity: .82; }
.bills-hero .big { font-size: 30px; font-weight: 700; letter-spacing: .01em; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.bills-hero-meta { display: flex; gap: 16px; font-size: 10.5px; opacity: .9; flex-wrap: wrap; }
.bills-tools { padding: 0 18px 8px; display: flex; flex-direction: column; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--ink-soft); font-size: 11px; padding: 5px 12px; border-radius: 999px; }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.search { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 11px; font: inherit; font-size: 12px; color: var(--ink); width: 100%; }
.month-switch { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-soft); }
.icon-btn { border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; }
.bill-group-head { display: flex; justify-content: space-between; padding: 10px 0 5px; font-size: 10.5px; color: var(--ink-faint); }
.bill-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 11px; margin-bottom: 7px; }
.bill-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; flex: 0 0 34px; }
.bill-main { flex: 1; min-width: 0; }
.bill-title { font-size: 13px; font-weight: 600; }
.bill-sub { font-size: 10px; color: var(--ink-faint); }
.bill-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bill-amt.income { color: var(--income); }
.empty { margin: 30px 18px; text-align: center; color: var(--ink-faint); font-size: 12px; }

/* 统计 */
.stats-card { margin: 4px 18px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px; }
.stats-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12px; font-weight: 600; }
.stats-card-head span { font-size: 10px; color: var(--ink-faint); font-weight: 400; }
.donut-wrap { display: flex; justify-content: center; padding: 4px 0 8px; }
.donut-center { text-align: center; }
.donut-center small { font-size: 10px; color: var(--ink-faint); display: block; }
.donut-center b { font-size: 18px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 12px; font-size: 10.5px; }
.legend-item { display: flex; align-items: center; gap: 5px; color: var(--ink-soft); }
.legend-item i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.legend-item b { margin-left: auto; color: var(--ink); font-weight: 600; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 74px; padding: 4px 2px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.bar-box { height: 56px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { width: 62%; border-radius: 5px 5px 0 0; background: var(--primary-soft); }
.bar.on { background: var(--primary); }
.bar-label { font-size: 9px; color: var(--ink-faint); }
.hbar-list { padding: 0 2px 4px; }
.hbar-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.hbar-label { width: 46px; flex: 0 0 46px; font-size: 10.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; height: 10px; border-radius: 999px; background: var(--card-soft); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 999px; }
.hbar-amt { width: 54px; flex: 0 0 54px; text-align: right; font-size: 10px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.daily-card { margin: 0 18px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; }
.daily-card b { font-size: 18px; }

/* 设置 */
.settings-wrap { flex: 1; overflow-y: auto; padding: 6px 18px 18px; }
.group-label { font-size: 10px; color: var(--ink-faint); margin: 12px 0 6px 4px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.set-row { display: flex; align-items: center; gap: 10px; }
.set-row .sr-main { flex: 1; min-width: 0; }
.set-row .sr-main b { display: block; font-size: 13px; font-weight: 600; }
.set-row .sr-main span { display: block; font-size: 10px; color: var(--ink-faint); }
.switch { width: 40px; height: 24px; border-radius: 999px; background: var(--line); border: 0; position: relative; flex: 0 0 40px; }
.switch::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .18s; }
.switch.on { background: var(--primary); }
.switch.on::after { left: 19px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 10px; color: var(--ink-faint); }
.field input, .field textarea { border: 1px solid var(--line); background: var(--card-soft); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 12px; color: var(--ink); outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--primary); }
.theme-dots { display: flex; gap: 12px; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid transparent; }
.theme-dot.on { border-color: var(--ink); }
.mem-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.mem-row:last-child { border-bottom: 0; }
.mem-row span { flex: 1; }
.mem-del { border: 0; background: transparent; color: var(--ink-faint); font-size: 11px; }

/* 弹层 */
.backdrop { position: absolute; inset: 0; background: rgba(22,19,15,.42); backdrop-filter: blur(2px); z-index: 41; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 90%; background: var(--card); border-radius: 24px 24px 0 0; z-index: 42; display: flex; flex-direction: column; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px 6px; }
.sheet-head h3 { margin: 0; font-size: 16px; }
.sheet-body { padding: 4px 18px 10px; overflow-y: auto; }
.sheet-actions { display: flex; gap: 8px; padding: 8px 18px 0; }
.sheet-mono { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; background: var(--card-soft); border-radius: 10px; padding: 10px; white-space: pre-wrap; max-height: 180px; overflow: auto; }
.import-preview { background: var(--card-soft); border-radius: 14px; padding: 12px; text-align: center; }
.import-preview .ip-avatar { width: 48px; height: 48px; border-radius: 14px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; margin: 0 auto 6px; font-size: 20px; }
.import-preview .ip-first { font-size: 11.5px; color: var(--ink-soft); max-height: 90px; overflow-y: auto; margin-top: 6px; text-align: left; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--ink-faint); }
.kv b { font-weight: 600; text-align: right; }

@media (max-width: 980px) {
  .stage { padding: 0; gap: 0; min-height: 100dvh; }
  .intro, .stage-note { display: none; }
  .phone { width: 100%; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; }
  .phone-screen { width: 100%; height: 100dvh; border-radius: 0; }
  .statusbar { display: none; }
  #tabbar { height: 62px; }
}
@media (max-height: 900px) and (min-width: 981px) {
  .phone { transform: scale(.9); transform-origin: center; margin: -43px 0; }
}
