/* ==========================================================================
   墨记 inkledger 设计系统
   设计 Token 见 PRD §6：墨绿主色阶 / 纸底 / 暖棕 / 语义色 / 胶带 / 圆角 / 阴影
   ========================================================================== */

:root {
  /* 墨绿主色阶 */
  --ink-900: #163A30;
  --ink-700: #1F4B3F;
  --ink-fg:  #1F4B3F; /* 强文字色（按钮底色用 --ink-700 不变） */
  --ink-500: #2D5F4F;
  --ink-300: #4E8472;
  --ink-100: #A9CDBE;
  --ink-200: #7FAE9C;   /* 墨绿浅阶（C4：补全此前未定义的 token，供 ink-divider/dotLine 使用） */
  --ink-50:  #E4F0EA;

  /* 纸底 */
  --paper-0: #FBF7EE;
  --paper-1: #F7F1E3;
  --paper-2: #F1E9D6;
  --paper-line: #E7DCC4;

  /* 暖棕 */
  --brown-700: #6B4F33;
  --brown-500: #5E4530; /* 加深以满足 WCAG AA 4.5:1（小号标签对比度） */
  --brown-300: #A6895F;

  /* 语义色 */
  --expense: #E2553F;
  --expense-soft: #F7D9D2;
  --income: #2FA36B;
  --income-soft: #CFEBD9;
  --warn: #E0A33E;
  --danger: #D6453C;

  /* 胶带 */
  --tape-pink: #E8A0A0;
  --tape-yellow: #F2C879;
  --tape-mint: #9FC1B0;
  --tape-purple: #B6A6E0;
  --tape-blue: #9DB8D6;

  /* 圆角 */
  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* 阴影 */
  --shadow-card: 0 8px 24px rgba(31, 75, 63, .08);
  --shadow-fab: 0 10px 28px rgba(31, 75, 63, .28);
  --blur: blur(20px) saturate(160%);

  --font-sans: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --font-kai: "STKaiti", "Kaiti SC", "Kaiti TC", serif;
  --font-hand: "Marker Felt", "Chalkboard SE", cursive;
  /* emoji 兜底栈：优先系统彩字，无则回落通用 emoji 字体（防部分 Android 显示方块） */
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;

  --tabbar-h: 56px;

  /* 统一缓动曲线（所有动效共用，避免生硬） */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* ===== 间距 / 字号 Token（4pt 栅格，设计系统化 B2） ===== */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 40px; --sp-8: 48px;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px;
  --fs-16: 16px; --fs-17: 17px; --fs-18: 18px; --fs-20: 20px; --fs-22: 22px;
  --fs-26: 26px; --fs-34: 34px; --fs-38: 38px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--ink-900);
  line-height: 1.55;
  background-color: var(--paper-0);
  /* 纸纹：内联 SVG feTurbulence 噪点（极低透明度）+ 点阵 */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='2' cy='2' r='1' fill='%23E7DCC4' opacity='0.5'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* 纸纹切换（设置 paper 字段控制 body class） */
body.paper-rice { /* 默认米白纸 */ }
body.paper-kraft {
  background-color: #EFE6D0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
body.paper-grid {
  background-image:
    linear-gradient(var(--paper-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px);
  background-size: 22px 22px;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 16px; }
a { color: var(--ink-fg); }

/* emoji 统一字体栈（含心情/分类图标），避免非彩字环境显示成方块 */
.emoji, .mood-chip, .mood-row button, .cat-tile .emoji, .cat-chip .emoji, .cat-rec-tag {
  font-family: var(--font-emoji);
}

/* 图标选择器宫格按钮 */
.icon-opt {
  width: 40px; height: 40px; font-size: 22px; border-radius: 10px;
  border: 1.5px solid var(--ink-100); background: var(--paper-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-emoji);
  transition: transform var(--ease, ease) .12s, border-color .12s, background .12s;
}
.icon-opt:hover { transform: translateY(-2px); border-color: var(--brown-500); }
.icon-opt.sel { background: var(--ink-50); border-color: var(--brown-500); box-shadow: 0 0 0 2px rgba(94,69,48,.18) inset; }

/* 记一笔快捷金额 chip */
.amount-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 2px 0; }
.amount-chips .chip {
  flex: 0 0 auto; padding: 6px 12px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--ink-100); border-radius: 999px; background: var(--paper-1);
  color: var(--ink-fg); cursor: pointer; font-variant-numeric: tabular-nums;
  transition: transform var(--ease, ease) .12s, background .12s, border-color .12s;
}
.amount-chips .chip:hover { background: var(--ink-50); border-color: var(--brown-500); transform: translateY(-1px); }
.amount-chips .chip:active { transform: scale(.96); }

