/* ============================================================
 * 智膳 · AI营养健康管理平台 样式表
 * 设计规范：移动端优先（max-width 480px 容器），
 * 主色 #16a34a 健康绿，圆角卡片 + 轻投影，符合H5交互习惯
 * ============================================================ */

:root {
  --primary: #16a34a;
  --primary-light: #22c55e;
  --primary-bg: #f0fdf4;
  --danger: #ef4444;
  --warn: #f59e0b;
  --info: #3b82f6;
  --text: #1e293b;
  --text-2: #64748b;
  --line: #e8edf2;
  --bg: #f6f8fa;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(15, 40, 30, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 15px; }
body {
  font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: .95rem; outline: none; }
img { display: block; }

/* ---------- 应用骨架 ---------- */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; padding-bottom: 76px; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 18px 12px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff; box-shadow: 0 2px 8px rgba(22, 163, 74, .25);
}
.topbar-logo { font-size: 1.15rem; font-weight: 700; letter-spacing: .5px; }
.topbar-sub { font-size: .72rem; opacity: .82; }

.view { padding: 14px 14px 20px; min-height: calc(100vh - 130px); }
.page-in { animation: pageIn .28s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 底部导航 ---------- */
.navbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; font-size: .68rem; color: var(--text-2); transition: color .2s;
}
.nav-item span { font-size: 1.25rem; line-height: 1; }
.nav-item.active { color: var(--primary); font-weight: 600; }

