/* 开饭：搪瓷白底 + 搪瓷蓝边，红只给“下一步”，绿只表示“有了/会了” */
:root {
  --ground: #eef2f0;
  --paper: #fbfcfb;
  --ink: #17233f;
  --ink2: #44506f;
  --ink3: #5f6a86;
  --line: #d3dbe6;
  --blue: #2146c7;
  --blue-deep: #18349a;
  --blue-soft: #e3e9fb;
  --red: #cf3520;
  --red-deep: #b02a17;
  --red-soft: #fce8e3;
  --green: #1c7448;
  --green-soft: #dff1e6;
  --teal: #116872;
  --teal-soft: #dcf0f1;
  --amber: #8a5800;
  --amber-soft: #faeecf;
  --r-tile: 14px;
  --r-card: 18px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --tabs-h: calc(58px + env(safe-area-inset-bottom));
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.55 -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--blue);
}
::selection { background: var(--blue); color: #fff; }
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--ground); position: relative; }
#view { padding: 0 16px calc(var(--tabs-h) + 24px); outline: none; }
#view.has-bar { padding-bottom: calc(var(--tabs-h) + 132px); }

/* 页头 */
.head { padding: calc(env(safe-area-inset-top) + 20px) 0 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--blue); letter-spacing: .12em; margin-bottom: 8px; }
.brand svg { width: 18px; height: 18px; }
h1 { font-size: 30px; line-height: 1.18; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h1.small { font-size: 26px; }
.lede { color: var(--ink2); font-size: 15px; margin-top: 8px; max-width: 30em; }
h2 { font-size: 19px; font-weight: 700; margin: 30px 0 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h2 small { font-size: 13px; font-weight: 400; color: var(--ink3); }
h3 { font-size: 14px; font-weight: 600; color: var(--ink2); margin: 18px 0 8px; }
.rim { height: 5px; border-top: 2px solid var(--blue); border-bottom: 1px solid var(--blue); margin: 2px 0 16px; opacity: .9; }

.fridge-btn { display: grid; justify-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--blue-deep); position: relative; flex: none; }
.fridge-btn span.box { width: 54px; height: 54px; border-radius: 16px; background: var(--paper); border: 2px solid var(--blue); display: grid; place-items: center; box-shadow: 0 8px 16px -10px rgba(33, 70, 199, .55); }
.fridge-btn svg { width: 26px; height: 26px; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }

/* 通用按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: 16px; white-space: nowrap; transition: transform .18s var(--ease), background .18s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--red); color: #fff; box-shadow: 0 10px 18px -10px rgba(207, 53, 32, .7); }
.btn.primary:hover { background: var(--red-deep); }
.btn.primary[disabled] { background: #c9cfd9; color: #fff; box-shadow: none; cursor: default; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.blue:hover { background: var(--blue-deep); }
.btn.ghost { background: var(--paper); color: var(--blue-deep); border: 1.5px solid var(--blue); }
.btn.quiet { background: transparent; color: var(--ink2); border: 1.5px solid var(--line); }
.btn.on { background: var(--green); color: #fff; border-color: var(--green); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.link { color: var(--blue-deep); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; padding: 6px 2px; }
.link.danger { color: var(--red-deep); }

/* 横向筛选条 */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip { flex: none; min-height: 38px; padding: 0 15px; border-radius: 999px; background: var(--paper); border: 1.5px solid var(--line); color: var(--ink2); font-size: 15px; font-weight: 500; transition: background .15s, color .15s, border-color .15s, transform .18s var(--ease); }
.chip:active { transform: scale(.95); }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.chip.no.on { background: var(--ink); border-color: var(--ink); }
.sticky { position: sticky; top: 0; z-index: 5; background: var(--ground); margin: 0 -16px; padding: 8px 16px 0; }
.sticky .chips { margin: 0 -16px; }

/* 搜索框 */
.search { position: relative; margin-bottom: 8px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink3); width: 20px; height: 20px; }
.search input, .field input, .field textarea { width: 100%; min-height: 46px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper); padding: 10px 14px; outline: none; transition: border-color .15s; }
.search input { padding-left: 42px; border-radius: 999px; }
.search input:focus, .field input:focus, .field textarea:focus { border-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--ink3); }

