/* 小家账本 · 样式
 * 版式：单栏手机布局，内容卡片 + 底部常驻输入框；所有覆盖层都是从底部弹出的面板，二级页面从右侧推入。
 * 颜色：中性灰带一点冷调；强调色 = 当前用户自己的角色色（--me），两人颜色只用来表达「谁」。
 */
:root {
  --bg: #F2F2F6;
  --surface: #FFFFFF;
  --surface-2: #F3F3F6;
  --surface-3: #E9E9EE;
  --line: rgba(60, 60, 67, 0.12);
  --text: #111114;
  --text-2: #5F5F67;
  --text-3: #9A9AA2;
  --danger: #E5484D;
  --ok: #2F9E6A;
  --scrim: rgba(17, 17, 20, 0.32);
  --frost: rgba(242, 242, 246, 0.78);
  --shadow-1: 0 1px 2px rgba(17, 17, 20, 0.04), 0 2px 10px rgba(17, 17, 20, 0.04);
  --shadow-2: 0 -1px 0 rgba(17, 17, 20, 0.04), 0 -8px 30px rgba(17, 17, 20, 0.10);
  --me: #4885DF;
  --me-ink: #2F6FCC;
  --me-on: #FFFFFF;
  --ryan: #4885DF;
  --partner: #EEB737;
  --ryan-ink: #2F6FCC;
  --partner-ink: #8A6400;
  --ryan-on: #FFFFFF;
  --partner-on: #1C1C1E;
  --total-mid: #18AA88;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "PingFang SC", system-ui, sans-serif;

  --r-card: 20px;
  --r-ctl: 12px;
  --r-sheet: 26px;
  --gutter: 16px;
  --composer-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101012;
    --surface: #1C1C1F;
    --surface-2: #26262A;
    --surface-3: #303035;
    --line: rgba(255, 255, 255, 0.08);
    --text: #F4F4F6;
    --text-2: #A2A2AA;
    --text-3: #6E6E76;
    --danger: #FF6369;
    --ok: #4CC38A;
    --scrim: rgba(0, 0, 0, 0.5);
    --frost: rgba(16, 16, 18, 0.72);
    --shadow-1: none;
    --shadow-2: 0 -1px 0 rgba(255, 255, 255, 0.05), 0 -10px 30px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101012;
  --surface: #1C1C1F;
  --surface-2: #26262A;
  --surface-3: #303035;
  --line: rgba(255, 255, 255, 0.08);
  --text: #F4F4F6;
  --text-2: #A2A2AA;
  --text-3: #6E6E76;
  --danger: #FF6369;
  --ok: #4CC38A;
  --scrim: rgba(0, 0, 0, 0.5);
  --frost: rgba(16, 16, 18, 0.72);
  --shadow-1: none;
  --shadow-2: 0 -1px 0 rgba(255, 255, 255, 0.05), 0 -10px 30px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--me); outline-offset: 2px; border-radius: 8px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 通用按压反馈：轻微缩小 */
.press { transition: transform var(--snappy-dur) var(--snappy), background-color 0.2s, opacity 0.2s; }
.press:active { transform: scale(0.97); }