/* ---------- 首页 ---------- */
.hero {
  background: linear-gradient(135deg, #16a34a, #0e7a37);
  border-radius: var(--radius); color: #fff; padding: 18px;
  box-shadow: 0 4px 16px rgba(22, 163, 74, .28);
}
.hero-hi { font-size: 1.1rem; font-weight: 700; }
.hero-date { font-size: .75rem; opacity: .85; margin-top: 3px; }
.hero-ring { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.hero-ring-text { flex: 1; }
.hero-kcal { font-size: 1.65rem; font-weight: 800; }
.hero-kcal small { font-size: .85rem; font-weight: 400; opacity: .85; }
.hero-kcal-sub { font-size: .72rem; opacity: .8; margin-top: 2px; }

.score-ring { border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.score-ring-inner {
  width: 78%; height: 78%; border-radius: 50%; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.03);
}
.score-ring-inner b { font-size: 1.3rem; line-height: 1; }
.score-ring-inner span { font-size: .62rem; color: var(--text-2); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.qa-btn {
  padding: 12px; border-radius: var(--radius); background: #fff; color: var(--text);
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow); transition: transform .15s;
}
.qa-btn:active { transform: scale(.97); }
.qa-btn:disabled { opacity: .55; }
.qa-primary { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }

/* ---------- 通用区块 ---------- */
.section { margin-top: 16px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.section-head h3 { font-size: .98rem; font-weight: 700; }
.section-head h3 small { font-size: .72rem; color: var(--text-2); font-weight: 400; }
.section-link { font-size: .78rem; color: var(--primary); }
.help-dot {
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary-bg);
  color: var(--primary); font-size: .78rem; font-weight: 700;
  display: grid; place-items: center; border: 1px solid #bbf7d0;
}
.empty { text-align: center; color: var(--text-2); padding: 34px 12px; font-size: .9rem; line-height: 1.7; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.empty.small { padding: 22px 12px; font-size: .84rem; background: #fbfcfe; box-shadow: none; border: 1px dashed var(--line); }
.muted { color: var(--text-2); font-size: .8rem; }

.tip-card {
  background: #fff; border-radius: var(--radius); padding: 13px 14px;
  font-size: .85rem; line-height: 1.6; color: var(--text);
  box-shadow: var(--shadow); border-left: 4px solid var(--warn);
  display: flex; flex-direction: column; gap: 4px;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 12px 16px; border-radius: 12px; font-size: .92rem; font-weight: 600;
  transition: transform .15s, opacity .2s; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; box-shadow: 0 3px 10px rgba(22,163,74,.3); }
.btn-ghost { background: #fff; color: var(--text-2); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 9px 12px; font-size: .82rem; }
.btn:disabled { opacity: .6; }

.spin {
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 记录页 ---------- */
.meal-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mt-btn {
  padding: 10px 4px; border-radius: 12px; background: #fff; font-size: .84rem;
  box-shadow: var(--shadow); border: 1.5px solid transparent; transition: all .2s;
}
.mt-btn.active { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); font-weight: 700; }

.upload-box {
  background: #fff; border: 2px dashed #cbd5e1; border-radius: var(--radius);
  min-height: 170px; display: grid; place-items: center; overflow: hidden;
  cursor: pointer; transition: border-color .2s; margin-bottom: 10px;
}
.upload-box:active { border-color: var(--primary); }
.upload-empty { text-align: center; color: var(--text-2); padding: 20px; }
.upload-icon { font-size: 2.2rem; }
.upload-empty p { font-weight: 600; color: var(--text); margin: 8px 0 4px; }
.upload-empty small { font-size: .74rem; line-height: 1.6; }
.upload-preview { width: 100%; max-height: 240px; object-fit: cover; }

.recognizing { text-align: center; color: var(--text-2); padding: 24px 12px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .88rem; }
.rec-bar { height: 5px; background: var(--line); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.rec-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, #22c55e, #16a34a); border-radius: 4px; animation: recmove 1.1s ease-in-out infinite; }
@keyframes recmove { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.rec-item {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border-radius: var(--radius); padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.rec-item-emoji { font-size: 1.5rem; }
.rec-item-main { flex: 1; min-width: 0; }
.rec-item-name { font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.rec-item-nutri { font-size: .74rem; color: var(--text-2); margin-top: 2px; }
.conf-tag { font-size: .64rem; padding: 2px 6px; border-radius: 6px; background: #fef3c7; color: #b45309; font-weight: 600; }
.conf-tag.ok { background: var(--primary-bg); color: var(--primary); }
.gram-ctrl { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-2); }
.gram-ctrl button {
  width: 26px; height: 26px; border-radius: 8px; background: var(--bg);
  font-size: .95rem; font-weight: 700; color: var(--text);
}
.rec-item-del { color: #cbd5e1; font-size: .95rem; padding: 4px; }
.save-zone { padding-bottom: 10px; }

/* ---------- 食物选择器 ---------- */
.fp-search {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 10px; background: var(--bg);
}
.fp-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.fp-cat {
  flex-shrink: 0; padding: 6px 11px; border-radius: 20px; font-size: .78rem;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--line);
}
.fp-cat.active { background: var(--primary-bg); color: var(--primary); border-color: #86efac; font-weight: 600; }
.fp-list { max-height: 44vh; overflow-y: auto; margin-top: 6px; }
.fp-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 6px; border-bottom: 1px solid var(--line); font-size: .88rem;
}
.fp-row:active { background: var(--primary-bg); }
.fp-row small { color: var(--text-2); font-size: .72rem; white-space: nowrap; }

/* ---------- 分析页 ---------- */
.an-cards { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.an-card {
  flex-shrink: 0; width: 108px; background: #fff; border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); font-size: .82rem; font-weight: 600;
  border: 1.5px solid transparent;
}
.an-card.active { border-color: var(--primary); background: var(--primary-bg); }
.an-card small { display: block; font-size: .68rem; color: var(--text-2); font-weight: 400; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-score { margin-top: 6px; font-size: 1.25rem; font-weight: 800; }
.an-score small { font-size: .66rem; margin-left: 4px; }
.an-score.na { font-size: .72rem; color: var(--text-2); font-weight: 400; }

.detail-head { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.detail-head-info { flex: 1; }
.detail-grade { font-size: 1.05rem; font-weight: 800; }
.detail-grade small { font-size: .72rem; opacity: .8; }
.detail-sub { font-size: .74rem; color: var(--text-2); margin-top: 3px; }
.detail-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.detail-chart { background: #fff; border-radius: var(--radius); padding: 10px 6px; box-shadow: var(--shadow); display: grid; place-items: center; }

.chart-box { background: #fff; border-radius: var(--radius); padding: 14px 10px; box-shadow: var(--shadow); }
.trend-legend { text-align: center; font-size: .7rem; color: var(--text-2); margin-top: 6px; }

.advice-box { background: #fff; border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); margin-top: 10px; }
.advice-title { font-size: .86rem; font-weight: 700; margin-bottom: 8px; }
.advice-row { font-size: .8rem; line-height: 1.65; color: #475569; padding: 7px 0; border-top: 1px dashed var(--line); }
.advice-row:first-of-type { border-top: none; }

.nutri-table {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px;
}
.nutri-table div { background: #fff; border-radius: 10px; padding: 9px 6px; text-align: center; box-shadow: var(--shadow); }
.nutri-table span { display: block; font-size: .68rem; color: var(--text-2); }
.nutri-table b { font-size: .88rem; margin-top: 2px; display: block; }

/* ---------- 发现页 ---------- */
.seg { display: flex; background: #e8edf2; border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 7px 10px; border-radius: 8px; font-size: .82rem; color: var(--text-2); }
.seg button.on { background: #fff; color: var(--primary); font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.seg-top { margin-bottom: 4px; }

.group-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gt-btn {
  padding: 10px 6px; border-radius: 12px; background: #fff; font-size: .8rem;
  box-shadow: var(--shadow); border: 1.5px solid transparent; color: var(--text);
}
.gt-btn.active { border-color: var(--gc); color: var(--gc); font-weight: 700; background: color-mix(in srgb, var(--gc) 8%, #fff); }

.group-banner { border-radius: var(--radius); padding: 13px 14px; margin-top: 12px; border: 1px solid; }
.group-banner b { font-size: .95rem; }
.group-banner p { font-size: .78rem; margin-top: 5px; line-height: 1.55; color: #475569; }
.group-meta { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; font-size: .72rem; color: var(--text-2); }

.kn-card {
  background: #fff; border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); margin-bottom: 8px; transition: opacity .3s;
}
.kn-card.read { opacity: .82; }
.kn-title { font-size: .88rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.kn-card.read .kn-title::after { content: '已读'; font-size: .62rem; color: var(--primary); background: var(--primary-bg); padding: 2px 6px; border-radius: 6px; font-weight: 400; }
.kn-body { font-size: .79rem; color: #475569; line-height: 1.7; margin-top: 6px; }
.src-note { font-size: .68rem; color: #94a3b8; line-height: 1.6; margin-top: 14px; text-align: center; padding: 0 10px; }

/* ---------- 社区 ---------- */
.post-card { background: #fff; border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.post-head { display: flex; align-items: center; gap: 9px; }
.post-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-bg); display: grid; place-items: center; font-size: 1.2rem; }
.post-head b { font-size: .86rem; display: block; }
.post-head small { font-size: .68rem; color: var(--text-2); }
.post-text { font-size: .86rem; line-height: 1.65; margin-top: 9px; white-space: pre-wrap; word-break: break-word; }
.post-img { width: 100%; max-height: 260px; object-fit: cover; border-radius: 10px; margin-top: 9px; }
.post-actions { display: flex; gap: 18px; margin-top: 10px; }
.post-actions button { font-size: .8rem; color: var(--text-2); padding: 3px 0; }
.post-actions button.liked { color: var(--danger); font-weight: 600; }
.post-comments { background: var(--bg); border-radius: 10px; padding: 9px 11px; margin-top: 9px; }
.post-cmt { font-size: .78rem; line-height: 1.6; color: #475569; }
.post-cmt b { color: var(--text); }
.post-cmt-input { display: flex; gap: 8px; margin-top: 9px; }
.post-cmt-input input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: .8rem; background: var(--bg);
}
.post-cmt-input button { color: var(--primary); font-weight: 700; font-size: .82rem; }
.post-textarea {
  width: 100%; min-height: 110px; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; resize: vertical; background: var(--bg); margin-bottom: 10px;
}
.post-img-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.post-img-prev { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }

/* ---------- 我的 ---------- */
.pf-card { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #16a34a, #0e7a37); border-radius: var(--radius); padding: 17px 16px; color: #fff; box-shadow: 0 4px 14px rgba(22,163,74,.25); }
.pf-avatar { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 1.7rem; }
.pf-info { flex: 1; }
.pf-name { font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-lv { font-size: .68rem; background: rgba(255,255,255,.22); padding: 3px 9px; border-radius: 12px; font-weight: 500; }
.pf-sub { font-size: .72rem; opacity: .85; margin-top: 5px; }
.pf-progress { height: 5px; background: rgba(255,255,255,.25); border-radius: 4px; margin-top: 9px; overflow: hidden; }
.pf-progress i { display: block; height: 100%; background: #fff; border-radius: 4px; transition: width .5s; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat-cell { background: #fff; border-radius: 12px; padding: 11px 4px; text-align: center; box-shadow: var(--shadow); }
.stat-cell b { font-size: 1.05rem; display: block; }
.stat-cell span { font-size: .62rem; color: var(--text-2); }

.task-row {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-radius: 12px; padding: 11px 13px; margin-bottom: 7px;
  box-shadow: var(--shadow); font-size: .84rem;
}
.task-row.done { opacity: .68; }
.task-row b { color: var(--warn); font-size: .78rem; }

.badge-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge { background: #fff; border-radius: 12px; padding: 12px 4px; text-align: center; box-shadow: var(--shadow); opacity: .45; }
.badge.got { opacity: 1; background: linear-gradient(160deg, #fff, #f0fdf4); border: 1px solid #bbf7d0; }
.badge-icon { font-size: 1.5rem; display: block; }
.badge small { font-size: .64rem; color: var(--text-2); margin-top: 4px; display: block; }

.menu { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.menu-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 15px; font-size: .88rem; border-bottom: 1px solid var(--line);
}
.menu-row:last-child { border-bottom: none; }
.menu-row:active { background: var(--bg); }
.menu-row i { color: #cbd5e1; font-style: normal; }

/* ---------- 登录认证 ---------- */
.auth-view { text-align: center; padding: 60px 30px 40px; }
.auth-logo { font-size: 3.4rem; }
.auth-view h2 { margin-top: 14px; font-size: 1.25rem; }
.auth-slogan { color: var(--text-2); font-size: .84rem; margin: 8px 0 26px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; padding: 10px; border-radius: 10px; background: var(--bg); font-weight: 600; color: var(--text-2); }
.auth-tabs button.on { background: var(--primary-bg); color: var(--primary); }
.f-label { display: block; font-size: .78rem; color: var(--text-2); margin: 10px 0 5px; text-align: left; }
.f-input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--bg); font-size: .92rem;
}
.auth-divider { text-align: center; font-size: .72rem; color: #94a3b8; margin: 16px 0 10px; }
.oauth-row { display: flex; gap: 10px; }
.oauth-btn {
  flex: 1; padding: 10px; border-radius: 11px; background: var(--bg);
  border: 1px solid var(--line); font-size: .82rem; font-weight: 600;
}
.auth-agree { font-size: .68rem; color: #94a3b8; line-height: 1.6; margin-top: 14px; text-align: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.form-grid label { font-size: .74rem; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.form-grid input, .form-grid select {
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.form-grid label:last-child { grid-column: 1 / -1; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .28s ease;
}
.modal-lg { min-height: 60vh; }
@keyframes slideUp { from { transform: translateY(60px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head b { font-size: 1rem; }
.modal-close { width: 30px; height: 30px; border-radius: 50%; background: var(--bg); color: var(--text-2); font-size: .85rem; }
.help-body { font-size: .84rem; line-height: 1.8; color: #475569; }
.help-body p { margin-bottom: 8px; }
.help-body b { color: var(--text); }

/* ---------- 新手引导 ---------- */
.ob-step { text-align: center; padding: 14px 6px 4px; }
.ob-icon { font-size: 3.2rem; }
.ob-dots { display: flex; justify-content: center; gap: 6px; margin: 16px 0; }
.ob-dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--line); transition: all .25s; }
.ob-dots i.on { width: 20px; background: var(--primary); }
.ob-step h3 { font-size: 1.08rem; }
.ob-step p { font-size: .84rem; color: var(--text-2); line-height: 1.75; margin: 10px 0 20px; text-align: left; }
.ob-btns { display: flex; gap: 10px; }
.ob-btns .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 66px; left: 50%; transform: translate(-50%, -12px);
  z-index: 200; max-width: 82%; padding: 11px 18px; border-radius: 12px;
  background: #1e293b; color: #fff; font-size: .84rem; opacity: 0;
  transition: all .3s ease; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.2);
  line-height: 1.5;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-success { background: #15803d; }
.toast-error { background: #dc2626; }

/* ---------- 桌面端适配 ---------- */
@media (min-width: 520px) {
  body { background: #eceff3; }
  .app { box-shadow: 0 0 40px rgba(0,0,0,.08); background: var(--bg); min-height: 100vh; }
}
