:root {
  --bg: #f6f1ea; --card: #fffdf9; --ink: #2b2420; --mute: #7d7168; --line: #e6dccf;
  --brand: #b4532a; --brand-ink: #fff; --ok: #2f7d4f; --ok-bg: #e3f1e7; --warn: #a15c00; --warn-bg: #fbecd2;
  --hot: #b3261e; --hot-bg: #fbe3e0; --kid: #2b5fa8; --kid-bg: #e2ecf9; --tag: #efe7dc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412; --card: #221e1b; --ink: #f1e9e1; --mute: #a3978c; --line: #3a332e;
    --brand: #e0764a; --brand-ink: #1a1512; --ok: #7fd3a0; --ok-bg: #1d3527; --warn: #f0b860; --warn-bg: #3b2c12;
    --hot: #ff9a8f; --hot-bg: #40201d; --kid: #9cc2f5; --kid-bg: #1d2c42; --tag: #332c27;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", Roboto, "Noto Sans SC", sans-serif; }
a { color: inherit; text-decoration: none; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 8px 0; line-height: 1.3; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 16px 0 4px; }
small, .hint, time { color: var(--mute); font-size: 13px; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.top .brand { font-weight: 700; white-space: nowrap; }
.top nav { display: flex; align-items: center; gap: 14px; font-size: 14px; min-width: 0; }
.top form { margin: 0; }
.link { background: none; border: 0; padding: 0; color: inherit; font-size: 14px; white-space: nowrap; }

.strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip a { flex: 1 0 44px; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); }
.strip a b { font-size: 17px; }
.strip a.wide { flex: 0 0 auto; padding: 6px 12px; justify-content: center; }
.strip a.wide b { font-size: 14px; white-space: nowrap; }
.strip.ranges { padding-top: 0; }
.strip.ranges a.wide { flex: 1 1 0; padding: 9px 6px; }
.strip a.today small { color: var(--brand); font-weight: 600; }
.strip a.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.strip a.on small { color: inherit; }

.dayhead { display: flex; align-items: center; justify-content: space-between; }
.dayhead .nav { font-size: 28px; line-height: 1; padding: 4px 14px; color: var(--brand); }
.dayhead .nav.off { color: var(--line); }
.daylog { margin: 0; color: var(--mute); font-size: 13px; text-align: center; }

.meal { margin-top: 18px; scroll-margin-top: 60px; }
.meal h2 small { margin-left: 8px; font-weight: 400; }
.dishes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.dish { display: flex; gap: 12px; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.dish.pinned { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.thumb { flex: 0 0 80px; height: 80px; border-radius: 10px; overflow: hidden; background: var(--tag); display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-size: 30px; color: var(--mute); }
.body { flex: 1; min-width: 0; }
.name { display: block; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 99px; background: var(--tag); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.hot { background: var(--hot-bg); color: var(--hot); }
.tag.kid { background: var(--kid-bg); color: var(--kid); }
.tag.good { background: none; color: var(--ok); box-shadow: inset 0 0 0 1px currentColor; }
.tag.plain { background: none; color: var(--mute); padding-left: 0; }
.acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.acts form { margin: 0; }
/* 整张菜卡片（图、菜名、标签那一块）点哪里都进菜谱；下面一排按钮照常是按钮 */
.dish { position: relative; }
.dish .name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.dish .acts { position: relative; z-index: 1; }
.act { min-height: 34px; min-width: 34px; padding: 4px 8px; border-radius: 99px; border: 1px solid var(--line); background: none; font-size: 13px; white-space: nowrap; }
.act.sq { padding: 4px 6px; }
.act.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.empty { color: var(--mute); text-align: center; padding: 14px 0; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: none; font-weight: 400; color: var(--mute); }
.btn.danger { background: none; color: var(--hot); border-color: var(--hot); font-weight: 400; }
.meal > .btn { width: 100%; margin-top: 10px; border-style: dashed; }
.foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 28px; }
.foot .btn { flex: 1; }
.log { margin-top: 8px; font-size: 13px; color: var(--mute); }
.log p { margin: 4px 0; }
.err { color: var(--hot); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 14px; }
.login { margin-top: 12vh; display: grid; gap: 14px; }
.login h1 { text-align: center; }
.login { margin-top: 4vh; }
.login .card { display: grid; gap: 12px; }
.login h2 { font-size: 17px; margin: 0; }
.login .hint { margin: 0; }
.loginbox { border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px 12px; margin: 14px 0 0; min-width: 0; }
.loginbox legend { padding: 0 6px; color: var(--mute); font-size: 14px; }
.mform .check { display: flex; align-items: center; gap: 10px; font-size: 16px; padding: 8px 0; }
.mform .check input { width: 22px; height: 22px; accent-color: var(--brand); }
.loginbox:has([name=can_login][type=checkbox]:not(:checked)) .loginfields { display: none; }
.card.note { color: var(--ink); line-height: 1.6; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--mute); }
input:not([type=checkbox]):not([type=radio]) { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 16px; }
.search { display: flex; gap: 8px; margin: 8px 0 14px; }
.filters .search { margin-bottom: 6px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0; color: var(--mute); }
.pager .btn { flex: 0 0 auto; }
.foot form { margin: 0; flex: 1; display: flex; }
.top nav { overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a, .top nav button { white-space: nowrap; }
.filters .hint { margin: 10px 0 0; }
.filters { margin-bottom: 14px; }
.search input { flex: 1; }
.backlink { display: inline-block; padding: 6px 0; color: var(--brand); }

.hero { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; display: block; background: var(--tag); }
.hero.none { display: flex; align-items: center; justify-content: center; color: var(--mute); aspect-ratio: 4 / 1; }
.desc { color: var(--mute); margin: 8px 0 0; }
.ings { list-style: none; margin: 0; padding: 0; }
.ings li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ings li:last-child { border: 0; }
.ings b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ings em { font-style: normal; color: var(--mute); font-size: 13px; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin-bottom: 10px; font-size: 17px; line-height: 1.6; }
.stars { display: flex; gap: 8px; margin-bottom: 10px; }
.stars label { flex: 1; display: block; }
.stars input { position: absolute; opacity: 0; }
.stars span { display: flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); font-size: 18px; color: var(--ink); }
.stars input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.stars input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
#rate .btn { width: 100%; margin-top: 10px; }
.rlist { list-style: none; padding: 0; margin: 12px 0 0; font-size: 14px; }
.rlist li { padding: 4px 0; }

.shop .si { display: grid; grid-template-columns: 28px 1fr auto; column-gap: 6px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 16px; }
.shop .si:last-child { border: 0; }
.si input { width: 22px; height: 22px; accent-color: var(--brand); grid-row: span 2; }
.si b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.si small { grid-column: 2 / 4; overflow-wrap: anywhere; }
.si input:checked ~ .n, .si input:checked ~ b { text-decoration: line-through; color: var(--mute); }
.pantry { margin-top: 18px; }
.pantry summary { padding: 10px 0; color: var(--mute); }

.skipped { padding: 14px; border: 1px dashed var(--line); border-radius: 14px; text-align: center; color: var(--mute); }
.skipped p { margin: 0 0 10px; }
.skipped form { margin: 0; }
.cookbtn { width: 100%; margin-top: 14px; }
dialog { width: min(92vw, 520px); max-height: 88vh; overflow: auto; padding: 16px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--card); color: var(--ink); }
/* 从屏幕底部滑上来的弹层 */
dialog.sheet { width: 100%; max-width: 560px; max-height: 88dvh; margin: auto auto 0; padding: 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0;
  overscroll-behavior: contain; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { animation: fade-in .28s ease; }
.sheet .in { display: block; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); margin: 0; }
.sheet .in::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet .hint { margin: 14px 0 0; }
.sheet .row { margin-top: 16px; }
.sheet label { margin-top: 10px; }
.sheet .chips label, .sheet .seg label { margin-top: 0; }
.sheetlink { display: block; width: 100%; margin-top: 12px; padding: 8px; text-align: center; color: var(--mute); font-size: 14px; background: none; border: 0; }
.sheetlink.danger { color: var(--hot); }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-width: 1px; border-radius: 22px; } }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { margin: 0 0 6px; font-size: 17px; outline: 0; }
dialog input:not([type=checkbox]) { margin-top: 10px; }
dialog .row { display: flex; gap: 10px; }
dialog .row .btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; }
.chips label { display: block; }
.chips input { position: absolute; opacity: 0; }
.chips span { display: inline-flex; align-items: center; min-height: 38px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 15px; color: var(--ink); }
.chips input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chips input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
#tap { margin: 0; }
.rlist li { border-top: 1px solid var(--line); padding: 8px 0; }


