/**
 * style.css —— 「记得」记账+备忘 App 样式（iOS 设计语言）
 * ------------------------------------------------------------
 * 设计规范：
 * - 配色：iOS 系统色板（背景 #f2f2f7 / 卡片白 / 系统蓝 #007aff）
 * - 金额语义色：支出红 #ff3b30 / 收入绿 #34c759（国内习惯：涨红跌绿同理）
 * - 卡片：大圆角 + 柔和投影；主按钮蓝底白字；危险操作红字描边
 * - 安全区：顶部刘海 + 底部 Home 横条（env(safe-area-inset-*)）
 * - [hidden] 全局强制隐藏：防止 display:flex 覆盖导致弹窗常显（关键坑）
 */

/* ==================== 基础与变量 ==================== */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --blue: #007aff;
  --indigo: #5e5ce6;
  --orange: #ff9500;
  --red: #ff3b30;
  --green: #34c759;
  --separator: rgba(60, 60, 67, 0.12);
  --radius: 16px;
  --radius-btn: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 关键：任何 hidden 属性必须真正隐藏（防止弹窗遮罩常显） */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; border: none; cursor: pointer; background: none; color: inherit; }
input, textarea { font-family: inherit; }

/* ==================== 顶部标题 ==================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}
.app-header__row { display: flex; align-items: flex-start; justify-content: space-between; }
.app-header h1 { font-size: 28px; font-weight: 800; letter-spacing: 0.3px; }
.app-header__sub { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  border-radius: 12px;
  background: rgba(120, 120, 128, 0.12);
  transition: transform 0.12s;
}
.icon-btn:active { transform: scale(0.92); }

/* 右上角操作区：用户昵称 + 设置按钮 */
.app-header__actions { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 4px;
  max-width: 120px;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: rgba(120, 120, 128, 0.12);
  border-radius: 999px;
  padding: 9px 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: transform 0.12s;
}
.user-chip:active { transform: scale(0.95); }

/* ==================== 主内容区 ==================== */
.app-main {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 74px) 12px calc(86px + var(--safe-bottom));
}
.page { animation: pageIn 0.18s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==================== 卡片 ==================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(29, 46, 84, 0.06);
}
.card__title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.card__title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card__title-row .card__title { margin-bottom: 0; }