/* ---------- 启动 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 0.3s ease;
}
.boot.out {
  opacity: 0;
  pointer-events: none !important;
  visibility: hidden;
}
.boot-mark { display: grid; justify-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.boot-mark svg { width: 56px; height: 56px; animation: bootSpin 1.8s var(--smooth) infinite; }
@keyframes bootSpin { 0% { transform: rotate(0); } 60%, 100% { transform: rotate(72deg); } }

/* ---------- 登录 ---------- */
.login {
  min-height: 100%;
  display: grid; place-items: center;
  padding: calc(var(--safe-t) + 32px) 24px calc(var(--safe-b) + 32px);
}
.login-card { width: min(360px, 100%); display: grid; gap: 28px; }
.login-brand { display: grid; justify-items: center; gap: 14px; text-align: center; }
.login-brand svg { width: 64px; height: 64px; }
.login-brand h1 { font-size: 28px; font-weight: 700; letter-spacing: 0.02em; }
.login-brand p { color: var(--text-2); font-size: 14px; }
.login form { display: grid; gap: 12px; }
.field {
  display: grid; gap: 6px;
}
.field label { font-size: 12px; color: var(--text-2); padding-left: 4px; }
.input {
  width: 100%; height: 50px; padding: 0 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  font-size: 17px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { border-color: var(--me); box-shadow: 0 0 0 4px color-mix(in srgb, var(--me) 18%, transparent); }
.btn-primary {
  height: 52px; border-radius: 16px;
  background: var(--text); color: var(--bg);
  font-size: 17px; font-weight: 600;
  margin-top: 6px;
}
.btn-primary:disabled { opacity: 0.5; }
.login-err { min-height: 20px; color: var(--danger); font-size: 13px; text-align: center; }

/* ---------- 应用骨架 ---------- */
.app { min-height: 100%; }
.main {
  padding: 0 var(--gutter) calc(var(--composer-h) + var(--safe-b) + 28px);
  max-width: 560px; margin: 0 auto;
  display: grid; gap: 14px;
}

/* 顶栏：滚动后变毛玻璃 */
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 14px) var(--gutter) 10px;
  margin: 0 calc(var(--gutter) * -1);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  transition: background-color 0.25s, box-shadow 0.25s;
}
.top.scrolled {
  background: var(--frost);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--line);
}
.period-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 30px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1;
  justify-self: start; padding: 2px 4px 2px 0;
}
.period-title svg { width: 16px; height: 16px; color: var(--text-3); margin-top: 4px; transition: transform var(--snappy-dur) var(--snappy); }
.period-title[aria-expanded="true"] svg { transform: rotate(180deg); }
.period-sub { grid-column: 1; font-size: 13px; color: var(--text-2); }
.top-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-1);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: 0.35; }
.me-btn { width: 40px; height: 40px; border-radius: 50%; margin-left: 4px; }

/* ---------- 头像 ---------- */
.avatar {
  --av: 32px;
  width: var(--av); height: var(--av); border-radius: 50%;
  display: inline-grid; place-items: center; flex-shrink: 0;
  font-size: calc(var(--av) * 0.42); font-weight: 600; line-height: 1;
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xs { --av: 20px; }
.avatar.sm { --av: 26px; }
.avatar.md { --av: 36px; }
.avatar.lg { --av: 40px; }
.avatar.xl { --av: 88px; }

/* ---------- 分段控件（日 / 月 / 年），滑块跟手 ---------- */
.seg {
  position: relative;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: 12px;
  background: var(--surface-3);
}
.seg button {
  position: relative; z-index: 1;
  height: 32px; border-radius: 9px;
  font-size: 14px; font-weight: 500; color: var(--text-2);
  transition: color 0.2s;
}
.seg button[aria-selected="true"] { color: var(--text); font-weight: 600; }
.seg-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px;
  border-radius: 9px; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform var(--smooth-dur) var(--bouncy), width var(--smooth-dur) var(--smooth);
}
:root[data-theme="dark"] .seg-thumb { background: #4A4A50; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg-thumb { background: #4A4A50; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 18px 0;
}
.card-head h2 { font-size: 17px; font-weight: 650; }
.card-meta { font-size: 13px; color: var(--text-3); }
.card-head .spacer { flex: 1; }

