/* 设计：浅蓝底 + 白色细描边卡片；中文用思源宋体，数字用 Playfair Display（等高数字）；
   三大营养素与四餐各有固定识别色，只用于小面积文字、圆点和标题带。 */
@font-face { font-family: "Noto Serif SC"; font-weight: 400; font-display: swap; src: url(fonts/noto-serif-sc-400.woff2) format("woff2"); }
@font-face { font-family: "Noto Serif SC"; font-weight: 500; font-display: swap; src: url(fonts/noto-serif-sc-500.woff2) format("woff2"); }
@font-face { font-family: "Noto Serif SC"; font-weight: 700; font-display: swap; src: url(fonts/noto-serif-sc-700.woff2) format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 400; font-display: swap; src: url(fonts/playfair-400.woff2) format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 500; font-display: swap; src: url(fonts/playfair-500.woff2) format("woff2"); }
@font-face { font-family: "Playfair Display"; font-weight: 700; font-display: swap; src: url(fonts/playfair-700.woff2) format("woff2"); }

:root {
  --bg: #D0E8F7; --surface: #FFFFFF; --border: #C3DAEA; --ink: #16241C; --muted: #6A7A70;
  --accent: #2D6A4F; --accent-soft: #E2EFE8; --on-accent: #FFFFFF; --stripe: #EFF5F1; --danger: #B5412F;
  --protein: #2B7BA6; --carbs: #D9772F; --fat: #C0527A;
  --breakfast-rgb: 210,162,42; --lunch-rgb: 46,139,106; --dinner-rgb: 91,109,184; --snack-rgb: 168,90,154;
  --breakfast-ink: #89691B; --lunch-ink: #1E5A45; --dinner-ink: #3B4778; --snack-ink: #6D3A64;
  --seg: rgba(255,255,255,.55);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --num: "Playfair Display", "Noto Serif SC", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0F1613; --surface: #17211C; --border: #27342D; --ink: #E6EEE8; --muted: #8FA096;
    --accent: #7CC4A0; --accent-soft: #203A2D; --on-accent: #0B2016; --stripe: #1D2A23; --danger: #F0958A;
    --protein: #6DB6DB; --carbs: #F0A066; --fat: #E88DAE;
    --breakfast-rgb: 227,188,85; --lunch-rgb: 93,190,152; --dinner-rgb: 142,157,224; --snack-rgb: 208,140,196;
    --breakfast-ink: #E3BC55; --lunch-ink: #5DBE98; --dinner-ink: #8E9DE0; --snack-ink: #D08CC4;
    --seg: rgba(23,33,28,.7); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0F1613; --surface: #17211C; --border: #27342D; --ink: #E6EEE8; --muted: #8FA096;
  --accent: #7CC4A0; --accent-soft: #203A2D; --on-accent: #0B2016; --stripe: #1D2A23; --danger: #F0958A;
  --protein: #6DB6DB; --carbs: #F0A066; --fat: #E88DAE;
  --breakfast-rgb: 227,188,85; --lunch-rgb: 93,190,152; --dinner-rgb: 142,157,224; --snack-rgb: 208,140,196;
  --breakfast-ink: #E3BC55; --lunch-ink: #5DBE98; --dinner-ink: #8E9DE0; --snack-ink: #D08CC4;
  --seg: rgba(23,33,28,.7); color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--serif); }
.num { font-family: var(--num); font-feature-settings: "lnum"; font-variant-numeric: lining-nums; }
button { font: inherit; border: 0; background: none; color: var(--accent); padding: 8px 10px; border-radius: 20px; cursor: pointer; }
button:disabled { opacity: .4; }
input, select { font: inherit; font-size: 16px; width: 100%; padding: 11px 13px; margin: 4px 0; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: auto; margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-top: 8px; }
h2 { margin: 6px 0 10px; font: 500 24px/1.25 var(--serif); }
.muted { color: var(--muted); } .small { font-size: 13px; color: var(--muted); } .tiny { font-size: 11px; color: var(--muted); }
.accent { color: var(--accent); } .err { color: var(--danger); }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.eyebrow { font-size: 11px; font-weight: 500; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }

