/* ==========================================================================
   家庭点餐系统 · 样式表（Rust 版）
   手机优先（基准 375px），CSS 变量做主题，无 UI 框架。
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2622;
  --muted: #7a6f66;
  --border: #e7ded2;
  --accent: #b45309;
  --accent-soft: #fdf1e3;
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #15803d;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --shadow: 0 1px 2px rgba(43, 38, 34, 0.06), 0 4px 12px rgba(43, 38, 34, 0.05);
  --gap: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 14px;
  min-height: var(--tap); display: inline-flex; align-items: center; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
}
.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--tap); }
.topbar__row--date { margin-top: 2px; }
.topbar__brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; min-height: var(--tap); }
.topbar__nav { display: flex; gap: 4px; }
.topbar__nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 14px; }
.topbar__nav a.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar__date { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 22px; line-height: 1; flex: 0 0 auto;
}
.iconbtn:hover { background: #f8e3cd; text-decoration: none; }

/* ---------------------------------------------------------------- 布局 */
.page { max-width: 720px; margin: 0 auto; padding: 12px 12px calc(28px + env(safe-area-inset-bottom)); }
.footer { max-width: 720px; margin: 0 auto; padding: 0 12px calc(24px + env(safe-area-inset-bottom)); }
.footer__note { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------------------------------------------------------------- 徽标 */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.badge--soft { background: var(--accent-soft); }
.badge--ok { background: #e7f6ec; color: var(--ok); }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 6px; font-size: 12px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag--muted { background: #f2ede6; color: var(--muted); }
.tag--ok { background: #e7f6ec; color: var(--ok); }
.tag--danger { background: #fdecec; color: var(--danger); }

/* ---------------------------------------------------------------- 菜单头 */
.menu-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.page-title { font-size: 20px; font-weight: 700; }
.menu-head__progress { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------- 步进器 */
.meal-stepper {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
  margin: 6px 0 14px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.meal-step {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 2px; border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--muted); font-size: 13px; text-align: center; min-height: var(--tap);
  text-decoration: none;
}
.meal-step:hover { background: var(--accent-soft); text-decoration: none; }
.meal-step.is-current { background: var(--accent-soft); color: var(--accent); border-color: #f0d6b5; font-weight: 700; }
.meal-step.is-done { color: var(--ok); }
.meal-step__dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: #f2ede6; color: var(--muted); font-size: 12px; font-weight: 700;
}
.meal-step.is-current .meal-step__dot { background: var(--accent); color: #fff; }
.meal-step.is-done .meal-step__dot { background: #e7f6ec; color: var(--ok); }
.meal-step__label { line-height: 1.2; }

/* ---------------------------------------------------------------- 时段聚焦 */
.meal-focus-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; padding-left: 2px; }
.meal-focus-head__title { font-size: 18px; font-weight: 700; }
.meal-focus-head__meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); min-width: var(--tap); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer; text-align: center;
  transition: filter 0.15s ease; -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { filter: brightness(0.94); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ghost { background: var(--surface); color: var(--accent); border-color: var(--border); }
.btn--small { min-height: var(--tap); padding: 0 14px; font-size: 14px; }
.btn--block { display: flex; width: 100%; min-height: 48px; font-size: 16px; }
.lockbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.lockbtn.is-on { background: var(--accent-soft); color: var(--accent); border-color: #f0d6b5; }

/* ---------------------------------------------------------------- 卡片 */
.card-grid { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 620px) { .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dish-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); min-width: 0; overflow-wrap: anywhere; }
.dish-card.is-locked { border-color: #f0d6b5; background: #fffdfa; }
.dish-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dish-card__title-wrap { min-width: 0; }
.dish-card__title { font-size: 17px; font-weight: 700; }
.dish-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.dish-card__lock { flex: 0 0 auto; }
.dish-card__empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.dish-card__more { margin: 2px 0 8px; border-top: 1px dashed var(--border); }
.dish-card__more-summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--accent); min-height: var(--tap); display: flex; align-items: center; gap: 4px; }
.dish-card__more-summary::-webkit-details-marker { display: none; }
.dish-card__more-summary::before { content: "▸"; }
.dish-card__more[open] .dish-card__more-summary::before { content: "▾"; }
.dish-card__more-body { padding-top: 4px; }

/* ---------------------------------------------------------------- 时间轴 */
.timeline { position: relative; padding-left: 18px; margin-bottom: 10px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline__item { position: relative; padding: 4px 0 8px; }
.timeline__marker { position: absolute; left: -18px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); }
.timeline__body { min-width: 0; }
.timeline__stage { display: inline-block; font-size: 11px; color: var(--muted); background: #f4efe8; border-radius: 5px; padding: 0 6px; margin-bottom: 2px; }
.timeline__text { font-size: 14.5px; line-height: 1.55; }
.timeline__hint { margin-top: 2px; font-size: 12.5px; color: var(--accent); }

/* ---------------------------------------------------------------- 提鲜 / 妈妈 */
.seasoning { background: #f4f8f2; border: 1px solid #dfeada; border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; }
.seasoning__label { display: block; font-size: 12px; color: var(--ok); font-weight: 700; margin-bottom: 3px; }
.seasoning__list { display: flex; flex-wrap: wrap; gap: 6px; }
.seasoning__item { font-size: 13px; background: var(--surface); border: 1px solid #dfeada; border-radius: 999px; padding: 2px 9px; }
.seasoning__amount { color: var(--muted); }
.mom-boost { background: #fdf3f6; border: 1px solid #f2dde4; border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; }
.mom-boost__label { display: block; font-size: 12px; color: #a63a5e; font-weight: 700; }
.mom-boost__text { font-size: 14px; margin-top: 3px; line-height: 1.5; }

/* ---------------------------------------------------------------- 食材 */
.ingredients__list { padding-top: 2px; }
.ingredients__item { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 14px; border-bottom: 1px dashed var(--border); }
.ingredients__item:last-child { border-bottom: none; }
.ingredients__name { flex: 1 1 auto; min-width: 0; }
.ingredients__amount { color: var(--muted); white-space: nowrap; }
.ingredients__buy { margin-left: 6px; color: var(--accent); }
.dish-card__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }

/* ---------------------------------------------------------------- 换菜 */
.swap-panel:empty { display: none; }
.swap-candidates { width: 100%; background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius-sm); padding: 10px; }
.swap-candidates__title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.swap-candidates__list { display: flex; flex-direction: column; gap: 6px; }
.swap-candidates__empty { font-size: 13px; color: var(--muted); }
.candidate-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; min-height: var(--tap); padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-family: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.candidate-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.candidate-btn__name { font-weight: 600; }
.candidate-btn__meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 提示 */
.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 12px; border: 1px solid transparent; }
.alert--ok { background: #e7f6ec; color: var(--ok); border-color: #c6e8d2; }
.alert--warn { background: #fdf6ea; color: var(--warn); border-color: #f0e0c0; }
.alert--danger { background: #fdecec; color: var(--danger); border-color: #f3cfcf; }
.notice-list { font-size: 13px; margin-bottom: 10px; padding-left: 4px; }
.notice-list li { padding: 3px 0 3px 14px; position: relative; }
.notice-list li::before { content: "•"; position: absolute; left: 2px; }
.notice-list--muted { color: var(--muted); }
.notice-list--danger { color: var(--danger); }
.empty-state { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 28px 16px; text-align: center; margin-bottom: 16px; }
.empty-state__title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.empty-state__hint { font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------------- 确认动作 */
.meal-focus-actions { margin-top: 14px; }
.meal-focus-actions__note { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; text-align: center; }
.meal-complete { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 16px; text-align: center; box-shadow: var(--shadow); margin: 8px 0 14px; }
.meal-complete__title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.meal-complete__hint { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }

/* ---------------------------------------------------------------- 参考折叠 */
.ref-panel { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ref-panel__summary { list-style: none; cursor: pointer; padding: 10px 12px; font-size: 13px; color: var(--muted); min-height: var(--tap); display: flex; align-items: center; }
.ref-panel__summary::-webkit-details-marker { display: none; }
.ref-panel__summary::before { content: "▸"; margin-right: 6px; }
.ref-panel[open] .ref-panel__summary::before { content: "▾"; }
.ref-panel__body { padding: 0 12px 12px; }
.ref-panel__body.coverage-bar { margin: 0; }

/* ---------------------------------------------------------------- 次级操作 */
.menu-secondary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.menu-secondary__form { flex: 0 0 auto; }

/* ---------------------------------------------------------------- 覆盖胶囊 */
.coverage-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.capsule { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 13px; flex: 0 0 auto; }
.capsule__icon { font-size: 15px; }
.capsule__label { color: var(--muted); }
.capsule__count { font-weight: 700; color: var(--text); }
.capsule__bar { display: block; width: 42px; height: 5px; border-radius: 999px; background: #f0e8dd; overflow: hidden; }
.capsule__fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.capsule--sub { font-size: 12px; padding: 4px 8px; }
.coverage-bar__note { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- 采购清单 */
.shopping-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.shopping-head__title { font-size: 19px; }
.shopping-head__meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.shop-group { margin-bottom: 18px; }
.shop-group__title { font-size: 15px; font-weight: 700; margin-bottom: 8px; padding-left: 2px; }
.shop-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.shop-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.shop-item:last-child { border-bottom: none; }
.shop-item.is-checked .shop-item__name { text-decoration: line-through; color: var(--muted); }
.shop-item__form { flex: 0 0 auto; }
.checkbtn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); min-width: var(--tap); padding: 0; border: none; background: transparent; cursor: pointer; }
.checkbtn__box { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 2px solid var(--border); border-radius: 7px; background: var(--surface); color: #fff; font-size: 15px; font-weight: 700; }
.shop-item.is-checked .checkbtn__box { background: var(--ok); border-color: var(--ok); }
.shop-item__body { min-width: 0; flex: 1 1 auto; }
.shop-item__name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.shop-item__amount { font-size: 14px; color: var(--accent); }
.shop-item__dishes { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- 平板以上 */
@media (min-width: 720px) {
  .page { padding: 18px 16px 40px; }
  .dish-card { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   助手页（LLM 辅助：草稿 / 话术 / 偏好标签）
   ========================================================================== */
.assistant { display: flex; flex-direction: column; gap: var(--gap); }
.assistant__intro { color: var(--muted); font-size: 13px; line-height: 1.7; }

.assistant-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.assistant-block__summary {
  padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: 15px;
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.assistant-block__summary::-webkit-details-marker { display: none; }
.assistant-block__summary::before { content: "▸"; color: var(--accent); font-size: 12px; }
.assistant-block[open] > .assistant-block__summary::before { content: "▾"; }
.assistant-block__body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.assistant-block__hint { color: var(--muted); font-size: 13px; line-height: 1.7; }
.assistant-block__hint code, .result__hint code { background: #f2ede6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.assistant-form { display: flex; flex-direction: column; gap: 8px; }
.textarea, .input, .select {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 15px; color: var(--text);
  background: #fffdfa; border: 1px solid var(--border); border-radius: var(--radius-sm);
  min-height: var(--tap);
}
.textarea { resize: vertical; line-height: 1.6; }
.textarea:focus, .input:focus, .select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.result { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.result__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.result__title { font-size: 18px; }
.result__meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.result__subtitle { font-size: 14px; color: var(--muted); font-weight: 600; margin-top: 4px; }
.result__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.result__hint { color: var(--muted); font-size: 12px; line-height: 1.6; flex: 1 1 180px; }

.step-list { display: flex; flex-direction: column; gap: 8px; }
.step-list__item { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; line-height: 1.6; padding-left: 2px; }
.step-list__stage { color: var(--accent); font-size: 12px; background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; height: fit-content; }
.step-list__text { flex: 1 1 100%; }
.step-list__diff { flex: 1 1 100%; color: var(--muted); font-size: 13px; }

.chip { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }

.code-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.55;
  background: #fbf7f1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; overflow-x: auto; white-space: pre; color: #4a3f36;
}

.job-list { display: flex; flex-direction: column; gap: 8px; }
.job-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.job-row:last-child { border-bottom: none; }
.job-row__task { font-weight: 600; }
.job-row__summary { color: var(--muted); flex: 1 1 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row__meta { color: var(--muted); font-size: 12px; }
.job-row__link { color: var(--accent); text-decoration: none; font-size: 12px; }
.job-row__link:hover { text-decoration: underline; }
