/* 代谢教练 H5 · 极简骨架样式（沿用 supplement-plan 视觉语言） */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f8fa; color: #1f2329; -webkit-font-smoothing: antialiased;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; background: #fff; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #fff; padding: 14px 20px; border-bottom: 1px solid #eaecf0;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-size: 17px; font-weight: 600; color: #ff6b35; }
.topbar .nick { font-size: 13px; color: #6b7280; }

/* ============ 视图 ============ */
.view { display: none; padding: 20px; }
.view.active { display: block; }

h1 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 14px 0 8px; color: #374151; }
.lead { font-size: 14px; color: #4b5563; line-height: 1.6; margin-bottom: 20px; }
.hint { font-size: 12px; color: #9ca3af; margin-top: 6px; line-height: 1.5; }

/* ============ 卡片 ============ */
.card {
  background: #fff; border: 1px solid #eaecf0; border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.card.featured {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border-color: #fdba74;
}

/* ============ 主分卡片 ============ */
.score-hero {
  text-align: center; padding: 28px 16px;
  background: linear-gradient(135deg, #ff9500, #ff6b35);
  color: #fff; border-radius: 16px; margin-bottom: 16px;
}
.score-hero .score-num {
  font-size: 56px; font-weight: 700; line-height: 1;
}
.score-hero .score-label { font-size: 13px; margin-top: 6px; opacity: 0.9; }

.score-sub {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px;
}
.score-sub .item {
  background: #f9fafb; border-radius: 10px; padding: 12px; text-align: center;
}
.score-sub .item .v { font-size: 22px; font-weight: 600; color: #ff6b35; }
.score-sub .item .l { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ============ 三餐 Tab ============ */
.meal-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px;
}
.meal-tab {
  background: #f3f4f6; border-radius: 10px; padding: 14px 8px;
  text-align: center; cursor: pointer; transition: all 0.15s;
  border: 2px solid transparent;
}
.meal-tab .name { font-size: 14px; font-weight: 500; }
.meal-tab .count { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.meal-tab.active { background: #fff; border-color: #ff9500; color: #ff6b35; }
.meal-tab.done { background: #fff; border-color: #10b981; }
.meal-tab.done .count { color: #10b981; }

/* ============ 食物选择 ============ */
.search-box {
  width: 100%; padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 15px; margin-bottom: 12px;
}
.search-box:focus { outline: 2px solid #ff9500; border-color: transparent; }

.food-category { margin-bottom: 12px; border: 1px solid #e5e7eb; border-radius: 8px; }
.food-category summary {
  padding: 12px 16px; font-weight: 500; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}
.food-category summary::-webkit-details-marker { display: none; }
.food-category summary::before {
  content: "▸"; margin-right: 8px; transition: transform 0.2s; color: #9ca3af;
}
.food-category[open] summary::before { transform: rotate(90deg); }
.food-list { padding: 0 16px 12px; }
.food-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-top: 1px solid #f3f4f6; cursor: pointer;
}
.food-item .name { flex: 1; font-size: 14px; }
.food-item .lamp {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.lamp.green { background: #10b981; }
.lamp.yellow { background: #f59e0b; }
.lamp.red { background: #ef4444; }
.food-item .portion-hint { font-size: 12px; color: #9ca3af; }
.food-item .add-btn {
  background: #ff9500; color: #fff; border: 0; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}

/* ============ 餐盘 ============ */
.tray {
  background: #fff7ed; border-radius: 10px; padding: 12px; margin-bottom: 14px;
}
.tray-empty {
  color: #9ca3af; text-align: center; padding: 18px; font-size: 13px;
}
.tray-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid #ffedd5;
}
.tray-item:last-child { border-bottom: 0; }
.tray-item .name { flex: 1; font-size: 14px; }
.tray-item .grams {
  width: 70px; padding: 4px 8px; border: 1px solid #fdba74; border-radius: 6px;
  font-size: 13px; text-align: center;
}
.tray-item .remove {
  background: #fef2f2; color: #ef4444; border: 0; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}

/* ============ 替换建议 ============ */
.replacement {
  background: #f9fafb; border-left: 3px solid #ff9500;
  padding: 12px; margin-bottom: 10px; border-radius: 6px;
}
.replacement .title { font-size: 13px; color: #ff6b35; font-weight: 500; margin-bottom: 4px; }
.replacement .arrow { font-size: 14px; line-height: 1.6; }
.replacement .reason { font-size: 12px; color: #6b7280; margin-top: 6px; }

/* ============ 按钮 ============ */
.btn-primary, .btn-secondary {
  width: 100%; padding: 14px; border: 0; border-radius: 10px;
  font-size: 16px; font-weight: 500; cursor: pointer; margin-top: 12px;
}
.btn-primary {
  background: linear-gradient(135deg, #ff9500, #ff6b35);
  color: #fff;
}
.btn-secondary {
  background: #f3f4f6; color: #4b5563;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.form-input {
  width: 100%; padding: 12px 16px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 16px; background: #fff;
}
.form-input:focus { outline: 2px solid #ff9500; border-color: transparent; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-row label {
  flex: 1; min-width: 100px; display: flex; align-items: center; justify-content: center;
  padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 8px; cursor: pointer;
  font-size: 14px; user-select: none;
}
.radio-row input { display: none; }
.radio-row input:checked + span,
.radio-row label.checked { background: #fff7ed; border-color: #ff9500; color: #ff6b35; }

/* ============ 未开通页 ============ */
.locked-view {
  text-align: center; padding: 60px 24px;
}
.locked-icon { font-size: 64px; margin-bottom: 20px; }
.locked-title { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.locked-body {
  background: #fff7ed; border-radius: 12px; padding: 20px;
  color: #6b7280; font-size: 14px; line-height: 1.7;
  margin: 20px 0;
}
.locked-body strong { color: #ff6b35; }

/* ============ 未开通页：积分自助兑换卡 ============ */
.redeem-card {
  margin-top: 18px; padding: 16px;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1px solid #ffd0a8; border-radius: 12px;
  text-align: left;
}
.redeem-card-title {
  font-size: 15px; font-weight: 600; color: #b3401a; margin-bottom: 6px;
}
.redeem-card-text {
  font-size: 13px; line-height: 1.6; color: #6b5048;
}
.redeem-card-text b { color: #ff6b35; }
.redeem-btn {
  margin-top: 12px; width: 100%; padding: 12px 16px;
  font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #ff9500, #ff6b35);
  border: none; border-radius: 10px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.28);
  transition: transform 0.06s ease, opacity 0.2s ease;
}
.redeem-btn:active { transform: translateY(1px); }
.redeem-btn:disabled { opacity: 0.6; cursor: default; box-shadow: none; }
.redeem-btn[data-insufficient="1"] {
  background: linear-gradient(135deg, #c9b0a4, #b59a8c); box-shadow: none;
}

/* ============ 趋势图 ============ */
.trends {
  background: #f9fafb; border-radius: 10px; padding: 16px; margin-top: 14px;
}
.trends .trend-empty {
  text-align: center; color: #9ca3af; font-size: 13px; padding: 24px;
}
.trends-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid #f3f4f6; font-size: 13px;
}
.trends-row:first-child { border-top: 0; }
.trends-row .date { width: 80px; color: #6b7280; }
.trends-row .score-bar {
  flex: 1; background: #e5e7eb; border-radius: 6px; height: 8px; overflow: hidden;
}
.trends-row .score-bar-fill {
  height: 100%; background: linear-gradient(90deg, #ff9500, #ff6b35);
}
.trends-row .score-num { width: 36px; text-align: right; font-weight: 500; }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
  background: rgba(31, 35, 41, 0.92); color: #fff;
  padding: 12px 20px; border-radius: 10px; font-size: 14px;
  z-index: 1000; max-width: 80%; text-align: center;
  opacity: 0; transition: opacity 0.2s;
}
.toast.show { opacity: 1; }

/* ============ 顶部状态条（API 失败兜底） ============ */
.banner-warn {
  background: #fffbeb; border-bottom: 1px solid #fcd34d;
  color: #92400e; padding: 8px 16px; font-size: 12px; text-align: center;
}

/* ============ 等级横幅 + 等级 chips ============ */
.level-banner {
  background: #fff7ed; border-radius: 10px; padding: 12px 14px;
  font-size: 14px; color: #4b5563; margin-bottom: 6px;
}
.level-banner strong { color: #ff6b35; }
.level-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.level-chip {
  border: 2px solid #e5e7eb; border-radius: 10px; padding: 10px 6px;
  text-align: center; cursor: pointer; transition: all 0.15s; background: #fff;
}
.level-chip .lv { font-size: 18px; font-weight: 700; color: #9ca3af; }
.level-chip .lv-label { font-size: 12px; font-weight: 500; margin-top: 2px; }
.level-chip .lv-desc { font-size: 11px; color: #9ca3af; margin-top: 3px; line-height: 1.4; }
.level-chip.active { border-color: #ff9500; background: #fff7ed; }
.level-chip.active .lv { color: #ff6b35; }

/* ============ 多选食物 ============ */
.select-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-top: 1px solid #f3f4f6; cursor: pointer;
}
.select-item input { width: 18px; height: 18px; accent-color: #ff6b35; flex-shrink: 0; }
.select-item .name { flex: 1; font-size: 14px; }
.select-item .portion-hint { font-size: 12px; color: #9ca3af; }
.badge-low {
  font-size: 11px; color: #059669; background: #ecfdf5;
  border-radius: 4px; padding: 1px 6px;
}

/* ============ 选食物底部固定栏 ============ */
.sticky-footer {
  position: sticky; bottom: 0; background: #fff; padding: 12px 0 4px;
  border-top: 1px solid #eaecf0; display: flex; align-items: center; gap: 12px;
}
.sticky-footer .select-count { font-size: 13px; color: #6b7280; white-space: nowrap; }
.sticky-footer .btn-primary { flex: 1; }

/* ============ 食谱结果 ============ */
.result-hero {
  background: linear-gradient(135deg, #ff9500, #ff6b35); color: #fff;
  border-radius: 16px; padding: 18px; margin-bottom: 14px; position: relative;
}
.result-hero .level-tag { font-size: 15px; font-weight: 600; }
.result-hero .hero-feas { position: absolute; top: 18px; right: 18px; font-size: 13px; }
.result-hero .hero-feas .ok { background: rgba(255,255,255,0.25); padding: 3px 10px; border-radius: 20px; }
.result-hero .hero-feas .warn { background: rgba(0,0,0,0.18); padding: 3px 10px; border-radius: 20px; }
.result-hero .metric { margin-top: 14px; }
.result-hero .metric-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.result-hero .bar { background: rgba(255,255,255,0.3); border-radius: 6px; height: 8px; overflow: hidden; }
.result-hero .bar-fill { height: 100%; background: #fff; }
.result-hero .bar-fill.over { background: #fde68a; }
.result-hero .bar-fill.protein { background: #d1fae5; }
.result-hero .metric-sub { font-size: 11px; opacity: 0.9; margin-top: 4px; }

.meal-card { padding: 14px 16px; }
.meal-card .meal-head { font-size: 15px; font-weight: 600; color: #ff6b35; margin-bottom: 8px; }
.recipe-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-top: 1px solid #f3f4f6; font-size: 14px;
}
.recipe-item:first-of-type { border-top: 0; }
.recipe-item .r-name { flex: 1; }
.recipe-item .r-role { font-size: 11px; color: #9ca3af; background: #f3f4f6; border-radius: 4px; padding: 1px 6px; }
.recipe-item .r-grams { font-size: 13px; color: #4b5563; white-space: nowrap; }

.excluded-item { font-size: 13px; color: #6b7280; padding: 8px 0; border-top: 1px solid #f3f4f6; line-height: 1.5; }
.excluded-item:first-child { border-top: 0; }
.excluded-item strong { color: #ef4444; }

.suggestion-card { background: #fffbeb; border-color: #fcd34d; }
.suggestion-card .sug-line { font-size: 13px; color: #92400e; line-height: 1.7; }

/* ============ 一周食谱：竖向日卡 accordion（零横滑） ============ */
.day-card { border: 1px solid #eaecf0; border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.day-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer; gap: 10px;
}
.day-card-head.static { cursor: default; }
.dch-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dch-label { font-size: 16px; font-weight: 600; color: #1f2329; }
.dch-meta { font-size: 12px; color: #9ca3af; }
.dch-arrow { color: #ff6b35; font-size: 14px; transition: transform 0.2s; flex: 0 0 auto; }
.day-card.open .dch-arrow { transform: rotate(180deg); }
.day-card-body { display: none; padding: 0 16px 14px; }
.day-card.open .day-card-body { display: block; }
.day-bar { background: #eef0f2; border-radius: 6px; height: 6px; overflow: hidden; margin: 0 0 12px; }
.day-bar-fill { height: 100%; background: linear-gradient(90deg, #ff9500, #ff6b35); }

/* 餐次块（日卡和长图共用） */
.meal-block { padding: 8px 0; border-top: 1px solid #f3f4f6; }
.meal-block:first-of-type { border-top: 0; }
.meal-head { font-size: 14px; font-weight: 600; color: #ff6b35; margin-bottom: 4px; }
.recipe-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 5px 0; font-size: 14px;
}
.recipe-item .r-name { flex: 1 1 auto; min-width: 0; word-break: break-word; line-height: 1.5; font-weight: 500; }
.recipe-item .r-detail { flex-basis: 100%; font-size: 12px; color: #9ca3af; }
.tag-col { font-size: 11px; color: #059669; background: #ecfdf5; border-radius: 4px; padding: 0 5px; }
.r-portion { font-size: 11px; color: #ff6b35; background: #fff7ed; border-radius: 4px; padding: 0 6px; white-space: nowrap; }

/* ============ 长图导出容器（屏外渲染，固定 640px 竖版） ============ */
#export-sheet {
  display: none; position: absolute; left: -9999px; top: 0;
  width: 640px; background: #fff7ed; padding: 28px; box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2329;
}
#export-sheet .es-header { text-align: center; padding-bottom: 18px; border-bottom: 2px solid #ff9500; margin-bottom: 18px; }
#export-sheet .es-brand { font-size: 26px; font-weight: 700; color: #ff6b35; }
#export-sheet .es-sub { font-size: 16px; color: #92400e; margin-top: 6px; }
#export-sheet .es-avg { font-size: 13px; color: #6b7280; margin-top: 8px; }
#export-sheet .es-day { background: #fff; border-radius: 12px; padding: 14px 18px; margin-bottom: 12px; }
#export-sheet .es-day-head { font-size: 17px; font-weight: 700; color: #ff6b35; margin-bottom: 8px; }
#export-sheet .es-day-head span { font-size: 12px; font-weight: 400; color: #9ca3af; }
#export-sheet .es-section-title { font-size: 18px; font-weight: 700; color: #ff6b35; margin: 18px 0 10px; }
#export-sheet .es-shop-run { background: #fff; border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
#export-sheet .es-shop-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
#export-sheet .es-shop-cat { font-size: 13px; color: #4b5563; line-height: 1.7; }
#export-sheet .es-shop-cat b { color: #ff6b35; }
#export-sheet .es-footer { text-align: center; font-size: 12px; color: #9ca3af; margin-top: 16px; }
#export-sheet .recipe-item { padding: 3px 0; }

/* ============ 长图预览遮罩（长按保存） ============ */
.img-preview-overlay {
  position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column; padding: 18px; overflow-y: auto;
}
.img-preview-overlay .ipo-tip { color: #fff; text-align: center; padding: 8px 0 14px; font-size: 15px; }
.img-preview-overlay img { width: 100%; border-radius: 8px; display: block; }
.img-preview-overlay .ipo-close {
  margin: 18px auto; padding: 10px 28px; background: #fff; color: #333;
  border: none; border-radius: 8px; font-size: 14px; cursor: pointer;
}

/* ============ 导出按钮 ============ */
.btn-export {
  width: 100%; padding: 12px; margin-bottom: 14px; border: 1px solid #ff9500;
  background: #fff7ed; color: #ff6b35; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-export:disabled { opacity: 0.6; }

/* ============ 全屏加载蒙层 ============ */
#loading-mask {
  display: none; position: fixed; inset: 0; z-index: 9998;
  background: rgba(255,255,255,0.88); align-items: center; justify-content: center;
}
#loading-mask.show { display: flex; }
#loading-mask .lm-box { text-align: center; }
#loading-mask .lm-spinner {
  width: 40px; height: 40px; margin: 0 auto 14px; border: 3px solid #fde0c8;
  border-top-color: #ff6b35; border-radius: 50%; animation: lm-spin 0.8s linear infinite;
}
@keyframes lm-spin { to { transform: rotate(360deg); } }
#loading-mask .lm-text { font-size: 14px; color: #92400e; }

/* ============ 生成失败页面内引导 ============ */
.blocker-card { text-align: center; padding: 24px 18px; }
.blocker-icon { font-size: 36px; }
.blocker-title { font-size: 16px; font-weight: 600; color: #1f2329; margin: 10px 0 6px; }
.blocker-tip { font-size: 13px; color: #6b7280; line-height: 1.6; }
.blocker-ex { text-align: left; margin-top: 14px; }
.blocker-ex-title { font-size: 13px; color: #92400e; margin-bottom: 6px; }

/* ============ 采购清单 ============ */
.shop-wrap { margin-top: 14px; border: 1px solid #fdba74; border-radius: 12px; overflow: hidden; }
.shop-summary { background: #fff7ed; padding: 12px 16px; font-weight: 600; color: #ff6b35; cursor: pointer; font-size: 15px; }
.shop-summary::-webkit-details-marker { display: none; }
.shop-run { margin: 10px; }
.shop-run-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.shop-cat { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid #f3f4f6; }
.shop-cat:first-of-type { border-top: 0; }
.shop-cat-name { flex: 0 0 48px; font-size: 13px; color: #ff6b35; font-weight: 500; }
.shop-items { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.shop-item { font-size: 13px; color: #4b5563; }
.shop-item b { color: #1f2329; font-weight: 600; }
.shop-collagen { margin: 0 10px 12px; font-size: 12px; color: #92400e; background: #fffbeb; border-radius: 8px; padding: 8px 12px; }

/* ============ 我的食谱历史 ============ */
.hist-item { background: #fff; border: 1px solid #eaecf0; border-radius: 10px; padding: 14px; margin-bottom: 10px; position: relative; cursor: pointer; }
.hist-item .hist-main { font-size: 15px; }
.hist-item .hist-sub { font-size: 12px; color: #9ca3af; margin-top: 4px; line-height: 1.5; }
.hist-item .hist-arrow { position: absolute; top: 14px; right: 14px; color: #ff6b35; font-size: 13px; }
.hist-slot { font-size: 13px; padding: 5px 0; border-top: 1px solid #f3f4f6; line-height: 1.5; }
.hist-slot:first-of-type { border-top: 0; }
.hist-slot-zh { color: #ff6b35; margin-right: 8px; font-size: 12px; }

/* ============ 小屏适配（≤360px） ============ */
@media (max-width: 360px) {
  #app { padding: 12px; }
  .day-card-head { padding: 12px 13px; }
  .dch-label { font-size: 15px; }
  .dch-meta { font-size: 11px; }
  .day-card-body { padding: 0 13px 12px; }
  .recipe-item { font-size: 13px; }
  .level-chips { gap: 6px; }
  .level-chip { padding: 8px 6px; }
  .level-chip .lv-desc { display: none; }
  .btn-export { font-size: 14px; }
  .sticky-footer { gap: 8px; }
}