/* 手感：按下有反馈，提交时转圈，换页和局部更新有过渡 */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
::view-transition-group(*) { animation-duration: .25s; }
.act, .btn, .chips span, .seg span, .stars span, .who, .member, .strip a { transition: transform .12s ease, background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.act:active, .btn:active, .who:active, .strip a:active, .chips label:active span, .seg label:active span, .stars label:active span { transform: scale(.94); }
.member:active { transform: scale(.98); }
.busy { pointer-events: none; opacity: .55; position: relative; color: transparent !important; }
.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--mute); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .act.on.busy::after { border-color: var(--brand-ink); border-top-color: transparent; }

/* 每餐的人 */
.mealhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mealhead h2 { margin: 0; white-space: nowrap; }
.who { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; min-width: 0; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); font-size: 14px; color: var(--mute); }
.who b { color: var(--ink); white-space: nowrap; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who i { font-style: normal; color: var(--brand); }
span.who { border: 0; background: none; padding: 0; }
.chips.big span { min-height: 46px; padding: 6px 16px; font-size: 17px; }
.chips.big input:checked + span::before { content: "✓"; margin-right: 6px; }
.guestchips:empty { display: none; }
.addguest { margin-top: 12px; border: 1px dashed var(--line); border-radius: 14px; padding: 0 12px; }
.addguest[open] { padding-bottom: 12px; border-style: solid; }
.addguest summary { padding: 12px 0; color: var(--brand); font-weight: 600; list-style: none; cursor: pointer; }
.addguest summary::-webkit-details-marker { display: none; }
.addguest input[type=text] { width: 100%; }
.addguest .seg.wide { margin: 10px 0 0; }
.sheetlinks { display: flex; justify-content: center; gap: 22px; margin: 12px 0 0; font-size: 14px; }
.sheetlinks a { color: var(--mute); padding: 8px 0; }
.addguest .btn { width: 100%; margin-top: 12px; }
.chips.big span small { margin-left: 6px; font-size: 12px; color: inherit; opacity: .8; }
.dish.off { opacity: .55; border-style: dashed; }
.dish.off .name { text-decoration: line-through; }
.sched { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
.sched th { font-size: 13px; font-weight: 400; color: var(--mute); padding: 2px 0; }
.sched th:first-child { width: 50px; }
.sched th button { min-height: 40px; padding: 0 4px; border: 0; background: none; color: var(--brand); font-size: 14px; white-space: nowrap; }
.sched td { padding: 3px 2px; }
.sched label { display: block; margin: 0; }
.sched input { position: absolute; opacity: 0; }
.sched span { display: flex; align-items: center; justify-content: center; height: 40px; border-radius: 10px; border: 1px solid var(--line); color: transparent;
  transition: background-color .15s ease, border-color .15s ease; }
.sched span::before { content: "✓"; }
.sched input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.hint.small { font-size: 12px; margin-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { display: block; flex: 1; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 4px 12px; font-size: 15px; color: var(--ink); white-space: nowrap; }
.seg input:checked + span { background: var(--brand); color: var(--brand-ink); }
.seg.wide { display: flex; margin-top: 12px; }
.tag.alg { white-space: normal; display: inline-block; margin-bottom: 4px; }

/* 家人资料 */
h2.sec { margin: 22px 0 8px; font-size: 15px; color: var(--mute); font-weight: 600; }
.members { display: grid; gap: 10px; }
.member { display: grid; gap: 4px; width: 100%; padding: 12px 14px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.member .mh { display: flex; align-items: center; gap: 8px; }
.member .mh b { font-size: 17px; }
.member .mh i { margin-left: auto; font-style: normal; color: var(--mute); font-size: 20px; }
.member .tag { white-space: normal; }
.addm { width: 100%; margin-top: 10px; border-style: dashed; }
.bykind label { display: none; }
.mform:has([name=kind][value=elder]:checked) .bykind .k-elder,
.mform:has([name=kind][value=adult]:checked) .bykind .k-adult,
.mform:has([name=kind][value=child]:checked) .bykind .k-child,
.addguest:has([type=radio][value=elder]:checked) .bykind .k-elder,
.addguest:has([type=radio][value=adult]:checked) .bykind .k-adult,
.addguest:has([type=radio][value=child]:checked) .bykind .k-child,
.bykind label:has(input:checked) { display: block; }
.chips.alg input:checked + span { background: var(--hot); border-color: var(--hot); color: #fff; }

/* 评分里的"谁爱吃" */
.wholike { display: grid; gap: 8px; margin-top: 8px; }
.wholike .chips { margin: 0; align-items: center; flex-wrap: nowrap; }
.wholike b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wholike .no input:checked + span { background: var(--mute); border-color: var(--mute); color: var(--bg); }

/* 做菜卡片：全屏，一次一步，字尽量大 */
.cook { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom)); }
.cook .bar { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--mute); }
.cook .bar .ttl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.cook progress { width: 100%; height: 6px; margin: 8px 0 0; accent-color: var(--brand); }
.cook .stage { flex: 1; min-height: 0; position: relative; margin: 8px 0; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.cook .card { position: absolute; inset: 0; margin: 0; display: none; flex-direction: column; padding: 12px 16px; }
.cook .card.on { display: flex; }
.cook .card.fwd { animation: card-fwd .22s cubic-bezier(.2, .8, .2, 1); }
.cook .card.back { animation: card-back .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes card-fwd { from { transform: translateX(28%); opacity: 0; } }
@keyframes card-back { from { transform: translateX(-28%); opacity: 0; } }
.cook .card h2 { color: var(--brand); font-size: 16px; margin: 0 0 6px; }
.cook .fit { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.cook .fit > * { margin: auto 0; width: 100%; }
.cook .fit p { font-size: 30px; line-height: 1.32; font-weight: 600; letter-spacing: .01em; }
.cook.en .fit p { line-height: 1.22; font-weight: 500; }
.cook .fit .ings { font-size: 19px; }
.cook .fit .ings li { padding: .28em 0; }
.cook .fit .ings em { font-size: .7em; }
.cook .taphint { margin: 6px 0 0; text-align: center; font-size: 13px; color: var(--mute); }
.cook .ctl { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px; }
.cook .ctl .btn { min-height: 56px; font-size: 18px; padding: 8px 6px; white-space: nowrap; }
.cook .rate { border: 1px solid var(--line); background: none; border-radius: 99px; padding: 6px 12px; font-size: 14px; color: var(--ink); white-space: nowrap; }
.cook .auto { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--mute); white-space: nowrap; }
.cook .auto input { width: 20px; height: 20px; accent-color: var(--brand); }

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; transition: none !important; }
}

/* 样板菜（/sample） */
.sgrid { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.sgrid a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; color: inherit; text-decoration: none; }
.sgrid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--tag); }
.sgrid b { display: block; padding: 7px 10px 0; line-height: 1.35; overflow-wrap: anywhere; }
.sgrid small { display: block; padding: 0 10px 8px; }
.ings.rich small { display: block; font-size: 13px; color: var(--mute); }
.ings.rich span { min-width: 0; }
.notes { margin: 0; padding-left: 20px; }
.notes li { margin-bottom: 8px; line-height: 1.6; }
.remind p { margin: 0 0 10px; line-height: 1.6; }
.cook .card .fit ul.notes { text-align: left; }
