/* ===== 碳循环减脂 H5 ===== */
:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #0d0d0d;
  --border: #2a2a2a;
  --text: #ddd;
  --text2: #999;
  --text3: #777;
  --text4: #666;
  --green: #00e676;
  --green2: #00c853;
  --amber: #e6ac00;
  --orange: #ff9800;
  --blue: #42a5f5;
  --red: #ef5350;
  --radius: 8px;
  --radius-sm: 6px;
  --transition: 0.15s;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 64px;
}

button {
  border: none; background: none; font: inherit; color: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
input {
  border: none; outline: none; font: inherit; color: inherit;
  background: none;
}
input::placeholder { color: var(--text3); }

/* ===== 工具类 ===== */
.btn-primary {
  display: block; width: 100%; height: 42px; line-height: 42px;
  text-align: center; background: var(--green2); color: var(--bg);
  font-size: 16px; font-weight: 700; border-radius: var(--radius);
  transition: opacity var(--transition);
}
.btn-primary:active { opacity: 0.75; }

.btn-outline {
  flex: 1; height: 38px; line-height: 38px; text-align: center;
  background: var(--surface); color: var(--green);
  border: 1px solid var(--green); border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  transition: opacity var(--transition);
}
.btn-outline:active { opacity: 0.7; }

.btn-warning {
  flex: 1; height: 38px; line-height: 38px; text-align: center;
  background: var(--amber); color: var(--bg);
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  transition: opacity var(--transition);
}
.btn-warning:active { opacity: 0.75; }

.btn-sm-outline {
  padding: 4px 14px; border: 1px solid rgba(230,172,0,0.3);
  border-radius: 12px; font-size: 12px; color: var(--amber);
  transition: opacity var(--transition);
}
.btn-sm-outline:active { opacity: 0.7; }

.btn-dashed {
  width: 100%; padding: 14px; border: 2px dashed #333;
  border-radius: var(--radius); color: var(--text3); font-size: 14px;
  transition: opacity var(--transition);
}
.btn-dashed:active { opacity: 0.7; }

/* ===== 页面容器 ===== */
.tab-page { display: none; padding: 16px 16px 24px; }
.tab-page.active { display: block; }

/* ===== 底部导航 ===== */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: 56px;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  z-index: 100;
}
.tab-btn {
  flex: 1; font-size: 12px; color: var(--text4); font-weight: 600;
  transition: color var(--transition);
}
.tab-btn.active { color: var(--green); }

/* ===== 计算器页 ===== */
.header { padding: 30px 0 24px; text-align: center; }
.title { font-size: 26px; font-weight: 800; color: var(--green); letter-spacing: 2px; }
.subtitle { font-size: 13px; color: var(--text3); margin-top: 6px; }

