/* 厨子端专属样式（依赖 base.css 的变量与组件类） */

body { min-height: 100vh; min-height: 100dvh; }
/* 弹层打开时锁定页面滚动（iOS 需要 position: fixed 才真正生效） */
body.lock { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

.stack-sm > * + * { margin-top: 8px; }
.req { color: var(--danger); font-style: normal; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}
.login-card { width: 100%; max-width: 360px; text-align: center; padding: 28px 22px 20px; }
.login-card .logo { font-size: 56px; line-height: 1; margin-bottom: 10px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin-top: 6px; color: var(--text-2); font-size: 14px; }
.login-card form { margin-top: 20px; display: grid; gap: 12px; }
.login-card .back { display: inline-block; margin-top: 10px; min-height: 44px; line-height: 44px; font-size: 14px; color: var(--text-2); }

/* ---------- 主界面骨架 ---------- */
.page { padding: 12px 0 calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.topbar .btn { padding: 0 14px; }
.topbar .btn-icon { padding: 0; }
.card-title { font-size: 16px; margin-bottom: 10px; }
.setting-row { min-height: 44px; cursor: pointer; user-select: none; }
.setting-text > span { display: block; }
.empty .btn { margin-top: 12px; }
/* 轮询连续失败时的断线提示条（吸在顶栏下方） */
.offline-bar {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: 19;
  padding: 6px 16px; text-align: center; font-size: 13px; font-weight: 500;
  background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid var(--line);
}

/* 分段选择器（订单筛选 / 难度） */
.seg { display: flex; padding: 3px; border-radius: var(--radius-pill); background: var(--surface-2); }
.seg button {
  flex: 1; min-height: 38px; padding: 0 6px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* 自绘开关 */
.switch { position: relative; display: inline-block; flex: 0 0 auto; width: 50px; height: 30px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .knob { position: absolute; inset: 0; border-radius: var(--radius-pill); background: var(--line); transition: background 0.2s; }
.switch .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.2s;
}
.switch input:checked + .knob { background: var(--success); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { box-shadow: 0 0 0 3px var(--primary-soft); }
.switch input:disabled + .knob { opacity: 0.5; }
.switch-row { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 14px; color: var(--text-2); user-select: none; }

/* ---------- 订单 ---------- */
.orders { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 12px; }
@media (min-width: 640px) { .orders { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.order { border-left: 4px solid transparent; min-width: 0; }
.order.is-pending { border-left-color: var(--accent); }
.order.is-cooking { border-left-color: var(--info); }
.order.is-done { border-left-color: var(--success); }
.order-head { display: flex; align-items: center; gap: 12px; }
.order-code { flex: 0 0 auto; font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: 0.01em; }
.order-code small { font-size: 14px; font-weight: 500; color: var(--text-3); margin-right: 1px; }
.order-who { flex: 1; min-width: 0; }
.order-who b { display: block; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; } /* 长桌号换行，不截断也不撑宽 */
.order-who span { font-size: 12px; color: var(--text-3); }
.order-head .status { flex: 0 0 auto; white-space: nowrap; }
.order-items { list-style: none; margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--line); }
.order-items li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; }
.order-items .emoji { font-size: 18px; line-height: 1.2; }
.order-items .name { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.order-items .qty { font-weight: 700; color: var(--primary); }
.order-items li.item-note {
  display: block; margin: -2px 0 4px 26px; padding: 3px 8px; border-radius: 6px;
  background: var(--accent-soft); color: #9a5f0a; font-size: 13px; font-weight: 500; overflow-wrap: anywhere;
}
.order-remark { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-size: 14px; overflow-wrap: anywhere; }
.order-remark b { font-weight: 600; }
.order-actions { display: flex; gap: 8px; margin-top: 12px; }
.order-actions .btn { flex: 1; padding: 0 8px; }
.order-actions .btn-cancel { flex: 0 0 auto; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .order-items li.item-note { color: var(--accent); } }
:root[data-theme="dark"] .order-items li.item-note { color: var(--accent); }

.order-meal-title {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 -4px; font-size: 14px; font-weight: 600; color: var(--text-2);
}
.order-meal-title::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--primary); }
.order-meal-title:first-child { margin-top: 4px; }
@media (min-width: 640px) { .order-meal-title { grid-column: 1 / -1; } }
.order-who .meal { color: var(--primary); font-weight: 600; margin-right: 6px; }

/* ---------- 做菜弹层 ---------- */
.sheet-cook {
  height: calc(100vh - 20px - var(--safe-top)); max-height: calc(100vh - 20px - var(--safe-top));
  height: calc(100dvh - 20px - var(--safe-top)); max-height: calc(100dvh - 20px - var(--safe-top));
}
.cook-nav { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.cook-nav::-webkit-scrollbar { display: none; }
.cook-nav .chip { flex: 0 0 auto; min-height: 36px; cursor: pointer; }
.cook-dish { padding: 14px; margin-bottom: 12px; }
.cook-dish h3 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.cook-dish h3 .qty { font-size: 13px; font-weight: 600; color: var(--primary); }
.cook-dish .meta { margin-top: 4px; font-size: 13px; color: var(--text-2); }
.cook-dish .note { margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--accent-soft); color: #9a5f0a; font-size: 13px; font-weight: 500; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cook-dish .note { color: var(--accent); } }
:root[data-theme="dark"] .cook-dish .note { color: var(--accent); }
.cook-dish h4 { margin-top: 12px; font-size: 14px; color: var(--text-2); display: flex; align-items: baseline; gap: 8px; }
.cook-ings { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 6px; }
.cook-ings li { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.cook-ings li span:last-child { color: var(--text-2); flex: 0 0 auto; }
.cook-steps { list-style: none; counter-reset: cs; margin-top: 6px; }
.cook-steps li {
  display: flex; gap: 10px; padding: 10px 6px; font-size: 15px; line-height: 1.6; border-radius: 8px; cursor: pointer;
}
.cook-steps li::before {
  counter-increment: cs; content: counter(cs);
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; margin-top: 2px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.cook-steps li.done { color: var(--text-3); text-decoration: line-through; background: var(--surface-2); }
.cook-steps li.done::before { background: var(--success); content: "✓"; }
.cook-tips { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; line-height: 1.6; white-space: pre-line; }
.cook-missing { padding: 14px; color: var(--text-3); }
.sheet-cook .sheet-foot .row .btn { flex: 1; }

/* ---------- 采购单 ---------- */
.shop-summary { margin: 12px 0 8px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.shop-summary b { color: var(--text); }
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-group { padding: 10px 12px 6px; }
.shop-group h3 { display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
.shop-group h3 .count { font-weight: 500; font-size: 12px; color: var(--text-3); }
.shop-group h3 button { border: 0; background: none; color: var(--primary); font-size: 13px; min-height: 32px; padding: 0 4px; }
.shop-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 0; border-top: 1px dashed var(--line); }
.shop-item:first-of-type { border-top: 0; }
.shop-item .check { width: 24px; height: 24px; flex: 0 0 auto; accent-color: var(--primary); }
.shop-item .what { flex: 1 1 auto; min-width: 0; }
.shop-item .what b { display: block; font-size: 15px; overflow-wrap: anywhere; }
.shop-item .what span { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-item .amt { flex: 0 0 auto; font-size: 15px; font-weight: 600; color: var(--primary); text-align: right; white-space: nowrap; }
.shop-item .amt small { display: block; font-size: 11px; font-weight: 400; color: var(--text-3); }
.shop-item.done .what b { text-decoration: line-through; color: var(--text-3); }
.shop-item.done .amt { color: var(--text-3); }
.shop-item .have-tag { font-size: 12px; color: var(--success); background: var(--success-soft); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.shop-item .check-tag { font-size: 12px; color: #9a5f0a; background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shop-item .check-tag { color: var(--accent); } }
:root[data-theme="dark"] .shop-item .check-tag { color: var(--accent); }
.shop-staples { font-size: 13px; color: var(--text-2); line-height: 1.7; padding: 4px 0 8px; }
.shop-actions { display: flex; gap: 8px; margin-top: 12px; }
.shop-actions .btn { flex: 1; padding: 0 8px; font-size: 14px; }
.shop-orders { font-size: 13px; color: var(--text-2); }
.shop-orders li { list-style: none; padding: 3px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.shop-orders .meal { font-weight: 600; color: var(--text); }

/* 冰箱 */
.pantry-card { margin-top: 16px; }
.pantry-add { display: grid; grid-template-columns: minmax(0, 1fr) 72px 64px auto; gap: 6px; }
.pantry-add .input { font-size: 16px; padding: 10px 8px; }
.pantry-add .btn { padding: 0 12px; }
.pantry-card .help { display: block; margin: 8px 0 10px; line-height: 1.5; }
.pantry-list { display: flex; flex-direction: column; }
.pantry-item { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 0; border-top: 1px dashed var(--line); }
.pantry-item .what { flex: 1 1 auto; min-width: 0; }
.pantry-item .what b { display: block; font-size: 15px; overflow-wrap: anywhere; }
.pantry-item .what span { display: block; font-size: 12px; color: var(--text-3); }
.pantry-item .stepper button { width: 32px; height: 32px; }
.pantry-item .stepper .num { min-width: 44px; font-size: 14px; }
.pantry-item .btn-icon { width: 36px; font-size: 16px; }
.pantry-sec { margin: 10px 0 2px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pantry-item .staple-tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text-3); }

/* AI 加菜 / 改菜 */
#aiCard .divider { margin: 14px 0; }
#aiCard .form .row .btn { flex: 1; }
#ai-web-row.muted { opacity: 0.5; }
.ai-recipe { padding: 12px 14px; }
.ai-recipe b { font-size: 16px; }
.ai-detail { margin-top: 8px; }
.ai-detail summary { cursor: pointer; font-size: 13px; color: var(--primary); min-height: 36px; display: flex; align-items: center; }
.ai-detail .cook-ings { grid-template-columns: 1fr; }
.steps-plain { margin: 8px 0 0 18px; padding: 0; font-size: 14px; line-height: 1.6; }
.steps-plain li { padding: 3px 0; }
.ai-recipe .row .btn { flex: 1; }
.ai-rewrite { padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.ai-rewrite .row .btn { flex: 0 0 auto; }

/* 家庭成员 */
.member-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 0; border-top: 1px dashed var(--line); }
.member-item:first-child { border-top: 0; }
.member-item .what { flex: 1 1 auto; min-width: 0; }
.member-item .what b { display: block; font-size: 15px; }
.member-item .what span { display: block; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }

/* ---------- 菜谱列表 ---------- */
#recipeChips { margin: 4px 0 4px; }
#recipeChips .chip { position: relative; min-height: 40px; }
#recipeChips .chip::after { content: ''; position: absolute; inset: -4px; } /* 外扩 4px 命中区，凑够 44px */
.recipe-card { padding: 12px 14px; }
.recipe-main { display: flex; gap: 12px; align-items: center; min-width: 0; }
.recipe-main .thumb { width: 60px; height: 60px; font-size: 30px; }
.recipe-name { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.recipe-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipe-name .status { flex: 0 0 auto; font-size: 12px; padding: 1px 8px; }
.recipe-meta { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.recipe-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.recipe-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.recipe-foot .btn { padding: 0 14px; }
.recipe-card.off .recipe-main { opacity: 0.55; }

/* ---------- 菜谱编辑弹层 ---------- */
.sheet-editor {
  height: calc(100vh - 20px - var(--safe-top)); max-height: calc(100vh - 20px - var(--safe-top));
  height: calc(100dvh - 20px - var(--safe-top)); max-height: calc(100dvh - 20px - var(--safe-top));
}
.sheet-editor .sheet-foot .row .btn { flex: 1; }
.sheet-editor .sheet-foot .row .btn-primary { flex: 2; }
.form { display: grid; gap: 16px; padding-top: 4px; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field > label .help { font-weight: 400; margin-left: 4px; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.emoji-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.emoji-input { width: 72px; min-height: 44px; padding: 4px; text-align: center; font-size: 22px; }
.emoji-picks { display: contents; } /* 让快捷按钮与输入框在同一行流式排列 */
.emoji-picks button {
  width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); font-size: 22px; line-height: 1;
}
.emoji-picks button.active { border-color: var(--primary); background: var(--primary-soft); }

.image-box { display: flex; gap: 12px; align-items: flex-start; }
.image-box .thumb { width: 96px; height: 96px; font-size: 44px; }
.image-ops { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.image-ops .btn { padding: 0 12px; font-size: 14px; }
.upload-btn { cursor: pointer; }
.upload-btn.busy { opacity: 0.6; pointer-events: none; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list:empty { display: none; }
.tag-chip { min-height: 40px; padding-right: 8px; border-color: var(--line); background: var(--accent-soft); color: #9a5f0a; cursor: pointer; }
.tag-chip .x { font-size: 16px; color: var(--text-3); margin-left: 2px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag-chip { color: var(--accent); } }
:root[data-theme="dark"] .tag-chip { color: var(--accent); }
.quick-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-tags .chip { min-height: 40px; cursor: pointer; }
.quick-tags .chip.active { cursor: default; }

.ing-row { display: flex; gap: 8px; align-items: center; }
.ing-row .amount { flex: 0 0 100px; }
.step-row { display: grid; grid-template-columns: 28px 1fr; gap: 4px 8px; }
.step-num { height: 44px; line-height: 44px; text-align: center; font-weight: 700; color: var(--text-3); }
.step-row .textarea { min-height: 72px; }
.step-ops { grid-column: 2; display: flex; justify-content: flex-end; gap: 2px; }
.step-ops .btn, .ing-row .btn-icon { color: var(--text-2); font-size: 18px; }
.step-ops .btn:disabled { opacity: 0.3; }
.btn-icon.danger { color: var(--danger); }

/* ---------- 分类 ---------- */
.cat-add { display: flex; gap: 8px; }
.cat-add .btn { flex: 0 0 auto; padding: 0 14px; }
.cat-help { margin: 8px 2px 12px; }
.cat-card { display: flex; flex-direction: column; gap: 8px; }
.cat-head { display: flex; align-items: center; gap: 10px; }
.cat-name { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-sort { flex: 0 0 auto; font-size: 12px; color: var(--text-3); }
.cat-count { font-size: 13px; color: var(--text-2); }
.cat-ops { display: flex; gap: 6px; }
.cat-ops .btn { padding: 0 12px; font-size: 14px; }
.cat-ops .grow-btn { flex: 1; }
.cat-ops .btn[aria-disabled="true"] { opacity: 0.45; }
.cat-rename { display: flex; gap: 8px; align-items: center; }
.cat-rename .btn { padding: 0 12px; }

/* ---------- 设置 ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 6px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat span { display: block; margin-top: 2px; font-size: 12px; color: var(--text-2); }
.stat.stat-pending { background: var(--accent-soft); }
.stat.stat-cooking { background: var(--info-soft); }
.stat.stat-done { background: var(--success-soft); }
#pwForm .btn { justify-self: start; }

/* ---------- 桌面端 ---------- */
@media (min-width: 720px) {
  .page { padding-top: 20px; }
  .recipe-main .thumb { width: 72px; height: 72px; font-size: 36px; }
  .stats { grid-template-columns: repeat(6, 1fr); }
  .pantry-add { grid-template-columns: minmax(0, 1fr) 100px 90px auto; }
}
/* 5 个 tab 时字号略收 */
.tabbar button { font-size: 10.5px; }

/* 编辑器：减脂 & 同食材搭配 */
.diet-fieldset { margin: 0; padding: 8px 12px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); gap: 8px; }
.diet-fieldset legend { padding: 0 6px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.diet-fieldset .field > label { font-size: 13px; }