/* 记一笔「更多选项」折叠 */
.more-toggle { margin-top: 4px; }
.more-toggle .v { color: var(--brown-500); font-size: 13px; }


/* ============================ 布局 ============================ */
#app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}
.page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  /* 页面切换过渡 */
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.page-content.fade-out { opacity: 0; transform: translateY(6px); }
.page-content.fade-in { opacity: 1; transform: translateY(0); animation: pageIn .3s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================ 顶部条 ============================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  /* 实底背景：防止滚动时下方内容从月份标题底下穿过重叠 */
  background: var(--paper-0);
}
.topbar .title {
  font-family: var(--font-kai);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: .04em;
}
.month-switch { display: flex; align-items: center; gap: 8px; }
.month-switch .m {
  font-family: var(--font-kai);
  font-size: 18px;
  color: var(--brown-700);
  min-width: 92px;
  text-align: center;
}
.month-pick {
  font-family: var(--font-kai);
  font-size: 18px;
  color: var(--brown-700);
  min-width: 92px;
  text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.month-pick:active { transform: scale(.96); background: rgba(255,255,255,.5); }
.icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--ink-fg);
  background: rgba(255,255,255,.55);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow-card);
}
.icon-btn:active { transform: scale(.94); }

/* ============================ 卡片 ============================ */
.card {
  background: rgba(255,255,255,.72);
  backdrop-filter: var(--blur);
  border: 1px solid rgba(255,255,255,.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.card.tape::before {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  width: 96px; height: 26px;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--tape-yellow);
  opacity: .55;
  mix-blend-mode: multiply;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  -webkit-mask:
    linear-gradient(#000 0 0) padding-box,
    repeating-linear-gradient(45deg, #000 0 4px, transparent 4px 8px) 0 0/100% 100%;
  clip-path: polygon(2% 18%, 98% 0, 100% 82%, 0 100%);
}
.kai { font-family: var(--font-kai); }
.hand { font-family: var(--font-hand); }

/* ============================ 概览卡 ============================ */
.overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.overview-2col .cell { max-width: none; }
.overview .cell .label { font-size: 12px; color: var(--brown-500); }
.overview .cell .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -0.01em; }
.overview .cell.income .val { color: var(--income); }
.overview .cell.expense .val { color: var(--expense); }
.overview .cell.balance .val { color: var(--ink-fg); }
/* 负结余必须用红色，且优先级压过上面的中性色（修复「负结余显示成绿色」） */
.overview .cell.balance .val.num-over { color: var(--danger); }

/* 净资产 hero（账本首页顶部） */
.net-asset { text-align: center; padding: 16px; }
.net-asset .na-label { font-size: 13px; color: var(--brown-500); letter-spacing: 0.06em; }
.net-asset .na-val {
  font-size: 38px; font-weight: 700; color: var(--ink-fg);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  margin: 4px 0 3px; line-height: 1.1;
  transition: color var(--ease);
}
.net-asset .na-sub { font-size: 11px; }

/* ============================ 时间线 ============================ */
.day-group { margin-bottom: 6px; }
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 6px 6px;
  color: var(--brown-700);
  font-family: var(--font-kai);
  font-size: 15px;
}
.day-head .sum { font-size: 12px; font-family: var(--font-sans); color: var(--brown-500); }
.day-head .sum .e { color: var(--expense); }
.day-head .sum .i { color: var(--income); }
.tx-list { display: flex; flex-direction: column; gap: 8px; }

/* 左滑行 */
.swipe-row { position: relative; overflow: hidden; border-radius: var(--radius-md); }
.swipe-row .actions {
  position: absolute; top: 0; right: 0; height: 100%;
  display: flex; align-items: stretch;
}
.swipe-row .actions button {
  width: 64px; color: #fff; font-size: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.swipe-row .actions .edit { background: var(--ink-300); }
.swipe-row .actions .copy { background: var(--ink-500); }
.swipe-row .actions .del { background: var(--danger); }
.swipe-row .front {
  position: relative; z-index: 2;
  /* 全不透明：避免编辑/复制/删除按钮透过卡片渗出半透明水印（与金额重叠） */
  background: var(--paper-2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  transform: translateX(var(--tx, 0)) translateY(var(--ty, 0));
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
  touch-action: pan-y;
}
.swipe-row .front:active { --ty: -1px; box-shadow: 0 12px 28px rgba(31,75,63,.14); }
/* 拖拽中关闭过渡以保证跟手；结束后由 JS 移除该 class 恢复过渡 */
.swipe-row .front.dragging { transition: none; }
.swipe-row .front, .swipe-row .actions { user-select: none; -webkit-user-select: none; }
.tx-cat-ico {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex: 0 0 auto;
  background: var(--ink-50);
}
.tx-main { flex: 1; min-width: 0; }
.tx-main .name { font-weight: 600; font-size: 15px; }
.tx-main .sub { font-size: 12px; color: var(--brown-500); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.tx-amount {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-align: right;
}
.tx-amount.expense { color: var(--expense); }
.tx-amount.income { color: var(--income); }
.tx-amount.transfer { color: var(--ink-fg); }
.tx-amount .tx-amt { white-space: nowrap; }
.tx-amount .tx-time {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--brown-500);
  white-space: nowrap;
}

/* ============================ 空状态 ============================ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--brown-500);
}
.empty svg { width: 140px; height: 140px; margin-bottom: 12px; }
.empty svg.emptyChart { width: 120px; height: 120px; }
.empty .tip { font-family: var(--font-kai); font-size: 17px; color: var(--brown-700); }

/* 空态插画极轻浮动微动效 */
.ill-float { animation: floatY 3.4s ease-in-out infinite; transform-origin: center; }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* 搜索关键字淡色高亮 */
mark.hl { background: rgba(242,200,121,.55); color: var(--ink-900); border-radius: 4px; padding: 0 2px; }

/* ============================ Tab Bar ============================ */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(251, 247, 238, .72);
  backdrop-filter: var(--blur);
  border-top: 1px solid rgba(255,255,255,.6);
  box-shadow: 0 -4px 20px rgba(31,75,63,.06);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-300);
  padding: 8px 0;
  transition: color .2s var(--ease), transform .2s var(--ease);
}
.tab.active { color: var(--ink-fg); }
.tab-ico { width: 24px; height: 24px; display: block; }
.tab-ico svg { width: 100%; height: 100%; }
.tab-label { font-size: 11px; }

.fab {
  width: 60px; height: 60px; margin-top: -28px;
  border-radius: var(--radius-pill);
  background: linear-gradient(145deg, var(--ink-500), var(--ink-700));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-fab);
  font-size: 30px; font-weight: 300;
  transition: transform .18s var(--ease);
}
.fab:active { transform: scale(.92) rotate(90deg); }
.fab span { display: flex; }
.fab span svg { width: 28px; height: 28px; }