/* ==================== 概览：Hero 卡片 ==================== */
.hero-card {
  text-align: center;
  padding: 22px 16px 18px;
  background: linear-gradient(160deg, #eaf0ff 0%, #ffffff 70%);
  border: 0.5px solid rgba(94, 92, 230, 0.12);
}
.hero-card__label { font-size: 13px; color: var(--text-2); }
.hero-card__value { font-size: 46px; font-weight: 800; line-height: 1.15; letter-spacing: -1px; }
.hero-card__symbol { font-size: 22px; font-weight: 600; color: var(--text-2); margin-right: 4px; }
.hero-card__split { display: flex; justify-content: center; gap: 22px; margin-top: 10px; }
.hero-split { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.hero-split__label { font-size: 12px; color: var(--text-2); }
.hero-split__value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-split__value--in { color: var(--green); }
.hero-split__value--out { color: var(--red); }
.hero-split__divider { width: 1px; align-self: stretch; background: var(--separator); }
.hero-card__meta { margin-top: 12px; }

/* 徽标 */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(142, 142, 147, 0.10);
  color: var(--text-2);
}
.badge--in { background: rgba(52, 199, 89, 0.12); color: var(--green); }
.badge--out { background: rgba(255, 59, 48, 0.10); color: var(--red); }

/* 预算进度条 */
.goal-progress__head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.goal-progress__bar { height: 8px; border-radius: 4px; background: rgba(142, 142, 147, 0.16); overflow: hidden; }
.goal-progress__fill { height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--blue), #5ac8fa); transition: width 0.35s ease; }
.goal-progress__fill.is-warn { background: linear-gradient(90deg, #ff9500, #ffb340); }
.goal-progress__fill.is-over { background: linear-gradient(90deg, #ff3b30, #ff6482); }

/* ==================== 快捷入口 ==================== */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.quick-btn {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 10px rgba(29, 46, 84, 0.06);
  transition: transform 0.12s;
}
.quick-btn:active { transform: scale(0.97); }
.quick-btn__icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; border-radius: 12px;
}

/* ==================== 明细：月份卡与流水列表 ==================== */
.month-card { padding: 12px 16px; }
.cal-nav { display: flex; align-items: center; justify-content: center; gap: 14px; }
.cal-nav__title { font-size: 15px; font-weight: 600; min-width: 110px; text-align: center; }
.cal-nav__btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--blue);
  border-radius: 10px;
}
.cal-nav__btn:disabled { color: #c7c7cc; }
.month-sum { display: flex; justify-content: center; gap: 34px; margin-top: 8px; }
.month-sum__item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.month-sum__label { font-size: 11px; color: var(--text-2); }
.month-sum__value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.month-sum__value--out { color: var(--red); }
.month-sum__value--in { color: var(--green); }

/* 流水分组：日期头 + 行 */
.tx-group__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 2px 4px;
}
.tx-group__date { font-size: 12px; font-weight: 600; color: var(--text-2); }
.tx-group__sum { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--separator);
}
.tx-row:last-child { border-bottom: none; }
.tx-row__icon {
  width: 40px; height: 40px; flex: 0 0 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; border-radius: 12px;
  background: rgba(142, 142, 147, 0.10);
}
.tx-row__body { flex: 1; min-width: 0; }
.tx-row__title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row__sub { font-size: 12px; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row__amount { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.tx-row__amount--out { color: var(--text); }
.tx-row__amount--in { color: var(--green); }

/* ==================== 备忘页 ==================== */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(29, 46, 84, 0.06);
}
.search-bar__icon { font-size: 14px; opacity: 0.7; }
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.search-bar input::-webkit-search-cancel-button { -webkit-appearance: none; }

.note-stats { font-size: 12px; color: var(--text-2); margin: 0 4px 10px; }

/* 备忘筛选栏：状态筛选 + 多选按钮 */
.notes-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 2px 10px;
}
.segmented--sm .segmented__item { font-size: 12px; padding: 6px 12px; white-space: nowrap; }
.btn-mini {
  flex-shrink: 0;
  font-size: 12px; font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.10);
  color: var(--blue);
  transition: transform 0.12s;
}
.btn-mini:active { transform: scale(0.94); }
.btn-mini.is-active { background: var(--blue); color: #fff; }

/* 多选批量操作栏（悬浮在页签栏上方） */
.batch-bar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(10px + var(--safe-bottom));
  z-index: 40;
  display: flex; gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 8px 30px rgba(29, 46, 84, 0.22);
  animation: pageIn 0.18s ease-out;
}
.batch-bar button { flex: 1; font-size: 13px; padding: 10px 0; }
.batch-bar button[disabled] { opacity: 0.45; }

/* 备忘日期分组头 */
.note-group__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 4px 0;
  font-size: 12px; font-weight: 700; color: var(--text-2);
}
.note-group__head:first-child { padding-top: 0; }
.note-group__count { font-weight: 400; }
.note-group__pin {
  font-style: normal;
  font-size: 10px; font-weight: 700;
  color: var(--orange);
  background: rgba(255, 149, 0, 0.13);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
}

/* 便签流（单列卡片，置顶在前） */
.note-flow { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(29, 46, 84, 0.06);
  border: 0.5px solid rgba(60, 60, 67, 0.06);
  text-align: left; width: 100%;
  transition: transform 0.12s, opacity 0.2s;
  animation: pageIn 0.18s ease-out;
  cursor: pointer;
}
.note-card:active { transform: scale(0.985); }
.note-card--pinned { border-left: 3px solid var(--orange); }
/* 整条已完成：灰显 + 标题划线 */
.note-card--done { opacity: 0.62; }
.note-card--done .note-card__title { text-decoration: line-through; }

