/* ============================================================
   菜谱卡 · 样式
   暖色系：#F5EFE6 底 / #E07A3F 强调 / #2E2A26 文字
   全部走变量，跟随系统浅色/深色自动切换（夜间做饭场景）
   ============================================================ */

:root {
  --bg: #F5EFE6;
  --card: #FFFDF9;
  --ink: #2E2A26;
  --ink2: #6E655B;
  --ink3: #9C9184;
  --accent: #E07A3F;
  --accent-soft: rgba(224, 122, 63, 0.12);
  --line: #E9DFD2;
  --chip: #EFE7DA;
  --shadow: 0 6px 18px rgba(90, 70, 40, 0.08);
  --radius: 14px;
  --gap: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1D1A17;
    --card: #28241F;
    --ink: #F0E9DF;
    --ink2: #B0A598;
    --ink3: #7E7468;
    --accent: #E68A52;
    --accent-soft: rgba(230, 138, 82, 0.16);
    --line: #38322B;
    --chip: #332D26;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: 0.5px; }

/* ---------- 页签布局：每页独立滚动 ---------- */
.page {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
}
.page.is-active { display: flex; }

.page-head {
  flex: none;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 10px;
  background: var(--bg);
}
.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.head-count { font-size: 13px; color: var(--ink3); }

.page-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(var(--safe-bottom) + 86px);
}

/* ---------- 场景 chip 行 ---------- */
.chips {
  display: flex; gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 34px;
  padding: 4px 15px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink2);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.chip.on { background: var(--accent); color: #FFF8F1; font-weight: 600; }

/* ---------- 今天页 ---------- */
.scene-note { margin: 6px 0 0; font-size: 13px; color: var(--ink3); }

.reroll-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.reroll-btn:active { transform: scale(0.96); }

.pick-card {
  width: 100%;
  text-align: left;
  display: block;
  margin-top: var(--gap);
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.pick-tag { font-size: 12.5px; color: var(--accent); font-weight: 600; }
.pick-name { font-size: 19px; font-weight: 700; margin: 2px 0 4px; }
.pick-meta { font-size: 13.5px; color: var(--ink2); }

/* ---------- 菜谱列表 ---------- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  padding: 0 14px;
  min-height: 44px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink3);
}
.search-bar svg { width: 17px; height: 17px; flex: none; }
.search-bar input {
  flex: 1; border: 0; outline: 0; background: none;
  font: inherit; color: var(--ink); min-width: 0;
}
.search-bar input::placeholder { color: var(--ink3); }

.dish-card {
  width: 100%;
  text-align: left;
  display: block;
  margin-top: var(--gap);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.dish-card:active { transform: scale(0.99); }
.dish-row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dish-name { font-size: 16.5px; font-weight: 650; }
.dish-cat {
  flex: none; font-size: 12px; color: var(--ink3);
  background: var(--chip); border-radius: 6px; padding: 1px 8px;
}
.dish-meta { margin-top: 3px; font-size: 13px; color: var(--ink2); }
.dish-meta b { color: var(--accent); font-weight: 600; }

.more-btn {
  display: block; width: 100%;
  margin: 14px auto 0;
  min-height: 44px;
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--ink2);
  font-size: 14px;
}

/* ---------- 占位页（买什么 / 我的） ---------- */
.placeholder {
  margin-top: 38vh;
  text-align: center;
  color: var(--ink2);
}
.ph-icon { font-size: 40px; }
.ph-sub { margin-top: 4px; font-size: 13px; color: var(--ink3); }

.empty { margin-top: 60px; text-align: center; color: var(--ink3); }
.foot-note { margin: 18px 0 0; font-size: 12.5px; color: var(--ink3); text-align: center; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px;
  color: var(--ink3);
}
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--accent); font-weight: 600; }

/* ---------- 详情页 ---------- */
.detail {
  position: fixed; inset: 0;
  z-index: 30;
  display: flex; flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  visibility: hidden;
}
.detail.open { transform: translateX(0); visibility: visible; }

.detail-nav {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.back-btn {
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; gap: 4px;
  color: var(--accent); font-size: 15px;
}
.back-btn svg { width: 13px; height: 16px; }
.nav-title {
  flex: 1; text-align: center;
  font-size: 16px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-spacer { min-width: 44px; }

.detail-body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--safe-bottom) + 76px);
}

.d-head-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink2); }
.d-cat { background: var(--chip); border-radius: 6px; padding: 1px 8px; font-size: 12px; color: var(--ink3); }
.d-name { margin: 6px 0 2px; font-size: 24px; font-weight: 750; line-height: 1.35; }
.d-time { font-size: 14px; color: var(--ink2); }
.d-kcal {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
}
.d-kcal b { color: var(--accent); }