/* ============================ 按钮 ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink-700);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-card);
  transition: transform .12s;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink-fg); box-shadow: none; border: 1px solid var(--ink-100); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: 13px; }

/* ============================ Sheet ============================ */
.sheet-layer {
  position: fixed; inset: 0; z-index: 60;
  display: none;
  align-items: flex-end; justify-content: center;
}
.sheet-layer.open { display: flex; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(22,58,48,.32);
  backdrop-filter: blur(2px);
  opacity: 0; transition: opacity .25s;
}
.sheet-layer.open .sheet-mask { opacity: 1; }
.sheet {
  position: relative;
  width: 100%; max-width: 480px;
  background: var(--paper-0);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -10px 40px rgba(22,58,48,.25);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sheet-layer.open .sheet { transform: translateY(0); }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--ink-100); margin: 4px auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }

/* Segmented */
.segmented {
  display: flex; background: var(--paper-2); border-radius: var(--radius-pill);
  padding: 3px; margin: 4px 0 8px;
}
.segmented button {
  flex: 1; padding: var(--sp-2) 0; border-radius: var(--radius-pill);
  color: var(--brown-500); font-weight: 600; font-size: var(--fs-14);
  transition: all .2s;
}
.segmented button.active { background: var(--paper-2); color: var(--ink-fg); box-shadow: var(--shadow-card); }

/* 金额显示 */
.amount-display {
  text-align: center; font-size: 32px; font-weight: 700; color: var(--ink-fg);
  font-variant-numeric: tabular-nums; padding: 2px 0 0; min-height: 40px;
  letter-spacing: -0.02em;
}
.amount-display .cur { font-size: 20px; color: var(--ink-300); margin-right: 4px; letter-spacing: 0; }

/* 将记金额提示（带类型色） */
.amount-hint {
  text-align: center; font-size: 13px; font-weight: 600; margin: -2px 0 4px;
  font-variant-numeric: tabular-nums; transition: color .18s var(--ease);
}
.amount-hint.hint-expense { color: var(--expense); }
.amount-hint.hint-income { color: var(--income); }
.amount-hint.hint-transfer { color: var(--ink-fg); }