/* ---------- 合计大卡 ---------- */
.hero { padding: 16px 18px 14px; display: grid; gap: 12px; overflow: hidden; }
.hero-row { display: flex; align-items: flex-start; gap: 8px; }
.hero-total {
  flex: 1; min-width: 0; text-align: left;
  display: grid; gap: 2px;
  border-radius: 14px; margin: -6px -8px; padding: 6px 8px;
  transition: background-color 0.2s, transform var(--snappy-dur) var(--snappy);
}
.hero-total:active { background: var(--surface-2); transform: scale(0.985); }
.hero-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.aa-tag {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 1px 6px 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
.aa-tag svg { width: 10px; height: 10px; transition: transform var(--smooth-dur) var(--bouncy); }
.hero-total[aria-expanded="true"] .aa-tag svg { transform: rotate(180deg); }
.hero-amount {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
}
.hero-amount .yen { font-size: 0.55em; font-weight: 600; margin-right: 2px; color: var(--text-2); }
.hero-amount .dec { font-size: 0.55em; color: var(--text-2); }
.trend-link {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 10px 0 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 600;
}
.trend-link svg { width: 14px; height: 14px; }
.trend-link .spark { width: 22px; height: 14px; color: var(--me-ink); }

.split {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden; gap: 2px;
  background: var(--surface-2);
}
.split i {
  display: block; height: 100%; border-radius: 999px;
  transition: flex-grow var(--smooth-dur) var(--smooth), opacity 0.25s;
}
.split i.r { background: var(--ryan); }
.split i.k { background: var(--partner); }
.split.dim-r i.r, .split.dim-k i.k { opacity: 0.25; }
.split.empty i { background: var(--surface-3); }

.people { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 14px;
  background: var(--surface-2); text-align: left; min-width: 0;
  transition: background-color 0.25s, box-shadow 0.25s, opacity 0.25s, transform var(--snappy-dur) var(--snappy);
}
.person:active { transform: scale(0.97); }
.person .who { display: grid; min-width: 0; }
.person .name { display: flex; align-items: baseline; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; }
.person .name > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.person .amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .pct { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.person[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--pc); background: color-mix(in srgb, var(--pc) 12%, var(--surface)); }
.people.scoped .person[aria-pressed="false"] { opacity: 0.55; }
.person.r { --pc: var(--ryan); }
.person.k { --pc: var(--partner); }
.person.r .amt { color: var(--ryan-ink); }
.person.k .amt { color: var(--partner-ink); }

/* AA 抽屉：只在点「合计」后滑出 */
.aa-drawer { height: 0; overflow: hidden; margin: 0 -18px -14px; contain: layout; }
.aa-inner {
  margin: 2px 12px 12px; padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--ryan) 14%, var(--surface-2)), color-mix(in srgb, var(--partner) 14%, var(--surface-2)));
  display: grid; gap: 8px;
}
.aa-line { display: flex; align-items: center; gap: 8px; font-size: 15px; flex-wrap: wrap; }
.aa-line .verb { color: var(--text-2); }
.aa-line .amt { margin-left: auto; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }
.aa-who { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.aa-note { font-size: 12px; color: var(--text-2); }
.aa-even { font-size: 15px; color: var(--text-2); }

/* ---------- 分类花朵 ---------- */
.pie-card { padding-bottom: 14px; }
.pie-stage {
  position: relative; height: 252px; margin-top: 2px;
  display: grid; place-items: center;
}
.pie-stage canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 296px; height: 296px; touch-action: manipulation; }
.pie-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 50%; text-align: center; cursor: pointer;
}
.pie-center .pc-label {
  max-width: 92%; font-size: 10.5px; line-height: 1.2; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pie-center .pc-amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.pie-center .pc-pct { font-size: 10px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pie-center:not(.has-pct) .pc-pct { display: none; }
.pie-center.pc-swap .pc-label, .pie-center.pc-swap .pc-pct { animation: pcSwap 0.32s var(--smooth); }
@keyframes pcSwap { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.pie-foot { padding: 0 18px; min-height: 22px; display: grid; }
.pie-legend { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 11px; color: var(--text-3); }
.pie-legend .bar { width: 64px; height: 6px; border-radius: 3px; }
.pie-split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pie-split .cell { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.pie-split .cell .v { display: grid; }
.pie-split .cell .n { font-size: 11px; color: var(--text-2); }
.pie-split .cell .a { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 650; }
.pie-split .cell .p { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pie-empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 18px 20px 10px; }
.pie-empty svg { width: 64px; height: 64px; color: var(--text-3); opacity: 0.5; }
.pie-empty p { color: var(--text-2); font-size: 14px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--surface-2); font-size: 13px; color: var(--text);
}
.fade-swap { animation: fadeSwap 0.35s var(--smooth); }
@keyframes fadeSwap { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 明细 ---------- */
.list-card { padding-bottom: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px 0 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--me) 14%, var(--surface-2)); color: var(--text);
  font-size: 12px; font-weight: 600;
}
.filter-chip svg { width: 10px; height: 10px; opacity: 0.6; }
.day { padding: 4px 0; }
.day-head {
  position: sticky; top: var(--top-h, 80px); z-index: 2;
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 18px 6px; font-size: 12px; color: var(--text-2);
  background: var(--surface);
}
.day-head .d { color: var(--text); font-weight: 600; font-size: 13px; }
.day-head .s { margin-left: auto; font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; text-align: left; position: relative;
  transition: background-color 0.15s;
}
.row:active { background: var(--surface-2); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 62px; right: 0; height: 1px; background: var(--line); }
.row .body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row .note { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.row .cat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.row .amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 650; white-space: nowrap; }
.row.enter { animation: rowIn 0.5s var(--bouncy) both; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-10px) scale(0.98); background: color-mix(in srgb, var(--me) 16%, transparent); } to { opacity: 1; transform: none; } }
.list-empty { padding: 28px 18px 32px; text-align: center; color: var(--text-3); font-size: 14px; }
.list-more { width: 100%; padding: 14px; font-size: 14px; color: var(--me-ink); font-weight: 600; }

