:root {
  --bg: #f6f3ec;
  --card: #fffdf8;
  --sunk: #efeadf;
  --ink: #1f2a24;
  --ink-2: #4b554e;
  --muted: #8a8f86;
  --line: #e6e0d3;
  --accent: #2f5d46;
  --accent-soft: #e3ece5;
  --on-accent: #fff;
  --chili: #c2502f;
  --chili-soft: #f6e4dc;
  --shadow: 0 1px 2px rgba(40, 35, 20, .05), 0 4px 16px rgba(40, 35, 20, .05);
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141815; --card: #1c211d; --sunk: #232924; --ink: #ecefe9; --ink-2: #c3c9c1;
    --muted: #8b928a; --line: #2d342e; --accent: #8cc4a3; --accent-soft: #233a2d; --on-accent: #10221a;
    --chili: #e8846a; --chili-soft: #3a2620; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141815; --card: #1c211d; --sunk: #232924; --ink: #ecefe9; --ink-2: #c3c9c1;
  --muted: #8b928a; --line: #2d342e; --accent: #8cc4a3; --accent-soft: #233a2d; --on-accent: #10221a;
  --chili: #e8846a; --chili-soft: #3a2620; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
main { padding: calc(env(safe-area-inset-top) + 20px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px); }

/* ── 底部导航 ── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; max-width: 132px; height: 52px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] svg { stroke-width: 2.2; }

/* ── 页头 ── */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 16px; }
.head h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: .01em; }
.head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── 日期条 ── */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 0 0 18px; }
.days button {
  height: 52px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  font-size: 15px; font-weight: 600; color: var(--ink-2); position: relative;
}
.days button small { font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.days button.is-today::after { content: ""; position: absolute; top: 6px; right: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--chili); }
.days button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.days button[aria-pressed="true"] small { color: inherit; opacity: .8; }

