/* ========== 基础 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* ===== v21 健康高端色彩补丁（唯一配色基准，后续 UI 一律以此为准）=====
     气质：自律 · 疗愈 · 静谧。严禁荧光青柠绿，严禁大面积铺色。 */
  --bg: #121212;            /* 页面底：中性碳黑，不带蓝倾向，非纯黑 */
  --bg-card: #1c1c1e;       /* 卡片 */
  --bg-sunk: #161616;       /* 下沉面：输入框 / 日志 / 内嵌面板 */
  --bg-raised: #232325;     /* 抬起面：浮层 / 列表项 / 弹窗按钮 */
  --bg-hover: #262628;

  /* 描边：1px 极低对比 + 顶部高光 */
  --border: rgba(255,255,255,0.08);
  --border-soft: rgba(255,255,255,0.04);
  --border-hi: rgba(255,255,255,0.14);

  /* 文字三级 */
  --text: #ffffff;          /* 主文字：纯白 */
  --text-sub: #8e8e93;      /* 次要灰 */
  --text-dim: #6e6e6e;

  /* 强调色：自然生命绿（唯一强调，绝不用荧光青柠） */
  --accent: #39d353;
  --accent-btn: #2ea043;    /* 主按钮深绿底 */
  --accent-line: rgba(57,211,83,0.45);   /* 浅绿描边 */
  --accent-soft: rgba(57,211,83,0.12);   /* 强调底（小面积） */
  --accent-dim: rgba(57,211,83,0.45);    /* 未达标进度填充 */
  --brand: #ffffff;
  --brand-dark: #ffffff;
  --primary: #ffffff;

  /* 语义色：仅状态标记与徽章，禁止大面积填充 */
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --blue: #6e6e6e;   /* 蓝已弃用：信息态退为中性灰 */

  /* 语义色的低透明度底（徽章底 / 状态块，始终小面积） */
  --ok-bg: rgba(63,185,80,0.12);
  --warn-bg: rgba(210,153,34,0.12);
  --danger-bg: rgba(248,81,73,0.12);

  /* 质感：圆角两档 + 阴影一档 */
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);

  /* 动效：150–250ms + 标准缓动 */
  --dur: 180ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* ========== 顶栏 ========== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: #161616;
  color: var(--text);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.title { font-size: 17px; font-weight: 500; letter-spacing: .3px; }
.sub { font-size: 12px; opacity: .85; margin-left: 8px; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ========== 按钮 ========== */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
/* v21 主按钮：深绿底 #2ea043 + 白字（自律、疗愈、绝不刺激） */
.btn-primary { background: var(--accent-btn); color: #ffffff; border: 1px solid var(--accent-btn); }
.btn-primary:hover { background: #348c4b; border-color: #348c4b; }
/* v21 次按钮：透明底 + 1px 浅绿描边 */
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent-line); }
.btn-secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-ghost {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }
.btn-close {
  background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--text-sub);
}

/* ========== 容器 ========== */
.container {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 24px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-header h2 { font-size: 16px; font-weight: 500; color: var(--text); }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  color: var(--text-sub);
  font-weight: 500;
}

/* ========== 表单 ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.form-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--text-sub);
  font-weight: 500;
}
/* 字段内联说明（如「热量缺口 / 盈余」的方向提示）：沿用原字号色板，不新增配色 */
.form-grid label .field-hint {
  font-size: 11px; font-weight: 400; line-height: 1.35;
  color: var(--text-sub);
}
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 14px;
  background: var(--bg-sunk);
  color: var(--text);
  transition: border-color var(--dur) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}
