/* ============================================================
   今餐吃啥 · 家常菜谱 — 暖橘烟火气设计系统 v1
   底色暖米白 #faf6ef · 主色番茄橘红 #e8582a · 姜黄/葱绿点缀
   ============================================================ */
:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --ink: #35302b;
  --ink-2: #6f675e;
  --ink-3: #a39a8e;
  --line: #efe7da;
  --brand: #e8582a;
  --brand-deep: #c74318;
  --brand-soft: #fdeee6;
  --amber: #e9a13b;
  --green: #6b9e4e;
  --green-soft: #edf5e6;
  --red-soft: #fdeae0;
  --shadow: 0 2px 14px rgba(87, 62, 38, 0.08);
  --radius: 18px;
  --serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
b, em { font-style: normal; }

/* ---------- Tab 根容器 ---------- */
#tab-root { max-width: 440px; margin: 0 auto; min-height: 100dvh; }
.tabpane { display: none; padding: 0 18px calc(92px + env(safe-area-inset-bottom)); animation: fadein .22s ease; }
.tabpane.on { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 2px 12px;
}
.brand { display: flex; flex-direction: column; gap: 1px; }
.brand-mark { font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: .04em; color: var(--brand-deep); }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.text-btn { font-size: 13px; color: var(--ink-3); padding: 6px 2px; }
.text-btn:active { color: var(--brand); }

.rand-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(232, 88, 42, .3);
}
.rand-btn:active { transform: scale(.96); }