/* 数字键盘（更紧凑：按键变小、间距收紧，仍保持 ≥44px 触控目标） */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 2px 0 6px; }
.keypad button {
  padding: 11px 0; border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ffffff, var(--paper-1));
  box-shadow: var(--shadow-card);
  font-size: 21px; font-weight: 600; color: var(--ink-900);
  transition: transform .12s var(--ease), background .12s var(--ease), box-shadow .12s var(--ease);
}
.keypad button:active { transform: scale(.93); background: var(--ink-50); box-shadow: 0 4px 12px rgba(31,75,63,.14); }
.keypad button.op { color: var(--ink-fg); background: var(--paper-2); font-size: 22px; }
.keypad button.done { background: linear-gradient(145deg, var(--ink-500), var(--ink-700)); color: #fff; font-size: 17px; box-shadow: var(--shadow-fab); }
.keypad button.done:active { transform: scale(.94); background: linear-gradient(145deg, var(--ink-700), var(--ink-900)); }

/* 分类搜索框 */
.cat-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-2); border-radius: var(--radius-pill);
  padding: 0 12px; margin: 2px 0 6px;
}
.cat-search .ico { width: 18px; height: 18px; color: var(--brown-500); display: flex; flex: 0 0 auto; }
.cat-search .ico svg { width: 100%; height: 100%; }
.cat-search input { border: none; background: transparent; box-shadow: none; padding: 10px 0; }
.cat-search input:focus { border: none; }

/* 分类平铺 */
.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 8px 0; }
.cat-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px; min-height: 60px; border-radius: var(--radius-md);
  background: rgba(255,255,255,.6);
  transition: transform .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
}
.cat-tile:active { transform: scale(.94) translateY(-1px); }
.cat-tile .emoji { font-size: 25px; }
.cat-tile .nm { font-size: 11px; color: var(--brown-700); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tile .rec-tag {
  position: absolute; top: -7px; right: -4px;
  font-style: normal; font-size: 9px; line-height: 1;
  background: var(--tape-yellow); color: var(--brown-700);
  padding: 1px 5px; border-radius: var(--radius-pill);
}
.cat-tile.sel {
  background: var(--ink-50);
  box-shadow: 0 0 0 2.5px var(--ink-300) inset, 0 4px 12px rgba(31,75,63,.12);
}
.cat-tile.add {
  border: 1.5px dashed var(--ink-300); background: rgba(169,205,190,.12);
}
.cat-tile.add .emoji { color: var(--ink-500); }
.cat-tile.add:active { transform: scale(.94); background: var(--ink-50); }
.cat-hint {
  font-size: 11.5px; color: var(--brown-500); line-height: 1.5;
  padding: 6px 10px; margin: 2px 0 6px;
  background: rgba(169,205,190,.14); border: 1px dashed rgba(169,205,190,.55);
  border-radius: var(--radius-sm);
}
/* 带二级分类的一级瓦片：渲染为「分组卡」——淡底 + 底部强调条，一眼看出可展开 */
.cat-tile.has-kids {
  background: linear-gradient(180deg, rgba(255,255,255,.72), var(--ink-50));
  border: 1px solid rgba(169,205,190,.55);
  box-shadow: inset 0 -3px 0 0 var(--ink-300);
}
.cat-tile.has-kids .emoji { font-size: 25px; }
.cat-tile.has-kids .nm { color: var(--ink-700); font-weight: 600; }
/* 数量 + 展开指示药丸：明确「N 个子类，点开」 */
.kids-badge {
  position: absolute; top: 4px; right: 4px;
  display: inline-flex; align-items: center; gap: 1px;
  font-style: normal; font-size: 10px; line-height: 1; font-weight: 700;
  color: #fff; background: var(--ink-500);
  padding: 3px 5px 3px 6px; border-radius: var(--radius-pill);
  box-shadow: 0 2px 6px rgba(31,75,63,.25);
}
.kids-badge b { font-variant-numeric: tabular-nums; }
.kids-badge .chev { font-size: 12px; display: inline-block; transform: rotate(90deg); transition: transform .2s var(--ease); }
.cat-tile.has-kids.expanded .kids-badge .chev { transform: rotate(-90deg); }
/* 二级分类面板：卡片化 + 标题栏 + 左侧强调边，与一级明显区分层级 */
.cat-children {
  grid-column: 1 / -1; margin: 6px 0 4px;
  background: linear-gradient(180deg, var(--paper-1), var(--paper-2));
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--ink-500); border-radius: var(--radius-md);
  padding: 8px 8px 10px; box-shadow: var(--shadow-card);
}
.cat-children-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--paper-line);
}
.cat-children-head .cch-title { font-size: 12px; color: var(--brown-700); font-weight: 700; }
.cat-children-head .cch-collapse {
  font-size: 12px; color: var(--brown-500); background: rgba(255,255,255,.6);
  border: 1px solid var(--paper-line); border-radius: var(--radius-pill); padding: 3px 10px;
}
.cat-children-head .cch-collapse:active { opacity: .6; background: var(--ink-50); }
.cat-children-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cat-children-grid .cat-tile { background: rgba(255,255,255,.9); padding: 7px 2px; border: 1px solid transparent; }
.cat-children-grid .cat-tile:active { transform: scale(.94); background: var(--ink-50); }
.cat-children-grid .cat-tile .emoji { font-size: 20px; }
.cat-children-grid .cat-tile .nm { font-size: 10px; color: var(--brown-700); }
/* 一级「全部」项：弱化样式，表示记到一级总账 */
.cat-children-grid .cat-tile.all { opacity: .85; background: transparent; border: 1px dashed var(--ink-100); }
.cat-children-grid .cat-tile.all .nm { color: var(--ink-500); font-weight: 600; }