.computed-row {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 12px 14px;
  background: var(--bg-sunk);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 12px;
}
.computed-row b { font-size: 15px; color: var(--text); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ========== 总览卡 ========== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.metric {
  background: var(--bg-sunk);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  border: 1px solid var(--border);
}
.m-label { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.m-value { font-size: 22px; font-weight: 500; color: var(--text); }
.m-unit { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.alerts-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.alert-chip {
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
}
.alert-chip.ok { background: rgba(63,185,80,0.12); color: var(--ok); }
.alert-chip.warn { background: rgba(210,153,34,0.12); color: var(--warn); }
.alert-chip.danger { background: rgba(248,81,73,0.12); color: var(--danger); }
.alert-chip.info { background: rgba(255,255,255,0.06); color: var(--text-sub); }

/* ========== OCR ========== */
.ocr-card {
  background: rgba(210,153,34,0.08);
  border: 1px dashed rgba(210,153,34,0.45);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}
.ocr-card summary { cursor: pointer; font-weight: 500; color: var(--warn); margin-bottom: 8px; }
.ocr-card textarea { width: 100%; margin-top: 6px; font-family: ui-monospace, monospace; }
.ocr-result {
  margin-top: 8px;
  font-size: 12px;
  background: var(--bg-sunk);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 24px;
  max-height: 200px;
  overflow: auto;
}

/* ========== 宏量进度条 ========== */
.macro-bar {
  display: grid;
  grid-template-columns: 100px 1fr 100px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.macro-bar .name { color: var(--text); font-weight: 500; }
.macro-bar .progress {
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.macro-bar .fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--radius-sm);
  transition: width var(--dur) var(--ease);
}
.macro-bar .fill.warn { background: var(--yellow); }
.macro-bar .fill.over { background: var(--red); }
.macro-bar .val {
  text-align: right;
  font-size: 12px;
  color: var(--text-sub);
}
.macro-bar .val b { color: var(--text); }

/* ========== 微量营养素 ========== */
.micro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.micro-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-sunk);
  position: relative;
}
.micro-item.status-ok { background: rgba(63,185,80,0.10); border-color: rgba(63,185,80,0.30); }
.micro-item.status-warn { background: rgba(210,153,34,0.10); border-color: rgba(210,153,34,0.30); }
.micro-item.status-adv { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.16); }
.micro-item.status-danger { background: rgba(248,81,73,0.10); border-color: rgba(248,81,73,0.30); }
.micro-item .n { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.micro-item .v { font-size: 12px; color: var(--text-sub); }
.micro-item .v b { color: var(--text); font-size: 14px; }
/* v23 D2：微量徽章 = 12% 透明底 + SVG 圆点 + 12px 文字 */
.micro-item .badge-mini {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.micro-item .badge-mini .dot-svg { width: 10px; height: 10px; }
.badge-mini.ok { background: rgba(63,185,80,0.12); color: var(--ok); }
.badge-mini.warn { background: rgba(210,153,34,0.12); color: var(--warn); }
.badge-mini.adv { background: rgba(255,255,255,0.12); color: var(--text-sub); }
.badge-mini.danger { background: rgba(248,81,73,0.12); color: var(--danger); }

/* ========== 推荐 ========== */
.rec-item {
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.rec-item h4 { font-size: 14px; margin-bottom: 6px; color: var(--text); }
.rec-item .gap-info { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.rec-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rec-option {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 12px;
}
.rec-option h5 { font-size: 12px; color: var(--text-sub); margin-bottom: 6px; }
.rec-option .food { font-weight: 500; color: var(--text); font-size: 13px; }
.rec-option .detail { color: var(--text-sub); margin-top: 4px; line-height: 1.5; }

/* ========== 表格 ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: rgba(255,255,255,0.04); color: var(--text-sub); font-weight: 500; font-size: 11px; text-transform: uppercase; }
tbody tr:hover { background: rgba(255,255,255,0.04); }

/* ========== 行内删除按钮 ========== */
.btn-del-row {
  min-width: 40px; min-height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-raised); color: var(--text-sub);
  font-size: 16px; line-height: 1; cursor: pointer;
  padding: 0 8px;
}
.btn-del-row:hover { background: rgba(248,81,73,0.12); border-color: rgba(248,81,73,0.35); }
.op-col { white-space: nowrap; text-align: center; }

/* ========== Modal ========== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-body h3 { font-size: 14px; margin-top: 14px; margin-bottom: 6px; color: var(--brand-dark); }
.modal-body ul, .modal-body ol { padding-left: 20px; margin-bottom: 8px; line-height: 1.7; }
.modal-body p { margin-bottom: 8px; font-size: 13px; color: var(--text); }

/* ===== v36 确认退出弹窗（复用 .modal / .modal-content，配色全部走 :root token） =====
   视觉规范：#1c1c1e 卡片底（--bg-card）+ 1px rgba(255,255,255,.08) 描边（--border）
   + 10px 圆角（--radius）—— 全部沿用现有 token，不写死任何颜色。 */
#modal-exit .modal-content { max-width: 320px; text-align: center; }
#modal-exit .modal-header { justify-content: center; margin-bottom: 6px; }
#modal-exit .exit-title { font-size: 15px; }
#modal-exit .exit-text { font-size: 13px; line-height: 1.6; color: var(--text-sub); margin-bottom: 18px; }
#modal-exit .exit-actions { justify-content: center; }
#modal-exit .exit-actions .btn-ghost,
#modal-exit .exit-actions .btn-primary { flex: 1 1 0; min-width: 108px; }
/* 确认按钮：生命绿实心（底用 token --accent，字用页面底色 token --bg 保证对比度） */
#modal-exit #btn-exit-ok { background: var(--accent); border-color: var(--accent); color: var(--bg); }
#modal-exit #btn-exit-ok:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.blue { background: var(--blue); }
.dot.red { background: var(--red); }
#tbl-links { list-style: none; padding-left: 0; }
#tbl-links li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
#tbl-links a { color: var(--accent); text-decoration: none; }

/* ========== Toast ========== */
#toast {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  /* v33：空容器绝不能挡住底部 Tab 栏的点击（命中测试保险） */
  pointer-events: none;
}
.toast-msg { pointer-events: auto; }
.toast-msg {
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slide-in var(--dur) var(--ease);
}
.toast-msg.ok { background: rgba(63,185,80,0.16); color: var(--ok); border-color: rgba(63,185,80,0.35); }
.toast-msg.err { background: rgba(248,81,73,0.16); color: var(--danger); border-color: rgba(248,81,73,0.35); }
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 食物搜索提示 ========== */
.food-hint { font-size: 12px; line-height: 1.5; margin-top: 4px; min-height: 0; }
.food-hint.ok { color: var(--ok); }
.food-hint.new { color: var(--warn); }
.hint-adopt { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ========== Combobox 候选浮层 ========== */
.food-picker { position: relative; }
.food-suggest {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  z-index: 60;
}
.food-suggest:empty { display: none; }
.food-suggest .fs-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px; min-height: 44px;
  cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.food-suggest .fs-item:last-of-type { border-bottom: none; }
.food-suggest .fs-item:hover,
.food-suggest .fs-item.active { background: rgba(255,255,255,0.06); }
.food-suggest .fs-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-suggest .fs-item .meta { font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.food-suggest .fs-new {
  padding: 10px 12px; min-height: 44px; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 500;
  border-top: 1px dashed var(--border);
  background: var(--bg-sunk);
}
.food-suggest .fs-new:hover { background: rgba(255,255,255,0.06); }

/* ---- v32 修复 1：抽屉内的联想列表脱离输入框宽度，横跨整个抽屉 ----
   JS 会按输入框与抽屉的实测位置覆写 left / right；这里给出基础值 + 悬浮层级。 */
.sheet .food-picker .food-suggest {
  left: 0; right: 0; width: 100%;
  z-index: 999;
  max-height: 200px; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}
/* 列表项不截断文字：整行可横向滚动 */
.sheet .food-picker .food-suggest .fs-item,
.sheet .food-picker .food-suggest .fs-new {
  white-space: nowrap; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sheet .food-picker .food-suggest .fs-item::-webkit-scrollbar,
.sheet .food-picker .food-suggest .fs-new::-webkit-scrollbar { display: none; }
.sheet .food-picker .food-suggest .fs-item .name {
  flex: 0 0 auto; min-width: 0; max-width: none;
  overflow: visible; text-overflow: clip;
}
.sheet .food-picker .food-suggest .fs-item .meta { flex: 0 0 auto; margin-left: auto; padding-left: 10px; }
/* 键盘弹出（视口变矮）时进一步收短，避免盖住输入框 */
@media (max-height: 700px) {
  .sheet .food-picker .food-suggest { max-height: 150px; }
}

/* ========== 新增食材 modal ========== */
.nf-group h3 { font-size: 13px; margin: 12px 0 6px; color: var(--brand-dark); }
.nf-group summary { cursor: pointer; font-weight: 500; color: var(--brand-dark); padding: 8px 0; font-size: 13px; }
.nf-group summary::marker { color: var(--accent); }
#nf-src[readonly] { background: var(--bg-sunk); color: var(--text-sub); }

/* ========== 数据维护 modal ========== */
.maintain-actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.maintain-actions button { width: 100%; }
.maintain-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
#maintain-log {
  max-height: 220px; overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6;
  padding: 10px 12px;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm);
  white-space: pre-wrap; word-break: break-word;
}

/* ========== OCR 结果 ========== */
.ocr-chip {
  display: inline-block; padding: 2px 6px; margin: 2px;
  background: rgba(210,153,34,0.14); border-radius: var(--radius-sm); font-size: 12px;
}
.ocr-save-row { display: flex; gap: 8px; margin-top: 8px; }
.ocr-save-row input { flex: 1; }

/* ========== 安装提示条 ========== */
.install-banner {
  display: none;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
}
.install-banner.show { display: flex; }
.install-banner .txt { line-height: 1.45; }
.install-banner .txt b { display: block; font-size: 14px; }
.install-banner button {
  background: #f0f0f0; color: #121212;
  border: none; border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.install-banner .close {
  background: rgba(255,255,255,.08); color: var(--text); padding: 4px 8px;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .container { padding: 0; margin: 0; gap: 10px; }
  .container > .card { min-width: 0; } /* 防止子元素撑开整页 */
  .card {
    border-radius: 0;
    padding: 14px 14px 16px;
    border-left: none; border-right: none;
    box-shadow: none;
    border-bottom: 6px solid var(--bg);
    max-width: 100%;
  }
  .card:last-child { border-bottom: none; }
  .card-header { margin-bottom: 10px; }
  .card-header h2 { font-size: 15px; }
  .badge { font-size: 10px; padding: 2px 6px; }

  /* 顶栏更紧凑 */
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .brand { gap: 6px; flex: 1; min-width: 0; }
  .logo { font-size: 18px; }
  .title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sub { display: none; }
  .topbar-actions { gap: 4px; margin-left: auto; }
  .btn-ghost { padding: 6px 8px; font-size: 11px; }

  /* 8 指标卡：中等屏 2 列 */
  .summary-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; margin-bottom: 10px; }
  .metric { padding: 10px 8px; border-radius: var(--radius-sm); }
  .m-label { font-size: 11px; }
  .m-value { font-size: 20px; }
  .m-unit { font-size: 10px; }
  .alerts-row { padding-top: 10px; }

  /* 表单两列：个人基础档案的性别/昵称等并排双列 */
  .form-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; margin-bottom: 10px; }
  .form-grid label { font-size: 13px; min-width: 0; overflow-wrap: break-word; }
  /* v31 修复：栅格子项默认 min-width:auto，number/search 输入框的固有宽度会把两列撑出屏幕 */
  .form-grid label input,
  .form-grid label select,
  .form-grid label textarea,
  .form-grid label .food-picker,
  .form-grid label .food-picker input { width: 100%; min-width: 0; max-width: 100%; }
  input, select, textarea { font-size: 16px; padding: 10px 12px; min-height: 42px; border-radius: var(--radius-sm); }

  /* 计算结果横滑 */
  .computed-row {
    overflow-x: auto; flex-wrap: nowrap;
    gap: 16px; padding: 10px 12px;
    width: 100%; max-width: 100%;
  }
  .computed-row span { white-space: nowrap; }
  .computed-row b { font-size: 14px; }

  /* 操作按钮全宽 */
  .actions-row { flex-direction: column; gap: 8px; }
  .actions-row button { width: 100%; padding: 11px; font-size: 15px; min-height: 44px; }

  /* v25：宏量进度条手机端两列并排（原来每项独占一行，板块被拉得过长） */
  #macro-bars {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .macro-bar {
    grid-template-columns: auto 1fr auto !important;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    padding: 9px 10px;
    background: var(--bg-sunk);
    border-radius: var(--radius-sm);
  }
  .macro-bar .name { font-size: 11px; line-height: 1.1; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .macro-bar .progress { order: 0; height: 8px; }
  .macro-bar .val { text-align: right; font-size: 10px; order: 0; white-space: nowrap; line-height: 1.1; }

  /* v25：微量营养素手机端两列并排 */
  .micro-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .micro-item { padding: 10px; }
  .micro-item .n { font-size: 13px; padding-right: 46px; }   /* 让出右上角徽章 */
  .micro-item .v { font-size: 12px; }
  .badge-mini { font-size: 11px; padding: 3px 7px; }

  /* 推荐卡片 */
  .rec-options { grid-template-columns: 1fr !important; }
  .rec-item { padding: 12px; }
  .rec-option { padding: 12px; }
  .rec-option h5 { font-size: 12px; }
  .rec-option .food { font-size: 14px; }

  /* 表格横向滚动,首列固定 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  #intake-detail-table { min-width: 808px; font-size: 12px; }
  #intake-detail-table th:first-child,
  #intake-detail-table td:first-child {
    position: sticky; left: 0;
    background: var(--bg-card);
    z-index: 2;
    min-width: 52px;
  }
  #intake-detail-table th:first-child { background: var(--bg-sunk); }
  #intake-detail-table th:last-child,
  #intake-detail-table td:last-child {
    position: sticky; right: 0;
    background: var(--bg-card);
    z-index: 2;
    min-width: 48px;
    border-left: 1px solid var(--border);
  }
  #intake-detail-table th:last-child { background: var(--bg-sunk); }

  /* 提示条、Toast */
  .food-hint { font-size: 12px; }
  .ocr-save-row { flex-direction: column; }
  .ocr-save-row button { width: 100%; }
  #toast { left: 10px; right: 10px; bottom: 10px; }
  .toast-msg { font-size: 13px; padding: 10px 12px; }

  /* 弹窗几乎全屏 */
  .modal { padding: 0; align-items: flex-end; }
  .modal-content {
    border-radius: var(--radius) var(--radius) 0 0;
    max-width: 100%;
    max-height: 85vh;
    padding: 18px;
  }

  /* Combobox 浮层：iOS 防聚焦缩放 */
  .food-suggest .fs-item,
  .food-suggest .fs-new { font-size: 15px; }
}

@media (max-width: 359px) {
  /* 超窄屏：总览才单列 */
  .summary-grid { grid-template-columns: 1fr !important; }
  .m-value { font-size: 22px; }
}

@media (min-width: 360px) and (max-width: 768px) {
  /* 主流手机(360-768px)：总览固定 2 列,更紧凑 */
  .summary-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .metric { padding: 10px 6px; }
  .m-value { font-size: 19px; }
}

/* ============== v8 增量：体重预测 / 食材查询 / 知识库 Tab ============== */
.predict-body { font-size: 13px; line-height: 1.7; padding: 4px 8px; }
.predict-body .delta-pos { color: var(--danger); font-weight: 500; }
.predict-body .delta-neg { color: var(--text-sub); font-weight: 500; }
.predict-body .delta-zero { color: var(--text-dim); font-weight: 500; }
.predict-body table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.predict-body td, .predict-body th { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 12px; }

.fab-mini {
  position: fixed; right: 18px; bottom: 18px;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary); color: #121212;
  border: none; font-size: 20px; box-shadow: var(--shadow);
  cursor: pointer; z-index: 999;
  transition: transform var(--dur) var(--ease);
}
.fab-mini:active { transform: scale(0.92); }

.fq-results { margin-top: 12px; max-height: 60vh; overflow-y: auto; }
.fq-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: var(--bg-sunk); }
.fq-card h4 { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.fq-card .src { font-size: 11px; color: var(--text-sub); margin-left: 6px; }
.fq-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: 11.5px; margin-top: 4px; }
.fq-grid div { color: var(--text-sub); }
.fq-grid b { color: var(--text); }
.fq-empty { color: var(--text-dim); font-size: 13px; padding: 20px 0; text-align: center; }

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab-btn { background: none; border: none; padding: 8px 14px; cursor: pointer; font-size: 13px; color: var(--text-sub); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--dur) var(--ease); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel.hidden { display: none; }

