/* === 薄肌 · 减脂塑形 — 视觉系统 === */
:root {
  /* 深色主题 (默认) */
  --bg: #0b0d12;
  --bg2: #11141b;
  --card: #161a23;
  --card2: #1d2230;
  --line: #262c3a;
  --line2: #303747;
  --text: #eef1f7;
  --muted: #8a93a6;
  --muted2: #5d6478;
  --accent: #5eead4;
  --accent2: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --info: #93c5fd;
  --pink: #f0abfc;
  --orange: #fb923c;
  --purple: #c4b5fd;
  --grad-card: linear-gradient(180deg, #181c26 0%, #131722 100%);
  --grad-hero: radial-gradient(120% 80% at 0% 0%, rgba(94,234,212,0.18) 0%, rgba(94,234,212,0) 60%),
               radial-gradient(120% 80% at 100% 0%, rgba(147,197,253,0.18) 0%, rgba(147,197,253,0) 60%),
               linear-gradient(180deg, #0e1219 0%, #0b0d12 100%);
  --grad-pill-low: linear-gradient(135deg, rgba(147,197,253,0.25), rgba(96,165,250,0.12));
  --grad-pill-high: linear-gradient(135deg, rgba(251,191,36,0.28), rgba(245,158,11,0.12));
  --grad-pill-train: linear-gradient(135deg, rgba(94,234,212,0.28), rgba(52,211,153,0.12));
  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.35);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.05) inset, 0 12px 40px rgba(0,0,0,0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
}

/* === 浅色奶油主题 (Foodie Flow 风格) === */
.theme-cream {
  --bg: #f6f1ea;
  --bg2: #faf6f0;
  --card: #ffffff;
  --card2: #fff7ec;
  --line: #ece4d6;
  --line2: #ddd2bf;
  --text: #2a2520;
  --muted: #8c8175;
  --muted2: #b3a999;
  --accent: #fb923c;          /* 橙色 */
  --accent2: #f97316;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --pink: #f9a8d4;
  --orange: #fb923c;
  --purple: #a78bfa;
  --grad-card: linear-gradient(180deg, #ffffff 0%, #fff8ef 100%);
  --grad-hero: linear-gradient(135deg, #ffe4c8 0%, #ffd6b3 50%, #fff0e0 100%);
  --grad-pill-low: linear-gradient(135deg, #dbeafe, #eff6ff);
  --grad-pill-high: linear-gradient(135deg, #fef3c7, #fffbeb);
  --grad-pill-train: linear-gradient(135deg, #d1fae5, #ecfdf5);
  --shadow-1: 0 1px 0 rgba(255,255,255,0.9) inset, 0 6px 20px rgba(212, 175, 130, 0.15);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.9) inset, 0 12px 32px rgba(212, 175, 130, 0.22);
}
/* 奶油主题下, 软色卡 (早/午/晚/加餐) */
.theme-cream .slot-card { background: #ffffff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 8px 22px rgba(212, 175, 130, 0.12); }
.theme-cream .slot-card.morning { background: linear-gradient(135deg, #fff4e3 0%, #ffe9cf 100%); }
.theme-cream .slot-card.lunch   { background: linear-gradient(135deg, #ffe9f0 0%, #ffd6e3 100%); }
.theme-cream .slot-card.snack   { background: linear-gradient(135deg, #f0e5ff 0%, #e3d3ff 100%); }
.theme-cream .slot-card.dinner  { background: linear-gradient(135deg, #e8f7e0 0%, #d3f0c5 100%); }
.theme-cream .slot-card .slot-title { color: #6b5d4c; }
.theme-cream .slot-card .slot-icon-bg { background: rgba(255,255,255,0.6); }
.theme-cream .slot-card .slot-add { color: #b8a48a; }
.theme-cream .slot-card .meal-row { background: rgba(255,255,255,0.55); border: 1px solid rgba(255,255,255,0.7); border-radius: 14px; }
.theme-cream .slot-card .meal-row .thumb { border: 1px solid rgba(255,255,255,0.8); }
.theme-cream .slot-card .meal-row .meta { color: #8a7d6c; }
.theme-cream .slot-card .meal-row .kcal-pill { background: rgba(255,255,255,0.7); color: #6b5d4c; }

/* 饼环 */
.ring {
  position: relative; width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ring svg { transform: rotate(-90deg); }
.ring .ring-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.ring .ring-inner .v { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.ring .ring-inner .l { font-size: 10px; color: var(--muted); margin-top: 4px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; }

/* 4 时段卡 */
.slot-card {
  padding: 14px;
  border-radius: 22px;
  position: relative;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
}
.slot-card .slot-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.slot-card .slot-title-group {
  display: flex; align-items: center; gap: 10px;
}
.slot-card .slot-icon-bg {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.slot-card .slot-title { font-weight: 700; font-size: 15px; }
.slot-card .slot-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.slot-card .slot-kcal {
  font-size: 13px; font-weight: 700;
  color: var(--accent);
}
.slot-card .slot-add {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 10px;
  border: 1.5px dashed currentColor;
  border-radius: 12px;
  background: rgba(255,255,255,0.3);
  opacity: 0.6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s ease, background .15s ease;
  margin-top: 6px;
}
.slot-card .slot-add:hover { opacity: 1; background: rgba(255,255,255,0.5); }
.slot-card .meal-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 14px;
  margin-top: 6px;
}
.slot-card .meal-row .thumb {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line);
}
.slot-card .meal-row .info { flex: 1; min-width: 0; }
.slot-card .meal-row .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-card .meal-row .meta { font-size: 11px; }
.slot-card .meal-row .kcal-pill {
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.slot-card .meal-row .delete { background: transparent; border: none; color: var(--muted); padding: 4px; cursor: pointer; }
.slot-card .meal-row .delete:hover { color: var(--danger); }
.slot-card .empty-slot { font-size: 11px; color: var(--muted); padding: 6px 0; text-align: center; }

/* FAB */
.fab {
  position: fixed; right: max(20px, calc(50vw - 360px + 20px));
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(251,146,60,0.4), 0 1px 0 rgba(255,255,255,0.2) inset;
  color: #fff; border: none; cursor: pointer; z-index: 25;
  transition: transform .15s ease;
}
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(0.95); }
.theme-cream .fab { color: #fff; }

/* 主题切换 */
.theme-toggle {
  position: fixed; top: 14px; right: 14px;
  z-index: 40;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.1); backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text);
}
.theme-cream .theme-toggle { background: rgba(255,255,255,0.7); border-color: var(--line); color: var(--text); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
.theme-cream html, body.theme-cream, .theme-cream { background: #f6f1ea; }
html.theme-cream { background: #f6f1ea; }
.theme-cream html { background: #f6f1ea; }
body.theme-cream { background: #f6f1ea; }

/* 手机壳 */
#app {
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 92px;
  background: var(--bg);
  position: relative;
}

/* ===== 顶部 Hero ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--grad-hero);
  border-bottom: 1px solid var(--line);
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: 1px; font-size: 16px;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #5eead4 0%, #34d399 60%, #fbbf24 130%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(94,234,212,0.35), 0 1px 0 rgba(255,255,255,0.2) inset;
  color: #08110d;
}
.theme-cream .brand-logo {
  background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
  box-shadow: 0 6px 18px rgba(251,146,60,0.35), 0 1px 0 rgba(255,255,255,0.3) inset;
  color: #fff;
}
.brand-title { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title b { font-size: 16px; letter-spacing: 1.5px; }
.brand-title span { font-size: 10px; color: var(--muted); letter-spacing: 2px; font-weight: 500; }
.date-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--muted); font-size: 11px;
  letter-spacing: 0.5px;
}

/* ===== 主体容器 ===== */
main { padding: 14px 14px 24px; }

.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin: 18px 4px 10px;
  font-size: 12px; color: var(--muted);
  letter-spacing: 1.5px; text-transform: uppercase;
  font-weight: 600;
}
.section-title .accent { color: var(--accent); }

/* ===== 卡片 ===== */
.card {
  background: var(--grad-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.card.glow::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(135deg, rgba(94,234,212,0.08), transparent 50%);
  pointer-events: none;
}

/* ===== 顶部状态卡 (饮食页) ===== */
.hero-card {
  position: relative;
  padding: 18px;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(94,234,212,0.18), transparent 50%),
    linear-gradient(180deg, #1a1f2c 0%, #131722 100%);
  border: 1px solid var(--line2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  display: flex;
  gap: 18px;
  align-items: center;
}
.theme-cream .hero-card {
  background: linear-gradient(135deg, #ffe4c8 0%, #ffd6b3 100%);
  border: 1px solid #f6d4ad;
  color: #2a2520;
}
/* 奶油主题下底部 tab 调整 */
.theme-cream .tabbar { background: rgba(255,255,255,0.85); border-top: 1px solid var(--line); }
.theme-cream .tab { color: var(--muted); }
.theme-cream .tab.active { color: var(--accent); }
.theme-cream .topbar { background: rgba(255,255,255,0.7); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.theme-cream .brand-logo { box-shadow: 0 6px 18px rgba(251,146,60,0.35), 0 1px 0 rgba(255,255,255,0.4) inset; }
.theme-cream .date-chip { background: rgba(255,255,255,0.7); border-color: var(--line); color: var(--muted); }
.theme-cream .card { background: #ffffff; border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(212, 175, 130, 0.12); }
.theme-cream .callout { background: rgba(255,255,255,0.6); border-color: var(--line); }
.theme-cream button { background: #fff; border: 1px solid var(--line); color: var(--text); }
.theme-cream button:hover { background: #fff7ec; }
.theme-cream button.primary { background: linear-gradient(135deg, #fb923c 0%, #f97316 100%); color: #fff; border: none; }
.theme-cream button.ghost { background: transparent; }
.theme-cream button.danger { color: var(--danger); border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.05); }
.theme-cream input, .theme-cream select, .theme-cream textarea { background: #fff; border-color: var(--line); color: var(--text); }
.theme-cream .empty { background: #fff; border-color: var(--line); }
.theme-cream .kpi { background: #fff; border-color: var(--line); }
.theme-cream .kpi .l { color: var(--muted); }
.theme-cream .list-item { background: #fff; border-color: var(--line); }
.theme-cream .list-item:hover { background: #fff7ec; }
.theme-cream .meal-name { color: var(--text); }
.theme-cream .section-title { color: var(--muted); }
.theme-cream .ring .ring-inner .l { color: var(--muted); }
.theme-cream .muted { color: var(--muted); }
.theme-cream .bar { background: rgba(0,0,0,0.06); }
.theme-cream .tag { background: rgba(0,0,0,0.04); color: var(--muted); border-color: var(--line); }
.theme-cream .tag.ok { color: #15803d; background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); }
.theme-cream .tag.high { color: #b45309; background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); }
.theme-cream .tag.danger { color: #b91c1c; background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); }
.theme-cream .tag.low { color: #1e40af; background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); }
.theme-cream .tag.train { color: #047857; background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); }
.theme-cream .cycle-cell { background: #fff; border-color: var(--line); }
.theme-cream .cycle-cell.low { background: linear-gradient(135deg, #dbeafe, #eff6ff); border-color: rgba(59,130,246,0.3); }
.theme-cream .cycle-cell.high { background: linear-gradient(135deg, #fef3c7, #fffbeb); border-color: rgba(245,158,11,0.3); }
.theme-cream .cycle-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-cream .set-chip { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: #047857; }
.theme-cream .set-chip .num { background: rgba(16,185,129,0.2); color: #047857; }
.theme-cream .msg.user { background: linear-gradient(135deg, #fb923c, #f97316); color: #fff; }
.theme-cream .msg.ai { background: #fff; border-color: var(--line); }
.theme-cream .msg.tool { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.3); }
.theme-cream .modal { background: #fff; border-color: var(--line); }
.theme-cream .modal .grab { background: var(--line2); }
.theme-cream .pill { background: rgba(0,0,0,0.04); color: var(--muted); }
.theme-cream .status-dot { box-shadow: 0 0 0 4px rgba(251,146,60,0.2); }
.theme-cream hr, .theme-cream .divider { background: var(--line); }
.hero-card .ring {
  position: absolute; top: -40px; right: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(94,234,212,0.35), transparent 70%);
  pointer-events: none;
}
.hero-card .header-line {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.hero-card .title { font-size: 13px; color: var(--muted); letter-spacing: 1px; }
.hero-card .badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--line2);
  color: var(--text);
}
.hero-card .badge.low { background: var(--grad-pill-low); color: #cfe4ff; border-color: rgba(147,197,253,0.35); }
.hero-card .badge.high { background: var(--grad-pill-high); color: #ffe6b3; border-color: rgba(251,191,36,0.35); }
.hero-card .badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* KPI 网格 */
.kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.kpi {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
}
.kpi .ico {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(94,234,212,0.12);
  color: var(--accent);
  margin-bottom: 4px;
}
.kpi .ico.carb { background: rgba(251,191,36,0.14); color: var(--warn); }
.kpi .ico.fat { background: rgba(240,171,252,0.14); color: var(--pink); }
.kpi .ico.fiber { background: rgba(147,197,253,0.14); color: var(--info); }
.kpi .ico.kcal { background: rgba(94,234,212,0.14); color: var(--accent); }
.kpi .ico.protein { background: rgba(251,113,133,0.14); color: #fda4af; }
.kpi .v { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.kpi .l { font-size: 10.5px; color: var(--muted); text-align: center; }
.kpi .pct { font-size: 10px; color: var(--muted2); margin-top: 2px; }

/* 进度条 */
.bar { height: 6px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s ease; border-radius: 99px; }
.bar.over > i { background: linear-gradient(90deg, var(--warn), #f97316); }
.bar.bad > i { background: linear-gradient(90deg, var(--danger), #ef4444); }

.bar-row { margin-top: 10px; }
.bar-row .top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bar-row .top b { color: var(--text); font-weight: 600; }

/* ===== 按钮 ===== */
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--card2);
  color: var(--text); border-radius: 12px; padding: 11px 14px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
button:hover { background: #252b3b; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: linear-gradient(135deg, #5eead4 0%, #34d399 100%);
  color: #08110d; border: none; font-weight: 700;
  box-shadow: 0 6px 20px rgba(94,234,212,0.25);
}
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; border-color: var(--line2); }
button.danger { color: var(--danger); border-color: rgba(251,113,133,0.4); background: rgba(251,113,133,0.06); }
button.danger:hover { background: rgba(251,113,133,0.12); }
button.subtle { background: rgba(255,255,255,0.04); border-color: var(--line); color: var(--muted); }

/* ===== 表单 ===== */
input, select, textarea {
  width: 100%; background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94,234,212,0.18);
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 10px; }

/* ===== 列表项 ===== */
.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px;
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
  transition: background .15s ease;
}
.list-item:hover { background: #232a3a; }
.list-item .meta { color: var(--muted); font-size: 12px; }

.thumb {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--line); flex-shrink: 0;
}

/* ===== 标签 ===== */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; background: rgba(255,255,255,0.06); color: var(--muted);
  border: 1px solid var(--line);
}
.tag.low { background: var(--grad-pill-low); color: #cfe4ff; border-color: rgba(147,197,253,0.35); }
.tag.high { background: var(--grad-pill-high); color: #ffe6b3; border-color: rgba(251,191,36,0.35); }
.tag.train { background: var(--grad-pill-train); color: #b9fce7; border-color: rgba(94,234,212,0.35); }
.tag.warn { color: #fbbf24; border-color: rgba(251,191,36,0.35); background: rgba(251,191,36,0.08); }
.tag.danger { color: #fb7185; border-color: rgba(251,113,133,0.35); background: rgba(251,113,133,0.08); }
.tag.ok { color: #5eead4; border-color: rgba(94,234,212,0.35); background: rgba(94,234,212,0.08); }

/* ===== 循环日历 ===== */
.cycle-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cycle-cell {
  padding: 10px 4px; text-align: center;
  border-radius: 12px;
  background: var(--card2);
  border: 1px solid var(--line);
  font-size: 12px;
  transition: transform .15s ease;
}
.cycle-cell:hover { transform: translateY(-1px); }
.cycle-cell.low { background: var(--grad-pill-low); border-color: rgba(147,197,253,0.35); }
.cycle-cell.high { background: var(--grad-pill-high); border-color: rgba(251,191,36,0.35); }
.cycle-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: 0 0 0 4px rgba(94,234,212,0.18); }
.cycle-cell .d { font-weight: 700; }
.cycle-cell .sub { font-size: 10px; opacity: .8; margin-top: 2px; }

/* ===== 对话 ===== */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 200px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg {
  padding: 10px 13px; border-radius: 14px;
  max-width: 86%; white-space: pre-wrap; word-break: break-word; line-height: 1.6;
  font-size: 14px;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.user {
  background: linear-gradient(135deg, #5eead4 0%, #34d399 100%);
  color: #08110d; align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(94,234,212,0.25);
}
.msg.ai {
  background: var(--card2);
  border: 1px solid var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg.tool {
  background: rgba(147,197,253,0.08);
  color: var(--info);
  border: 1px dashed rgba(147,197,253,0.35);
  align-self: center;
  font-size: 12px;
  max-width: 95%;
}
.msg .label { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; margin-bottom: 4px; opacity: 0.7; font-size: 11px; }

/* ===== 模态 ===== */
.modal-bg {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 22px 22px 0 0;
  width: 100%; max-width: 720px;
  padding: 18px 16px 24px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 -16px 48px rgba(0,0,0,0.6);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal h3 {
  margin: 0 0 14px; font-size: 16px;
  display: flex; align-items: center; gap: 8px;
  letter-spacing: 0.5px;
}
.modal .grab { width: 36px; height: 4px; background: var(--line2); border-radius: 99px; margin: 0 auto 12px; }

.empty {
  color: var(--muted); text-align: center;
  padding: 36px 16px;
  font-size: 13px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* ===== 底部 Tab ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(11,13,18,0.85);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tab {
  flex: 1; background: transparent; border: none;
  padding: 8px 4px;
  color: var(--muted); font-size: 11px;
  border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: color .15s ease;
}
.tab svg { transition: transform .15s ease; }
.tab.active { color: var(--accent); }
.tab.active svg { transform: translateY(-2px); filter: drop-shadow(0 4px 8px rgba(94,234,212,0.4)); }

/* ===== 工具栏 ===== */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== 杂项 ===== */
.muted { color: var(--muted); font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.05); font-size: 11px; color: var(--muted); margin-right: 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.spacer { height: 10px; }
.callout {
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  font-size: 12px; color: var(--muted);
  display: flex; gap: 10px; align-items: flex-start;
}
.callout .ico { color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* ===== 训练集合 ===== */
.set-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(94,234,212,0.08);
  border: 1px solid rgba(94,234,212,0.25);
  border-radius: 999px;
  font-size: 11.5px; color: #b9fce7;
  font-variant-numeric: tabular-nums;
}
.set-chip .num {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(94,234,212,0.2); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}

/* ===== 列表视觉高度 ===== */
.list-item .meal-name { font-weight: 600; margin-bottom: 4px; }
.list-item .meal-stats { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.list-item .meal-stat b { color: var(--text); font-weight: 600; }

/* ===== 状态点 ===== */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 6px;
  box-shadow: 0 0 0 4px rgba(94,234,212,0.2);
}
.status-dot.ok { background: var(--accent); box-shadow: 0 0 0 4px rgba(94,234,212,0.2); }
.status-dot.off { background: var(--muted2); box-shadow: 0 0 0 4px rgba(93,100,120,0.2); }

/* Toast 动画 */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* === 移动端 PWA 优化 === */
button, .tab, input, select, textarea {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input, textarea, select { font-size: 16px; } /* iOS 防缩放 */

/* 键盘弹起时: tabbar 隐藏, 留出底部空间给系统栏 */
.tabbar { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.keyboard-open .tabbar { display: none; }

/* 安卓 3 按钮导航: 防止 tabbar 被遮挡 */
@supports (padding: max(0px)) {
  #app > main { padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom))); }
}

/* PWA 安装提示横幅 */
.install-banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 40;
  background: linear-gradient(135deg, rgba(94,234,212,0.95), rgba(52,211,153,0.95));
  color: #08110d;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.35);
  animation: slideUp .35s cubic-bezier(.2,.8,.3,1.2);
}
.install-banner .icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.install-banner .txt { flex: 1; line-height: 1.4; }
.install-banner .txt b { font-size: 13px; }
.install-banner .txt span { display: block; font-size: 11px; opacity: .8; }
.install-banner button {
  border: none; padding: 7px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.install-banner .install { background: #08110d; color: #fff; }
.install-banner .dismiss { background: rgba(255,255,255,0.25); color: #08110d; margin-left: 4px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 桌面浏览器 (非移动设备) 时, 显示一个温和的"安装到手机"提示 */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .install-banner { bottom: 24px; left: auto; right: 24px; width: 320px; }
}