.d-sec { margin-top: 20px; }
.d-sec > h2 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; }
.ing-group { border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.ing-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.ing-row:last-child { border-bottom: 0; }
.ing-name b { font-weight: 550; }
.ing-opt { font-size: 12px; color: var(--ink3); margin-left: 6px; }
.ing-qty { flex: none; text-align: right; color: var(--ink2); font-size: 13.5px; max-width: 55%; }

.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 9px 0 9px 38px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 2px; top: 11px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.tips-text { white-space: pre-line; font-size: 14.5px; color: var(--ink2); }

.action-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 10px;
  padding: 10px 16px calc(var(--safe-bottom) + 10px);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.act-main, .act-sub {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 650;
}
.act-main { background: var(--accent); color: #FFF8F1; }
.act-main:active { transform: scale(0.98); }
.act-sub { background: var(--chip); color: var(--ink3); }
.act-sub:disabled { opacity: 0.55; }

/* ---------- 我的页（Step 3） ---------- */
.me-sec { margin-top: 20px; }
.me-title { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; }
.me-hint { margin: 7px 0 0; font-size: 12.5px; color: var(--ink3); }

.group-card {
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.set-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.set-row:last-child { border-bottom: 0; }
.set-val { color: var(--ink2); text-align: right; }

.seg-ctrl {
  display: flex;
  background: var(--chip);
  border-radius: 12px;
  padding: 3px;
}
.seg-ctrl button {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  color: var(--ink2);
  font-size: 14px;
}
.seg-ctrl button.on {
  background: var(--card);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow);
}

.weight-row { display: flex; gap: 8px; }
.weight-row input {
  flex: 1; min-width: 0;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
  outline: none;
}
.weight-row input:focus { border-color: var(--accent); }
.weight-row button {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #FFF8F1;
  font-weight: 650;
}
.weight-row button:active { transform: scale(0.97); }
.weight-chart { display: block; width: 100%; height: 120px; margin-top: 10px; }
.weight-list { list-style: none; margin: 6px 0 0; padding: 0; }
.weight-list li {
  display: flex; justify-content: space-between;
  padding: 6px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
  color: var(--ink2);
}
.weight-list .wt-empty { border-bottom: 0; color: var(--ink3); }

.d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.d-tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  border-radius: 6px;
  padding: 1px 9px;
}

/* ---------- 本周页（Step 4） ---------- */
.useplan-btn {
  display: block; width: 100%;
  margin-top: 16px;
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #FFF8F1;
  font-size: 16px;
  font-weight: 700;
}
.day-card {
  margin-top: var(--gap);
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.day-card.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.day-head { display: flex; align-items: center; gap: 8px; }
.day-date { font-size: 14.5px; font-weight: 650; }
.day-card.is-today .day-date { color: var(--accent); }
.day-scene {
  font-size: 11.5px;
  border-radius: 6px;
  padding: 1px 8px;
  background: var(--chip);
  color: var(--ink2);
}
.day-scene.sc-cut { background: var(--accent-soft); color: var(--accent); }
.day-scene.sc-warm { background: rgba(200, 90, 60, 0.16); color: #C05B33; }
.day-scene.sc-leisure { background: rgba(120, 140, 80, 0.18); color: #6B7C42; }
.swap-btn {
  margin-left: auto;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink2);
  font-size: 12.5px;
}
.day-dishes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 8px;
}
.day-dish {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--chip);
  font-size: 14.5px;
  font-weight: 550;
  color: var(--ink);
}
.day-dish:active { transform: scale(0.97); }
.day-dishes .plus { color: var(--ink3); font-size: 13px; }
.day-kcal { margin-top: 8px; font-size: 13px; color: var(--ink2); }
.day-kcal b { color: var(--accent); }
.day-reason {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink3);
}

/* ---------- 买什么页（Step 4） ---------- */
.shop-tools { display: flex; gap: 8px; margin-top: 10px; }
.shop-tools button {
  flex: 1;
  min-height: 42px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.shop-tools button:active { transform: scale(0.98); }
.shop-sec { margin-top: 14px; }
.shop-cat {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.shop-cat i {
  font-style: normal;
  font-size: 12px;
  color: var(--ink3);
  margin-left: 6px;
}
.shop-item {
  width: 100%;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  min-height: 44px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font-size: 14.5px;
}
.shop-item:last-child { border-bottom: 0; }
.shop-item .s-name { font-weight: 550; }
.shop-item .s-qty { color: var(--ink2); font-size: 13.5px; flex: none; }
.shop-item.done .s-name {
  text-decoration: line-through;
  color: var(--ink3);
}

/* ---------- 图片弹层 / 轻提示 ---------- */
.img-mask {
  position: fixed; inset: 0;
  z-index: 50;
  background: rgba(20, 16, 12, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.img-panel { text-align: center; max-width: 100%; }
.img-panel img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.img-panel .share-hint { color: #F0E9DF; font-size: 13px; margin: 10px 0; }
.img-panel button {
  min-height: 44px;
  padding: 0 28px;
  border-radius: 12px;
  background: var(--accent);
  color: #FFF8F1;
  font-weight: 650;
}
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--safe-bottom) + 96px);
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(30, 26, 22, 0.92);
  color: #FFF8F1;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 999px;
}

/* hidden 属性优先于本文件的 display 声明（img-mask 的遮罩曾因此盖住全页） */
.img-mask[hidden], .toast[hidden] { display: none; }
.fallback-note {
  margin: 0 0 10px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}

/* ---------- 离线角标（Step 5） ---------- */
.net-note {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  left: 50%; transform: translateX(-50%);
  z-index: 55;
  background: rgba(110, 84, 60, 0.92);
  color: #FFF8F1;
  font-size: 12.5px;
  padding: 6px 16px;
  border-radius: 999px;
}