/* ============== v9 增量：判定面板 + 知识库图表 ============== */
.judge-panel {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: var(--bg-sunk);
  border-left: 2px solid var(--text-dim);
  font-size: 13px; line-height: 1.7;
}
.judge-panel.ok        { background: rgba(63,185,80,0.10); border-left-color: var(--ok); }
.judge-panel.warn      { background: rgba(210,153,34,0.10); border-left-color: var(--warn); }
.judge-panel.danger    { background: rgba(248,81,73,0.10); border-left-color: var(--danger); }
.judge-panel.info      { background: rgba(255,255,255,0.05); border-left-color: var(--text-dim); }
.judge-icon  { font-size: 22px; flex-shrink: 0; }
.judge-text  { color: var(--text); white-space: pre-wrap; }
.judge-text .row { display: block; }

.kb-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 8px 0 14px;
}
.kb-table th, .kb-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left;
}
.kb-table th { background: rgba(255,255,255,0.04); color: var(--text-sub); font-weight: 500; }
.kb-table td svg { vertical-align: middle; }

.kb-svg, .kb-radar {
  display: block; max-width: 100%; height: auto;
  margin: 6px 0 14px; padding: 8px;
  background: var(--bg-sunk); border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* ============== v9 polish：完成度环 + 加入今日按钮 + KB 小修 ============== */
.completion-ring { display: flex; align-items: center; gap: 14px; margin: 8px 0 4px; padding: 4px 8px; }
.completion-text .pct { font-size: 22px; font-weight: 500; color: var(--text); line-height: 1; }
.completion-text .lbl { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

.btn-add-rec {
  margin-top: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border-hi); color: var(--text);
  border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; transition: all var(--dur) var(--ease);
}
.btn-add-rec:hover:not(:disabled) { background: var(--brand-dark); color: #121212; }
.btn-add-rec:disabled { background: rgba(255,255,255,0.03); color: var(--text-dim); border-color: var(--border); cursor: default; }

/* 移动端悬浮按钮避让 */
@media (max-width: 640px) {
  .fab-mini { right: 12px; bottom: 70px; width: 42px; height: 42px; font-size: 18px; }
}

/* 缺口推荐内元素换行 */
.rec-option { padding: 6px 8px; border-radius: var(--radius-sm); }
.rec-option .food { font-weight: 500; color: var(--text); margin: 2px 0; }
.rec-option .detail { font-size: 11.5px; color: var(--text-sub); line-height: 1.5; }

.kb-myth {
  border-left: 2px solid var(--danger);
  background: rgba(248,81,73,0.10);
  padding: 8px 12px;
  margin: 8px 0;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.kb-myth-q { color: var(--danger); font-weight: 500; margin-bottom: 3px; }
.kb-myth-a { color: var(--text); line-height: 1.6; }

/* v10 知识库新增板块样式（沿用现有色板，仅新增不改动） */
.kb-h { font-size: 14px; font-weight: 500; color: var(--text); margin: 18px 0 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kb-h .tag { font-size: 11px; font-weight: 500; color: var(--text-sub); background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 6px; }
.kb-lv { display: block; margin-top: 5px; font-size: 11px; color: var(--text-sub); }
.kb-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kb-cap { font-size: 12.5px; color: var(--text-sub); line-height: 1.7; margin: 4px 0 2px; padding-left: 18px; }
.kb-cap li { margin: 4px 0; }
.kb-cap li b { color: var(--text); }
.kb-note { font-size: 11.5px; color: var(--text-sub); margin: 4px 0 12px; }


/* ============== 第三批新增组件 ============== */
/* 1. 三大营养素供能占比扇形图 */
.macro-pie-wrap {
  margin-top: 12px; padding: 10px 12px;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.mp-title { font-size: 12px; font-weight: 500; color: var(--text-sub); margin-bottom: 6px; }
.macro-pie { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mp-svg { width: 140px; height: 140px; flex: 0 0 140px; }
.pie-empty { width: 100%; padding: 26px 16px; text-align: center; color: var(--text-sub); font-size: 12.5px; }
.mp-legend-box { flex: 1 1 180px; min-width: 180px; }
.mp-legend { font-size: 12px; color: var(--text-sub); margin: 4px 0; }
.mp-legend b { color: var(--text); font-weight: 500; }
.mp-legend .dot { margin-right: 6px; }

/* 2. 营养查询详情弹窗 */
.fd-meta {
  font-size: 12.5px; color: var(--text-sub); line-height: 1.7;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; margin-bottom: 10px;
}
.fd-meta b { color: var(--text); }
.fd-tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: var(--radius-sm); margin-left: 4px; }
.fd-tag.builtin { background: rgba(255,255,255,0.06); color: var(--text-sub); }
.fd-tag.user { background: rgba(63,185,80,0.12); color: var(--ok); }
.fd-group-title { font-size: 13px; margin: 12px 0 6px; color: var(--brand-dark); }
.fd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.fd-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 5px 8px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fd-k { font-size: 12px; color: var(--text-sub); }
.fd-v { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; }
.fd-u { font-size: 10.5px; font-weight: 400; color: var(--text-sub); margin-left: 3px; }
.fd-ops { margin-top: 12px; display: flex; gap: 8px; }
.fq-card.fq-click { cursor: pointer; }
.fq-card.fq-click:hover { border-color: var(--brand); }
.fq-more { font-size: 11px; color: var(--accent); margin-top: 4px; }

/* 3. 微量营养素风险提示行 */
.micro-item .risk { margin-top: 4px; font-size: 11px; line-height: 1.4; }
.micro-item .risk.low { color: var(--danger); }
.micro-item .risk.ok { color: var(--ok); }
.micro-item .risk.over { color: var(--danger); }

/* 4. 我的食物库 */
.mf-tip { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.mf-list { display: flex; flex-direction: column; gap: 8px; }
.mf-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.mf-main { min-width: 0; flex: 1 1 auto; }
.mf-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-meta { font-size: 11.5px; color: var(--text-sub); margin-top: 2px; }
.mf-ops { display: flex; gap: 6px; flex: 0 0 auto; }
.mf-btn {
  min-height: 30px; padding: 4px 10px; font-size: 12px; cursor: pointer;
  background: var(--bg-raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.mf-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.mf-btn.danger:hover { border-color: var(--red); color: var(--red); }
.mf-empty {
  padding: 18px 12px; text-align: center; font-size: 12.5px; color: var(--text-sub);
  background: var(--bg-sunk); border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.mf-actions { margin-top: 10px; }
.nf-lock-tip {
  background: rgba(210,153,34,0.10); border: 1px solid rgba(210,153,34,0.30); color: var(--warn);
  font-size: 12.5px; padding: 8px 10px; border-radius: var(--radius-sm); margin-bottom: 10px;
}

/* 5. 加入今日确认框 */
.modal-sm { max-width: 380px; }
.ar-food { font-weight: 500; font-size: 14px; margin-bottom: 8px; }
.ar-label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.ar-hint { font-size: 11.5px; color: var(--text-sub); }
#ar-amount { width: 100%; padding: 8px 10px; font-size: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ar-tip { font-size: 11.5px; color: var(--text-sub); margin-top: 6px; }
.ar-actions { margin-top: 12px; }

/* 6. 锚点导航 */
.anchor-nav {
  position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
  z-index: 40; display: flex; flex-direction: column; gap: 6px;
}
.anchor-btn {
  min-height: 34px; padding: 6px 10px; font-size: 12px; cursor: pointer;
  color: var(--text); background: rgba(31,31,31,.95);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.anchor-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.anchor-btn.active { background: var(--brand); border-color: var(--brand); color: #121212; }

@media (max-width: 768px) {
  .anchor-nav {
    right: 0; left: 0; top: auto; bottom: 0; transform: none;
    flex-direction: row; gap: 6px; overflow-x: auto;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) 8px;
    background: rgba(18,18,18,.96); border-top: 1px solid var(--border);
  }
  .anchor-btn { flex: 0 0 auto; min-height: 36px; }
  .macro-pie { justify-content: center; }
  .container { padding-bottom: 64px; }
}

/* ============== v11：卡片折叠 + 体重理论趋势预测 ============== */
/* —— 卡片折叠 —— */
.card { scroll-margin-top: 74px; }   /* 锚点跳转时避开 sticky 顶栏（约 61px） */
.card-header { cursor: pointer; }
.card-header h2 { margin: 0; }
.card-header .badge,
.card-header label { margin-left: auto; }
.card-toggle {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: inline-flex; align-items: center; justify-content: center;
  margin: 0 8px 0 0; padding: 0; border: none; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06); color: var(--text-sub);
  font-size: 15px; line-height: 1; cursor: pointer;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.card-toggle:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.card.collapsed .card-toggle { transform: rotate(-90deg); }
.card.collapsed > *:not(.card-header) { display: none !important; }

/* —— 体重理论趋势预测 —— */
.wp-block {
  margin-top: 14px; padding: 14px 16px;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius);
}
.wp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.wp-title { font-size: 14px; font-weight: 500; color: var(--text); margin: 0; }
.wp-range { font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.wp-range select { font-size: 13px; padding: 4px 8px; min-height: auto; }
.wp-svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 6px auto 0; background: var(--bg-sunk); border-radius: var(--radius-sm); }
.wp-stats { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; font-size: 12.5px; color: var(--text-sub); }
.wp-stats b { color: var(--text); font-weight: 500; }
.wp-caption { margin-top: 8px; font-size: 11.5px; color: var(--text-sub); line-height: 1.5; }
.wp-empty { padding: 18px 12px; text-align: center; font-size: 12.5px; color: var(--text-sub); background: var(--bg-sunk); border: 1px dashed var(--border); border-radius: var(--radius-sm); }

@media (max-width: 768px) {
  .card { scroll-margin-top: 92px; }
  .wp-range select { min-height: auto; font-size: 13px; }
  /* 手机上把折叠按钮做大做明显，避免“看不见 / 点不中” */
  .card-toggle { width: 36px; height: 36px; flex-basis: 36px; font-size: 17px; margin-right: 8px; }
}

/* ============== v15：补剂录入 / 明细全字段 / OCR 预览 ============== */
/* 录入口切换（食物 / 补剂）与面板显隐 */
.intake-tabs { margin: 2px 0 12px; }
#intake-food-grid.hidden,
#intake-food-actions.hidden,
#intake-supp-panel.hidden { display: none !important; }
#intake-supp-panel .form-grid { margin-bottom: 0; }
#s-supp { width: 100%; }
.supp-note {
  font-size: 11.5px; color: var(--text-sub); line-height: 1.6;
  margin-top: 8px; padding: 8px 10px; background: var(--bg-sunk);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* 明细表：全套 30 列，横向滚动 + 列头带单位 */
#intake-detail-table th,
#intake-detail-table td {
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 8px;
}
#intake-detail-table th .th-u { font-weight: 400; opacity: .7; font-size: 10px; margin-left: 1px; }
#intake-detail-table td.dt-food { max-width: 200px; white-space: normal; word-break: break-all; }
.dt-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 10px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.06); color: var(--text-sub);
  vertical-align: middle; white-space: nowrap;
}
.dt-hint { font-size: 11.5px; color: var(--text-sub); margin-top: 8px; line-height: 1.6; }

/* 我的食物库：食物 / 补剂 分栏 */
.mf-tabs { margin: 2px 0 10px; }

/* 新增食材：补剂提示 */
.nf-supp-tip {
  display: none; font-size: 12px; color: var(--warn); background: rgba(210,153,34,0.10);
  border: 1px solid rgba(210,153,34,0.30); border-radius: var(--radius-sm); padding: 8px 10px;
  margin: 6px 0 10px; line-height: 1.65;
}

/* OCR 预览弹窗 */
.ocr-basis { font-size: 12px; color: var(--text-sub); margin: 4px 0 8px; line-height: 1.6; }
.ocr-ok-note { font-size: 12.5px; color: var(--ok); margin-bottom: 6px; }
.ocr-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.ocr-chip.learned { background: rgba(63,185,80,0.12); color: var(--ok); border-color: rgba(63,185,80,0.28); }
.ocr-u-title { font-size: 13px; font-weight: 500; color: var(--warn); margin: 10px 0 6px; }
.ocr-unmatched { display: flex; flex-direction: column; gap: 8px; }
.ocr-u-row {
  border: 1px dashed rgba(248,81,73,0.35); background: rgba(248,81,73,0.10);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.ocr-u-line { font-size: 12.5px; color: var(--danger); margin-bottom: 6px; word-break: break-all; line-height: 1.5; }
.ocr-u-row select { width: 100%; }
.ocr-u-hint { font-size: 11.5px; color: var(--warn); margin-top: 5px; line-height: 1.55; }

/* ========== 版本更新提示条 ==========
   位于 <header> 与 <main> 之间（body 直接子元素），不参与 .container 的 grid，
   宽度用 calc(100% - 48px) 与卡片左右对齐，避免桌面端列宽被撑大后按钮跑到视口外。
   默认隐藏；关掉后同一版本不再弹（不打扰）。 ========== */
.update-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: calc(100% - 48px);
  max-width: 1232px;
  margin: 12px auto 0;
  padding: 9px 12px;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
}
.update-bar.show { display: flex; }
.update-bar .txt { flex: 1; min-width: 0; }
.update-bar .acts { display: flex; align-items: center; gap: 6px; flex: none; }
.update-bar button {
  border: none; border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
  background: #f0f0f0; color: #121212;
}
.update-bar button:hover { opacity: .88; }
.update-bar .close { background: rgba(255,255,255,.08); color: var(--text); padding: 4px 8px; }

/* 更新确认弹窗正文 */
.up-body { font-size: 13.5px; line-height: 1.8; color: var(--text); margin-bottom: 14px; }
.up-body b { color: var(--text); }
.up-body .up-tip { display: block; margin-top: 8px; color: var(--text-sub); font-size: 12.5px; }

/* 顶栏版本徽标：网页版 / 添加到主屏的版本，都能一眼看出跑的是哪一版 */
.ver-badge {
  font-size: 11px; font-weight: 500; line-height: 1.7;
  padding: 1px 7px; margin-left: 2px;
  border-radius: var(--radius-sm); white-space: nowrap;
  background: rgba(255,255,255,.08); color: var(--text);
  border: 1px solid var(--border);
  vertical-align: middle;
}

@media (max-width: 768px) {
  /* 手机端卡片去圆角、满宽，提示条跟着满宽 */
  .update-bar { width: 100%; max-width: none; margin: 10px 0 0; border-radius: 0; font-size: 12.5px; }
  .update-bar button { padding: 6px 10px; }
  .ver-badge { font-size: 10px; padding: 1px 6px; }
}


/* ========== v20：去蓝光暗色基调 · 全局补充 ==========
   说明：这一节只做全局性兜底（原生控件配色、数字等宽、滚动条、
   减少动效），不改变任何既有布局与组件结构。 ========== */
html { color-scheme: dark; }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;   /* 所有数字等宽，避免跳动 */
}
input, select, textarea, button { font-variant-numeric: tabular-nums; }
/* 字重只用 400 / 500：压掉浏览器对 b/strong/标题/表头的默认 700 */
b, strong, h1, h2, h3, h4, h5, h6, th, optgroup, legend { font-weight: 500; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
::selection { background: rgba(255,255,255,0.16); color: var(--text); }
a { color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-sunk); }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-sunk);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* 卡片顶部 1px 微弱高光（仅在桌面端叠加，手机端沿用原有的无阴影方案） */
@media (min-width: 769px) {
  .card { box-shadow: var(--shadow), inset 0 1px 0 var(--border-soft); }
}

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

/* =========================================================
   v21 组件层 · 健康高端暗色
   A3 驾驶舱 / A4 膳食明细 / C1 缺口推荐 / C2 饮水运动
   C3 我的常吃 / C4 营养表解析
   ========================================================= */
.u21-hidden { display: none !important; }
.u21-ic { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }
.u21-ic svg { width: 100%; height: 100%; display: block; }
/* v23：index.html 里的图标占位（由 ui21 注入内联 SVG） */
.ui-ic {
  width: 15px; height: 15px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: -2px; color: currentColor;
}
.ui-ic svg { width: 100%; height: 100%; display: block; }
.u21-num { font-weight: 600; color: #ffffff; font-variant-numeric: tabular-nums; }

/* ---- 底部 Toast（全局禁用 alert / prompt / confirm，一律用它） ---- */
#u21-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 400; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.u21-msg {
  padding: 10px 16px; border-radius: var(--radius); background: var(--bg-raised);
  border: 1px solid var(--border); color: var(--text); font-size: 13px;
  box-shadow: var(--shadow-md); animation: u21-in 200ms var(--ease);
}
.u21-msg.ok { border-color: rgba(57,211,83,0.35); }
.u21-msg.warn { border-color: rgba(210,153,34,0.40); }
.u21-msg.err { border-color: rgba(248,81,73,0.42); color: var(--danger); }
@keyframes u21-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- 暗色确认弹窗 / 底部抽屉 ---- */
.u21-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62); z-index: 320;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: u21-fade 160ms var(--ease);
}
@keyframes u21-fade { from { opacity: 0; } to { opacity: 1; } }
.u21-sheet {
  width: 100%; max-width: 380px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  box-shadow: var(--shadow-md);
}
.u21-sheet h4 { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.u21-sheet p { font-size: 13px; color: var(--text-sub); line-height: 1.7; }
.u21-acts { display: flex; gap: 10px; margin-top: 18px; }
.u21-acts button {
  flex: 1; padding: 10px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer; border: 1px solid transparent;
  transition: all var(--dur) var(--ease);
}
.u21-btn-ok { background: var(--accent-btn); color: #ffffff; }
.u21-btn-ok:hover { background: #348c4b; }
.u21-btn-danger { background: transparent; color: var(--danger); border-color: rgba(248,81,73,0.45); }
.u21-btn-danger:hover { background: rgba(248,81,73,0.10); }
.u21-btn-cancel { background: transparent; color: var(--text-sub); border-color: var(--border); }
.u21-btn-cancel:hover { background: rgba(255,255,255,0.05); color: var(--text); }

.u21-drawer-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62); z-index: 330;
  display: flex; align-items: flex-end; justify-content: center;
}
.u21-drawer {
  width: 100%; max-width: 520px; background: var(--bg-card);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 16px 16px 0 0; padding: 18px 20px 26px;
  animation: u21-up 220ms var(--ease);
}
@keyframes u21-up { from { transform: translateY(100%); } to { transform: none; } }
.u21-drawer h4 { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 14px; }
.u21-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--text-sub); }
.u21-field input, .u21-field select {
  background: var(--bg-sunk); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; width: 160px;
}
.u21-field input:focus, .u21-field select:focus { outline: none; border-color: var(--accent-line); }

/* ================= A3 驾驶舱 ================= */
.a3-cockpit {
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px;
}
.a3-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.a3-cap { font-size: 12px; color: var(--text-sub); letter-spacing: 0.4px; }
.a3-big {
  font-size: 30px; font-weight: 600; color: #ffffff;
  font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -0.5px;
}
.a3-big em { font-style: normal; font-size: 13px; font-weight: 400; color: var(--text-sub); margin-left: 6px; }
.a3-remain { text-align: right; font-size: 12px; color: var(--text-sub); }
.a3-remain b { font-size: 16px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.a3-remain.over b { color: var(--danger); }
.a3-remain .u21-ic { margin-right: 4px; vertical-align: -3px; }
.a3-barwrap { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.a3-bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.10); overflow: hidden; }
.a3-fill { height: 100%; width: 0; border-radius: 2px; background: var(--accent-dim); transition: width 400ms var(--ease), background 240ms var(--ease); }
.a3-fill.done { background: var(--accent); }
.a3-target { font-size: 12px; color: var(--text-sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
.a3-target b { color: var(--text); font-weight: 500; }
.a3-o3 { margin-top: 10px; font-size: 14px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.a3-o3 b { color: var(--text); font-weight: 500; }
@media (max-width: 768px) { .a3-big { font-size: 26px; } .a3-cockpit { padding: 14px; } }

/* ================= A4 膳食明细 ================= */
.a4-groups { display: grid; gap: 12px; }
.a4-group { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.a4-ghead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.a4-gname { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; }
.a4-gname::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--accent); }
.a4-gsum { font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.a4-item { border-top: 1px solid var(--border-soft); }
.a4-item:first-of-type { border-top: none; }
.a4-line { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.a4-main { flex: 1; min-width: 0; cursor: pointer; background: none; border: none; text-align: left; padding: 0; color: inherit; font: inherit; }
.a4-name { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a4-tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.a4-quick { margin-top: 2px; font-size: 12px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.a4-quick b { color: var(--text); font-weight: 500; }
.a4-chev { flex: none; color: var(--text-dim); transition: transform 200ms var(--ease); }
.a4-item.open .a4-chev { transform: rotate(180deg); }
.a4-ops { display: flex; gap: 2px; flex: none; }
.a4-ib {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: transparent; border: 1px solid transparent;
  color: var(--text-sub); cursor: pointer; transition: all var(--dur) var(--ease);
}
.a4-ib:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.a4-ib.del:hover { color: var(--danger); background: rgba(248,81,73,0.10); }
@media (hover: hover) and (min-width: 769px) {
  .a4-ops { opacity: 0; transition: opacity var(--dur) var(--ease); }
  .a4-item:hover .a4-ops, .a4-item:focus-within .a4-ops { opacity: 1; }
}
@media (hover: none) { .a4-ops { opacity: 1; } }
.a4-panel { max-height: 0; overflow: hidden; transition: max-height 240ms var(--ease); }
.a4-item.open .a4-panel { max-height: 1600px; }
.a4-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 8px 14px 14px; background: var(--border-soft); }
.a4-cell { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; background: var(--bg-card); padding: 6px 8px; font-size: 12px; min-width: 0; }
.a4-cell .k { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a4-cell .v { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.a4-legacy { margin-top: 12px; }
.a4-legacy summary { font-size: 12.5px; color: var(--text-sub); cursor: pointer; padding: 6px 0; }
.a4-empty { padding: 24px; text-align: center; font-size: 13px; color: var(--text-dim); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---- v37：今日膳食 —— 多选删除工具条 + 行首勾选框 ---- */
.a4-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 8px 10px; background: var(--bg-sunk);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.a4-bar.is-multi { background: var(--bg-raised); border-color: var(--accent-line); }
.a4-bar-txt { flex: 1; min-width: 0; font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.a4-bar-txt b { color: var(--text); font-weight: 500; }
.a4-bar-btn {
  flex: none; min-height: 32px; padding: 0 12px; font: inherit; font-size: 12px;
  color: var(--text-sub); background: transparent; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.a4-bar-btn:hover { color: var(--text); border-color: var(--border-hi); }
.a4-bar-btn.del { color: var(--danger); border-color: rgba(248,81,73,0.32); }
.a4-bar-btn.del:hover { color: var(--danger); background: rgba(248,81,73,0.10); }
.a4-bar-btn[disabled] { opacity: .45; cursor: not-allowed; color: var(--text-dim); border-color: var(--border-soft); }
.a4-bar-btn[disabled]:hover { color: var(--text-dim); border-color: var(--border-soft); background: transparent; }
.a4-pick, .a4-pick-all {
  flex: none; width: 22px; height: 22px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-hi); border-radius: 6px; background: transparent;
  color: transparent; cursor: pointer; transition: all var(--dur) var(--ease);
}
.a4-pick .u21-ic, .a4-pick-all .u21-ic { width: 14px; height: 14px; }
.a4-pick.on, .a4-pick-all.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.a4-item.picked > .a4-line { background: var(--accent-soft); }
.a4-groups.is-multi .a4-item { cursor: pointer; }

/* ---- v37：「复制昨天」撤回条（复制这批的撤销入口） ---- */
.cy-undo-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 8px 10px; background: var(--bg-raised);
  border: 1px solid var(--accent-line); border-radius: var(--radius-sm);
}
.cy-undo-bar[hidden] { display: none; }   /* display:flex 会盖掉 [hidden]，必须显式复位 */
.cy-undo-ic { display: flex; flex: none; color: var(--accent); }
.cy-undo-txt { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-sub); }
.cy-undo-txt b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.cy-undo-btn {
  flex: none; min-height: 32px; padding: 0 12px; font: inherit; font-size: 12px;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 8px; cursor: pointer; transition: filter var(--dur) var(--ease);
}
.cy-undo-btn:hover { filter: brightness(1.18); }
.cy-undo-x {
  flex: none; width: 26px; height: 26px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); background: transparent; border: 1px solid transparent;
  border-radius: 6px; cursor: pointer; transition: all var(--dur) var(--ease);
}
.cy-undo-x:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* ================= C1 缺口推荐 ================= */
.rec-gap { margin-bottom: 16px; }
.rec-gap-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.rec-gap-h .t { font-size: 13.5px; font-weight: 500; color: var(--text); }
.rec-gap-h .g { font-size: 11.5px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.c1-combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }
.c1-combo { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.c1-ch { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.c1-rank {
  width: 18px; height: 18px; border-radius: 5px; background: rgba(255,255,255,0.07);
  color: var(--text-sub); font-size: 11px; display: flex; align-items: center;
  justify-content: center; font-variant-numeric: tabular-nums; flex: none;
}
.c1-type { font-size: 11px; color: var(--text-dim); }
.c1-foods { display: grid; gap: 4px; margin-bottom: 10px; }
.c1-food { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text); }
.c1-food .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c1-food .g { color: var(--accent); font-variant-numeric: tabular-nums; flex: none; }
.c1-slider { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.c1-pct { font-size: 11.5px; color: var(--text-sub); width: 40px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.c1-range { -webkit-appearance: none; appearance: none; flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.10); outline: none; margin: 0; }
.c1-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #39d353; border: 2px solid #1c1c1e; cursor: pointer;
  transition: transform 150ms var(--ease);
}
.c1-range::-webkit-slider-thumb:active { transform: scale(1.18); }
.c1-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #39d353; border: 2px solid #1c1c1e; cursor: pointer; }
.c1-range::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.10); }
.c1-add {
  width: 100%; padding: 8px; border-radius: var(--radius-sm); background: transparent;
  border: 1px solid var(--accent-line); color: var(--accent); font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all var(--dur) var(--ease);
}
.c1-add:hover { background: var(--accent-soft); border-color: var(--accent); }
.rec-nogap { padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius); font-size: 13px; color: var(--text-sub); }

/* ================= C2 饮水 · 运动 · 体重趋势 ================= */
.c2-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px) { .c2-grid { grid-template-columns: 1fr; } }
.c2-card { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.c2-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; width: 100%; background: none; border: none; color: inherit; font: inherit; cursor: pointer; }
.c2-head .t { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; }
.c2-head .u21-ic { color: var(--accent); }
.c2-chev { color: var(--text-dim); transition: transform 200ms var(--ease); }
.c2-card.open .c2-chev { transform: rotate(180deg); }
/* v24：折叠改为 JS 实测高度 + 固定曲线，桌面 / 移动一致，不再用 max-height 定值硬跳 */
.c2-body {
  padding: 0 14px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 280ms cubic-bezier(0.22, 0.61, 0.36, 1),
              padding-bottom 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.c2-card.open > .c2-body { max-height: none; padding-bottom: 14px; }
@media (prefers-reduced-motion: reduce) {
  .c2-body { transition: none; }
  .c2-chev { transition: none; }
}
.c2-big { font-size: 28px; font-weight: 600; color: #ffffff; font-variant-numeric: tabular-nums; line-height: 1.2; }
.c2-big em { font-style: normal; font-size: 12px; font-weight: 400; color: var(--text-sub); margin-left: 5px; }
.c2-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; font-variant-numeric: tabular-nums; }
.c2-bar { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.10); overflow: hidden; margin: 10px 0; }
.c2-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 300ms var(--ease); }
.c2-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.c2-quick button {
  padding: 6px 10px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.05);
  border: 1px solid var(--border); color: var(--text-sub); font-size: 12px; cursor: pointer;
  font-variant-numeric: tabular-nums; transition: all var(--dur) var(--ease);
}
.c2-quick button:hover { background: rgba(255,255,255,0.10); color: var(--text); }
.c2-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-sub); }
.c2-row select, .c2-row input {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 8px; font-size: 12.5px; flex: 1; min-width: 0;
}
.c2-row select:focus, .c2-row input:focus { outline: none; border-color: var(--accent-line); }
.c2-ex-list { display: grid; gap: 4px; margin-top: 8px; }
.c2-ex { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-sub); background: var(--bg-card); border-radius: 6px; padding: 5px 8px; }
.c2-ex button { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 0; }
.c2-ex button:hover { color: var(--danger); }
.c2-weight { margin-top: 12px; }
.c2-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.c2-toggle button { padding: 5px 12px; background: transparent; border: none; color: var(--text-sub); font-size: 12px; cursor: pointer; transition: all var(--dur) var(--ease); }
.c2-toggle button.on { background: var(--accent-soft); color: var(--accent); }
.c2-chart { margin-top: 10px; }
.c2-chart svg { width: 100%; height: auto; display: block; }
.c2-note { font-size: 11.5px; color: var(--text-dim); margin-top: 6px; line-height: 1.6; }