/* 状态文字：未完成红 / 已完成绿 */
.note-status {
  flex-shrink: 0;
  font-size: 11px; font-weight: 700;
}
.note-status.is-undone { color: var(--red, #ff3b30); }
.note-status.is-done { color: var(--green); }
/* 组内序号 */
.note-card__no { font-size: 12px; color: var(--text-2); font-weight: 600; flex-shrink: 0; font-variant-numeric: tabular-nums; }
/* 行内操作按钮：完成(/撤销) + 删除 */
.note-card__acts { display: flex; gap: 6px; flex-shrink: 0; }
.note-act {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  transition: transform 0.12s;
}
.note-act:active { transform: scale(0.94); }
.note-act--done { background: rgba(52, 199, 89, 0.13); color: var(--green); }
.note-act--done.is-done { background: rgba(120, 120, 128, 0.12); color: var(--text-2); }
.note-act--del { background: rgba(255, 59, 48, 0.10); color: var(--red, #ff3b30); }
/* 多选复选框 */
.note-check {
  width: 20px; height: 20px; flex: 0 0 20px;
  border-radius: 6px;
  border: 1.5px solid #c7c7cc;
  color: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.note-check.is-on { background: var(--blue); border-color: var(--blue); color: #fff; }
.note-card__head { display: flex; align-items: center; gap: 6px; }
.note-card__pin { font-size: 12px; }
.note-card__title { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card__time { font-size: 11px; color: var(--text-2); flex-shrink: 0; }
.note-card__content {
  font-size: 13px; color: #3a3a3c; margin-top: 6px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; word-break: break-word;
}
.note-card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.note-tag {
  font-size: 11px; color: var(--blue);
  background: rgba(0, 122, 255, 0.08);
  border-radius: 999px; padding: 2px 9px;
}

/* 备忘页内联新建按钮 */
.fab-inline {
  position: fixed;
  right: 18px;
  bottom: calc(96px + var(--safe-bottom));
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(10, 108, 255, 0.35);
  z-index: 15;
  transition: transform 0.12s;
}
.fab-inline:active { transform: scale(0.92); }

/* ==================== 统计页 ==================== */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card { margin-bottom: 0; padding: 13px 15px; }
.stat-card__label { font-size: 12px; color: var(--text-2); }
.stat-card__value { font-size: 20px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -0.3px; }
.stat-card__value--out { color: var(--red); }
.stat-card__value--in { color: var(--green); }

.donut-wrap { display: flex; justify-content: center; padding: 4px 0 12px; }
.donut-wrap canvas { width: 190px; height: 190px; }
.chart-wrap canvas { width: 100%; height: 200px; display: block; }

/* 分类排行 */
.cat-rank { margin-top: 4px; }
.cat-rank__row { padding: 9px 0; border-bottom: 1px solid var(--separator); }
.cat-rank__row:last-child { border-bottom: none; }
.cat-rank__top { display: flex; align-items: center; gap: 10px; }
.cat-rank__emoji {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; border-radius: 10px;
  background: rgba(142, 142, 147, 0.10);
}
.cat-rank__name { font-size: 14px; font-weight: 500; flex: 1; }
.cat-rank__amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cat-rank__percent { font-size: 12px; color: var(--text-2); width: 44px; text-align: right; }
.cat-rank__bar { height: 4px; border-radius: 2px; background: rgba(142, 142, 147, 0.12); margin-top: 7px; margin-left: 42px; overflow: hidden; }
.cat-rank__fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }

.legend-row { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* ==================== 备忘便签横滑（概览） ==================== */
.pinned-scroll { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.pinned-scroll .note-card { min-width: 220px; max-width: 220px; }

/* ==================== 分段控件（iOS） ==================== */
.segmented {
  display: flex;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 10px;
  padding: 2px;
  margin-bottom: 14px;
}
.segmented__item {
  flex: 1;
  padding: 7px 0;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  border-radius: 8px;
  transition: all 0.15s;
}
.segmented__item.is-active {
  background: #fff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ==================== 底部页签栏 ==================== */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: rgba(249, 249, 251, 0.94);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 0.5px solid rgba(60, 60, 67, 0.12);
}
.tabbar__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0;
  color: #9a9aa0;
}
.tabbar__item.is-active { color: var(--blue); }
.tabbar__icon { font-size: 21px; line-height: 1.2; filter: grayscale(0.1); }
.tabbar__text { font-size: 10px; font-weight: 500; }
.tabbar__item--center { justify-content: center; }
.tabbar__fab {
  width: 48px; height: 48px;
  margin-top: -22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  color: #fff;
  font-size: 26px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(10, 108, 255, 0.38);
  transition: transform 0.12s;
}
.tabbar__item:active .tabbar__fab { transform: scale(0.92); }

/* ==================== 全屏 Sheet（记一笔 / 备忘编辑） ==================== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  animation: sheetUp 0.22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet__inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 8px) 14px calc(8px + var(--safe-bottom));
  overflow: hidden; /* 固定布局：头/键盘固定，中部独立滚动，键盘不遮挡输入项 */
}
/* 记一笔中部滚动区：分类 + 二级分类 + 账户/日期/备注 */
.add-middle {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
}
.add-meta { padding-bottom: 4px; }
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 12px;
}
.sheet__title { font-size: 16px; font-weight: 700; }

/* 金额显示 */
.amount-display {
  display: flex; align-items: center; justify-content: flex-end; gap: 2px;
  padding: 10px 6px 14px;
  position: relative;
}
.amount-display__symbol { font-size: 26px; font-weight: 600; color: var(--text-2); margin-right: 6px; }
.amount-display__value {
  font-size: 44px; font-weight: 800; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: right;
}
.amount-clear {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  font-size: 13px; color: var(--red);
  padding: 6px 8px;
}
.amount-display.is-empty .amount-display__value { color: #c7c7cc; }

/* 分类网格 */
#catGrid { margin-bottom: 8px; }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 2px;
  border-radius: 12px;
  font-size: 12px; color: var(--text-2);
  transition: all 0.12s;
}
.cat-item__emoji {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border-radius: 50%;
  background: rgba(142, 142, 147, 0.10);
  transition: all 0.15s;
}
.cat-item.is-active { color: var(--blue); font-weight: 600; }
.cat-item.is-active .cat-item__emoji {
  background: rgba(0, 122, 255, 0.12);
  box-shadow: 0 0 0 2px var(--blue) inset;
  transform: scale(1.05);
}
.cat-item:active .cat-item__emoji { transform: scale(0.94); }

/* 记一笔中间 meta 区（位于滚动中区内，不再占 flex 剩余空间） */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.chip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.10);
  color: var(--text);
  transition: all 0.12s;
}
.chip.is-active { background: rgba(0, 122, 255, 0.12); color: var(--blue); font-weight: 600; }
.chip__emoji { font-size: 15px; }

/* 二级分类 chips 行 */
.sub-chips { padding: 2px 2px 10px; }
.sub-chips .chip { font-size: 12px; padding: 5px 11px; }
/* 二级分类「＋自定义」chip 与其展开的输入框 */
.chip--add { color: var(--blue); background: rgba(0, 122, 255, 0.08); font-weight: 600; }
.chip-input {
  flex-shrink: 0;
  width: 110px;
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(0, 122, 255, 0.35);
  outline: none;
  background: #fff;
  color: var(--text);
}

/* 备忘「下一笔」按钮 */
.btn-next {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--orange);
  color: #fff;
  font-size: 15px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(255, 149, 0, 0.30);
  transition: transform 0.12s;
}
.btn-next:active { transform: scale(0.98); }

/* 多笔暂存区：每笔一枚橙色胶囊，可单独移除 */
.pending-list {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 0 2px 8px;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.pending-chip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 149, 0, 0.12);
  color: var(--orange);
  font-weight: 600;
  animation: pageIn 0.18s ease-out;
}
.pending-chip b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pending-chip .pending-chip__del { color: var(--text-2); font-size: 13px; padding: 2px 4px; }

/* ==================== 数字键盘 ==================== */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}
.keypad__key {
  height: 50px;
  border-radius: 12px;
  background: #fff;
  font-size: 21px; font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(29, 46, 84, 0.10);
  transition: transform 0.08s, background 0.08s;
  user-select: none;
  -webkit-user-select: none;
}
.keypad__key:active { transform: scale(0.95); background: rgba(118, 118, 128, 0.16); }
.keypad__key--fn { background: rgba(118, 118, 128, 0.12); font-size: 18px; }
.keypad__key--next { background: rgba(255, 149, 0, 0.14); color: var(--orange); font-size: 15px; font-weight: 700; }
.keypad__key--next:active { background: rgba(255, 149, 0, 0.26); }
.keypad__key--wide { grid-column: span 2; }
.keypad__key--save {
  grid-column: span 2;
  background: linear-gradient(135deg, #0a84ff, #007aff);
  color: #fff;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.28);
}
.keypad__key--save:disabled {
  background: rgba(118, 118, 128, 0.16);
  color: #aeaeb2;
  box-shadow: none;
}

/* ==================== 备忘编辑器 ==================== */
.color-row { display: flex; gap: 12px; justify-content: center; padding: 4px 0 14px; }
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: all 0.15s;
  position: relative;
}
.color-dot.is-active { border-color: var(--blue); transform: scale(1.12); }
.color-dot.is-active::after {
  content: '✓';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--blue); font-weight: 700;
}