/* ---------- 统计条 ---------- */
.stat-strip {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.stat-cell {
  flex: 1; background: var(--card); border-radius: 14px;
  padding: 10px 6px; text-align: center;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1px;
}
.stat-cell b { font-family: var(--serif); font-size: 22px; color: var(--brand-deep); line-height: 1.2; }
.stat-cell span { font-size: 11px; color: var(--ink-3); }
.stat-cell:nth-child(2) b { color: var(--green); }
.stat-cell:nth-child(3) b { color: var(--amber); }

/* ---------- 最近做过 ---------- */
.cooked-strip { margin-bottom: 14px; }
.cooked-head { font-size: 12px; color: var(--ink-3); margin-bottom: 7px; }
.cooked-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cooked-chips .cchip {
  font-size: 12px; color: var(--ink-2);
  background: var(--card); border-radius: 999px;
  padding: 5px 12px; box-shadow: var(--shadow);
}
.cchip b { color: var(--brand-deep); font-weight: 600; }

/* ---------- 匹配分组 ---------- */
.match-groups { display: flex; flex-direction: column; gap: 18px; }
.mgroup-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 0 2px 8px;
}
.mgroup-head b { font-family: var(--serif); font-size: 17px; color: var(--ink); }
.mgroup-head .cnt { font-size: 12px; color: var(--ink-3); }
.mgroup-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; align-self: center; }
.mg-can .dot { background: var(--green); }
.mg-near .dot { background: var(--amber); }
.mg-far  .dot { background: #d8d0c4; }

.dish-cards { display: flex; flex-direction: column; gap: 9px; }
.dish-card {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  text-align: left; width: 100%;
  transition: transform .12s ease;
}
.dish-card:active { transform: scale(.98); }
.dc-emoji {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: var(--brand-soft);
}
.dc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-name { font-size: 15.5px; font-weight: 600; color: var(--ink); }
.dc-meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.dc-meta .lack { color: var(--amber); }
.dc-go { flex: none; color: var(--ink-3); display: grid; place-items: center; }

/* ---------- 空状态 ---------- */
.empty-hint {
  text-align: center; padding: 64px 20px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-ico { font-size: 44px; margin-bottom: 4px; }
.empty-hint b { font-size: 16px; color: var(--ink-2); }
.empty-hint p { font-size: 13px; color: var(--ink-3); line-height: 1.7; }
.empty-go {
  margin-top: 12px; background: var(--brand); color: #fff;
  font-size: 14px; font-weight: 600;
  padding: 10px 26px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(232, 88, 42, .3);
}
.empty-go:active { transform: scale(.96); }

/* ---------- 菜谱库 ---------- */
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 13px;
  padding: 10px 13px; margin-bottom: 11px;
  box-shadow: var(--shadow); color: var(--ink-3);
}
.search-wrap input {
  flex: 1; border: none; outline: none; background: none;
  font-size: 14px; color: var(--ink); font-family: inherit;
}
.search-wrap input::placeholder { color: var(--ink-3); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 11px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font-size: 13px; color: var(--ink-2);
  background: var(--card); border-radius: 999px;
  padding: 7px 15px; box-shadow: var(--shadow);
}
.chip.on { background: var(--brand); color: #fff; font-weight: 600; }

.dish-list { display: flex; flex-direction: column; gap: 9px; }

/* ---------- 我的食材 ---------- */
.seasoning-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-radius: 14px;
  padding: 12px 15px; margin-bottom: 15px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.seasoning-toggle b { font-size: 14px; display: block; }
.seasoning-toggle span { font-size: 12px; color: var(--ink-3); }
.switch {
  width: 46px; height: 27px; border-radius: 999px; flex: none;
  background: #ddd5c8; position: relative; transition: background .18s ease;
}
.switch i {
  position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: transform .18s ease;
}
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"] i { transform: translateX(19px); }

.stock-groups { display: flex; flex-direction: column; gap: 16px; }
.sgroup {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 15px 15px; box-shadow: var(--shadow);
}
.sgroup-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.sgroup-head b { font-family: var(--serif); font-size: 15.5px; color: var(--ink); }
.sgroup-head .n { font-size: 12px; color: var(--brand); font-weight: 600; }
.ing-flow { display: flex; flex-wrap: wrap; gap: 8px; }
.ing-pick {
  font-size: 13px; color: var(--ink-2);
  background: var(--bg); border-radius: 999px;
  padding: 7px 13px; border: 1px solid transparent;
  transition: all .12s ease;
}
.ing-pick:active { transform: scale(.94); }
.ing-pick.on {
  background: var(--green-soft); color: #4a7a2e;
  border-color: #cfe3bd; font-weight: 600;
}
.ing-pick.on::before { content: "✓ "; font-size: 11px; }

/* ---------- 购物清单（独立页） ---------- */
.page-tip { background: var(--card); border-radius: 14px; padding: 11px 15px; box-shadow: var(--shadow); margin-bottom: 14px; color: var(--ink-2); font-size: 13px; }
.page-list {
  background: var(--card); border-radius: var(--radius);
  padding: 6px 15px; box-shadow: var(--shadow);
}
.page-list .shop-item { padding: 13px 2px; }
.page-list .shop-empty { padding: 48px 0; line-height: 1.9; }

.shop-box { 
  margin-top: 16px;
  background: var(--card); border-radius: var(--radius);
  padding: 13px 15px 15px; box-shadow: var(--shadow);
}
.sync-actions { display: flex; gap: 9px; margin-top: 10px; }
.sync-btn {
  flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  background: var(--bg); border-radius: 11px; padding: 10px 8px;
  transition: transform .12s ease;
}
.sync-btn:active { transform: scale(.96); }
.sync-btn.primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(232, 88, 42, .25); }
.sync-btn:disabled { opacity: .55; }
.sync-bind { display: flex; gap: 8px; margin-top: 10px; }
.sync-bind input {
  flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 12px; font-size: 15px; letter-spacing: .12em;
  text-transform: uppercase; font-family: inherit; background: var(--card); color: var(--ink);
  outline: none;
}
.sync-bind input:focus { border-color: var(--brand); }
.sync-code-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: 12px; padding: 11px 13px;
  margin-bottom: 9px;
}
.sync-code {
  flex: 1; font-size: 21px; letter-spacing: .22em; color: var(--brand-deep);
  font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace;
}
.sync-code-row .sync-btn { flex: none; padding: 8px 14px; }
.sync-msg { font-size: 12.5px; color: var(--green); margin-top: 8px; min-height: 17px; }
.seasoning-toggle.slim { box-shadow: none; background: var(--bg); padding: 10px 12px; margin-top: 4px; }