/* ---------- 底部输入框 ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 8px var(--gutter) calc(var(--safe-b) + 10px);
  background: var(--frost);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -1px 0 var(--line);
  transition: transform var(--smooth-dur) var(--smooth);
}
.composer-inner { max-width: 560px; margin: 0 auto; display: grid; gap: 8px; }
.preview { display: flex; align-items: center; gap: 6px; height: 0; overflow: hidden; transition: height var(--smooth-dur) var(--smooth); }
.preview.on { height: 30px; }
.preview .pv {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: var(--surface); font-size: 13px; box-shadow: var(--shadow-1);
  animation: pvIn 0.35s var(--bouncy) both;
}
.preview .pv:nth-child(2) { animation-delay: 30ms; }
.preview .pv:nth-child(3) { animation-delay: 60ms; }
.preview .pv .dot { width: 8px; height: 8px; border-radius: 50%; }
.preview .pv.amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 650; }
.preview .hint { font-size: 12px; color: var(--text-2); }
@keyframes pvIn { from { opacity: 0; transform: translateY(6px) scale(0.92); } to { opacity: 1; transform: none; } }
.bar {
  display: flex; align-items: center; gap: 8px;
  height: 46px; padding: 0 5px 0 16px; border-radius: 23px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-1);
  transition: box-shadow 0.2s;
}
.bar:focus-within { box-shadow: 0 0 0 1.5px var(--me), 0 0 0 5px color-mix(in srgb, var(--me) 15%, transparent); }
.bar input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 16px; }
.bar input::placeholder { color: var(--text-3); }
.send {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--me); color: var(--me-on);
  transition: transform var(--snappy-dur) var(--bouncy), opacity 0.2s, background-color 0.3s;
}
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: 0.3; transform: scale(0.85); }
.send.busy svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 提示条 ---------- */
.toasts {
  position: fixed; left: 0; right: 0; z-index: 60; pointer-events: none;
  bottom: calc(var(--composer-h) + var(--safe-b) + 18px);
  display: grid; justify-items: center; padding: 0 16px;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: 100%; min-height: 44px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
.toast .msg { flex: 1; min-width: 0; }
.toast.bad { background: var(--danger); color: #fff; }
.toast .act {
  height: 30px; padding: 0 12px; border-radius: 10px;
  font-size: 13px; font-weight: 650; color: inherit;
  background: color-mix(in srgb, currentColor 16%, transparent);
}
.toast.no-act { padding-right: 16px; }

/* ---------- 底部面板 ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  max-height: calc(100% - var(--safe-t) - 24px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--shadow-2);
  padding-bottom: var(--safe-b);
  touch-action: pan-y;
}
:root[data-theme="dark"] .sheet { background: #202024; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet { background: #202024; } }
.sheet-grab { flex-shrink: 0; height: 22px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grab::before { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--surface-3); }
.sheet-head { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 20px 10px; touch-action: none; }
.sheet-head h3 { font-size: 18px; font-weight: 650; flex: 1; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 20px; -webkit-overflow-scrolling: touch; }
.sheet-close {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
}
.sheet-close svg { width: 12px; height: 12px; }

/* 表单 */
.form { display: grid; gap: 14px; }
.form .lbl { font-size: 12px; color: var(--text-2); margin: 0 0 6px 4px; display: block; }
.amount-input { font-family: var(--font-num); font-size: 28px; font-weight: 700; height: 58px; }
.cat-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-opt {
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); font-size: 14px;
  transition: background-color 0.2s, color 0.2s, transform var(--snappy-dur) var(--bouncy);
}
.cat-opt[aria-checked="true"] { background: var(--text); color: var(--bg); font-weight: 600; }
.cat-new { width: 82px; height: 34px; border-radius: 999px; border: 1px dashed var(--text-3); background: none; text-align: center; font-size: 14px; outline: none; }
.cat-new:focus { border-style: solid; border-color: var(--me); }
.form-hint { font-size: 12px; color: var(--text-3); padding-left: 4px; }
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }
.btn {
  height: 50px; border-radius: 14px; font-size: 16px; font-weight: 600;
  background: var(--surface-2);
}
.btn.primary { background: var(--me); color: var(--me-on); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; }
.readonly-note { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }

