/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f6f4ee;
  --bg-card: #ffffff;
  --bg-warm: #f3e7d3;
  --text: #2c2620;
  --text-soft: #6e6357;
  --text-mute: #a8a097;
  --accent: #b9694b;
  --accent-soft: #d99a7a;
  --tag-time: #6f93a8;
  --tag-time-soft: #c3d6e1;
  --orange: #d97a4a;
  --brown: #8b6243;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 14px rgba(70, 50, 30, 0.06);
}

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
  background: #e6e4dc;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 0;
  -webkit-font-smoothing: antialiased;
}

/* ===== 手机外壳 ===== */
.phone-frame {
  width: 390px;
  max-width: 100%;
  background: var(--bg);
  border-radius: 36px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
  overflow: hidden;
  position: relative;
  min-height: 844px;
  padding-bottom: 80px;
}

/* ===== 状态栏 ===== */
.status-bar {
  height: 32px;
  background: linear-gradient(180deg, #d8d6ce 0%, var(--bg) 100%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  font-size: 13px;
  font-weight: 600;
  color: #2c2620;
}
.status-icons { display: flex; gap: 6px; font-size: 11px; align-items: center; }
.status-icons svg { width: 16px; height: 16px; }

/* ===== 应用头部 ===== */
.app-header {
  position: relative;
  background: linear-gradient(180deg, #d8d6ce 0%, var(--bg) 100%);
  padding: 4px 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-icon {
  font-size: 22px;
  color: var(--text);
  cursor: pointer;
  width: 24px;
  text-align: center;
  line-height: 1;
}
.app-title { font-size: 20px; font-weight: 700; flex: 0 0 auto; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(180,160,140,0.4);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  padding: 0;
}
.icon-btn svg { width: 18px; height: 18px; stroke: #4a3f33; }
.icon-btn.night-mode {
  background: linear-gradient(135deg, #f5e8a3, #d9c264);
  border-color: #b69f3f;
}
.icon-btn.night-mode svg { fill: #8a6f1c; stroke: #8a6f1c; }
.search-pill {
  margin-left: auto;
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(180,160,140,0.3);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 160px;
  height: 32px;
  font-size: 12px;
  color: var(--text-mute);
}
.search-pill svg { width: 14px; height: 14px; stroke: #8a7e6e; flex-shrink: 0; }
.search-pill input {
  border: none; background: transparent; outline: none;
  font-size: 12px; color: var(--text-soft); flex: 1; min-width: 0;
}

/* ===== Tab Bar 内部 ===== */
.tab-bar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding-top: 12px;
  padding-bottom: 10px;
}
.back-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  font-size: 28px;
  font-weight: 300;
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1;
}
.tab-search {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(0,0,0,0.04);
  position: relative;
}
.tab-search.focused {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(217, 122, 74, 0.15);
}
.tab-search svg { width: 14px; height: 14px; stroke: #8a7e6e; flex-shrink: 0; }
.tab-search input {
  border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--text-soft); flex: 1; min-width: 0;
}
.search-clear {
  width: 20px; height: 20px;
  background: #ece1c8;
  border: none;
  border-radius: 50%;
  color: var(--text-soft);
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.search-clear:hover { background: #d9c8a8; color: var(--text); }

/* 搜索下拉建议面板 */
.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(70, 50, 30, 0.14), 0 0 0 1px rgba(0,0,0,0.04);
  z-index: 60;
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.search-suggest[hidden] { display: none; }
.search-suggest-head {
  padding: 8px 14px 4px;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.5px;
  background: #faf6ec;
  border-radius: 12px 12px 0 0;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-top: 1px solid #f3ecdb;
  transition: background 0.12s;
}
.suggest-item:first-of-type { border-top: none; }
.suggest-item:active, .suggest-item:hover {
  background: #fdf3e3;
}
.suggest-item .sg-cat {
  font-size: 10px;
  color: var(--brown);
  background: #f3e6d0;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.suggest-item .sg-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-item .sg-meta {
  font-size: 11px;
  color: var(--text-mute);
  flex-shrink: 0;
  white-space: nowrap;
}
.suggest-empty-hint {
  padding: 18px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
}

/* 搜索高亮（不匹配的卡片淡化） */
.cat-block.search-hidden { display: none; }
.recipe-card.search-hidden { display: none; }
.recipe-card.search-match {
  box-shadow: 0 0 0 2px rgba(217, 122, 74, 0.4), 0 4px 14px rgba(70, 50, 30, 0.06);
}

/* 搜索无结果提示 */
.search-empty {
  padding: 60px 16px;
  text-align: center;
  color: var(--text-mute);
}
.search-empty p { font-size: 14px; margin-bottom: 4px; }
.search-empty .hint { font-size: 12px; }
.search-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ===== 汇总看板 ===== */
.dashboard-card {
  margin: 4px 16px 14px;
  padding: 18px 22px;
  background: linear-gradient(135deg, #fbf3e2 0%, #f4e6cf 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  box-shadow: var(--shadow);
}
.dashboard-text h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.notebook-icon {
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f5b840, #d99c20);
  border-radius: 4px;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  font-family: "Times New Roman", serif;
  font-style: italic;
  box-shadow: 0 1px 3px rgba(217,156,32,0.3);
}
.dashboard-text p {
  font-size: 12px;
  color: var(--text-soft);
  margin-left: 30px;
}
.dashboard-pagination {
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(180,160,140,0.4);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* ===== 统计卡片 ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--brown);
  letter-spacing: -0.5px;
  line-height: 1.2;
}
.stat-label {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

/* ===== 快速跳转 ===== */
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 18px 16px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.title-bar {
  width: 3px;
  height: 14px;
  background: var(--orange);
  border-radius: 3px;
  display: inline-block;
}
.title-count { color: var(--text-soft); font-weight: 500; margin-left: 4px; }

.chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 16px;
}
.chip {
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}
.chip:active { transform: scale(0.96); }
.chip.active {
  background: linear-gradient(135deg, #fff3e0, #ffe2c2);
  box-shadow: 0 0 0 2px var(--orange), 0 2px 8px rgba(217,122,74,0.18);
}

/* 分类配方总览下拉面板 */
.chip-overview {
  margin: 8px 16px 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(70, 50, 30, 0.14), 0 0 0 1px rgba(0,0,0,0.04);
  overflow: hidden;
  animation: overviewIn 0.18s ease-out;
}
.chip-overview[hidden] { display: none; }
@keyframes overviewIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chip-overview-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 8px;
  font-size: 12px;
  color: var(--brown);
  background: #faf6ec;
  border-bottom: 1px solid #f3ecdb;
}
.chip-overview-head .ov-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-mute);
}
.chip-overview-head .ov-close {
  margin-left: 6px;
  width: 22px; height: 22px;
  border: none; background: #ece1c8; border-radius: 50%;
  color: var(--text-soft); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.chip-overview-head .ov-close:hover { background: #d9c8a8; }
.ov-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-top: 1px solid #f6f0e2;
  transition: background 0.12s;
}
.ov-item:first-of-type { border-top: none; }
.ov-item:hover, .ov-item:active { background: #fdf3e3; }
.ov-item .ov-thumb {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffe2c2, #ffb87a);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ov-item .ov-name {
  font-size: 13px; color: var(--text); font-weight: 500;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ov-item .ov-meta {
  font-size: 11px; color: var(--text-mute);
  flex-shrink: 0; white-space: nowrap;
}
.ov-item .ov-arrow {
  color: var(--text-mute); font-size: 14px;
  flex-shrink: 0;
}
.ov-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
}
.chip-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  position: relative;
}
.chip-icon::before {
  content: "";
  width: 12px;
  height: 12px;
  position: relative;
  background: rgba(255,255,255,0.85);
  border-radius: 50% 50% 30% 30% / 60% 60% 40% 40%;
  display: block;
}
.chip-icon.cake::before {
  border-radius: 50% 50% 30% 30% / 60% 60% 40% 40%;
}
.chip-icon.bread::before {
  width: 14px; height: 9px;
  border-radius: 50% 50% 40% 40% / 80% 80% 40% 40%;
}
.chip-icon.cookie::before {
  border-radius: 40%;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,0.15);
}
.chip-icon.dumpling::before {
  width: 14px; height: 10px;
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  border-top: 3px solid transparent;
}
.chip-icon.pastry::before {
  width: 13px; height: 13px;
  border-radius: 30% 70% 30% 70%;
  transform: rotate(45deg);
}
.chip-icon.sauce::before {
  width: 10px; height: 13px;
  border-radius: 30% 30% 50% 50%;
}
.chip-icon.candy::before {
  width: 12px; height: 12px;
  border-radius: 30%;
  transform: rotate(45deg);
}
.chip-icon.drink::before {
  width: 10px; height: 13px;
  border-radius: 0 0 30% 30%;
  border-top: 4px solid rgba(255,255,255,0.6);
}
.chip-icon.cake { background: linear-gradient(135deg, #ffd9b3, #ffb87a); }
.chip-icon.bread { background: linear-gradient(135deg, #f0d9a8, #cfa667); }
.chip-icon.cookie { background: linear-gradient(135deg, #d8b384, #a87a4d); }
.chip-icon.dumpling { background: linear-gradient(135deg, #fff1c2, #e8c878); }
.chip-icon.pastry { background: linear-gradient(135deg, #e8b58a, #b8773e); }
.chip-icon.sauce { background: linear-gradient(135deg, #c8b08a, #8a6c4a); }
.chip-icon.candy { background: linear-gradient(135deg, #f5a8c5, #d96aa3); }
.chip-icon.drink { background: linear-gradient(135deg, #f5b8a8, #e8694a); }

.chip .count {
  margin-left: auto;
  color: var(--text-mute);
  font-size: 11px;
}

/* ===== 配方卡片 ===== */
.category-section { position: relative; padding-bottom: 80px; }
.recipe-card {
  margin: 0 16px;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  position: relative;
}
.recipe-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.recipe-thumb {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #ffe9c5, #f4c890);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #b85a2c;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.recipe-thumb::before {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  background: #ff6b6b;
  border-radius: 50%;
  top: 6px; right: 8px;
  z-index: 3;
}
.recipe-thumb::after {
  content: "";
  position: absolute;
  inset: 8px 6px 14px;
  background: repeating-linear-gradient(
    90deg,
    #fff5e0 0 6px,
    #ffd9a0 6px 8px
  );
  border-radius: 4px;
  opacity: 0.6;
}
.recipe-thumb span { position: relative; z-index: 2; }

.recipe-title-wrap { flex: 1; min-width: 0; }
.recipe-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.recipe-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tag-temp { background: #fbe7d6; color: #b85a2c; }
.tag-time { background: var(--tag-time-soft); color: #3d627a; }
.tag svg { width: 12px; height: 12px; }

/* 可编辑的标签数字 */
.tag-editable {
  display: inline-block;
  min-width: 14px;
  text-align: center;
  outline: none;
  cursor: text;
  border-bottom: 1px dashed currentColor;
  padding: 0 2px;
  transition: background 0.15s;
  user-select: text;
  -webkit-user-select: text;
}
.tag-editable:hover {
  background: rgba(255,255,255,0.5);
  border-radius: 3px;
}
.tag-editable:focus {
  background: #fff;
  border-radius: 3px;
  border-bottom-style: solid;
  box-shadow: 0 0 0 2px rgba(217, 122, 74, 0.25);
}

.favorite-btn {
  background: transparent;
  border: none;
  font-size: 26px;
  color: var(--text-mute);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s;
}
.favorite-btn.active { color: var(--orange); }

/* ===== 份数换算 ===== */
.portion-row {
  background: #faf6ee;
  border: 1px solid #eee3cf;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.portion-label { color: var(--text-soft); }
.portion-input-wrap {
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  border: 1px solid #ece1c8;
}
.portion-input {
  width: 36px;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: transparent;
}
.portion-base { color: var(--text-mute); font-size: 12px; flex: 1; }
.convert-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== 食材列表 ===== */
.ingredient-list {
  list-style: none;
  margin-bottom: 10px;
}
.ingredient-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed #ece5d8;
  font-size: 14px;
}
.ingredient-list li:last-child { border-bottom: none; }
.ingredient-list .amount { color: var(--brown); font-weight: 600; }

/* ===== Meta ===== */
.recipe-meta {
  font-size: 11px;
  color: var(--text-mute);
  padding: 6px 2px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* ===== 步骤 ===== */
.recipe-steps {
  background: #faf6ee;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 13px;
}
.recipe-steps summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.recipe-steps summary::-webkit-details-marker { display: none; }
.recipe-steps ol {
  padding-left: 18px;
  margin-top: 8px;
  color: var(--text-soft);
  line-height: 1.7;
}

/* ===== 卡片操作 ===== */
.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f0e9da;
}
.action-btn {
  flex: 1;
  background: #faf6ee;
  border: 1px solid #ece1c8;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn.danger { color: #c66; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: calc(50% - 195px + 22px);
  bottom: 110px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d97a4a, #b85a2c);
  border: none;
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(217, 122, 74, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }

@media (max-width: 420px) {
  .fab {
    right: 22px;
    bottom: 90px;
  }
}

/* ===== 底部 Tabbar ===== */
.bottom-tabbar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid #f0e9da;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 0 10px;
  margin-top: 12px;
  z-index: 4;
}
.tab-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-mute);
  font-size: 11px;
}
.tab-item.active { color: var(--orange); }
.tab-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}
.tab-icon svg { width: 22px; height: 22px; }

/* ===== 响应式 ===== */
@media (max-width: 420px) {
  .phone-frame {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
  }
  body { padding: 0; }
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 20, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal {
  background: var(--bg);
  width: 390px;
  max-width: 100%;
  max-height: 88vh;
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f0e9da;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  width: 30px;
  height: 30px;
  background: #f6f4ee;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 16px 20px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #e5dccb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  resize: none;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--orange);
}
.form-group textarea {
  line-height: 1.6;
  font-family: -apple-system, "PingFang SC", monospace;
}
.form-hint {
  font-size: 11px;
  color: var(--text-mute);
  margin: -2px 0 6px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.category-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.cat-opt {
  background: #fff;
  border: 1px solid #e5dccb;
  border-radius: 8px;
  padding: 8px 4px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.cat-opt.active {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}

.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 0 20px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
}
.modal-cancel {
  flex: 1;
  background: #fff;
  border: 1px solid #e5dccb;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 500;
}
.modal-submit {
  flex: 2;
  background: linear-gradient(135deg, #d97a4a, #b85a2c);
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(217, 122, 74, 0.3);
}

/* ===== 食材列表（表单内） ===== */
.ing-list-header {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.8fr 28px;
  gap: 6px;
  padding: 0 4px 6px;
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
}
.ing-list-header span:not(:last-child) { text-align: center; }
.ing-list-header span:first-child { text-align: left; }

.ing-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5dccb;
  border-radius: 12px;
  padding: 8px;
  min-height: 60px;
}
.ing-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.8fr 28px;
  gap: 6px;
  align-items: center;
}
.ing-row input {
  width: 100%;
  background: #faf6ee;
  border: 1px solid #ece1c8;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  text-align: center;
}
.ing-row .ing-name-input { text-align: left; }
.ing-row input:focus { border-color: var(--orange); background: #fff; }
.ing-total-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--brown);
  text-align: center;
}
.ing-row-del {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 14px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ing-row-del:hover { background: #fbe7d6; color: #c66; }

.add-ing-btn {
  width: 100%;
  background: #fff;
  border: 1px dashed #d9c8a8;
  border-radius: 10px;
  padding: 10px;
  font-size: 13px;
  color: var(--orange);
  cursor: pointer;
  font-weight: 600;
  margin-top: 8px;
}
.add-ing-btn:hover { background: #faf6ee; }

.total-cost-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #fbf3e2, #f4e6cf);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  font-weight: 600;
  color: var(--text);
}
.total-cost-val {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
}

/* ===== 配方卡片：克重比例条 ===== */
.scale-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #faf6ee;
  border: 1px solid #eee3cf;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.scale-label {
  color: var(--text-soft);
  font-weight: 600;
}
.scale-input-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #ece1c8;
  border-radius: 8px;
  padding: 0 4px 0 8px;
  flex: 0 0 auto;
}
.scale-prefix {
  color: var(--orange);
  font-weight: 700;
  font-size: 14px;
}
.scale-input {
  width: 50px;
  border: none;
  outline: none;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  padding: 6px 4px;
  background: transparent;
  color: var(--text);
}
.scale-btn {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.scale-btn:hover { background: #c46c40; }
.scale-reset {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid #ece1c8;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

/* ===== 食材表格（卡片内） ===== */
.ingredient-table {
  list-style: none;
  margin-bottom: 10px;
  background: #fff;
}
.ingredient-table li {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.8fr;
  gap: 6px;
  padding: 8px 4px;
  font-size: 13px;
  border-bottom: 1px dashed #ece5d8;
  align-items: center;
}
.ingredient-table li:last-child { border-bottom: none; }
.ingredient-table .ing-thead {
  background: #faf6ee;
  border-radius: 8px;
  border-bottom: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
  padding: 6px 4px;
}
.ingredient-table .ing-name { font-weight: 500; color: var(--text); }
.ingredient-table .ing-cell { text-align: center; color: var(--brown); font-weight: 500; }
.ingredient-table .ing-grams-cell { color: var(--text); }
.ingredient-table .ing-price-cell { color: var(--text-soft); font-size: 12px; }
.ingredient-table .ing-total-cell { color: var(--accent); font-weight: 600; }

.recipe-cost-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #fff7e8, #f4e6cf);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0 12px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
}
.recipe-cost-val {
  font-size: 17px;
  color: var(--accent);
  font-weight: 700;
}

/* ===== 侧边抽屉 ===== */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  animation: fadeIn 0.2s ease;
}
.drawer-mask.show { display: block; }

.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 80%;
  height: 100vh;
  background: var(--bg);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 20px rgba(0,0,0,0.15);
}
.side-drawer.show { transform: translateX(0); }

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 50px 20px 16px;
  background: linear-gradient(135deg, #fbf3e2, #f4e6cf);
  border-bottom: 1px solid #f0e9da;
}
.drawer-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.drawer-close {
  width: 30px;
  height: 30px;
  background: rgba(255,255,255,0.7);
  border: none;
  border-radius: 50%;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
}

.drawer-menu {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s;
}
.drawer-item:hover { background: #faf6ee; }
.drawer-icon { font-size: 18px; }
.drawer-text { flex: 1; font-weight: 500; }
.drawer-arrow {
  color: var(--text-mute);
  font-size: 18px;
  font-weight: 300;
}

.drawer-footer {
  padding: 16px 20px;
  font-size: 11px;
  color: var(--text-mute);
  text-align: center;
  border-top: 1px solid #f0e9da;
}

/* ===== 成本表 ===== */
.cost-overlay { z-index: 150; }
.cost-modal { max-height: 85vh; }

.cost-list-header {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.9fr 28px;
  gap: 6px;
  padding: 0 4px 6px;
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 600;
}
.cost-list-header span:not(:last-child) { text-align: center; }
.cost-list-header span:first-child { text-align: left; }

.cost-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 1px solid #e5dccb;
  border-radius: 12px;
  padding: 8px;
  min-height: 60px;
  max-height: 50vh;
  overflow-y: auto;
}
.cost-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 0.9fr 28px;
  gap: 6px;
  align-items: center;
}
.cost-row input {
  width: 100%;
  background: #faf6ee;
  border: 1px solid #ece1c8;
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  text-align: center;
}
.cost-row .cost-name-input { text-align: left; }
.cost-row input:focus { border-color: var(--orange); background: #fff; }
.cost-unit-display {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  background: #faf6ee;
  border-radius: 6px;
  padding: 6px 4px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
}