/* 常用（最近使用）横向滑动行 */
.cat-recent { margin: 2px 0 8px; }
.cat-recent-label { font-size: 12px; color: var(--brown-500); padding: 2px 2px 4px; }
.cat-recent-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.cat-recent-row::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,.7); box-shadow: var(--shadow-card);
  font-size: 13px; color: var(--ink-900); transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.cat-chip .emoji { font-size: 18px; }
.cat-chip:active { transform: scale(.95); }
.cat-chip.sel { background: var(--ink-50); box-shadow: 0 0 0 2px var(--ink-300) inset; }
.cat-chip.pinned { background: var(--ink-50); }
.cat-chip .pin-btn {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; border-radius: var(--radius-pill);
  background: rgba(255,255,255,.7); border: 1px solid var(--ink-100);
  filter: grayscale(1) opacity(.5); transition: all .15s var(--ease);
}
.cat-chip .pin-btn.on { filter: none; background: var(--ink-50); border-color: var(--ink-300); box-shadow: 0 0 0 2px rgba(31,75,63,.12) inset; }
.cat-chip .pin-btn:active { transform: scale(.9); }
.cat-chip .unpin { font-size: 15px; line-height: 1; color: var(--brown-500); margin-left: 1px; padding: 0 2px; }
.cat-chip .unpin:active { opacity: .5; }
.cat-empty {
  text-align: center; color: var(--brown-500); font-size: 13px;
  padding: 14px; background: var(--paper-1); border-radius: var(--radius-md); margin: 4px 0;
}

/* 折叠区 */
.collapse { border-top: 1px dashed var(--paper-line); margin-top: 8px; }
.collapse .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) 2px; font-size: var(--fs-14);
}
.collapse .row .k { color: var(--brown-700); }
.collapse .row .v { color: var(--ink-900); display: flex; align-items: center; gap: 6px; }
.collapse .body { padding: 4px 2px 10px; }
.mood-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mood-chip { font-size: 24px; width: 42px; height: 42px; border-radius: var(--radius-md); background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; }
.mood-chip.sel { box-shadow: 0 0 0 2px var(--ink-300) inset; background: var(--ink-50); }
.field-input, .field-area, select.field-input {
  width: 100%; border: 1px solid var(--paper-line); border-radius: var(--radius-md);
  padding: 10px 12px; background: var(--paper-2); color: var(--ink-900); outline: none;
}
.field-area { min-height: 60px; resize: vertical; }
.field-input:focus { border-color: var(--ink-300); }