/* ── 卡片 ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .08em; }
.badge { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.warm { background: var(--chili-soft); color: var(--chili); }
.note { color: var(--ink-2); font-size: 14px; margin: 2px 0 6px; }

.dish { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.card-head + .dish, .note + .dish { border-top: 0; }
.dish-main { flex: 1; min-width: 0; text-align: left; display: block; }
.dish-name { font-size: 18px; font-weight: 600; line-height: 1.35; }
.dish.side .dish-name { font-size: 16.5px; font-weight: 500; }
.dish-meta { font-size: 13px; color: var(--muted); margin-top: 1px; }
.dish-meta .hot { color: var(--chili); }
.dish.rice .dish-name { font-size: 15px; font-weight: 400; color: var(--ink-2); }
.swap {
  flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2);
}
.swap:active { background: var(--sunk); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  background: var(--accent); color: var(--on-accent);
}
.btn.block { width: 100%; margin-top: 10px; }
.btn.ghost { background: var(--sunk); color: var(--ink); }
.btn.small { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn svg { width: 18px; height: 18px; }
.btn:active { opacity: .85; }

.banner { display: flex; align-items: center; gap: 10px; background: var(--chili-soft); color: var(--chili); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14.5px; }
.banner span { flex: 1; }
.banner .btn { background: var(--chili); color: #fff; height: 34px; font-size: 14px; }

/* ── 一周 ── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.chip { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); color: var(--ink-2); }
.chip b { color: var(--ink); font-weight: 600; margin-left: 2px; }
.week-day { display: block; width: 100%; text-align: left; }
.week-day .card-head h2 { font-size: 17px; color: var(--ink); letter-spacing: 0; }
.wrow { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 5px 0; font-size: 15px; }
.wrow .k { color: var(--muted); font-size: 13px; padding-top: 1px; }
.wrow .v small { color: var(--muted); font-size: 12.5px; }
.week-day.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── 分段控件 ── */
.seg { display: flex; background: var(--sunk); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; height: 36px; border-radius: 10px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

/* ── 采购单 ── */
.shop-group h3 { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .08em; margin: 0 0 4px; }
.check { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border-top: 1px solid var(--line); text-align: left; }
.shop-group h3 + .check { border-top: 0; }
.check .box { width: 22px; height: 22px; border-radius: 7px; border: 1.8px solid var(--line); flex-shrink: 0; display: grid; place-items: center; }
.check .box svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; stroke: var(--on-accent); }
.check .nm { flex: 1; font-size: 16px; }
.check .nm small { display: block; color: var(--muted); font-size: 12.5px; }
.check .amt { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 15px; }
.check[aria-checked="true"] .box { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"] .box svg { opacity: 1; }
.check[aria-checked="true"] .nm, .check[aria-checked="true"] .amt { color: var(--muted); text-decoration: line-through; }
.progress { height: 6px; background: var(--sunk); border-radius: 99px; overflow: hidden; margin: -4px 0 14px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 2px 14px; }
.pantry { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pantry span { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--sunk); color: var(--ink-2); }

/* ── 菜谱库 ── */
.search { position: relative; margin-bottom: 12px; }
.search input { width: 100%; height: 44px; border-radius: 14px; border: 0; background: var(--card); box-shadow: var(--shadow); padding: 0 14px 0 40px; font-size: 16px; outline: none; }
.search input:focus { box-shadow: 0 0 0 2px var(--accent); }
.search svg { position: absolute; left: 13px; top: 11px; width: 20px; height: 20px; color: var(--muted); }
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex-shrink: 0; height: 32px; padding: 0 13px; border-radius: 999px; font-size: 13.5px; background: var(--card); box-shadow: var(--shadow); color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.lib-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.lib-row:first-child { border-top: 0; }
.lib-row.off .dish-name { color: var(--muted); text-decoration: line-through; }
.toggle-off { flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); }
.lib-row.off .toggle-off { background: var(--chili-soft); color: var(--chili); border-color: transparent; }
details.dislike { margin-bottom: 12px; }
details.dislike summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 15px; }
details.dislike summary::-webkit-details-marker { display: none; }
details.dislike summary small { color: var(--muted); font-weight: 400; font-size: 13px; }
details.dislike[open] summary { margin-bottom: 10px; }
.ing-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ing-chips button { font-size: 13.5px; padding: 5px 11px; border-radius: 999px; background: var(--sunk); color: var(--ink-2); }
.ing-chips button[aria-pressed="true"] { background: var(--chili-soft); color: var(--chili); text-decoration: line-through; }
.foot { color: var(--muted); font-size: 12.5px; text-align: center; margin: 24px 8px 0; line-height: 1.7; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ── 底部弹层 ── */
dialog#sheet {
  border: 0; padding: 0; margin: 0; max-width: none; max-height: none; width: 100%; height: 100%;
  background: transparent; color: var(--ink);
}
dialog#sheet::backdrop { background: rgba(10, 14, 11, .38); }
dialog#sheet[open] { display: flex; align-items: flex-end; justify-content: center; }
.sheet-inner {
  position: relative; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  animation: up .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 700px) {
  dialog#sheet[open] { align-items: center; }
  .sheet-inner { border-radius: 22px; max-height: 86vh; }
}
.sheet-grab { width: 38px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 8px; }
.sheet-close { position: sticky; top: 0; float: right; width: 34px; height: 34px; border-radius: 50%; background: var(--sunk); display: grid; place-items: center; margin: 0 -6px 0 8px; z-index: 2; }
.sheet-close svg { width: 18px; height: 18px; }
.sheet h2 { font-size: 24px; margin: 4px 0 4px; line-height: 1.3; }
.sheet .meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.sheet .meta .hot { color: var(--chili); }
.sheet h3 { font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .06em; margin: 20px 0 8px; }
.sheet h3.big { font-size: 18px; color: var(--ink); letter-spacing: 0; margin-top: 26px; }
.ing-list { background: var(--card); border-radius: 14px; padding: 4px 14px; box-shadow: var(--shadow); }
.ing-list div { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15.5px; }
.ing-list div:first-child { border-top: 0; }
.ing-list span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.season { font-size: 14.5px; color: var(--ink-2); }
ol.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; }
ol.steps li { counter-increment: s; position: relative; padding: 0 0 14px 38px; font-size: 16px; line-height: 1.6; }
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 700; display: grid; place-items: center;
}
.tip { background: var(--accent-soft); color: var(--ink); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; margin-top: 6px; }
.tip.warm { background: var(--chili-soft); }
.sheet-actions { display: flex; gap: 8px; margin-top: 20px; }
.sheet-actions .btn { flex: 1; }
.opt { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 0; border-top: 1px solid var(--line); }
.opt:first-child { border-top: 0; }
.opt.cur .dish-name::after { content: "当前"; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 99px; margin-left: 8px; vertical-align: 2px; }
.opt .arrow { color: var(--muted); }
.opt-group { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 2px; letter-spacing: .06em; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 30; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  main { padding-top: 40px; }
}
.dish-meta .big { color: var(--accent); font-weight: 600; }
.big-card { box-shadow: inset 0 0 0 1.5px var(--accent-soft), var(--shadow); }