/* 顶栏与底栏 */
#top { padding: calc(8px + env(safe-area-inset-top)) 20px 6px; max-width: 640px; margin: 0 auto; }
#top .line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#top .line + .line { justify-content: flex-end; margin-top: 6px; }
.brand { font-size: 20px; font-weight: 500; }
.seg { display: inline-flex; background: var(--seg); border-radius: 18px; padding: 3px; }
.seg button { font-size: 12px; padding: 6px 12px; border-radius: 15px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 700; }
main { padding: 8px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav#tabs button { flex: 1; border-radius: 0; padding: 14px 0 10px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 5px; }
nav#tabs b { font-size: 15px; font-weight: 400; letter-spacing: 1px; }
nav#tabs i { display: block; width: 16px; height: 3px; border-radius: 2px; background: transparent; }
nav#tabs button.on { color: var(--accent); } nav#tabs button.on b { font-weight: 700; } nav#tabs button.on i { background: var(--accent); }

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 20px; margin: 14px 0; overflow: hidden; }
.card.meal { padding: 0; }
.bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin: 6px 0 0; }
.bar > i { display: block; height: 100%; border-radius: 2px; }
.macro-line { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.macro-line b { font-size: 14px; font-weight: 500; }

.dateh { display: flex; align-items: center; justify-content: space-between; }
.dateh .arrow { font-size: 28px; font-weight: 300; color: var(--muted); padding: 4px 14px; }
.dateh h2 { margin: 0; }
.dateh .back { font-size: 12px; font-weight: 500; color: var(--accent); padding: 2px 0; }

.sum { display: flex; align-items: center; gap: 22px; }
.ring { width: 128px; height: 128px; position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring b { font-size: 32px; font-weight: 400; line-height: 1.1; } .ring span { font-size: 10px; color: var(--muted); letter-spacing: .5px; }
.remain { font-size: 38px; line-height: 1.1; } .remain small { font-size: 13px; color: var(--muted); font-family: var(--serif); margin-left: 4px; }
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mcol .lab { font-size: 12px; color: var(--muted); } .mcol .val { font-size: 22px; line-height: 1.2; } .mcol .val small { font-size: 11px; color: var(--muted); font-family: var(--serif); }
.sum .cols { margin-top: 20px; } .cardsec { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.mini { font-size: 13px; font-weight: 500; } .mini span { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }

.btns { display: flex; gap: 8px; margin-top: 14px; }
.btns button { flex: 1; padding: 10px 2px; font-size: 14px; font-weight: 500; white-space: nowrap; border-radius: 22px; background: var(--accent-soft); color: var(--accent); }
.btns button.o { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* 餐卡：标题带 */
.mealhead { display: flex; align-items: center; gap: 8px; padding: 14px 20px; }
.mealhead h3 { margin: 0; flex: 1; font-size: 22px; font-weight: 700; letter-spacing: 2px; }
html.en .mealhead h3 { letter-spacing: .5px; }
.mealhead .kc { font-size: 24px; } .mealhead .kc small { font-size: 11px; color: var(--muted); font-family: var(--serif); }
.mealhead .add { width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--surface); font-size: 18px; font-weight: 700; margin-left: 4px; }
.mealbody { padding: 12px 20px 14px; }
.meal.m-BREAKFAST .mealhead { background: rgba(var(--breakfast-rgb), .16); } .meal.m-BREAKFAST h3, .meal.m-BREAKFAST .add { color: var(--breakfast-ink); }
.meal.m-LUNCH .mealhead { background: rgba(var(--lunch-rgb), .16); } .meal.m-LUNCH h3, .meal.m-LUNCH .add { color: var(--lunch-ink); }
.meal.m-DINNER .mealhead { background: rgba(var(--dinner-rgb), .16); } .meal.m-DINNER h3, .meal.m-DINNER .add { color: var(--dinner-ink); }
.meal.m-SNACK .mealhead { background: rgba(var(--snack-rgb), .16); } .meal.m-SNACK h3, .meal.m-SNACK .add { color: var(--snack-ink); }
.ml { font-size: 13px; } .ml .l { color: var(--muted); } .ml b { font-weight: 700; }
.p { color: var(--protein); } .c { color: var(--carbs); } .f { color: var(--fat); }
.entry { display: flex; align-items: center; gap: 8px; padding: 10px; margin-top: 0; border-top: 1px solid var(--border); cursor: pointer; }
.entry.st { background: var(--stripe); border-radius: 10px; }
.entry .name { font-size: 15px; font-weight: 500; } .entry .x { color: var(--muted); font-size: 20px; font-weight: 300; padding: 4px 10px; }
.entry .kc { font-size: 17px; } .entry .kc small { font-size: 11px; color: var(--muted); font-family: var(--serif); }

/* 添加食物 */
.head { display: flex; align-items: center; gap: 4px; }
.fooditem { padding: 10px 12px; border-radius: 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.fooditem.st { background: var(--stripe); }
.fooditem .name { font-size: 15px; font-weight: 500; } .fooditem .kc { font-size: 18px; } .fooditem .kc small { font-size: 11px; color: var(--muted); font-family: var(--serif); }
.fooditem .more { padding: 4px 10px; font-size: 20px; color: var(--muted); }
.fooditem .acts { display: flex; flex-wrap: wrap; } .fooditem .acts button { padding: 4px 10px; font-size: 13px; }

.chart { display: flex; align-items: flex-end; height: 190px; gap: 4px; }
.chart > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); }
.chart i { display: block; width: 60%; border-radius: 3px 3px 0 0; margin: 2px 0 4px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden] { display: none; }
#modal .dlg { background: var(--surface); border-radius: 24px; padding: 22px; width: 100%; max-width: 420px; max-height: 88vh; overflow-y: auto; }
#modal .dlg h3 { margin: 0 0 8px; font-size: 20px; font-weight: 500; }
#modal .acts { display: flex; justify-content: flex-end; gap: 4px; margin-top: 14px; }
.btnrow { display: flex; gap: 8px; } .btnrow > button { flex: 1; padding: 10px 4px; white-space: nowrap; border-radius: 22px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.btnrow > button.o { background: transparent; border: 1px solid var(--border); color: var(--ink); }
button.fill { background: var(--accent); color: var(--on-accent); padding: 10px 18px; font-weight: 500; }