/* 食材格子 */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { position: relative; min-height: 56px; padding: 6px 4px; border-radius: var(--r-tile); background: var(--paper); border: 1.5px solid var(--line); font-size: 16px; font-weight: 500; line-height: 1.2; text-align: center; transition: transform .2s var(--ease), background .15s, border-color .15s, color .15s; }
.tile:active { transform: scale(.94); }
.tile.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 8px 14px -10px rgba(33, 70, 199, .8); }
.tile.in::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--paper); }
.tile.on.in::after { box-shadow: 0 0 0 2px var(--blue); background: #fff; }
.legend { font-size: 13px; color: var(--ink3); margin: 12px 0 0; display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.cat-title { font-size: 14px; font-weight: 600; color: var(--blue-deep); margin: 18px 0 8px; }

/* 底部操作条 */
#bar { position: fixed; left: 0; right: 0; bottom: var(--tabs-h); z-index: 20; pointer-events: none; }
#bar .inner { max-width: 480px; margin: 0 auto; padding: 20px 16px 12px; background: linear-gradient(to top, var(--ground) 72%, rgba(238, 242, 240, 0)); pointer-events: auto; }
#bar .picked { font-size: 13px; color: var(--ink2); display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 32px; }
#bar .picked b { color: var(--ink); font-weight: 600; }
#bar .picked span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bar .row { display: flex; gap: 10px; margin-top: 4px; }
#bar .row .btn.primary { flex: 1; }

/* 底部导航 */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--paper); border-top: 1.5px solid var(--line); }
#tabs .inner { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabs-h); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 12px; color: var(--ink3); font-weight: 500; position: relative; }
#tabs button[aria-current="page"] { color: var(--blue); font-weight: 700; }
#tabs button[aria-current="page"]::before { content: ""; position: absolute; top: -1.5px; left: 28%; right: 28%; height: 3px; background: var(--blue); border-radius: 0 0 3px 3px; }

/* 菜牌 */
.dishes { display: grid; gap: 10px; }
.dish { display: grid; grid-template-columns: 58px 1fr; gap: 14px; align-items: center; width: 100%; text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-card); padding: 12px 14px 12px 12px; transition: transform .2s var(--ease), border-color .15s; }
.dish:active { transform: scale(.985); }
.dish:hover { border-color: var(--blue); }
.plaque { width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.t-meat { background: var(--red-soft); color: var(--red-deep); }
.t-veg { background: var(--green-soft); color: var(--green); }
.t-soup { background: var(--blue-soft); color: var(--blue-deep); }
.t-cold { background: var(--teal-soft); color: var(--teal); }
.t-staple { background: var(--amber-soft); color: var(--amber); }
.dish .name { font-size: 17px; font-weight: 700; line-height: 1.3; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dish .desc { font-size: 13.5px; color: var(--ink2); margin-top: 1px; }
.dish .meta { font-size: 13px; color: var(--ink3); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; line-height: 1.5; }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.miss { background: var(--amber-soft); color: var(--amber); }
.tag.warn { background: var(--red-soft); color: var(--red-deep); }
.tag.know { background: var(--blue-soft); color: var(--blue-deep); }
.tag svg { width: 12px; height: 12px; stroke-width: 2.6; }

.empty { text-align: center; padding: 36px 20px; color: var(--ink2); background: var(--paper); border: 1.5px dashed var(--line); border-radius: var(--r-card); }
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.empty .btn { margin-top: 16px; }
.backrow { padding: calc(env(safe-area-inset-top) + 14px) 0 4px; }
.backrow .link { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; }
.backrow svg { width: 18px; height: 18px; }
.toolbar { display: flex; gap: 10px; margin: 14px 0 6px; }
.toolbar .btn { flex: 1; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #e1e7e6; border-radius: 999px; padding: 4px; margin: 4px 0 12px; }
.seg button { min-height: 38px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink2); font-variant-numeric: tabular-nums; }
.seg button.on { background: var(--paper); color: var(--blue-deep); box-shadow: 0 2px 6px -2px rgba(23, 35, 63, .25); }
.toggle-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); margin: 2px 0 12px; }
.toggle-line input { width: 20px; height: 20px; accent-color: var(--blue); }