/* 我的 */
.me-head { display: grid; justify-items: center; gap: 8px; padding: 4px 0 8px; }
.me-avatar { position: relative; }
.me-avatar .edit {
  position: absolute; right: -2px; bottom: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); color: var(--text);
}
.me-avatar .edit svg { width: 14px; height: 14px; }
.nick {
  font-size: 20px; font-weight: 650; text-align: center;
  border: 0; background: none; outline: none; width: 100%; max-width: 240px;
  border-bottom: 1.5px solid transparent; padding: 2px 4px;
  transition: border-color 0.2s;
}
.nick:focus { border-bottom-color: var(--me); }
.group { background: var(--surface-2); border-radius: 16px; padding: 14px; display: grid; gap: 12px; }
.group-title { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transition: transform var(--snappy-dur) var(--bouncy), box-shadow 0.2s;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2.5px var(--surface-2), 0 0 0 4.5px var(--sw); transform: scale(0.88); }
.swatch:disabled { opacity: 0.25; cursor: not-allowed; }
.row-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); font-size: 15px; }
.row-btn.danger { color: var(--danger); justify-content: center; font-weight: 600; }
.stack { display: grid; gap: 12px; }

/* 日期面板 */
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-nav .t { flex: 1; text-align: center; font-weight: 650; font-size: 16px; }
.dow, .days { display: grid; grid-template-columns: repeat(7, 1fr); }
.dow span { text-align: center; font-size: 11px; color: var(--text-3); padding-bottom: 6px; }
.days { gap: 4px 0; }
.dcell {
  position: relative; height: 50px; border-radius: 12px;
  display: grid; align-content: center; justify-items: center; gap: 1px;
  font-family: var(--font-num); font-size: 16px; font-weight: 550;
}
.dcell.out { visibility: hidden; }
.dcell .sp { font-size: 9.5px; font-weight: 500; color: var(--text-3); font-variant-numeric: tabular-nums; height: 12px; }
.dcell .heat { position: absolute; inset: 3px 4px; border-radius: 10px; background: var(--me); opacity: calc(var(--h, 0) * 0.75); z-index: -1; }
.dcell.today { color: var(--me-ink); }
.dcell.sel { background: var(--text); color: var(--bg); }
.dcell.sel .sp { color: inherit; opacity: 0.7; }
.dcell.future { color: var(--text-3); }
.dcell .mk { position: absolute; top: 2px; right: 5px; font-size: 8.5px; font-family: var(--font); font-weight: 600; color: var(--danger); }
.dcell .mk.work { color: var(--text-3); }
.days { isolation: isolate; }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mcell { height: 66px; border-radius: 14px; background: var(--surface-2); display: grid; align-content: center; justify-items: center; gap: 2px; position: relative; overflow: hidden; }
.mcell .m { font-weight: 650; font-size: 16px; }
.mcell .s { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mcell .fill { position: absolute; left: 50%; bottom: 8px; height: 3px; border-radius: 2px; transform: translateX(-50%); width: calc(var(--f, 0%) * 0.6); background: var(--me); opacity: 0.7; z-index: 0; }
.mcell > :not(.fill) { position: relative; z-index: 1; }
.mcell.sel { background: var(--text); color: var(--bg); }
.mcell.sel .s { color: inherit; opacity: 0.7; }
.mcell.sel .fill { display: none; }
.ylist { display: grid; gap: 8px; }
.ycell { display: flex; align-items: center; height: 54px; padding: 0 16px; border-radius: 14px; background: var(--surface-2); font-weight: 650; font-size: 17px; }
.ycell .s { margin-left: auto; font-weight: 500; font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ycell.sel { background: var(--text); color: var(--bg); }
.ycell.sel .s { color: inherit; opacity: 0.75; }
.today-btn { margin-top: 14px; width: 100%; }

/* 裁剪 */
.crop-stage { position: relative; width: 280px; height: 280px; margin: 6px auto 14px; border-radius: 50%; overflow: hidden; background: var(--surface-2); touch-action: none; }
.crop-stage img { position: absolute; left: 50%; top: 50%; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 12px; }
.crop-zoom input { flex: 1; accent-color: var(--me); }
.crop-hint { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* ---------- 二级页面：趋势 ---------- */
.page {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg);
  overflow-y: auto; overscroll-behavior: contain;
  will-change: transform;
}
.page-top {
  position: sticky; top: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--safe-t) + 10px) 8px 8px;
  background: var(--frost);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.page-top h1 { font-size: 17px; font-weight: 650; }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 2px; height: 36px; padding: 0 8px; color: var(--me-ink); font-size: 16px; }
