/* ===== 抗炎饮食 · 样式 ===== */
:root {
  --green: #2e7d5b;
  --green-l: #e8f3ed;
  --green-d: #1e5a41;
  --accent: #e07a3f;
  --accent-l: #fdf0e6;
  --purple: #7c5cbf;
  --purple-l: #f0ebfb;
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1f2420;
  --text2: #6b756e;
  --text3: #9aa39d;
  --line: #e8e6e0;
  --red: #d9534f;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(31, 36, 32, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(72px + var(--safe-b)); }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; }
input, textarea, select {
  border: none; outline: none; background: none;
  -webkit-appearance: none; appearance: none;
}

/* ===== 顶部 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(246, 245, 241, .88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: calc(var(--safe-t) + 14px) 18px 10px;
  border-bottom: .5px solid var(--line);
}
.topbar-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.topbar h1 { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -.4px; }
.topbar .sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.topbar .date-chip {
  font-size: 12px; color: var(--green); background: var(--green-l);
  padding: 4px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap;
}

/* ===== 布局 ===== */
.page { display: none; padding: 14px 16px 20px; animation: fade .22s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 15px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card.tight { padding: 12px 14px; }
.sec-title {
  font-size: 13px; font-weight: 700; color: var(--text2);
  margin: 20px 4px 9px; letter-spacing: .3px;
  display: flex; align-items: center; justify-content: space-between;
}
.sec-title .more { font-weight: 500; color: var(--green); font-size: 12.5px; }

/* ===== 抗炎总览 ===== */
.score-wrap { display: flex; gap: 14px; align-items: center; }
.ring {
  width: 84px; height: 84px; border-radius: 50%; flex: 0 0 84px;
  display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--green) calc(var(--p, 0) * 1%), var(--green-l) 0);
}
.ring::after {
  content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--card);
}
.ring-in { position: relative; z-index: 1; text-align: center; }
.ring-in b { display: block; font-size: 24px; line-height: 1.1; color: var(--green-d); }
.ring-in span { font-size: 10.5px; color: var(--text3); }
.score-txt { flex: 1; min-width: 0; }
.score-txt h3 { margin: 0 0 3px; font-size: 15.5px; }
.score-txt p { margin: 0; font-size: 12.5px; color: var(--text2); line-height: 1.5; }

.macro-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.macro {
  background: var(--bg); border-radius: 12px; padding: 9px 6px; text-align: center;
}
.macro b { display: block; font-size: 16px; }
.macro span { font-size: 10.5px; color: var(--text3); }
.macro .bar { height: 3px; border-radius: 2px; background: var(--line); margin-top: 6px; overflow: hidden; }
.macro .bar i { display: block; height: 100%; background: var(--green); border-radius: 2px; }

/* ===== 餐次卡片 ===== */
.meal-card { background: var(--card); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.meal-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px;
  border-bottom: .5px solid var(--line);
}
.meal-ico {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-size: 18px; background: var(--green-l);
}
.meal-head .t { flex: 1; min-width: 0; }
.meal-head .t b { display: block; font-size: 15px; }
.meal-head .t span { font-size: 11.5px; color: var(--text3); }
.meal-head .add {
  font-size: 13px; font-weight: 600; color: var(--green);
  background: var(--green-l); padding: 6px 13px; border-radius: 20px;
}
.meal-body { padding: 4px 0; }
.dish-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 15px;
  border-bottom: .5px solid var(--line);
}
.dish-row:last-child { border-bottom: none; }
.dish-emo {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
  display: grid; place-items: center; font-size: 20px; background: var(--bg);
}
.dish-info { flex: 1; min-width: 0; }
.dish-info b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-info span { font-size: 11.5px; color: var(--text3); }
.dish-del { color: var(--text3); font-size: 20px; padding: 0 4px; line-height: 1; }
.empty-row { padding: 20px 15px; text-align: center; color: var(--text3); font-size: 13px; }

/* ===== 按钮 ===== */
.btn {
  display: block; width: 100%; padding: 14px; border-radius: 14px;
  background: var(--green); color: #fff; font-size: 15.5px; font-weight: 600; text-align: center;
}
.btn:active { opacity: .82; }
.btn.ghost { background: var(--green-l); color: var(--green-d); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--text2); }
.btn.sm { padding: 10px; font-size: 14px; border-radius: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }

/* ===== 搜索 ===== */
.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--card);
  border-radius: 14px; padding: 11px 14px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.search-box .ico { color: var(--text3); font-size: 15px; }
.search-box input { flex: 1; min-width: 0; }
.search-box .clear { color: var(--text3); font-size: 18px; }

/* ===== Chips ===== */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 20px; font-size: 13.5px;
  background: var(--card); color: var(--text2); box-shadow: var(--shadow); white-space: nowrap;
}
.chip.on { background: var(--green); color: #fff; font-weight: 600; }
.chip.on.g { background: var(--green); }
.chip.sel { background: var(--green-l); color: var(--green-d); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--green); }

/* ===== 菜谱卡 ===== */
.rcard {
  background: var(--card); border-radius: var(--radius); padding: 13px 14px;
  margin-bottom: 11px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center;
}
.rcard-emo {
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 52px;
  display: grid; place-items: center; font-size: 26px; background: linear-gradient(135deg, var(--green-l), #f2f8f5);
}
.rcard-main { flex: 1; min-width: 0; }
.rcard-main b { font-size: 15px; font-weight: 600; display: block; }
.rcard-main .meta { font-size: 11.5px; color: var(--text3); margin: 2px 0 5px; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px; padding: 2px 7px; border-radius: 6px;
  background: var(--bg); color: var(--text2);
}
.tag.anti { background: var(--green-l); color: var(--green-d); font-weight: 600; }
.tag.warn { background: #fdecec; color: var(--red); }
.tag.ok { background: var(--green-l); color: var(--green-d); }
.rcard-star { flex: 0 0 auto; text-align: right; }
.rcard-star .s { font-size: 11px; color: var(--accent); letter-spacing: -1px; }
.rcard-star .k { font-size: 11px; color: var(--text3); }

/* ===== 匹配结果 ===== */
.match-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 9px; }
.match-head b { font-size: 14px; }
.match-head span { font-size: 12px; color: var(--text3); }
.miss { font-size: 11.5px; color: var(--accent); margin-top: 5px; }

/* ===== 购物清单 ===== */
.shop-cat { margin-bottom: 16px; }
.shop-cat h4 { margin: 0 4px 8px; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.shop-item {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px;
  background: var(--card); border-bottom: .5px solid var(--line);
}
.shop-item:first-of-type { border-radius: 14px 14px 0 0; }
.shop-item:last-of-type { border-bottom: none; border-radius: 0 0 14px 14px; }
.shop-item.done { opacity: .45; }
.shop-item.done .n { text-decoration: line-through; }
.box {
  width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line);
  flex: 0 0 22px; display: grid; place-items: center; font-size: 13px; color: #fff;
}
.box.on { background: var(--green); border-color: var(--green); }
.shop-item .n { flex: 1; font-size: 14.5px; }
.shop-item .q { font-size: 12.5px; color: var(--text2); }

/* ===== 我的 ===== */
.row {
  display: flex; align-items: center; gap: 11px; padding: 13px 15px;
  background: var(--card); border-bottom: .5px solid var(--line);
}
.row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.row:last-child { border-bottom: none; border-radius: 0 0 var(--radius) var(--radius); }
.row .l { flex: 1; min-width: 0; }
.row .l b { display: block; font-size: 14.5px; font-weight: 500; }
.row .l span { font-size: 11.5px; color: var(--text3); }
.row .r { font-size: 13px; color: var(--text3); }
.switch {
  width: 47px; height: 28px; border-radius: 14px; background: var(--line);
  position: relative; transition: .2s; flex: 0 0 47px;
}
.switch.on { background: var(--green); }
.switch i {
  position: absolute; top: 2px; left: 2px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: .2s;
}
.switch.on i { transform: translateX(19px); }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  padding: 7px 0 6px; text-align: center; color: var(--text3);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab .ti { font-size: 21px; line-height: 1; }
.tab .tn { font-size: 10px; font-weight: 500; }
.tab.on { color: var(--green); }

/* ===== 浮动结果条（配菜页） ===== */
.floatbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(70px + var(--safe-b) + 8px); z-index: 70;
  background: var(--green); color: #fff; border-radius: 15px;
  padding: 11px 12px 11px 16px; display: none; align-items: center; gap: 10px;
  box-shadow: 0 6px 22px rgba(46, 125, 91, .34); font-size: 14.5px; font-weight: 600;
  animation: rise .25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.floatbar.on { display: flex; }
.floatbar.idle { background: #7b857e; box-shadow: 0 6px 22px rgba(0, 0, 0, .18); }
.floatbar .cnt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; }
.floatbar .cnt small { display: block; font-weight: 400; font-size: 11px; opacity: .85; }
.floatbar .go {
  background: rgba(255, 255, 255, .24); padding: 7px 14px;
  border-radius: 18px; font-size: 13.5px; white-space: nowrap;
}
.floatbar:active { transform: scale(.985); }

/* ===== 弹层 ===== */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .38); z-index: 90;
  opacity: 0; pointer-events: none; transition: .25s;
}
.sheet-bg.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--bg); border-radius: 24px 24px 0 0;
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  max-height: 92vh; display: flex; flex-direction: column;
}
.sheet.on { transform: none; }
.sheet-head {
  padding: 12px 18px 10px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: .5px solid var(--line); flex: 0 0 auto;
}
.sheet-head b { font-size: 17px; }
.sheet-head .x { font-size: 22px; color: var(--text3); line-height: 1; padding: 0 4px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px calc(24px + var(--safe-b)); flex: 1; }
.grab {
  width: 36px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 8px auto 0;
}