/* ================= C3 我的常吃 ================= */
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.fav-item {
  position: relative; background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 12px 10px; cursor: pointer;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.fav-item:hover { border-color: var(--accent-line); }
.fav-item:active { transform: scale(0.98); }
.fav-name { font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 22px; }
.fav-meta { font-size: 11.5px; color: var(--text-sub); margin-top: 2px; font-variant-numeric: tabular-nums; }
.u21-star {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer; color: var(--text-dim);
}
.u21-star svg { transition: transform 200ms var(--ease); }
.u21-star:active svg { transform: scale(1.3); }
.u21-star.on { color: var(--accent); }
.fav-empty { padding: 20px; text-align: center; font-size: 12.5px; color: var(--text-dim); border: 1px dashed var(--border); border-radius: var(--radius); line-height: 1.7; }
.mf-item { position: relative; }

/* ================= C4 营养表解析 ================= */
.c4-box { background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 10px; }
.c4-guide { font-size: 12px; color: var(--text-sub); line-height: 1.75; margin-bottom: 8px; }
.c4-guide b { color: var(--text); font-weight: 500; }
.c4-texta {
  width: 100%; min-height: 110px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px; font-size: 13px;
  line-height: 1.7; resize: vertical; font-family: inherit;
}
.c4-texta:focus { outline: none; border-color: var(--accent-line); }
.c4-acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.c4-title { font-size: 12.5px; color: var(--text-sub); margin: 12px 0 6px; }
.c4-hits { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.c4-hit { font-size: 12px; color: var(--text-sub); background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.c4-hit b { color: var(--accent); font-weight: 500; }
.c4-fail { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 8px; }
.c4-line { font-size: 12px; color: var(--warn); margin-bottom: 6px; word-break: break-all; }
.c4-fr { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.c4-fr select, .c4-fr input {
  background: var(--bg-sunk); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 6px 8px; font-size: 12.5px;
}
.c4-fr select { flex: 1; min-width: 130px; }
.c4-fr input { width: 88px; }
.c4-u { font-size: 12px; color: var(--text-dim); width: 48px; flex: none; }
.c4-ignore { background: none; border: 1px solid var(--border); color: var(--text-dim); border-radius: 6px; padding: 5px 8px; font-size: 12px; cursor: pointer; }
.c4-ignore:hover { color: var(--text); border-color: var(--border-hi); }
.c4-done { margin-top: 12px; border: 1px solid var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); padding: 14px; }
.c4-done h5 { font-size: 13.5px; font-weight: 500; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.c4-done h5 .u21-ic { color: var(--accent); }
.c4-fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin-bottom: 12px; }
.c4-fgrid div { font-size: 12px; color: var(--text-sub); background: rgba(0,0,0,0.25); border-radius: 6px; padding: 5px 8px; font-variant-numeric: tabular-nums; }
.c4-fgrid b { color: var(--text); font-weight: 500; }
.c4-tip { font-size: 11.5px; color: var(--text-sub); line-height: 1.7; margin-bottom: 10px; }

/* =========================================================
   v22 · 一、每个板块的少量绿色点缀（自然生命绿 #39d353）
   原则：只做「点、线、条」，绝不铺面；不做渐变 / 发光
   ========================================================= */
/* 1) 每个板块标题左侧一根 3px 绿竖条 */
.card > .card-header > h2 {
  position: relative;
  padding-left: 11px;
}
.card > .card-header > h2::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 14px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.9;
}
/* 2) 右上角徽章：低饱和绿底 + 绿字（小面积） */
.badge {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
/* 3) 总览小格：标签前一颗 4px 绿点 */
.metric .m-label { position: relative; padding-left: 9px; }
.metric .m-label::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  opacity: 0.75;
}
.metric.mod-off .m-label::before { background: var(--text-dim); opacity: .5; }
/* 4) 宏量进度条：达标 = 绿 */
.macro-bar .fill { background: var(--accent-dim); }
.macro-bar .fill.ok { background: var(--accent); }
/* 5) 卡片右上角「+」引导按钮：透明底 + 1px 浅绿描边 */
.mod-add {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 6px; width: 22px; height: 22px;
  font-size: 14px; line-height: 1;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.mod-add:hover { background: var(--accent-soft); }
/* 6) 分组小标题的绿点 + C2 子卡图标绿 */
.a4-gname::before {
  content: ""; display: inline-block;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: .85;
  margin-right: 7px; vertical-align: 1px;
}
.c2-head .t .u21-ic:first-child { color: var(--accent); opacity: .9; }
/* 7) 饮水进度条填绿 */
.c2-bar i { background: var(--accent) !important; }

/* =========================================================
   v22 · 二、模块开关卡（用户自行选择开启哪些功能）
   ========================================================= */
.mod-note {
  font-size: 12px; color: var(--text-sub); line-height: 1.7;
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px; margin-bottom: 12px;
}
.mod-note b { color: var(--accent); font-weight: 500; }
.mod-group { margin-bottom: 14px; }
.mod-group-t {
  font-size: 11.5px; color: var(--text-dim);
  letter-spacing: .5px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 7px;
}
.mod-group-t::after {
  content: ""; flex: 1; height: 1px; background: var(--border-soft);
}
.mod-list { display: grid; gap: 7px; }
.mod-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; text-align: left; cursor: pointer;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.mod-row:hover { background: var(--bg-raised); border-color: var(--border-hi); }
.mod-row.on { border-color: rgba(57, 211, 83, 0.28); }
.mod-row.on .mod-name { color: var(--text); }
.mod-row:not(.on) .mod-name { color: var(--text-sub); }
.mod-name { font-size: 13.5px; flex: none; min-width: 96px; }
.mod-hint {
  flex: 1; font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mod-mini { flex: none; font-size: 12px; font-variant-numeric: tabular-nums; }
.mod-mini b { font-weight: 500; }
.mod-mini b.ok { color: var(--accent); }
.mod-mini b.over { color: var(--danger); }
.mod-mini b.dim { color: var(--text-dim); font-weight: 400; }
/* 开关：深绿底 + 白滑块 */
.sw {
  position: relative; flex: none;
  width: 34px; height: 20px; border-radius: 999px;
  background: #2c2c2e; border: 1px solid var(--border);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.sw i {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #8e8e93;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sw.on { background: var(--accent-btn); border-color: var(--accent-btn); }
.sw.on i { transform: translateX(14px); background: #ffffff; }
.mod-acts { display: flex; gap: 8px; margin: 4px 0 12px; }
.mod-rate {
  border-top: 1px solid var(--border-soft); padding-top: 12px;
}
.mod-rate-head {
  font-size: 13px; color: var(--text-sub); margin-bottom: 9px;
  display: flex; align-items: baseline; gap: 8px;
}
.mod-rate-head b {
  font-size: 20px; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.mod-rate-head span { font-size: 11.5px; color: var(--text-dim); }
.mod-rate-items { display: grid; gap: 6px; }
.mod-rate-item {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--text-sub);
}
.mod-rate-item > span { flex: none; width: 108px; }
.mod-rate-item > i {
  flex: 1; height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.07); overflow: hidden;
}
.mod-rate-item > i > b { display: block; height: 100%; background: var(--accent-dim); border-radius: 2px; }
.mod-rate-item.ok > i > b { background: var(--accent); }
.mod-rate-item.over > i > b { background: var(--danger); }
.mod-rate-item > .v { flex: none; width: 40px; text-align: right; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.mod-rate-empty {
  font-size: 12px; color: var(--text-dim); line-height: 1.7;
  border: 1px dashed var(--border-hi); border-radius: var(--radius-sm); padding: 10px 12px;
}
@media (max-width: 640px) {
  .mod-name { min-width: 0; font-size: 13px; }
  .mod-hint { display: none; }
  .mod-rate-item > span { width: 84px; }
}

/* =========================================================
   v22 · 三、未启用的模块：置灰 + 虚线 + 「未启用」角标
   ========================================================= */
/* v23：未启用的模块直接消失（不是变淡） */
.mod-off { display: none !important; }
/* 高亮提示（点「+」跳到开关卡时闪一下） */
@keyframes modFlash {
  0%, 100% { box-shadow: var(--shadow); }
  35%, 65% { box-shadow: 0 0 0 2px var(--accent-line); }
}
.mod-flash { animation: modFlash 1.2s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .mod-flash { animation: none; }
  .sw i, .sw { transition: none; }
}

/* =========================================================
   v23 · D3 环形完成度（手写 SVG stroke-dashoffset）
   桌面横排 / 移动端竖排；环与数字 300ms 同步
   ========================================================= */
.d3-wrap {
  display: flex; align-items: center; gap: 18px;
  margin-top: 14px;
}
.d3-ring-box { position: relative; width: 120px; height: 120px; flex: none; }
.d3-svg { width: 120px; height: 120px; display: block; }
.d3-arc {
  transition: stroke-dashoffset 300ms var(--ease), stroke 300ms var(--ease);
}
.d3-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.d3-pct {
  font-size: 28px; font-weight: 600; color: #ffffff; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.d3-pct.dim { font-size: 20px; color: var(--text-sub); }
.d3-sub { font-size: 11.5px; color: var(--text-sub); margin-top: 3px; }
.d3-bars { flex: 1; min-width: 0; display: grid; gap: 10px; align-content: center; }
.d3-bar {
  display: grid; grid-template-columns: 52px 1fr auto;
  align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-sub);
}
.d3-bn { font-size: 12px; }
.d3-track {
  display: block; height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.d3-fill {
  display: block; height: 100%; border-radius: 2px;
  background: var(--accent-dim);
  transition: width 300ms var(--ease), background 300ms var(--ease);
}
.d3-bv {
  font-size: 12px; font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.d3-bv.over { color: var(--danger); }
.d3-bars .mod-add { justify-self: start; margin-top: 2px; }
@media (max-width: 768px) {
  .d3-wrap { flex-direction: column; align-items: stretch; gap: 14px; }
  .d3-ring-box { margin: 0 auto; }
}

/* =========================================================
   v23 · D1 文案风格（暗色卡片选择，禁原生 radio）
   ========================================================= */
.copy-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.copy-card {
  position: relative; text-align: left; cursor: pointer;
  padding: 11px 12px 11px;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.copy-card:hover { border-color: var(--border-hi); }
.copy-card.on { border-color: #39d353; background: rgba(57, 211, 83, 0.06); }
.cc-tick {
  position: absolute; top: 9px; right: 9px;
  color: var(--text-dim); opacity: 0;
  transition: opacity 180ms var(--ease), color 180ms var(--ease);
}
.cc-tick .u21-ic { width: 14px; height: 14px; display: block; }
.copy-card.on .cc-tick { opacity: 1; color: var(--accent); }
.cc-name { display: block; font-size: 13.5px; color: var(--text-sub); }
.copy-card.on .cc-name { color: var(--text); }
.cc-desc { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.cc-sample {
  display: block; font-size: 11px; color: var(--text-sub); line-height: 1.6;
  margin-top: 9px; padding-left: 8px;
  border-left: 2px solid var(--border);
}
.copy-card.on .cc-sample { border-left-color: var(--accent-line); }
@media (max-width: 640px) { .copy-grid { grid-template-columns: 1fr; } }

/* =========================================================
   v23 · D2 三级警报（红横条 / 黄折叠 / 灰圆点）
   v32：红条 → 顶部「暗色卡片」（左侧红细线 + 短标签 + 底部抽屉），不再大面积红块
   v33：红条从「页面最顶部」移进「今日膳食明细」卡片内部，所以去掉页面级对齐
        （max-width / auto 外边距 / 左右 24px 内边距），改为卡片内的紧凑提示条
   ========================================================= */
.alert-banner { margin: 0 0 12px; }
.alert-banner[hidden] { display: none; }
.ab-card {
  background: rgba(248, 81, 73, 0.06);
  border: 1px solid rgba(248, 81, 73, 0.22);
  border-left: 3px solid #f85149;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
html[data-theme="light"] .ab-card { background: rgba(248, 81, 73, 0.07); }
.ab-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-ic { flex: none; display: flex; }
.ab-title { font-size: 13px; color: var(--text); font-weight: 500; }
.ab-more {
  margin-left: auto; display: inline-flex; align-items: center; gap: 3px;
  background: none; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: 999px; padding: 3px 10px; font-size: 11.5px; cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ab-more:hover { border-color: var(--border-hi); color: var(--text); }
.ab-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ab-tag {
  font-size: 12px; line-height: 1.5; color: var(--text-sub);
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px;
  font-variant-numeric: tabular-nums;
}
.alert-board { display: grid; gap: 10px; }
.alert-group {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-sunk); overflow: hidden;
}
.alert-group[hidden] { display: none; }
.alert-group.warn { border-color: rgba(210, 153, 34, 0.26); }
.ag-head {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 11px; font-size: 12px; color: var(--text-sub);
}
.ag-toggle {
  margin-left: auto; background: none; cursor: pointer;
  border: 1px solid var(--border); color: var(--text-sub);
  border-radius: 6px; padding: 3px 8px; font-size: 11.5px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ag-toggle:hover { border-color: var(--border-hi); color: var(--text); }
.ag-body { padding: 0 11px 10px; display: grid; gap: 6px; }
.ag-line {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12.5px; line-height: 1.7; color: var(--text-sub);
}
.ag-line .dot-svg { flex: none; margin-top: 4px; }
.ag-more {
  max-height: 0; overflow: hidden;
  display: grid; gap: 6px;
  transition: max-height 240ms var(--ease);
}
.ag-more.open { max-height: 460px; }

/* =========================================================
   v23 · E1 首屏加载动画（纯 CSS + 内联 SVG）
   ========================================================= */
#boot-loader {
  position: fixed; inset: 0; z-index: 9999;
  background: #121212;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 320ms var(--ease);
}
#boot-loader.hide { opacity: 0; pointer-events: none; }
.boot-ring { width: 64px; height: 64px; }
.boot-ring circle { fill: none; stroke: #39d353; stroke-width: 1.5; stroke-linecap: round; }
.boot-ring .t { opacity: 0.16; }
.boot-ring .a {
  stroke-dasharray: 58 164;
  transform-origin: 32px 32px;
  animation: bootSpin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite,
             bootFade 1.5s ease-in-out infinite;
}
@keyframes bootSpin {
  0%   { transform: rotate(0deg);   stroke-dashoffset: 150; }
  100% { transform: rotate(360deg); stroke-dashoffset: 30; }
}
@keyframes bootFade {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .boot-ring .a { animation: none; opacity: 1; stroke-dashoffset: 60; }
}

/* =========================================================
   v25 · 手机端并排（短项不再独占一行）
   ========================================================= */
@media (max-width: 768px) {
  /* 功能与达标模块：开关行两列 */
  .mod-list { grid-template-columns: 1fr 1fr; gap: 6px; }
  .mod-row {
    padding: 8px 10px;
    gap: 6px;
    min-height: 44px;                 /* 保持可点面积 */
  }
  .mod-name { min-width: 0; flex: 1; font-size: 12.5px; line-height: 1.25; }
  .mod-hint { display: none; }        /* 窄列里放不下说明，只留名称 + 开关 + 百分比 */
  .mod-group-t { font-size: 12px; }
  /* 大屏两列时「文案风格」仍独占一行更清楚，维持 1 列 */
  .copy-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 380px) {
  /* 极窄屏：开关名都短，仍保持两列并排；宏量进度条较宽退回单列防挤断 */
  #macro-bars { grid-template-columns: 1fr; }
  /* 维生素/矿物质仍并排双列 */
  .micro-grid { grid-template-columns: 1fr 1fr !important; }
}

/* =========================================================
   v27 · 移动端结构：路由 / 底部抽屉 / 深浅模式 / 食物库 / 排版
   （结构骨架，刻意不深入复杂视觉细节）
   ========================================================= */

/* 标题字体（思源黑体优先） */
:root {
  --font-title: "Source Han Sans SC", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
h1, h2, h3, .title, .card-header h2, .fl-h, .brand .title {
  font-family: var(--font-title);
  font-weight: 500;
}

/* 数字：等宽对齐（千分位） */
.tnum, .m-value, #completion-pct, .c2-big,
.metric .m-value, .d3-bv, .completion-pct {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
/* 单位：偏小且颜色浅一档 */
.m-unit, .unit {
  font-size: 0.78em;
  color: var(--text-sub);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* 深浅模式：浅色覆盖（默认仍是深色，即现有基调） */
html[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-sunk: #f0f0f2;
  --bg-raised: #e9e9ec;
  --bg-hover: #dededf;
  --border: rgba(0, 0, 0, 0.10);
  --border-soft: rgba(0, 0, 0, 0.05);
  --border-hi: rgba(0, 0, 0, 0.18);
  --text: #1c1c1e;
  --text-sub: #6e6e73;
  --text-dim: #8e8e93;
  --accent: #2ea043;
  --accent-btn: #2ea043;
  --accent-line: rgba(46, 160, 67, 0.5);
  --accent-soft: rgba(46, 160, 67, 0.10);
  --accent-dim: rgba(46, 160, 67, 0.45);
  --brand-dark: #1c1c1e;
  --primary: #1c1c1e;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] #app-tabbar { background: rgba(245, 245, 247, 0.85); }

/* 深色模式下：进度环 + 核心大数字加微弱霓虹绿光晕（严禁大面积发光） */
.completion-arc { filter: drop-shadow(0 0 6px rgba(57, 211, 83, 0.5)); }
#card-summary .m-value, #completion-pct { filter: drop-shadow(0 0 5px rgba(57, 211, 83, 0.35)); }
html[data-theme="light"] .completion-arc,
html[data-theme="light"] #card-summary .m-value,
html[data-theme="light"] #completion-pct { filter: none; }

/* 外壳 + 面板 */
#app-shell { padding-bottom: 84px; }
/* ⚠ v33：必须限定 `#app-shell >`。裸的 `.tab-panel:not(.is-active){display:none}` 是全局规则，
   会把「使用说明」弹窗（#modal-help）里同样用 .tab-panel 的三个面板全部隐藏
   —— 弹窗只剩 Tab 标题、正文空白（v27 引入的既存 bug）。 */
#app-shell > .tab-panel:not(.is-active) { display: none; }
#app-shell > .tab-panel.is-active { animation: tabIn 200ms var(--ease); }
@keyframes tabIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* v32 修复 3：驾驶舱最外层父容器强制上下单列堆叠（宽屏也不再并排），
   仅作用于外层；卡片内部布局（基础档案双列 / 缺口推荐双列 / c2 网格）原样保留。
   ⚠ v33 回归修复：必须带 .is-active —— 裸 `#tab-home` 的 id 优先级（1,0,0）会压过
   `.tab-panel:not(.is-active){display:none}`（0,2,0），导致驾驶舱永远显示、
   其它 Tab 点了没反应（切过去的新面板被排到 7000px 之后，屏幕上看不到变化）。 */
#tab-home.is-active { display: flex; flex-direction: column; gap: 20px; }

.panel-wrap { max-width: 1280px; margin: 0 auto; padding: 16px 16px 48px; }
@media (min-width: 720px) { .panel-wrap { padding: 24px 24px 48px; } }

/* 底部 Tab 栏：56px · 半透明毛玻璃 · 极细顶部边框 */
#app-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: 56px; display: flex;
  background: rgba(28, 28, 30, 0.82);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 0.5px solid var(--border-hi);
  padding-bottom: env(safe-area-inset-bottom);
}
#app-tabbar .tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-sub); font-size: 11px; padding: 6px 0;
  transition: color var(--dur) var(--ease);
}
#app-tabbar .tab svg { width: 22px; height: 22px; }
#app-tabbar .tab.is-active { color: var(--accent); }
#app-tabbar .tab.is-active svg { filter: drop-shadow(0 0 4px rgba(57, 211, 83, 0.5)); }

/* 中间巨大绿色加号（食物录入入口）：图标在上 · 文字在下 */
#app-tabbar .tab-fab {
  flex: 0 0 auto; align-self: center; position: relative; top: -22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 0; border: none; background: none; cursor: pointer;
}
#app-tabbar .tab-fab .fab-circle {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-btn); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45), 0 0 0 4px var(--bg);
  transition: transform var(--dur) var(--ease);
}
#app-tabbar .tab-fab .fab-circle svg { width: 26px; height: 26px; }
#app-tabbar .tab-fab .fab-label { font-size: 10px; line-height: 1; color: #8e8e93; }
#app-tabbar .tab-fab:active .fab-circle { transform: scale(0.92); }

/* 设置页：数据操作区（从顶栏搬来的按钮） */
#settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#settings-actions .topbar-actions { flex-wrap: wrap; width: 100%; margin: 0; }

/* 浮动添加按钮（FAB） */
#fab-add {
  position: fixed; right: 16px; bottom: 72px; z-index: 55;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-btn); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
}
#fab-add svg { width: 24px; height: 24px; }

/* 底部抽屉（Bottom Sheet）：从底部上滑 · 圆角顶部 · 暗色背景 */
.sheet-root { position: fixed; inset: 0; z-index: 80; visibility: hidden; }
.sheet-root.open { visibility: visible; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-card); border-radius: 18px 18px 0 0;
  border-top: 0.5px solid var(--border-hi);
  transform: translateY(100%); transition: transform 260ms var(--ease);
  max-height: 88vh; display: flex; flex-direction: column;
}
.sheet-root.open .sheet { transform: translateY(0); }
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border-hi); margin: 8px auto 0; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 10px; border-bottom: 0.5px solid var(--border);
}
.sheet-head h3 { font-size: 16px; font-weight: 500; font-family: var(--font-title); }
.sheet-close { background: transparent; border: none; color: var(--text-sub); cursor: pointer; line-height: 1; display: flex; }
.sheet-body { overflow-y: auto; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }
body.sheet-open { overflow: hidden; }

/* 食物库 */
.fl-bar { position: sticky; top: 0; background: var(--bg); padding: 10px 0 4px; z-index: 2; }
.fl-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
}
.fl-search .fl-ic { display: flex; color: var(--text-sub); }
.fl-search .fl-ic svg { width: 18px; height: 18px; }
.fl-search input { flex: 1; border: none; background: transparent; color: var(--text); font-size: 15px; outline: none; }
/* v31：分类浏览（.fl-cats / .fl-cat）已移除，食品库只保留关键词搜索 */
.fl-section { margin-top: 14px; }
.fl-h { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.fl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.fl-item {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.fl-item:active { background: var(--bg-hover); }
.fl-name { font-size: 14px; color: var(--text); }
.fl-meta { font-size: 11px; color: var(--text-sub); margin-top: 2px; }
.fl-empty { color: var(--text-dim); font-size: 13px; padding: 12px 2px; }

/* 首页添加条 */
.home-add-bar { grid-column: 1 / -1; margin-bottom: 4px; }
.home-add-bar .btn-primary { width: 100%; padding: 12px; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.home-add-bar .btn-primary svg { width: 18px; height: 18px; }

/* 顶部栏在窄屏下避免溢出 */
@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar-actions { flex-wrap: wrap; }
  #app-tabbar .tab span { font-size: 10px; }
}

/* ============== v30：手机端收尾清理 ==============
   1) 右下「食材营养查询」浮标在手机上会压住卡片正文，改为食物库顶部入口，浮标仅桌面保留
   2) 卡片头部在窄屏允许换行，右侧徽标/控件不再被挤出卡片边界  */
.fl-query-entry {
  display: none;              /* 桌面端用右下浮标，此项只在手机显示 */
  align-items: center; gap: 8px;
  width: 100%; margin: 10px 0 2px;
  padding: 11px 14px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: 14px; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.fl-query-entry svg { width: 17px; height: 17px; color: var(--text-sub); flex: none; }
.fl-query-entry .fl-qe-sub { margin-left: auto; font-size: 11.5px; color: var(--text-sub); }
.fl-query-entry:active { background: var(--bg-hover); border-color: var(--border-hi); }

@media (max-width: 768px) {
  .fl-query-entry { display: flex; }
  #fab-query { display: none !important; }          /* 手机端不再悬浮压字 */

  .card-header { flex-wrap: wrap; align-items: flex-start; row-gap: 6px; }
  .card-header h2 { flex: 1 1 auto; min-width: 0; }
  .card-header .badge,
  .card-header label,
  .card-header .card-toggle { flex: 0 0 auto; }
  .card-header > .btn-ghost { flex: 0 0 auto; }
}


/* =========================================================
   v32 · 严重项说明抽屉 / 新手引导卡片 / 表单提示
   ========================================================= */

/* ---- 详细风险说明：底部上滑暗色抽屉 ---- */
.alert-sheet { position: fixed; inset: 0; z-index: 95; visibility: hidden; }
.alert-sheet.open { visibility: visible; }
.as-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.alert-sheet.open .as-backdrop { opacity: 1; }
.as-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: #1c1c1e; border-radius: 18px 18px 0 0;
  border-top: 0.5px solid var(--border-hi);
  transform: translateY(100%); transition: transform 260ms var(--ease);
  max-height: 80vh; display: flex; flex-direction: column;
}
.alert-sheet.open .as-panel { transform: translateY(0); }
.as-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 10px;
}
.as-item {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-left: 3px solid #f85149; border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.as-item .as-t { font-size: 13px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.as-item .as-risk { font-size: 12px; line-height: 1.7; color: var(--text-sub); margin-top: 5px; }

/* ---- 首页新手引导卡片（左侧生命绿细线） ---- */
.onboard-card { border: 1px solid rgba(57, 211, 83, 0.3); border-left: 3px solid #39d353; }
.onboard-card[hidden] { display: none; }
.onboard-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.onboard-txt { flex: 1 1 200px; font-size: 13px; line-height: 1.6; color: var(--text-sub); margin: 0; }
.onboard-go {
  margin-left: auto; display: inline-flex; align-items: center; gap: 3px;
  background: none; border: 1px solid rgba(57, 211, 83, 0.35);
  color: var(--accent); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.onboard-go:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---- 设置页：个人基础档案顶部 12px 提示 ---- */
.form-hint { font-size: 12px; line-height: 1.6; color: var(--text-dim); margin: 0 0 12px; }

/* =========================================================
   v34 · 趋势曲线（手机端放大 + 触摸浮动提示）
   ========================================================= */
#trend-chart { position: relative; }
#trend-chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }

.trend-tip {
  position: absolute; top: 4px; left: 0;
  transform: translateX(-50%);
  min-width: 134px; max-width: 212px;
  background: #1c1c1e;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 8px 10px;
  opacity: 0; pointer-events: none;
  transition: opacity 150ms var(--ease);
  z-index: 6;
}
.trend-tip.show { opacity: 1; }
.trend-tip .tt-date {
  font-size: 12px; font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums; margin-bottom: 5px;
}
.trend-tip .tt-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.trend-tip .tt-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.trend-tip .tt-k { flex: 1 1 auto; }
.trend-tip .tt-v { color: var(--text); font-weight: 500; }

/* =========================================================
   v34 · 「复制昨天」：细线图标 14×14 + 12px 文字的幽灵按钮
   ========================================================= */
.cy-btn,
#btn-copy-yesterday {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-sub);
  font-size: 12px; font-weight: 400; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cy-btn .cy-ic { display: inline-flex; width: 14px; height: 14px; flex: none; color: inherit; }
.cy-btn .cy-ic svg { width: 14px; height: 14px; display: block; }
.cy-btn .cy-txt { font-size: 12px; }
#btn-copy-yesterday:hover,
#btn-copy-yesterday:focus-visible,
#btn-copy-yesterday:active {
  color: #39d353;
  border-color: rgba(57, 211, 83, 0.35);
  background: rgba(57, 211, 83, 0.06);
}
@media (max-width: 768px) { #btn-copy-yesterday { padding: 5px 9px; } }

/* =========================================================
   v34 · 文案风格卡的说明与预览（三套语料变长，预览限 4 行）
   ========================================================= */
.copy-note { margin: 0 0 8px; }
.copy-note b { color: var(--text-sub); font-weight: 500; }
.cc-sample {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 警报分组里的两个按钮：第一个靠右推，第二个紧随其后（不要各占一份 auto 边距） */
.ag-head .ag-toggle { margin-left: 0; }
.ag-head .ag-toggle:first-of-type { margin-left: auto; }

/* =========================================================
   v35 · 补剂录入搜索框（左侧内联放大镜 + 聚焦转生命绿）
   ========================================================= */
.supp-picker { position: relative; display: block; }
.supp-picker .sp-ic {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-sub); pointer-events: none; z-index: 1;
}
.supp-picker .sp-ic svg { width: 16px; height: 16px; display: block; }
/* 用 id 前缀抬高特异性：压过媒体查询里的 `input, select, textarea { padding }` */
#intake-supp-panel .supp-picker input[type="text"] {
  width: 100%; padding-left: 32px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
#intake-supp-panel .supp-picker input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#intake-supp-panel .supp-picker input[type="text"]::placeholder { color: var(--text-dim); }
/* 选中值载体（原来的 <select> 换成隐藏域，只存已确认的补剂名） */
#intake-supp-panel #s-supp { display: none; }
/* 无结果 / 提示行（复用 .food-suggest 浮层） */
.food-suggest .fs-none {
  display: flex; align-items: center;
  padding: 12px; min-height: 44px;
  font-size: 13px; color: var(--text-sub);
}

/* ---- 动效降级 ---- */
@media (prefers-reduced-motion: reduce) {
  .alert-sheet .as-backdrop,
  .alert-sheet .as-panel,
  #app-tabbar .tab-fab .fab-circle { transition: none; }
  .alert-sheet.open .as-panel { transform: none; }
  .trend-tip { transition: none; }
  .cy-btn, #btn-copy-yesterday { transition: none; }
  #intake-supp-panel .supp-picker input[type="text"] { transition: none; }
}
