* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --line: rgba(60, 60, 67, 0.10);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.page { max-width: 480px; margin: 0 auto; padding: 14px 16px 100px; display: flex; flex-direction: column; gap: 14px; }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; padding: 6px 4px 2px; }
.card { background: var(--card); border-radius: 18px; padding: 18px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* ===== 今日 hero ===== */
.hero { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px 18px; }
.ring-wrap { position: relative; width: 150px; height: 150px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #e9e9eb; stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--blue); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 377; stroke-dashoffset: 377; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center b { font-size: 34px; font-weight: 700; letter-spacing: -1px; }
.ring-center small { color: var(--muted); font-size: 12px; margin-top: -4px; }

.macro-row { display: flex; width: 100%; }
.macro { flex: 1; text-align: center; }
.macro b { font-size: 18px; font-weight: 600; }
.macro span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ===== 按钮 ===== */
.action-row { display: flex; gap: 12px; }
.action-btn { flex: 1; padding: 15px; border: 0; border-radius: 16px; font-size: 16px; font-weight: 600; cursor: pointer; font-family: inherit; }
.action-btn.primary { background: var(--blue); color: #fff; }
.action-btn:not(.primary) { background: var(--card); color: var(--blue); }
.action-btn:active { opacity: .7; }

.btn { display: block; width: 100%; margin-top: 12px; padding: 14px; font-size: 16px; font-weight: 600; border: 0; border-radius: 14px; background: #f2f2f7; color: var(--blue); cursor: pointer; font-family: inherit; }
.btn.primary { background: var(--blue); color: #fff; }
.btn:disabled { opacity: .4; }
.btn:active { opacity: .7; }

.preview { display: none; width: 100%; border-radius: 14px; margin-top: 10px; max-height: 260px; object-fit: contain; background: #000; }
.status { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 16px; }

/* ===== 食物列表 ===== */
.food-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.food-item:last-child { border-bottom: 0; }
.food-top { display: flex; justify-content: space-between; align-items: center; }
.food-name { font-weight: 600; font-size: 15px; }
.food-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin: 5px 0; gap: 10px; }
.food-row label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.food-row input { width: 76px; }
.food-nutri { font-size: 13px; color: var(--text); }
.food-nutri b { color: var(--blue); font-weight: 600; }
.food-nutri small { color: var(--muted); }
.del { background: none; border: 0; color: var(--red); font-size: 18px; cursor: pointer; padding: 2px 6px; }

/* ===== 记录列表 ===== */
.record-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.record-item:last-child { border-bottom: 0; }
.record-head { font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.record-nutri { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px 0; }
.warn { color: var(--red); font-size: 13px; font-weight: 600; text-align: center; padding: 4px 0; min-height: 20px; }

/* ===== 报表 ===== */
.seg-control { display: flex; background: #f2f2f7; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.seg-control button { flex: 1; padding: 8px 0; border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit; }
.seg-control button.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
#chart { width: 100%; display: block; }
.report-summary { text-align: center; font-size: 14px; color: var(--muted); margin-top: 10px; }
.report-summary b { color: var(--text); }

/* ===== 我的 ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 5px; }
label.full { grid-column: 1 / -1; }
input, select {
  font-size: 16px; padding: 12px 14px; border: 0; border-radius: 12px; background: #f2f2f7;
  color: var(--text); width: 100%; font-family: inherit; -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: 0; }
.bmr-result { margin-top: 14px; font-size: 14px; text-align: center; }
.bmr-result b { color: var(--blue); }

/* ===== 底部弹窗 sheet ===== */
.sheet { position: fixed; inset: 0; z-index: 100; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-body { position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: 480px; background: var(--card); border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h3 { font-size: 17px; font-weight: 600; }
.close { background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; }

/* ===== Tab 栏 ===== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 50;
}
.tabbar button { flex: 1; padding: 8px 0 6px; background: none; border: 0; color: var(--muted); font-size: 11px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: inherit; }
.tabbar button .icon { font-size: 22px; line-height: 1; }
.tabbar button.active { color: var(--blue); }