/* ===== 菜谱详情 ===== */
.rh { text-align: center; padding: 6px 0 4px; }
.rh .e { font-size: 46px; }
.rh h2 { margin: 6px 0 2px; font-size: 21px; }
.rh .en { font-size: 12px; color: var(--text3); }
.rh .stars { font-size: 14px; color: var(--accent); margin-top: 4px; }
.note-box {
  background: var(--green-l); border-radius: 14px; padding: 12px 14px;
  font-size: 13px; color: var(--green-d); line-height: 1.6; margin: 14px 0;
}
.note-box b { display: block; margin-bottom: 3px; font-size: 12px; }
.step { display: flex; gap: 11px; margin-bottom: 12px; }
.step .n {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; margin-top: 2px;
}
.step p { margin: 0; font-size: 14.5px; line-height: 1.62; }
.ing-item {
  display: flex; justify-content: space-between; padding: 9px 0;
  border-bottom: .5px dashed var(--line); font-size: 14px;
}
.ing-item:last-child { border-bottom: none; }
.ing-item .q { color: var(--text2); font-size: 13px; }
.ing-item .q .opt { color: var(--text3); font-size: 11px; }
.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 4px; }
.mini { background: var(--bg); border-radius: 12px; padding: 9px 4px; text-align: center; }
.mini b { display: block; font-size: 15px; }
.mini span { font-size: 10px; color: var(--text3); }

/* ===== 食材选择 ===== */
.ing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ing-pick {
  padding: 10px 6px; border-radius: 12px; background: var(--card); text-align: center;
  box-shadow: var(--shadow); font-size: 13px; position: relative; border: 1.5px solid transparent;
}
.ing-pick.on { background: var(--green-l); border-color: var(--green); color: var(--green-d); font-weight: 600; }
.ing-pick .e { display: block; font-size: 17px; margin-bottom: 2px; }
.ing-pick .a { position: absolute; top: 4px; right: 5px; font-size: 9px; color: var(--accent); }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 50px 30px; color: var(--text3); }
.empty .e { font-size: 44px; margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-size: 14px; }
.empty .s { font-size: 12.5px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(14px);
  background: rgba(31, 36, 32, .92); color: #fff; padding: 10px 20px; border-radius: 22px;
  font-size: 13.5px; z-index: 200; opacity: 0; pointer-events: none; transition: .25s; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translateX(-50%); }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 14px; padding: 13px 8px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; color: var(--green-d); }
.stat span { font-size: 11px; color: var(--text3); }

.hint { font-size: 12px; color: var(--text3); line-height: 1.6; padding: 0 4px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