/* 备菜 */
.day { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-card); padding: 14px; margin-bottom: 10px; }
.day.today { border-color: var(--blue); }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.day-head b { font-size: 18px; }
.day-head span { font-size: 13px; color: var(--ink3); font-variant-numeric: tabular-nums; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #e6ebf1; }
.plan-row .plaque { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
.plan-row .n { flex: 1; font-weight: 600; text-align: left; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink3); flex: none; }
.icon-btn:hover { background: #e6ebf1; color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.add-dish { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; margin-top: 4px; border-radius: 999px; border: 1.5px dashed var(--blue); color: var(--blue-deep); font-weight: 600; font-size: 14px; }
.add-dish svg { width: 16px; height: 16px; stroke-width: 2.4; }

/* 冰箱 */
.fridge-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fitem { text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-tile); padding: 10px 12px; min-height: 72px; }
.fitem b { display: block; font-size: 16px; }
.fitem span { display: block; font-size: 12.5px; color: var(--ink3); }
.fitem.soon { border-color: #d9a441; background: #fffaf0; }
.fitem.soon span.st { color: var(--amber); font-weight: 600; }
.fitem.old { border-color: var(--red); background: var(--red-soft); }
.fitem.old span.st { color: var(--red-deep); font-weight: 600; }
.note { font-size: 13px; color: var(--ink3); margin-top: 10px; }
.panel { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--r-card); padding: 16px; }
.panel h3:first-child { margin-top: 0; }
.panel .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* 抽屉 */
#scrim { position: fixed; inset: 0; background: rgba(23, 35, 63, .45); z-index: 40; animation: fade .25s both; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 480px; margin: 0 auto; max-height: 90dvh; display: flex; flex-direction: column; background: var(--paper); border-radius: 22px 22px 0 0; border-top: 2px solid var(--blue); animation: rise .42s var(--ease) both; }
#sheet[hidden], #scrim[hidden] { display: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 12px 8px 20px; }
.sheet-head h2 { margin: 0; font-size: 22px; line-height: 1.25; display: block; }
.sheet-body { overflow-y: auto; padding: 0 20px 20px; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #e6ebf1; background: var(--paper); }
.sheet-foot .btn { flex: 1; padding: 0 12px; }
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--ink2); margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.ing-rows { border-top: 1px solid #e6ebf1; }
.ing-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e6ebf1; list-style: none; align-items: center; }
.ing-rows { padding: 0; }
.ing-rows .amt { color: var(--ink2); font-variant-numeric: tabular-nums; text-align: right; }
.ing-rows .nm { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.season { color: var(--ink); line-height: 1.9; }
.season span { display: inline-block; padding: 1px 10px; margin: 0 6px 6px 0; border-radius: 8px; background: #ecf0f4; font-size: 14.5px; }
ol.steps { padding: 0; counter-reset: s; display: grid; gap: 12px; }
ol.steps li { list-style: none; display: grid; grid-template-columns: 28px 1fr; gap: 10px; counter-increment: s; }
ol.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--blue); color: var(--blue-deep); font-weight: 700; font-size: 14px; display: grid; place-items: center; }

/* 表单 */
.field { display: grid; gap: 6px; margin-top: 16px; }
.field label, .field .lab { font-size: 14px; font-weight: 600; color: var(--ink2); }
.field .hint { font-size: 12.5px; color: var(--ink3); }
.field textarea { min-height: 120px; resize: vertical; }
.ing-edit { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; margin-bottom: 8px; }
.err { color: var(--red-deep); font-size: 14px; font-weight: 600; margin-top: 12px; }

/* 采购清单 */
.shop li { list-style: none; }
.shop ul { padding: 0; }
.shop label { display: grid; grid-template-columns: 24px 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid #e6ebf1; }
.shop input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); }
.shop .amt { color: var(--red-deep); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.shop label:has(input:checked) b { text-decoration: line-through; color: var(--ink3); font-weight: 500; }
.shop b { font-weight: 600; }

.combo-opts { margin-bottom: 14px; }
.days-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.days-pick .btn { justify-content: flex-start; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 150px); transform: translate(-50%, 12px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .25s, transform .35s var(--ease); z-index: 60; width: max-content; max-width: 88vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 350px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  h1 { font-size: 26px; }
}
@media (min-width: 481px) {
  body { background: #e3e9e6; }
  #app { box-shadow: 0 0 0 1.5px var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