.note-editor {
  background: var(--card);
  border-radius: var(--radius);
  padding: 6px 16px;
  box-shadow: 0 2px 10px rgba(29, 46, 84, 0.06);
}
.note-editor__title {
  width: 100%;
  border: none; outline: none; background: transparent;
  font-size: 19px; font-weight: 700;
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--separator);
  color: var(--text);
}
/* 标题常用枚举 chips：历史频次 + 预置 */
.title-chips { padding: 6px 0 2px; }
.title-chips .chip { font-size: 12px; padding: 4px 11px; }
.note-editor__content {
  width: 100%;
  border: none; outline: none; background: transparent;
  font-size: 15px; line-height: 1.6;
  padding: 10px 0;
  resize: none; min-height: 130px;
  color: var(--text);
}

/* iOS 开关 */
.toggle {
  width: 48px; height: 29px;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.24);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle__knob {
  position: absolute; top: 2px; left: 2px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s;
}
.toggle.is-on { background: var(--green); }
.toggle.is-on .toggle__knob { transform: translateX(19px); }

/* ==================== 设置页 ==================== */
.page-settings { background: var(--bg); }
.settings-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.settings-head__title { font-size: 20px; font-weight: 800; }

/* ==================== 表单行 ==================== */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 0;
  border-bottom: 1px solid var(--separator);
}
.field-row--tight { min-height: 44px; }
.field-row:last-of-type { border-bottom: none; }
.field-row__label { flex: 0 0 92px; font-size: 14px; color: var(--text); }
.field-row__input {
  flex: 1; min-width: 0;
  border: none; outline: none;
  background: transparent;
  font-size: 16px;
  text-align: right;
  color: var(--text);
}
.field-row__input::placeholder { color: #c7c7cc; }
.field-row > .chip-row, .field-row > .toggle, .field-row > .unit-chips { margin-left: auto; }
.field-icon { font-size: 14px; margin-right: 2px; }
.field-row__input[type="date"] {
  min-height: 44px; padding: 0;
  -webkit-appearance: none; appearance: none;
  text-align: right;
}
.field-row__input[type="date"]::-webkit-date-and-time-value { text-align: right; }
.field-row__input[type="date"]::-webkit-calendar-picker-indicator { display: none; -webkit-appearance: none; }

/* ==================== 按钮体系 ==================== */
.btn-primary {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  font-size: 16px; font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #0a84ff, #007aff);
  border-radius: var(--radius-btn);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.28);
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: rgba(118, 118, 128, 0.16); color: #aeaeb2; box-shadow: none; }

.btn-secondary {
  padding: 11px;
  font-size: 14px; font-weight: 600;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.10);
  border-radius: var(--radius-btn);
  transition: transform 0.1s;
}
.btn-secondary:active { transform: scale(0.97); }