.shop-box {
  margin-top: 16px;
  background: var(--card); border-radius: var(--radius);
  padding: 13px 15px 15px; box-shadow: var(--shadow);
}
.shop-head { display: flex; justify-content: space-between; align-items: center; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.shop-tip { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.shop-list { display: flex; flex-direction: column; gap: 2px; }
.shop-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px dashed var(--line);
}
.shop-item:last-child { border-bottom: none; }
.shop-item .checkbox {
  width: 20px; height: 20px; border-radius: 7px; flex: none;
  border: 1.6px solid #d5ccbe; display: grid; place-items: center;
  color: transparent; font-size: 12px;
}
.shop-item.done .checkbox { background: var(--green); border-color: var(--green); color: #fff; }
.shop-item .s-name { flex: 1; font-size: 14px; color: var(--ink); }
.shop-item .s-name .s-qty {
  font-style: normal; font-size: 12px; color: var(--brand-deep); font-weight: 600;
  margin-left: 6px; font-variant-numeric: tabular-nums;
}
.shop-item.done .s-name { color: var(--ink-3); text-decoration: line-through; }
.shop-item .s-src { font-size: 11px; color: var(--ink-3); }
.shop-empty { text-align: center; font-size: 13px; color: var(--ink-3); padding: 12px 0 6px; }

/* ---------- 底部 Tab 栏 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 440px;
  display: flex; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 7px 0 calc(7px + env(safe-area-inset-bottom));
}
.tbtn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; color: var(--ink-3); padding: 4px 0;
}
.tbtn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tbtn.on { color: var(--brand); font-weight: 600; }
.tbtn { position: relative; }
.fav-dot {
  position: absolute; top: 2px; right: calc(50% - 16px);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--card);
}
.fav-dot[hidden] { display: none; }

/* ---------- 二级页（详情）---------- */
.stackpage[hidden] { display: none; }
.stackpage {
  position: fixed; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 440px;
  z-index: 80;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slidein .24s ease;
}
@keyframes slidein { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%); } }
.stack-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.stack-title { font-size: 14px; color: var(--ink-2); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2);
}
.icon-btn:active { background: var(--brand-soft); color: var(--brand); }
.icon-btn.fav-on { color: var(--brand); }
.icon-btn.fav-on svg path { fill: var(--brand); stroke: var(--brand); }

