:root {
  --bg: #fdf8f2;
  --card: #ffffff;
  --ink: #2b2320;
  --sub: #9a8c82;
  --hair: #f0e4d8;
  --accent: #e8641c;
  --accent-soft: #fdeee2;
  --green: #3d8b5f;
  --green-soft: #e8f4ec;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", sans-serif;
  min-height: 100dvh;
}
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px 120px;
}
header { text-align: center; margin-bottom: 20px; }
h1 { font-size: 30px; letter-spacing: 1px; }
.sub { color: var(--sub); font-size: 14px; margin-top: 6px; }
.hidden { display: none !important; }

/* 搜索 */
.search-wrap { position: sticky; top: 8px; z-index: 5; }
#search {
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  border: 1.5px solid var(--hair);
  border-radius: 14px;
  background: var(--card);
  outline: none;
  box-shadow: 0 2px 10px rgba(180, 120, 60, 0.06);
}
#search:focus { border-color: var(--accent); }

/* 已选区 */
.selected-box {
  margin-top: 14px;
  background: var(--accent-soft);
  border: 1.5px dashed #f0c9a8;
  border-radius: 14px;
  padding: 12px 12px 10px;
}
#seasoning-box { background: var(--green-soft); border-color: #bcd9c6; }
.selected-box h2 { font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.selected-box .hint { font-weight: normal; color: var(--sub); font-size: 12px; }
.clear-all {
  float: right;
  border: none;
  background: none;
  color: var(--sub);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}
.clear-all:active { color: var(--accent); }

/* 小片片 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 14px;
  white-space: nowrap;
}
.chip.picked { background: #eee; color: var(--sub); text-decoration: line-through; }
.chip.selectable { cursor: pointer; transition: border-color 0.12s, transform 0.05s; -webkit-tap-highlight-color: transparent; }
.chip.selectable:active { transform: scale(0.95); }
.chip.selectable.on { border-color: var(--green); background: var(--green-soft); text-decoration: none; color: var(--ink); }
.chip .x { color: var(--sub); cursor: pointer; font-size: 15px; padding: 0 2px; }
.chip select {
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 12px;
  background: var(--bg);
  color: var(--ink);
  padding: 2px 2px;
}
.chip .qty { display: inline-flex; align-items: center; gap: 4px; }
.chip .qty button {
  width: 22px; height: 22px;
  border: 1px solid var(--hair);
  background: var(--bg);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--accent);
}
.chip .qty .val { font-size: 13px; min-width: 44px; text-align: center; }
.chip input.amt {
  width: 52px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 12px;
  padding: 2px 4px;
  background: var(--bg);
}

/* 目录 */
.cat { margin-top: 20px; }
.cat > h2 { font-size: 16px; margin-bottom: 10px; }
.cat > h2 .emoji { margin-right: 4px; }
.cat.seasoning > h2 { margin-top: 4px; }
.section-label {
  margin-top: 26px;
  font-size: 13px;
  color: var(--sub);
  letter-spacing: 2px;
  border-top: 1px solid var(--hair);
  padding-top: 14px;
}
.add-custom {
  margin-top: 10px;
  display: inline-block;
  border: 1.5px dashed var(--accent);
  color: var(--accent);
  background: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}

/* 底部行动条 */
#action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
  display: none;
  justify-content: center;
}
body.picking #action-bar { display: flex; }
.btn {
  border: none;
  border-radius: 14px;
  font-size: 16px;
  padding: 13px 22px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  width: 100%;
  max-width: 608px;
  box-shadow: 0 4px 14px rgba(232, 100, 28, 0.35);
}
.btn.primary:disabled { background: #e8cdb8; box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: var(--card); border: 1.5px solid var(--hair); color: var(--ink); font-size: 14px; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
#view-dishes .btn-row, #view-recipe .btn-row { margin-bottom: 10px; }

/* 菜品卡片 */
.view-title { font-size: 18px; margin: 6px 0 14px; text-align: center; }
.dish {
  background: var(--card);
  border: 1.5px solid var(--hair);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.dish:active { border-color: var(--accent); }
.dish h3 { font-size: 18px; }
.dish .reason { color: var(--sub); font-size: 14px; margin-top: 6px; line-height: 1.5; }
.dish .meta { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tag {
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag.warn { background: #fdf0e0; color: #b06a00; }
.dish .cta { margin-top: 10px; color: var(--accent); font-size: 14px; font-weight: 600; }

/* 食谱卡 */
.recipe {
  background: var(--card);
  border: 1.5px solid var(--hair);
  border-radius: 16px;
  padding: 20px 16px;
}
.recipe h2 { font-size: 24px; text-align: center; }
.recipe .intro { text-align: center; color: var(--sub); font-size: 14px; margin-top: 6px; }
.recipe .meta { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.recipe h3 {
  font-size: 15px;
  margin: 20px 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--accent);
}
.ing-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ing-table td { padding: 6px 4px; border-bottom: 1px dashed var(--hair); }
.ing-table td:last-child { text-align: right; color: var(--sub); white-space: nowrap; }
.steps { counter-reset: step; }
.steps li {
  list-style: none;
  counter-increment: step;
  position: relative;
  padding: 8px 0 8px 38px;
  font-size: 15px;
  line-height: 1.65;
  border-bottom: 1px dashed var(--hair);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 10px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  text-align: center;
  line-height: 24px;
}
.tips li { list-style: none; font-size: 14px; color: var(--sub); padding: 5px 0 5px 20px; position: relative; line-height: 1.5; }
.tips li::before { content: "💡"; position: absolute; left: 0; font-size: 12px; top: 7px; }

/* 登录 */
.login-card {
  background: var(--card);
  border: 1.5px solid var(--hair);
  border-radius: 16px;
  padding: 24px 18px;
  max-width: 360px;
  margin: 30px auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card input {
  padding: 13px 14px;
  font-size: 16px;
  border: 1.5px solid var(--hair);
  border-radius: 12px;
  background: var(--bg);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-hint { text-align: center; color: var(--sub); font-size: 12px; }

/* 顶栏 tab */
#topnav {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
#topnav button {
  border: 1.5px solid var(--hair);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
}
#topnav button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* 收藏打分组件 */
.fav-widget {
  background: var(--card);
  border: 1.5px solid var(--hair);
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
  text-align: center;
}
.fw-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.stars { font-size: 28px; letter-spacing: 4px; color: #ddd; user-select: none; }
.stars span { cursor: pointer; }
.stars span.lit, .stars.readonly { color: #f5a623; }
.tag.star { background: #fdf3e0; color: #c07d10; }
.fav-widget.readonly .stars { color: #f5a623; font-size: 22px; }
.fav-by { color: var(--sub); font-size: 13px; margin-top: 6px; }
#fw-note {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1.5px solid var(--hair);
  border-radius: 10px;
  background: var(--bg);
  outline: none;
  box-sizing: border-box;
}
#fw-note:focus { border-color: var(--accent); }
#fw-save { margin-top: 10px; width: 100%; }
#fw-del { margin-top: 8px; width: 100%; }

/* 空态 */
.empty { text-align: center; color: var(--sub); font-size: 14px; padding: 40px 0; }

/* 加载 & 提示 */
.loading {
  position: fixed; inset: 0;
  background: rgba(253, 248, 242, 0.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 20;
}
.spinner { font-size: 52px; animation: wobble 1s ease-in-out infinite; }
@keyframes wobble { 0%,100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
.loading p { margin-top: 14px; color: var(--sub); font-size: 15px; }
.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 30;
  max-width: 86vw;
  text-align: center;
}