.btn-danger {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  font-size: 15px; font-weight: 600;
  color: var(--red);
  background: transparent;
  border: 1.5px solid rgba(255, 59, 48, 0.45);
  border-radius: var(--radius-btn);
  transition: transform 0.1s;
}
.btn-danger:active { transform: scale(0.98); background: rgba(255, 59, 48, 0.06); }

.btn-plain { font-size: 15px; color: var(--text); padding: 8px 4px; }
.btn-plain--primary { color: var(--blue); font-weight: 600; }

.btn-mini {
  font-size: 12px; font-weight: 600;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.10);
  padding: 5px 11px;
  border-radius: 999px;
}
.btn-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 4px; }

/* ==================== 弹窗 ==================== */
.modal-mask {
  position: fixed; inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.38);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 16px;
  padding: 20px 18px;
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.modal--narrow { max-width: 300px; }
.modal__title { font-size: 17px; font-weight: 700; text-align: center; }
.modal__desc { font-size: 14px; color: var(--text-2); text-align: center; margin-top: 8px; line-height: 1.5; }
.modal__actions { display: flex; gap: 10px; margin-top: 18px; }
.modal__actions .btn-secondary, .modal__actions .btn-danger { margin-top: 0; flex: 1; }

/* ==================== 空态与提示 ==================== */
.empty-state { text-align: center; padding: 30px 16px; color: var(--text); font-size: 15px; }
.empty-state__icon { font-size: 38px; margin-bottom: 8px; opacity: 0.85; }
.hint-text { font-size: 12px; color: var(--text-2); line-height: 1.55; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(110px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  max-width: 78vw;
  text-align: center;
  animation: toastIn 0.2s ease-out;
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ==================== 桌面端适配（窄窗口仍居中，最大 520px） ==================== */
@media (min-width: 560px) {
  .app-main, .app-header, .tabbar, .sheet__inner { max-width: 520px; }
  .app-header, .tabbar { left: 50%; transform: translateX(-50%); }
  .sheet__inner { left: 50%; transform: translateX(-50%); }
  .fab-inline { right: calc(50% - 242px); }
}
