/* 小布轻食搭子 —— 移动端优先（iPhone 16 Pro Max 440×956），暖色食物系 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #FFF7EF;
  --card: #FFFFFF;
  --ink: #40312A;
  --ink-2: #8A6A52;
  --ink-3: #B9A28F;
  --accent: #FF8A3D;
  --accent-deep: #F0701F;
  --accent-soft: #FFE3C7;
  --good: #4CAF7D;
  --bad: #FF6B5E;
  --warn: #FFB020;
  --line: #F3E7DA;
  --radius: 20px;
  --tab-h: 58px;
  --shadow: 0 2px 14px rgba(180, 130, 80, 0.07);
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
body { min-height: 100vh; }

.hidden { display: none !important; }
.file-hidden { display: none; }
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
input { font-family: inherit; }
.small { font-size: 12px; color: var(--ink-3); }
.accent { color: var(--accent-deep); }

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- 头部 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 247, 239, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-cat { font-size: 30px; }
.header-brand h1 { font-size: 19px; font-weight: 700; }
.header-brand p { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.header-tdee {
  background: var(--accent-soft); color: var(--accent-deep);
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  min-height: 32px;
}

/* ---------- 主区 ---------- */
.app-main {
  flex: 1;
  padding: 8px 14px calc(var(--tab-h) + 26px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.tab-page { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 700; margin-bottom: 10px;
}
.card-title .small { font-weight: 400; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: linear-gradient(135deg, #FF9A4D, #FF7A2E);
  color: #fff; font-size: 15px; font-weight: 700;
  border-radius: 14px; padding: 0 20px; min-height: 46px;
  box-shadow: 0 4px 14px rgba(255, 122, 46, 0.3);
}
.btn-primary:active { transform: scale(0.97); }
.btn-soft {
  background: #FFF3E6; color: var(--accent-deep);
  font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 0 16px; min-height: 44px;
}
.btn-ghost {
  background: transparent; color: var(--ink-2);
  font-size: 14px; border-radius: 12px; padding: 0 16px; min-height: 44px;
}
.btn-danger {
  background: #FFE9E6; color: var(--bad);
  font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 0 16px; min-height: 44px;
}
.btn-danger-soft {
  background: #fff; border: 1px solid #FFD8D2; color: var(--bad);
  font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 0 16px; min-height: 44px;
}
.btn-sm { min-height: 32px; font-size: 12px; padding: 0 12px; border-radius: 10px; }
.icon-btn {
  min-width: 40px; min-height: 40px; border-radius: 12px;
  font-size: 20px; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- 进度环 ---------- */
.ring-card { display: flex; align-items: center; gap: 18px; }
.ring-wrap { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.ring-wrap svg { width: 100%; height: 100%; display: block; }
.ring-bg { fill: none; stroke: #F1E5D7; stroke-width: 12; }
.ring-arc {
  fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 70px 70px;
  transition: stroke-dasharray .5s ease, stroke .5s ease;
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-remain { font-size: 26px; font-weight: 800; line-height: 1; }
.ring-remain i { font-style: normal; font-size: 12px; color: var(--ink-3); margin-left: 2px; }
.ring-cap { font-size: 12px; color: var(--ink-2); margin-top: 5px; }
.ring-side { display: flex; flex-direction: column; gap: 9px; flex: 1; }
.kv { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.ring-side .kv { margin-bottom: 0; }
.kv b { margin-left: auto; font-size: 16px; color: var(--ink); font-weight: 700; }
.kv i { font-style: normal; font-size: 11px; color: var(--ink-3); }

/* ---------- 餐次卡片 ---------- */
.meal-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.meal-card.filled { padding: 14px 16px; }
.meal-empty {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 16px; font-size: 15px; font-weight: 600; min-height: 58px;
}
.meal-empty-hint { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.meal-icon { font-size: 22px; }
.meal-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.meal-kcal { margin-left: auto; font-weight: 700; color: var(--accent-deep); font-size: 14px; }
.meal-entry { border-top: 1px dashed var(--line); padding: 10px 0; cursor: pointer; }
.meal-entry:first-of-type { border-top: none; padding-top: 4px; }
.meal-photo img {
  width: 100%; border-radius: 12px; display: block;
  max-height: 220px; object-fit: cover;
}
.food-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  background: #FFF3E6; color: #A5621F;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}
.meal-note { margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.add-more-btn {
  width: calc(100% - 32px); margin: 4px 16px 14px;
  padding: 9px 0; border-radius: 12px;
  background: #FFF3E6; color: var(--accent-deep);
  font-size: 13px; font-weight: 600;
}

/* ---------- 小结 / 体重 ---------- */
.def-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; color: var(--ink-2); margin-bottom: 8px;
}
.def-line b { font-size: 17px; }
.def-line b.good { color: var(--good); }
.def-line b.bad { color: var(--bad); }
.def-hint {
  font-size: 13px; color: var(--ink-2); line-height: 1.6;
  background: #FFF7EC; border-radius: 12px; padding: 10px 12px;
}
.def-hint b { color: var(--good); }
.weight-row { display: flex; gap: 10px; align-items: center; }
.weight-row input {
  flex: 1; min-height: 46px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FFFDF9;
  padding: 0 14px; font-size: 16px; color: var(--ink);
}
.weight-row input:focus { outline: none; border-color: var(--accent); }
#weightToday { margin-top: 8px; }

/* ---------- 遮罩 / bottom sheet / 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(43, 26, 15, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.modal-overlay { align-items: center; padding: 20px; }
.sheet {
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-box {
  width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto;
  background: var(--card); border-radius: 22px;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.94); opacity: .5; } to { transform: none; opacity: 1; } }

/* sheet 内部 */
.sheet-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; margin-bottom: 12px; }
.sheet-photo {
  position: relative; border-radius: 14px; overflow: hidden;
  background: #F7EEE2; min-height: 80px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.sheet-photo img { width: 100%; display: block; max-height: 240px; object-fit: cover; }
.sheet-photo-empty { color: var(--ink-3); font-size: 13px; padding: 28px 0; }
.sheet-photo-status {
  position: absolute; inset: 0; background: rgba(255, 247, 239, 0.9);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--accent-deep);
}
.sheet-photo-status:empty { display: none; }
.sheet-photo-btns { display: flex; gap: 8px; margin-bottom: 12px; }
.sheet-photo-btns .btn-soft { flex: 1; }
.food-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.food-row input {
  min-height: 44px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #FFFDF9; padding: 0 10px; font-size: 16px; color: var(--ink);
  min-width: 0;
}
.food-row .f-name { flex: 2.2; }
.food-row .f-amount { flex: 1.4; }
.food-row .f-kcal { flex: 1; }
.food-row input:focus { outline: none; border-color: var(--accent); }
.food-row .f-del { color: var(--ink-3); font-size: 15px; padding: 10px; min-width: 40px; }
.sheet-add { width: 100%; margin: 4px 0 12px; }
.sheet-note {
  width: 100%; min-height: 46px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FFFDF9;
  padding: 12px 14px; font-size: 16px; color: var(--ink); margin-bottom: 12px;
}
.sheet-note:focus { outline: none; border-color: var(--accent); }
.sheet-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.sheet-total { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.sheet-total b { font-size: 20px; color: var(--accent-deep); }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn-primary { flex: 1.6; }
.sheet-actions .btn-ghost { flex: 1; }
.sheet-actions .btn-danger { flex: 1; }

/* 问卷 */
.modal-head { margin-bottom: 14px; }
.modal-head b { font-size: 17px; display: block; }
.modal-head .small { display: block; margin-top: 4px; }
.ob-field { margin-bottom: 14px; }
.ob-field > label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 8px;
}
.ob-radios { display: flex; gap: 8px; }
.ob-pill {
  position: relative;
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line);
  font-size: 14px; background: #FFFDF9; cursor: pointer;
}
.ob-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.ob-pill:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-deep); font-weight: 600;
}
.ob-act { display: flex; flex-direction: column; gap: 8px; }
.ob-act .ob-pill { justify-content: flex-start; padding: 0 14px; }
.ob-field > input {
  width: 100%; min-height: 46px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FFFDF9;
  padding: 0 14px; font-size: 16px; color: var(--ink);
}
.ob-field > input:focus { outline: none; border-color: var(--accent); }
.ob-tdee {
  text-align: center; font-size: 14px; color: var(--ink-2);
  background: #FFF7EC; border-radius: 14px; padding: 12px; margin-bottom: 14px;
}
.ob-tdee b { color: var(--accent-deep); font-size: 20px; margin: 0 4px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-primary { flex: 1; }
.modal-actions .btn-ghost { flex: 1; }
.ob-recover { text-align: center; margin-top: 6px; }
.ob-recover .btn-ghost { font-size: 13px; color: var(--accent-deep); }

/* 确认弹窗 */
.confirm-text { font-size: 14px; color: var(--ink-2); line-height: 1.7; margin-bottom: 16px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%;
  bottom: calc(var(--tab-h) + 28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(56, 40, 28, 0.92); color: #fff;
  font-size: 14px; padding: 11px 18px; border-radius: 999px;
  z-index: 60; max-width: 84vw; text-align: center;
}

/* ---------- 底 tab 栏 ---------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 440px; margin: 0 auto;
  display: flex;
  background: rgba(255, 252, 248, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--ink-3);
  padding: 6px 0; min-height: 46px; border-radius: 14px;
}
.tab-btn .tab-icon { font-size: 21px; }
.tab-btn.active { color: var(--accent-deep); font-weight: 700; }

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-size: 16px; font-weight: 700; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 6px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--ink-3); padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: #FBF4EA;
}
.cal-cell.empty { background: transparent; }
.cal-cell.hit { background: #DCF0E4; color: #2E7D52; font-weight: 700; }
.cal-cell.partial { background: #FFE9C9; color: #A5621F; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-dot {
  position: absolute; bottom: 5px; width: 5px; height: 5px;
  border-radius: 50%; background: var(--warn);
}
.cal-legend { display: flex; gap: 12px; margin-top: 12px; font-size: 11px; color: var(--ink-3); align-items: center; flex-wrap: wrap; }
.cal-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.cal-legend .dot.hit { background: #DCF0E4; border: 1px solid #A8D5BB; }
.cal-legend .dot.partial { background: #FFE9C9; border: 1px solid #F0C98D; }
.cal-legend .dot.wt { background: var(--warn); }
.cal-detail-hint { color: var(--ink-3); font-size: 13px; text-align: center; padding: 8px 0; }
.cal-detail-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.cal-day-total { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.mini-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.mini-entry:last-child { border-bottom: none; }
.mini-entry .mini-kcal { margin-left: auto; font-weight: 700; color: var(--accent-deep); }

/* ---------- 趋势 ---------- */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border-radius: 16px;
  padding: 13px 6px; text-align: center; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 19px; color: var(--accent-deep); font-weight: 800; }
.stat span { font-size: 11px; color: var(--ink-3); margin-top: 3px; display: block; }
.chart-svg { width: 100%; height: 180px; display: block; }
.chart-grid { stroke: #F0E4D5; stroke-width: 1; }
.chart-tick { fill: var(--ink-3); font-size: 10px; font-family: inherit; }
.chart-thr { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-thr-label { fill: var(--good); font-size: 10px; font-family: inherit; }
.chart-empty { color: var(--ink-3); font-size: 13px; text-align: center; padding: 40px 10px; }

/* ---------- 设置 ---------- */
#setProfileView .kv b { font-weight: 600; }
.share-row { display: flex; gap: 10px; margin-bottom: 10px; }
.share-row input {
  flex: 1; min-height: 46px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FFFDF9;
  padding: 0 12px; font-size: 16px; color: var(--ink);
}
#shareResult { margin-top: 4px; }
#shareLink {
  width: 100%; min-height: 44px; border-radius: 12px;
  border: 1.5px dashed var(--accent);
  background: #FFF9F1; padding: 10px 12px;
  font-size: 13px; color: var(--ink-2); margin-bottom: 8px;
}
.share-actions { display: flex; gap: 8px; }
.share-actions .btn-soft { flex: 1; }
.data-actions { display: flex; gap: 10px; }
.data-actions .btn-soft { flex: 1; }
.about-card p { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }

/* ---------- 照片预览 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(20, 12, 6, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 14px; }

/* ---------- 分享落地页 ---------- */
.share-page .app-main {
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: 30px;
}
.share-loading { color: var(--ink-3); text-align: center; padding: 60px 0; font-size: 14px; }
.share-err { color: var(--ink-2); text-align: center; padding: 60px 20px; font-size: 14px; line-height: 1.8; }
.share-hero {
  background: linear-gradient(160deg, #FFDDBE, #FFF6EC 70%);
  border-radius: 24px; padding: 26px 20px 22px; text-align: center;
}
.share-brand { font-size: 14px; font-weight: 600; color: var(--accent-deep); }
.share-date { font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.share-kcal { font-size: 46px; font-weight: 800; margin-top: 10px; }
.share-kcal i {
  font-style: normal; font-size: 15px; color: var(--ink-2);
  margin-left: 6px; font-weight: 400;
}
.share-budget { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.share-weight {
  display: inline-block; margin-top: 10px;
  background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; color: var(--ink-2);
}
.share-card { background: var(--card); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); }
.share-card-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.share-card-head span { color: var(--accent-deep); font-weight: 700; }
.share-photo { width: 100%; border-radius: 12px; margin-bottom: 8px; }
.share-foods { display: flex; flex-wrap: wrap; gap: 6px; }
.share-note { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.share-poster-btn { width: 100%; margin-top: 4px; }
.share-foot { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 14px; }

/* 横屏/桌面留白 */
@media (min-width: 441px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