/* ============================ Modal ============================ */
.modal-layer { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-layer.open { display: flex; }
.modal-mask { position: absolute; inset: 0; background: rgba(22,58,48,.35); }
.modal {
  position: relative; width: 100%; max-width: 360px;
  background: var(--paper-0); border-radius: var(--radius-lg);
  box-shadow: 0 16px 50px rgba(22,58,48,.3); padding: var(--sp-5);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 8px; font-family: var(--font-kai); font-size: 20px; color: var(--ink-900); }
.modal .msg { color: var(--brown-700); font-size: 14px; line-height: 1.5; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; }
/* 三按钮（取消 / 额外操作 / 确定）竖排，避免小屏挤成一团 */
.modal .actions.col { flex-direction: column-reverse; }
.modal .actions.col .btn { width: 100%; justify-content: center; }

/* ============================ Toast ============================ */
.toast-layer { position: fixed; left: 0; right: 0; bottom: 120px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(22,58,48,.92); color: #fff; padding: var(--sp-3) 18px;
  border-radius: var(--radius-pill); font-size: var(--fs-14); box-shadow: var(--shadow-fab);
  animation: toastIn .25s ease; max-width: 80%;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ink-700); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================ 报表 ============================ */
.seg-tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.seg-tabs button {
  flex: 1; padding: var(--sp-2) 0; min-height: 40px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,.6); color: var(--brown-500); font-weight: 600; font-size: var(--fs-13);
}
.seg-tabs button.active { background: var(--ink-700); color: #fff; }
.chart-wrap { display: flex; justify-content: center; position: relative; }
svg .slice { transition: opacity .2s var(--ease), stroke .2s var(--ease), stroke-width .2s var(--ease); cursor: pointer; }
svg .slice:hover, svg .slice.sel { stroke: #fff; stroke-width: 2.5; }
.legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 6px; border-radius: var(--radius-sm); transition: background .18s var(--ease); }
.legend .li.sel { background: var(--ink-50); }
.legend .dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.legend .li .pct { margin-left: auto; color: var(--brown-500); font-variant-numeric: tabular-nums; }

/* 趋势折线数据点 + 悬浮气泡 */
svg .pt { cursor: pointer; transition: r .15s var(--ease), stroke-width .15s var(--ease); }
svg .pt:hover { stroke-width: 2.5; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: rgba(22,58,48,.94); color: #fff; font-size: 11px; line-height: 1.5;
  padding: 6px 10px; border-radius: 10px; box-shadow: var(--shadow-fab);
}

/* 热力图 */
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.heatmap .hm-head { font-size: 11px; color: var(--brown-500); text-align: center; padding-bottom: 2px; }
.heatmap .cell {
  aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 9px; color: var(--brown-500); position: relative;
  background: var(--paper-2); overflow: hidden;
}
/* 有数据的日子背景变深，文字转白以保证对比度 */
.heatmap .cell.has { color: rgba(255,255,255,.92); }
/* 低强度格（浅墨绿底）：改用深字，避免白字在浅底上对比不足（实测 1.06:1） */
.heatmap .cell.has.lo { color: var(--ink-900); }
.heatmap .cell.has.lo .v { color: var(--ink-900); opacity: .75; }
.heatmap .cell .d { font-size: 11px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.heatmap .cell .v { font-size: 10px; line-height: 1.1; opacity: .85; margin-top: 1px; }
.heatmap .cell:hover, .heatmap .cell:active { outline: 2px solid var(--ink-300); }

/* 月环比 chip */
.mom-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mom {
  padding: 3px 10px; border-radius: var(--radius-pill, 999px);
  font-size: 12px; font-variant-numeric: tabular-nums;
  background: var(--paper-2); color: var(--brown-500);
}
.mom.good { background: rgba(47,163,107,.12); color: #2FA36B; }
.mom.bad { background: rgba(226,85,63,.12); color: var(--expense); }
.mom.flat { background: var(--paper-2); color: var(--brown-500); }
.mom-note { font-size: 11px; color: var(--brown-500); }

/* ============================ 预算 ============================ */
.budget-total .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-fg); }
.budget-total .meta { font-size: 13px; color: var(--brown-500); margin-top: 2px; }
.progress { height: 12px; border-radius: var(--radius-pill); background: var(--paper-2); overflow: hidden; margin: 12px 0 6px; }
.progress .fill { height: 100%; background: linear-gradient(90deg, var(--ink-300), var(--ink-700)); border-radius: var(--radius-pill); transition: width .4s; }
.progress .fill.warn { background: linear-gradient(90deg, var(--warn), #E8B968); }
.progress .fill.over { background: linear-gradient(90deg, var(--expense), var(--danger)); }
.cat-budget { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--paper-line); }
.cat-budget:last-child { border-bottom: none; }
.cat-budget .nm { flex: 1; }
.cat-budget .amt { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--brown-700); }
/* 预算数字阈值变色（应用内提醒，无推送） */
.num-warn { color: var(--warn); }
.num-over { color: var(--danger); }

/* 首页预算预警：超支提示条 + 可点击的预算文案 */
.budget-alert {
  margin-top: 12px; padding: 9px 12px; border-radius: 10px;
  background: rgba(214, 69, 60, .10); color: var(--danger);
  font-size: 13px; line-height: 1.55; text-align: center;
  border: 1px solid rgba(214, 69, 60, .22);
}
.budget-link { color: var(--brown-500); text-decoration: underline; text-underline-offset: 2px; }

/* 筛选生效时的标记，提示上方数字为筛选结果而非整月 */
.tag-filtered {
  display: inline-block; padding: 1px 7px; margin-right: 4px;
  border-radius: var(--radius-pill, 999px);
  background: var(--ink-50); color: var(--ink-fg);
  font-size: 11px; vertical-align: 1px;
}

/* ============================ 设置 / 列表 ============================ */
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: var(--sp-3) var(--sp-4); background: rgba(255,255,255,.7);
  border-radius: var(--radius-md); margin-bottom: 8px; box-shadow: var(--shadow-card);
  min-width: 0; overflow: hidden;
}
.list-row .ico { width: 38px; height: 38px; border-radius: var(--radius-md); background: var(--ink-50); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: 0 0 auto; }
.list-row .body { flex: 1; min-width: 0; overflow: hidden; }
.list-row .body .t { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .body .s { font-size: 12px; color: var(--brown-500); margin-top: 2px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .r { color: var(--brown-500); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.list-row .r .mini { width: 30px; height: 30px; border-radius: var(--radius-pill); display: flex; align-items: center; justify-content: center; color: var(--ink-300); }
.list-row .r .mini:active { background: var(--ink-50); }
.list-row .r .mini.del { color: var(--danger); }

.section-title { font-family: var(--font-kai); font-size: 18px; color: var(--brown-700); margin: 16px 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--brown-500); font-size: 13px; }
.center { text-align: center; }
.spacer { height: 12px; }
.pill-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--ink-50); color: var(--ink-fg); font-size: 12px; margin: 2px; }
.loading-wrap { text-align: center; padding: 40px; }
.loading-wrap svg { width: 60px; height: 60px; }