.detail-scroll { flex: 1; overflow-y: auto; padding: 18px 20px calc(24px + env(safe-area-inset-bottom)); }
.detail-head h2 { font-family: var(--serif); font-size: 26px; color: var(--ink); margin-bottom: 9px; }
.d-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 份数切换器 ---------- */
.serving-box {
  display: flex; align-items: center; gap: 9px;
  margin-top: 12px;
  background: var(--card); border-radius: 13px;
  padding: 9px 12px; box-shadow: var(--shadow);
}
.srv-label { font-size: 13px; color: var(--ink-2); font-weight: 600; flex: none; }
.srv-chips { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.srv-chips::-webkit-scrollbar { display: none; }
.srv-chip {
  flex: none; min-width: 38px; text-align: center;
  font-size: 13px; color: var(--ink-2);
  background: var(--bg); border-radius: 999px;
  padding: 6px 11px; border: 1px solid transparent;
  transition: all .12s ease;
}
.srv-chip:active { transform: scale(.94); }
.srv-chip.on {
  background: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(232, 88, 42, .28);
}
.srv-note { flex: none; font-size: 11px; color: var(--ink-3); }
.tag {
  font-size: 12px; color: var(--brand-deep);
  background: var(--brand-soft); border-radius: 999px; padding: 3.5px 11px; font-weight: 600;
}
.meta-chip { font-size: 12px; color: var(--ink-2); background: var(--card); border-radius: 999px; padding: 3.5px 11px; box-shadow: var(--shadow); }
.d-status { margin-top: 11px; font-size: 13px; padding: 9px 13px; border-radius: 11px; }
.d-status.ok { color: #4a7a2e; background: var(--green-soft); }
.d-status.near { color: #b06f14; background: #fdf3e2; }
.d-status.far { color: var(--ink-2); background: var(--card); box-shadow: var(--shadow); }

.d-section { margin-top: 20px; }
.d-section h3 { font-family: var(--serif); font-size: 16px; margin-bottom: 10px; color: var(--ink); }
.ing-grid { display: flex; flex-direction: column; gap: 7px; }
.ing-row {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border-radius: 12px;
  padding: 9px 13px; box-shadow: var(--shadow);
  font-size: 14px;
}
.ing-row .role { font-size: 10.5px; flex: none; border-radius: 5px; padding: 1.5px 6px; font-weight: 600; }
.ing-row .role.main { color: var(--brand-deep); background: var(--brand-soft); }
.ing-row .role.aux { color: var(--ink-3); background: var(--bg); }
.ing-row .role.season { color: #7a6a4f; background: #f6f0e4; }
.ing-row .i-name { flex: 1; color: var(--ink); }
.ing-row .i-qty {
  flex: none; font-size: 13px; font-weight: 600; color: var(--brand-deep);
  font-variant-numeric: tabular-nums;
}
.ing-row.miss .i-qty { color: var(--amber); }
.ing-row.miss .i-name { color: var(--ink-3); }
.ing-row .have-flag { font-size: 12px; color: var(--green); flex: none; }
.ing-row .miss-flag {
  font-size: 12px; color: var(--brand); flex: none;
  border: 1px solid var(--brand); border-radius: 999px; padding: 2px 9px;
}
.ing-row.miss .miss-flag.added { background: var(--brand); color: #fff; }

.d-steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.d-steps li {
  counter-increment: step;
  position: relative; padding-left: 36px;
  font-size: 14.5px; color: var(--ink-2); line-height: 1.65;
}
.d-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 2px;
  width: 25px; height: 25px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
/* ---------- 步骤卡（图文增强） ---------- */
.step-card {
  background: var(--card); border-radius: 14px;
  padding: 12px 14px !important;
  box-shadow: var(--shadow);
  display: flex; gap: 10px;
}
.step-card::before { top: 14px !important; z-index: 1; }
.st-body { flex: 1; min-width: 0; }
.st-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.st-tech {
  font-size: 11px; font-weight: 600; color: var(--brand-deep);
  background: var(--brand-soft); border-radius: 999px; padding: 2.5px 9px;
}
.st-heat {
  font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2.5px 9px;
  display: inline-flex; align-items: center; gap: 4px;
}
.st-heat i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.st-heat.high { color: #c0392b; background: #fdeae0; }
.st-heat.high i { background: #c0392b; }
.st-heat.mid { color: #b06f14; background: #fdf3e2; }
.st-heat.mid i { background: #e9a13b; }
.st-heat.low { color: #4a7a2e; background: var(--green-soft); }
.st-heat.low i { background: #6b9e4e; }
.st-text { color: var(--ink); font-size: 14px; }
.st-timer-row { margin-top: 8px; }
.st-timer {
  font-size: 12.5px; font-weight: 600;
  color: var(--brand-deep); background: var(--brand-soft);
  border: 1px dashed #f0b9a0; border-radius: 999px;
  padding: 6px 14px;
  transition: all .15s ease;
}
.st-timer:active { transform: scale(.95); }
.st-timer i { font-style: normal; font-size: 11px; opacity: .7; margin-left: 3px; }
.st-timer.running {
  background: var(--brand); color: #fff; border-style: solid; border-color: var(--brand);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(232, 88, 42, .35);
}
.st-timer.done { background: var(--green); border-color: var(--green); color: #fff; }
.d-tip {
  margin-top: 20px;
  background: #fdf3e2; border-radius: var(--radius);
  padding: 13px 16px;
}
.d-tip em { font-size: 12px; color: #b06f14; font-weight: 600; display: block; margin-bottom: 3px; }
.d-tip p { font-size: 13.5px; color: #7a6142; line-height: 1.7; }

.detail-cta {
  display: flex; gap: 10px;
  padding: 11px 20px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--card);
}
.ctrl-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14.5px; font-weight: 600;
  border-radius: 13px; padding: 12px 10px;
  transition: transform .12s ease;
}
.ctrl-btn:active { transform: scale(.97); }
.ctrl-btn.primary { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(232, 88, 42, .28); }
.ctrl-btn.ghost { background: var(--bg); color: var(--ink-2); }

/* ---------- 弹层 ---------- */
.sheet-mask[hidden] { display: none; }
.sheet-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(53, 45, 36, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: maskin .2s ease;
}
@keyframes maskin { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 440px;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  animation: sheetup .26s ease;
}
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 38px; height: 4.5px; border-radius: 999px; background: #ddd3c4; margin: 0 auto 14px; }
.sheet-title { font-family: var(--serif); font-size: 18px; text-align: center; margin-bottom: 16px; color: var(--ink); }

.rand-body { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-align: center; }
.rand-name { font-family: var(--serif); font-size: 24px; color: var(--brand-deep); margin-bottom: 8px; }
.rand-meta { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.rand-tip { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.rand-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%);
  z-index: 120;
  background: rgba(53, 45, 36, .92); color: #fff;
  font-size: 13.5px; border-radius: 999px;
  padding: 10px 22px;
  animation: toastin .2s ease;
  max-width: 82vw; text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%); } }