.back svg { width: 20px; height: 20px; }
.page-body { max-width: 560px; margin: 0 auto; padding: 6px var(--gutter) calc(var(--safe-b) + 32px); display: grid; gap: 14px; }
.tnav { display: flex; align-items: center; gap: 8px; }
.tnav .t { flex: 1; text-align: center; font-size: 15px; font-weight: 650; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 16px; padding: 12px; display: grid; gap: 2px; box-shadow: var(--shadow-1); }
.stat .k { font-size: 12px; color: var(--text-2); }
.stat .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 700; white-space: nowrap; }
.stat .v.long { font-size: 16px; }
.stat .v.longer { font-size: 14px; }
.stat .d { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-card { padding: 14px 0 10px; }
.chart-card .card-head { padding-top: 0; }
.chart-wrap { position: relative; height: 230px; margin: 6px 0 0; touch-action: pan-y; }
.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none;
  transform: translateX(-50%);
  padding: 6px 10px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 12px; line-height: 1.35; white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  transition: opacity 0.15s;
}
.chart-tip b { font-family: var(--font-num); font-size: 15px; }
.chart-tip .who { display: flex; gap: 8px; opacity: 0.8; }
.chart-legend { display: flex; gap: 14px; padding: 4px 18px 0; font-size: 12px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.chart-legend .avg i { width: 12px; height: 0; border-top: 1.5px dashed var(--text-3); border-radius: 0; }
.jump { margin: 8px 18px 0; width: calc(100% - 36px); display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; animation: fadeSwap 0.3s var(--smooth); }
.jump b { color: var(--me-ink); font-weight: 650; }
.cmp-row { display: flex; align-items: center; gap: 10px; padding: 10px 18px; }
.cmp-row + .cmp-row { border-top: 1px solid var(--line); }
.cmp-row .c { width: 44px; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.cmp-row .bars { flex: 1; display: grid; gap: 4px; }
.cmp-row .b { height: 6px; border-radius: 3px; transition: width var(--smooth-dur) var(--smooth); }
.cmp-row .b.prev { background: var(--surface-3); }
.cmp-row .v { width: 92px; text-align: right; display: grid; flex-shrink: 0; }
.cmp-row .v .a { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 650; font-size: 15px; }
.cmp-row .v .d { font-size: 11px; font-variant-numeric: tabular-nums; }
.up { color: var(--danger); }
.down { color: var(--ok); }
.flat { color: var(--text-3); }

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

/* 窄屏（≤360px）：人卡去掉头像，金额完整显示 */
@media (max-width: 360px) {
  .person .avatar { display: none; }
  .person { padding: 8px 12px; }
  .hero-amount { font-size: 36px; }
}