/* ============================ 点缀装饰 ============================ */
/* 卡片右下角小墨滴装饰 */
.card .ink-dot {
  position: absolute; bottom: 8px; right: 10px;
  width: 8px; height: 8px;
  background: var(--ink-300); opacity: .25;
  border-radius: 50% 50% 45% 55%;
  transform: rotate(25deg); pointer-events: none;
}
.card .ink-dot::after {
  content: ""; position: absolute; top: -3px; left: -2px;
  width: 4px; height: 4px;
  background: var(--ink-300); opacity: .18;
  border-radius: 50%;
}

/* 分隔线带小墨点 */
.ink-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 4px 10px; color: var(--ink-100);
}
.ink-divider::before, .ink-divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--paper-line), transparent);
}
.ink-divider .dot {
  width: 5px; height: 5px;
  background: var(--ink-200); opacity: .5;
  border-radius: 50%; display: inline-block;
}

/* 资产总计卡片左侧墨绿竖条 + 右上胶带角 */
.net-asset {
  border-left: 3.5px solid var(--ink-500);
  position: relative;
}
.net-asset::after {
  content: "";
  position: absolute; top: -6px; right: 16px;
  width: 20px; height: 20px;
  background: var(--tape-mint); opacity: .35;
  border-radius: 3px;
  transform: rotate(12deg);
  mix-blend-mode: multiply;
}

/* Tab 切换时图标微弹跳 */
.tab.active .tab-ico { animation: tabBounce .35s var(--ease); }
@keyframes tabBounce {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* 空状态底部装饰线 */
.empty { position: relative; }
.empty::before {
  content: "";
  position: absolute; bottom: 6px; left: 50%;
  transform: translateX(-50%);
  width: 40px; height: 3px;
  background: var(--paper-line); border-radius: 2px;
  opacity: .4;
}

/* FAB 按钮外围光晕 */
.fab::before {
  content: "";
  position: absolute; inset: -4px;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(31,75,63,.2);
  transition: box-shadow .3s var(--ease);
  pointer-events: none;
}
.fab:active::before { box-shadow: 0 0 0 14px rgba(31,75,63,0); }

/* 日分组头部左侧小方块装饰 */
.day-head { position: relative; padding-left: 18px; }
.day-head::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 10px; height: 10px;
  border: 1.5px solid var(--brown-300); border-radius: 2px;
  opacity: .5;
}