.input-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px; border: 1px solid var(--border);
}
.input-row { display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.weight-input {
  width: 140px; height: 56px; background: var(--bg); border-radius: var(--radius-sm);
  text-align: center; font-size: 28px; font-weight: 700; color: #fff;
  border: 2px solid var(--border); transition: border-color 0.2s;
}
.weight-input:focus { border-color: var(--green); }
.unit { font-size: 20px; color: var(--text2); margin-left: 10px; font-weight: 600; }

.history { margin-top: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.history-label { font-size: 12px; color: var(--text4); }
.history-tag {
  display: inline-block; padding: 4px 12px; background: var(--surface);
  color: var(--green); border-radius: 12px; font-size: 12px;
  border: 1px solid var(--border); cursor: pointer;
  transition: opacity var(--transition);
}
.history-tag:active { opacity: 0.7; }

#resultsArea { margin-top: 24px; }
.section-title { font-size: 16px; font-weight: 700; color: #ccc; margin-bottom: 14px; }
#dayCards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--border); position: relative;
}
.card.low { background: rgba(0,230,118,0.03); border-color: rgba(0,230,118,0.12); }
.card.high {
  border-color: rgba(255,193,7,0.25);
  background: linear-gradient(135deg, var(--surface) 60%, rgba(255,193,7,0.04));
}
.card-badge {
  display: inline-block; padding: 3px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 600; margin-bottom: 14px;
}
.badge-low { background: rgba(0,230,118,0.12); color: var(--green); }
.badge-high { background: rgba(255,193,7,0.15); color: var(--amber); }

.card-nutrients { display: flex; }
.nutrient { flex: 1; text-align: center; }
.nutrient-label { display: block; font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.nutrient-value { font-size: 15px; font-weight: 700; color: var(--text); }
.nutrient-value.highlight { color: var(--amber); }
.card-kcal { margin-top: 12px; text-align: right; font-size: 12px; color: var(--text4); }

.high-watermark {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 22px; font-weight: 900; color: rgba(255,193,7,0.05);
  letter-spacing: 2px; pointer-events: none;
}

.actions { margin-top: 20px; display: flex; gap: 10px; }

.formula-box {
  margin-top: 20px; padding: 16px; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.formula-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.formula-text { font-size: 12px; color: var(--text3); line-height: 1.7; }

/* ===== 饮食规划页 ===== */
.day-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.day-tab {
  flex: 1; text-align: center; padding: 10px 0;
  background: var(--surface); border-radius: var(--radius);
  font-size: 14px; color: var(--text3); border: 1px solid var(--border);
  font-weight: 600; transition: all 0.2s;
}
.day-tab:active { opacity: 0.7; }
.day-tab.active.low { border-color: var(--green); color: var(--green); background: rgba(0,230,118,0.06); }
.day-tab.active.high { border-color: var(--amber); color: var(--amber); background: rgba(255,193,7,0.06); }

.edit-date-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin-bottom: 14px;
  background: rgba(255,193,7,0.08); border-radius: var(--radius-sm);
  border: 1px solid rgba(255,193,7,0.2);
  font-size: 13px; color: var(--amber);
}

.target-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; border: 1px solid var(--border);
}
.target-label { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.target-macros { display: flex; gap: 10px; margin-bottom: 18px; }
.target-item {
  flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; background: var(--bg);
}
.ti-carb { color: var(--orange); }
.ti-protein { color: var(--blue); }
.ti-fat { color: var(--red); }

.progress-row { display: flex; align-items: center; margin-bottom: 8px; }
.progress-label { width: 48px; font-size: 12px; color: #888; }
.progress-bar { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 0 10px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.fill-carb { background: var(--orange); }
.fill-protein { background: var(--blue); }
.fill-fat { background: var(--red); }
.progress-val { width: 90px; font-size: 12px; color: var(--text2); text-align: right; }
.total-kcal { display: block; text-align: right; font-size: 13px; color: var(--green); font-weight: 600; margin-top: 6px; }

/* 餐块 */
.meal-block {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; border: 1px solid var(--border);
}
.meal-header { display: flex; align-items: center; margin-bottom: 12px; }
.meal-icon { font-size: 16px; margin-right: 6px; }
.meal-name { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.meal-kcal { font-size: 12px; color: var(--text4); margin-right: 10px; }
.meal-add-btn {
  padding: 5px 14px; border: 1px solid var(--green);
  border-radius: 12px; font-size: 13px; color: var(--green);
  transition: opacity var(--transition);
}
.meal-add-btn:active { opacity: 0.7; }
.meal-del-btn {
  width: 28px; height: 28px; line-height: 28px; text-align: center;
  color: #ff5252; font-size: 20px; margin-left: 4px;
  transition: opacity var(--transition);
}
.meal-del-btn:active { opacity: 0.7; }

.food-items { display: flex; flex-direction: column; gap: 5px; }
.food-row {
  display: flex; align-items: center; background: var(--bg);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.food-info { flex: 1; }
.food-name { display: block; font-size: 14px; color: var(--text); font-weight: 600; }
.food-amount { font-size: 12px; color: #888; }
.food-macros { display: flex; gap: 8px; margin-right: 8px; }
.fm-item { font-size: 11px; color: var(--text4); }
.food-del-btn {
  width: 24px; height: 24px; line-height: 24px; text-align: center;
  color: #ff5252; font-size: 18px;
}
.empty-meal { text-align: center; padding: 20px; color: #555; font-size: 13px; }

.add-meal-row { margin-top: 4px; }

.advice-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--border); margin-top: 16px;
}
.advice-title { font-size: 15px; font-weight: 700; color: var(--amber); margin-bottom: 10px; }
.advice-tip { font-size: 13px; color: var(--text2); line-height: 1.7; padding-left: 10px; display: block; }
.advice-dist {
  padding: 10px; background: var(--bg); border-radius: var(--radius-sm);
  margin-top: 10px; font-size: 13px; color: var(--green); font-weight: 600;
}

.save-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; margin-top: 16px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.save-target { flex: 1; font-size: 13px; color: var(--text3); }
.save-target b { color: var(--green); font-weight: 600; }
.save-btn {
  padding: 8px 22px; background: var(--green2); color: var(--bg);
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 700;
  transition: opacity var(--transition);
}
.save-btn:active { opacity: 0.75; }
.save-btn.outline {
  background: transparent; color: var(--green); border: 1px solid var(--green);
}

.empty-state { text-align: center; padding: 60px 0; }
.empty-state p { font-size: 15px; color: var(--text4); margin-bottom: 20px; }

/* ===== 食物库 ===== */
.search-input {
  width: 100%; height: 42px; background: var(--surface); border-radius: var(--radius);
  padding: 0 16px; font-size: 15px; color: var(--text);
  border: 1px solid var(--border); transition: border-color 0.2s; margin-bottom: 14px;
}
.search-input:focus { border-color: var(--green); }

.cat-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  margin-bottom: 16px; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0; padding: 7px 18px; background: var(--surface);
  border-radius: 14px; font-size: 13px; color: var(--text3);
  border: 1px solid var(--border); transition: all var(--transition);
  white-space: nowrap;
}
.cat-chip:active { opacity: 0.7; }
.cat-chip.active { background: rgba(0,230,118,0.1); color: var(--green); border-color: rgba(0,230,118,0.3); }

.food-list { display: flex; flex-direction: column; gap: 10px; }
.food-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; border: 1px solid var(--border);
}
.food-card-head { display: flex; align-items: center; margin-bottom: 14px; }
.food-card-name { font-size: 15px; font-weight: 700; color: var(--text); flex: 1; }
.food-card-cat {
  padding: 3px 10px; background: var(--bg); border-radius: 4px;
  font-size: 11px; color: var(--text4);
}
.food-card-stats { display: flex; margin-bottom: 14px; }
.fs-item { flex: 1; text-align: center; }
.fs-val { display: block; font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.fs-label { font-size: 11px; color: var(--text4); }
.fs-carb { color: var(--orange); }
.fs-protein { color: var(--blue); }
.fs-fat { color: var(--red); }
.fs-kcal { color: var(--amber); }

.food-card-calc { border-top: 1px solid #1f1f1f; padding-top: 10px; }
.fcc-label { font-size: 12px; color: #888; margin-bottom: 6px; display: block; }
.fcc-row { display: flex; align-items: center; }
.fcc-input {
  width: 70px; height: 32px; background: var(--bg); border-radius: 6px;
  text-align: center; font-size: 15px; color: #fff; border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.fcc-input:focus { border-color: var(--green); }
.fcc-unit { font-size: 13px; color: var(--text2); margin: 0 8px; }
.fcc-result { font-size: 12px; color: var(--green); }

/* ===== 日历页 ===== */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; margin-bottom: 14px;
}
.month-label { font-size: 18px; font-weight: 700; color: var(--text); }
.nav-arrow {
  width: 38px; height: 38px; line-height: 38px; text-align: center;
  font-size: 14px; color: var(--green); background: var(--surface);
  border-radius: 50%; border: 1px solid var(--border);
  transition: opacity var(--transition);
}
.nav-arrow:active { opacity: 0.7; }

.weekday-row { display: flex; margin-bottom: 8px; }
.weekday-row span {
  flex: 1; text-align: center; font-size: 13px; color: var(--text3); padding: 6px 0;
}

.date-grid {
  display: flex; flex-wrap: wrap;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--border);
}
.date-cell {
  width: calc(100% / 7); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; border-right: 1px solid #1f1f1f; border-bottom: 1px solid #1f1f1f;
  cursor: pointer; transition: background 0.12s;
}
.date-cell:nth-child(7n) { border-right: none; }
.date-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.date-cell:active { background: #252525; }
.date-cell .day-num { font-size: 14px; color: #ccc; }
.date-cell.today .day-num { color: var(--green); font-weight: 700; }
.date-cell.selected { background: rgba(0,230,118,0.1); }
.date-cell.selected .day-num { color: var(--green); font-weight: 700; }
.date-dot {
  width: 5px; height: 5px; border-radius: 50%; margin-top: 3px;
}
.date-dot.low { background: var(--green); }
.date-dot.high { background: var(--amber); }

.detail-section {
  margin-top: 18px; background: var(--surface); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--border);
}
.detail-header { display: flex; align-items: baseline; margin-bottom: 14px; }
.detail-date { font-size: 15px; font-weight: 700; color: var(--text); margin-right: 10px; }
.detail-type {
  font-size: 12px; color: var(--green); padding: 3px 10px;
  background: rgba(0,230,118,0.1); border-radius: 4px;
}
.detail-empty { text-align: center; padding: 24px; color: #555; font-size: 14px; }
.detail-meals { display: flex; flex-direction: column; gap: 10px; }
.detail-meal { background: var(--bg); border-radius: var(--radius-sm); padding: 12px; }
.dm-header { font-size: 14px; color: var(--text); font-weight: 600; margin-bottom: 8px; }
.dm-food { display: flex; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--surface); }
.dmf-name { flex: 1; font-size: 13px; color: #ccc; }
.dmf-amount { font-size: 12px; color: var(--text3); margin-right: 10px; }
.dmf-macros { font-size: 11px; color: var(--text4); }
.detail-totals {
  margin-top: 14px; padding: 14px; background: var(--bg); border-radius: var(--radius-sm);
  display: flex; flex-wrap: wrap; gap: 6px 16px;
}
.dt-label { font-size: 12px; color: var(--text3); }
.dt-val { font-size: 14px; color: var(--text); font-weight: 600; }
.dt-val.kcal { color: var(--green); }
.detail-actions { margin-top: 14px; display: flex; gap: 10px; justify-content: center; }
.detail-btn {
  padding: 8px 24px; border: 1px solid var(--green);
  border-radius: 14px; font-size: 14px; color: var(--green);
  transition: opacity var(--transition);
}
.detail-btn:active { opacity: 0.7; }
.detail-btn.primary { background: var(--green2); color: var(--bg); border: none; font-weight: 600; }
.no-select { text-align: center; padding: 40px 0; color: #555; font-size: 15px; }

/* ===== 食物选择面板 ===== */
.picker-overlay {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 200;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.picker-panel {
  height: 75vh; background: var(--surface); border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
}
.picker-header {
  display: flex; align-items: center; padding: 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.picker-header span { flex: 1; font-size: 15px; font-weight: 700; color: var(--text); }
.picker-close {
  width: 32px; height: 32px; line-height: 32px; text-align: center;
  font-size: 24px; color: var(--text2); transition: opacity var(--transition);
}
.picker-close:active { opacity: 0.7; }

.picker-search-input {
  width: calc(100% - 28px); height: 38px; margin: 0 14px;
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 0 14px; font-size: 14px; color: var(--text);
  border: 1px solid var(--border); flex-shrink: 0;
  transition: border-color 0.2s;
}
.picker-search-input:focus { border-color: var(--green); }

.picker-cats-scroll {
  display: flex; gap: 8px; padding: 10px 14px; flex-shrink: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.picker-cats-scroll::-webkit-scrollbar { display: none; }
.picker-cat-chip {
  flex-shrink: 0; padding: 7px 16px; background: var(--bg);
  border-radius: 12px; font-size: 13px; color: var(--text3);
  border: 1px solid var(--border); transition: all var(--transition);
  white-space: nowrap;
}
.picker-cat-chip:active { opacity: 0.7; }
.picker-cat-chip.active { background: rgba(0,230,118,0.1); color: var(--green); border-color: rgba(0,230,118,0.3); }

.picker-food-list {
  flex: 1; overflow-y: auto; padding: 0 14px;
  -webkit-overflow-scrolling: touch;
}
.picker-food-item {
  display: flex; align-items: center; padding: 14px 10px;
  border-bottom: 1px solid #1f1f1f; cursor: pointer;
  transition: background 0.12s;
}
.picker-food-item:active { background: #222; }
.picker-food-item.selected { background: rgba(0,230,118,0.06); }
.pfi-left { flex: 1; }
.pfi-name { display: block; font-size: 15px; color: var(--text); margin-bottom: 2px; }
.pfi-macros { font-size: 12px; color: var(--text4); }
.pfi-kcal { font-size: 13px; color: var(--amber); font-weight: 600; }

.picker-bottom {
  padding: 14px 16px 24px; border-top: 1px solid var(--border);
  background: var(--bg); flex-shrink: 0;
}
.grams-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.grams-label { font-size: 15px; color: var(--green); font-weight: 600; }
.grams-input-wrap { display: flex; align-items: center; }
.grams-input {
  width: 90px; height: 40px; background: var(--surface); border-radius: var(--radius-sm);
  text-align: center; font-size: 20px; font-weight: 700; color: #fff; border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.grams-input:focus { border-color: var(--green); }
.grams-unit { font-size: 15px; color: var(--text2); margin-left: 8px; }
.grams-preview { text-align: right; font-size: 13px; color: #888; margin-bottom: 10px; }

/* ===== 加餐弹窗 ===== */
.extra-picker-panel {
  background: var(--surface); border-radius: 14px 14px 0 0;
  padding-bottom: 24px;
}
.extra-option {
  width: 100%; display: flex; align-items: center; padding: 18px 18px;
  border-bottom: 1px solid #1f1f1f; transition: background 0.12s;
}
.extra-option:active { background: #222; }
.eo-icon { font-size: 22px; margin-right: 14px; }
.eo-name { font-size: 16px; color: var(--text); font-weight: 600; flex: 1; text-align: left; }
.eo-desc { font-size: 13px; color: var(--text4); }

.custom-name-input {
  width: 100%; height: 42px; background: var(--bg); border-radius: var(--radius);
  padding: 0 16px; font-size: 16px; color: #fff; border: 1px solid var(--border);
  margin-bottom: 16px; transition: border-color 0.2s;
}
.custom-name-input:focus { border-color: var(--green); }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.85); color: #fff; padding: 10px 24px;
  border-radius: 8px; font-size: 14px; z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

/* ===== Modal ===== */
.modal-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 250;
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; width: 300px; text-align: center;
}
.modal-box p { font-size: 15px; color: var(--text); margin-bottom: 20px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns button { flex: 1; height: 38px; border-radius: var(--radius); font-size: 14px; font-weight: 600; }
.modal-cancel { background: #333; color: var(--text2); }
.modal-confirm { background: var(--green2); color: var(--bg); }
