/* ====== 变量 ====== */
:root {
  --primary: #e8732a;
  --primary-dark: #d05f1c;
  --primary-light: #fff3ea;
  --text: #2c2620;
  --text-light: #8a8175;
  --border: #ece4d8;
  --bg: #faf6f0;
  --card: #ffffff;
  --danger: #d9483a;
  --success: #5a9e6f;
  --shadow: 0 2px 12px rgba(120, 80, 40, 0.08);
  --radius: 12px;
  --max-width: 480px;
}

/* ====== Reset ====== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ====== 应用容器 ====== */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 32px;
}

/* ====== 顶部导航 ====== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar .back { font-size: 22px; color: var(--text); padding: 4px 6px; cursor: pointer; line-height: 1; }
.topbar .action { color: var(--primary); font-weight: 500; cursor: pointer; font-size: 14px; }

/* ====== 按钮 ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: var(--danger); }
.btn.light { background: var(--primary-light); color: var(--primary); }
.btn.sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn.block { width: 100%; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-light); }
.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { resize: vertical; min-height: 80px; }

/* ====== 卡片 / 菜谱卡片 ====== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.recipe-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s;
}
.recipe-card:active { transform: scale(.98); }
.recipe-card .cover { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--primary-light); }
.recipe-card .info { padding: 10px 12px; }
.recipe-card .name { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.35; }
.recipe-card .cat { font-size: 11px; color: var(--text-light); }

/* ====== 分类标签 ====== */
.tags { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; }
.tags::-webkit-scrollbar { display: none; }
.tag {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  background: var(--primary-light);
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
.tag.active { background: var(--primary); color: #fff; }

/* ====== 浮动按钮 ====== */
.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 16px rgba(232, 115, 42, .4);
  cursor: pointer;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(40, 30, 20, .92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: transform .25s, opacity .25s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ====== 空状态 ====== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}
.empty .emoji { font-size: 48px; margin-bottom: 12px; }
.empty .text { font-size: 14px; }

/* ====== 通用布局 ====== */
.page { padding: 16px; }
.section { margin-bottom: 24px; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; }
.section-title .more { font-size: 13px; color: var(--text-light); font-weight: 400; }

.list { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* 两列布局下，空状态/加载态跨列居中 */
.grid-2 > .empty, .grid-2 > .loading { grid-column: 1 / -1; }

/* ====== 复选框 ====== */
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.check-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.check-item .content { flex: 1; }
.check-item .name { font-size: 15px; font-weight: 500; }
.check-item .sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.check-item.checked .name { text-decoration: line-through; color: var(--text-light); }
.check-item.checked { opacity: .6; }
.check-item .del { color: var(--text-light); font-size: 20px; padding: 4px 8px; cursor: pointer; }

/* ====== 步骤展示 ====== */
.step-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.step-item .step-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.step-item .step-no {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.step-item .step-head > span:nth-child(2) { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-light); }
.step-item .step-dur {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.step-item .step-body { padding: 14px; }
.step-item .step-action { font-size: 15px; line-height: 1.7; }
.step-item .step-img { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--primary-light); display: block; }

/* ====== 食材/调料行 ====== */
.ing-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.ing-row:last-child { border-bottom: none; }
.ing-row .ing-name { font-size: 15px; }
.ing-row .ing-amount { font-size: 14px; color: var(--primary); font-weight: 500; }

/* ====== 底部固定操作条 ====== */
.bottom-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  z-index: 30;
}

/* ====== 换算调节器 ====== */
.scaler {
  background: linear-gradient(135deg, var(--primary-light), #fff);
  border: 1px solid #f0d9c2;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.scaler .sc-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--primary-dark); }
.scaler .sc-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.scaler .sc-row:last-child { margin-bottom: 0; }
.scaler select, .scaler input { flex: 1; }
.scaler .sc-tip { font-size: 12px; color: var(--text-light); margin-top: 8px; line-height: 1.5; }

/* ====== 成品图九宫格 ====== */
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.result-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* ====== 视频播放 ====== */
video { width: 100%; border-radius: var(--radius); display: block; background: #000; }

/* ====== 加载态 ====== */
.loading { text-align: center; padding: 30px; color: var(--text-light); font-size: 14px; }

/* ====== 通用弹窗 Modal ====== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-mask.show { display: flex; }
.modal-box { background: #fff; border-radius: 16px; padding: 22px 20px; width: 100%; max-width: 320px; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; text-align: center; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.modal-actions .btn { width: 100%; }

/* ====== 详情页换算后高亮 ====== */
.ing-row .ing-amount.changed { color: var(--danger); font-weight: 600; }

/* ====== 底部 Tab 导航 ====== */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(120, 80, 40, 0.06);
}
.tabbar .tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 8px 0 6px;
  color: var(--text-light);
  font-size: 11px;
  position: relative;
  cursor: pointer;
  transition: color .15s;
}
.tabbar .tab .icon { font-size: 22px; line-height: 1; }
.tabbar .tab .label { font-size: 11px; }
.tabbar .tab.active { color: var(--primary); }
.tabbar .tab.active .icon { transform: scale(1.08); }
.tabbar .tab .badge {
  position: absolute;
  top: 2px;
  left: 50%;
  margin-left: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  font-weight: 600;
  border: 1.5px solid var(--card);
  box-sizing: content-box;
}
.app.has-tabbar { padding-bottom: 64px; }

/* ====== 首页快捷卡片（采购清单入口） ====== */
.shortcut-card {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff3ea 0%, #ffe2c8 100%);
  border: 1px solid #f0d9c2;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: transform .15s;
  position: relative;
  overflow: hidden;
}
.shortcut-card:active { transform: scale(.98); }
.shortcut-card .sc-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(232, 115, 42, .3);
}
.shortcut-card .sc-text { flex: 1; min-width: 0; }
.shortcut-card .sc-title { font-size: 15px; font-weight: 600; color: var(--text); }
.shortcut-card .sc-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.shortcut-card .sc-arrow { color: var(--primary); font-size: 22px; flex-shrink: 0; }
.shortcut-card .sc-count {
  position: absolute; top: 10px; right: 14px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ====== 空状态带 CTA ====== */
.empty-cta {
  margin-top: 16px;
  display: inline-block;
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 22px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.empty-cta:active { transform: scale(.96); }