/* ==================== 深色模式（data-theme="dark"） ==================== */
:root[data-theme="dark"] {
  /* 墨绿文字阶翻转：--ink-700 保留作品牌按钮底色（深绿），文字统一用 --ink-fg */
  --ink-900: #EDF5F0;
  --ink-fg:  #8FD9BC;   /* 强文字：浅薄荷，品牌一致且对比达标 */
  --ink-500: #3C7A66;
  --ink-300: #6FB3A0;   /* 次级/静默文字 */
  --ink-100: #33433D;   /* 描边 */
  --ink-50:  #1E2A25;   /* 浅色块背景 */

  /* 纸底翻转 */
  --paper-0: #13161A;
  --paper-1: #191D22;
  --paper-2: #21262B;   /* 卡片/表面 */
  --paper-line: #2C3330;

  /* 暖棕（深色底需提亮以满足 4.5:1） */
  --brown-700: #C2A07E;   /* 分类名/标签文字，需足够亮 */
  --brown-500: #C9A983;
  --brown-300: #9C8064;

  /* 语义色提亮（深色底更醒目） */
  --expense: #FF7A66;
  --expense-soft: #3A2420;
  --income: #4FD79A;
  --income-soft: #1E3329;
  --warn: #F5C15C;
  --danger: #FF6B5E;

  /* 阴影在深色底加重 */
  --shadow-card: 0 8px 24px rgba(0,0,0,.4);
  --shadow-fab: 0 10px 28px rgba(0,0,0,.55);
}
/* 关闭浅色纸纹，统一深色底（ specificity 高于 body.paper-* ） */
html[data-theme="dark"] body {
  background-color: var(--paper-0);
  background-image: none;
}
/* 深色模式下 tabbar / topbar 使用表面色而非纸白，避免“白条” */
:root[data-theme="dark"] .topbar { background: var(--paper-1); }
:root[data-theme="dark"] .tabbar { background: var(--paper-1); border-top-color: var(--ink-100); }

/* 半透明白表面在深色底统一改为深色表面（卡片/列表/键盘/分类块/心情/分段/月份选择） */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .list-row,
:root[data-theme="dark"] .keypad button,
:root[data-theme="dark"] .cat-tile,
:root[data-theme="dark"] .cat-chip,
:root[data-theme="dark"] .mood-chip,
:root[data-theme="dark"] .seg-tabs button,
:root[data-theme="dark"] .month-pick {
  background: var(--paper-2);
  border-color: var(--ink-100);
}
:root[data-theme="dark"] .card { border: 1px solid var(--ink-100); }
:root[data-theme="dark"] .icon-btn { background: rgba(255,255,255,.08); }
/* 日历热力格文字在深色底保持可读（彩色格上的白字） */
:root[data-theme="dark"] .heatmap .cell.has { color: rgba(255,255,255,.92); }
:root[data-theme="dark"] .heatmap .cell.has.lo { color: rgba(255,255,255,.92); }
:root[data-theme="dark"] .heatmap .cell.has.lo .v { color: rgba(255,255,255,.92); opacity: .85; }

/* 新元素深色模式同步 */
:root[data-theme="dark"] .cat-tile.has-kids { background: var(--paper-1); border-color: var(--ink-100); box-shadow: inset 0 -3px 0 0 var(--ink-500); }
:root[data-theme="dark"] .kids-badge { background: var(--ink-300); color: var(--ink-900); }
:root[data-theme="dark"] .cat-hint { background: rgba(111,179,160,.12); border-color: var(--ink-100); }
:root[data-theme="dark"] .cat-children { background: var(--paper-1); border-color: var(--ink-100); }
:root[data-theme="dark"] .cat-tile.add { background: rgba(111,179,160,.1); border-color: var(--ink-300); }
:root[data-theme="dark"] .cat-chip .pin-btn { background: var(--paper-1); border-color: var(--ink-100); }
:root[data-theme="dark"] .keypad button { background: linear-gradient(180deg, var(--paper-2), var(--paper-1)); color: var(--ink-900); }

/* ==================== 减弱动态效果（C3：晕动症用户） ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}


/* ==================== 深色精修（WorkBuddy 二期 2026-09-08） ==================== */
/* topbar 与页面同底：消除深色模式顶部的色块分层 */
:root[data-theme="dark"] .topbar { background: var(--paper-0); }
/* 进度条：槽底提亮一档可见；渐变末端不再沉入深色底 */
:root[data-theme="dark"] .progress { background: var(--paper-line); }
:root[data-theme="dark"] .progress .fill { background: linear-gradient(90deg, var(--ink-300), #8FD9BC); }
:root[data-theme="dark"] .progress .fill.warn { background: linear-gradient(90deg, var(--warn), #FFD98A); }
:root[data-theme="dark"] .progress .fill.over { background: linear-gradient(90deg, var(--expense), #FF9C8F); }
/* 胶带装饰在深底下降透明度：保留手账感、去掉闷块 */
:root[data-theme="dark"] .card.tape::before { opacity: .32; }
:root[data-theme="dark"] .net-asset::after { opacity: .22; }
