/* Cook Box - mobile-first (โทนเดียวกับ Fit Checklist แต่ใช้สีเขียว) */
:root {
  --bg: #f6f8f2; --card: #ffffff; --ink: #1c1f17; --muted: #646a5c; --line: #e2e6da;
  --primary: #2f6b3a; --primary-ink: #ffffff; --primary-soft: #e3f0e1;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #a16207; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --staple: #6b7280; --staple-soft: #eef0f2;
  --shadow: 0 1px 2px rgba(20, 40, 10, .06), 0 4px 14px rgba(20, 40, 10, .06);
  --radius: 16px; --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121510; --card: #1c2119; --ink: #f1f5ec; --muted: #a8b09f; --line: #313a2c;
    --primary: #7cc68a; --primary-ink: #0d1f10; --primary-soft: #23361f;
    --ok: #4ade80; --ok-soft: #12321f; --warn: #facc15; --warn-soft: #3a2f0d; --bad: #f87171; --bad-soft: #3d1a1a;
    --staple: #9ca3af; --staple-soft: #2a2f33; --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Sarabun', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  font-size: 17px; line-height: 1.55; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
body.no-nav { padding-bottom: 24px; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .center { text-align: center; }
.mt { margin-top: 14px; } .mt-s { margin-top: 6px; } .mb0 { margin-bottom: 0; } .hidden { display: none !important; }
.break { word-break: break-all; }
.lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.sec { font-size: 1.05rem; margin: 22px 2px 10px; display: flex; align-items: center; gap: 8px; }
.pre { white-space: pre-wrap; }

.topbar { position: sticky; top: 0; z-index: 20; background: var(--primary); color: var(--primary-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between; }
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: inherit; }
.topbar .who { font-size: .85rem; opacity: .95; }
.container { max-width: 680px; margin: 0 auto; padding: 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: .95rem; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .74rem; font-weight: 600; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav svg { width: 24px; height: 24px; }
svg.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
details.card > summary, details.picks > summary { cursor: pointer; font-weight: 700; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.card > summary { display: flex; justify-content: space-between; }
details.card > summary::after { content: '+'; color: var(--primary); font-size: 1.3rem; line-height: 1; }
details.card[open] > summary::after { content: '\2212'; }
details.card[open] > summary { margin-bottom: 10px; }
details.picks { margin-top: 12px; }
details.picks > summary { color: var(--primary); font-size: .95rem; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.grey { background: var(--line); color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.block { display: flex; width: 100%; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: .88rem; border-radius: 10px; }
.btn[disabled] { opacity: .6; }
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
.field { margin-bottom: 14px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.flash.ok { background: var(--ok-soft); color: var(--ok); } .flash.error { background: var(--bad-soft); color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }
.chip small { font-size: .7rem; color: var(--muted); font-weight: 600; }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip.on svg { width: 14px; height: 14px; }
.chip.sm { min-height: 26px; padding: 1px 10px; font-size: .8rem; cursor: default; }
.chip.have { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.miss { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

.rcard { display: block; color: inherit; }
.rcard .title { font-weight: 700; font-size: 1.05rem; }
.pct { font-weight: 700; color: var(--primary); font-size: .95rem; }
.fav { color: #d97706; margin-right: 4px; } .fav svg { fill: currentColor; width: 16px; height: 16px; }
.favbtn.on { color: #d97706; border-color: #d97706; } .favbtn.on svg { fill: currentColor; }
.subnav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-size: .9rem; font-weight: 600; }
.subnav a small { color: var(--muted); }
.subnav a.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.subnav a.active small { color: inherit; opacity: .8; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }

.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; align-items: baseline; gap: 8px; padding: 8px 0 8px 12px; border-top: 1px solid var(--line); border-left: 4px solid transparent; }
.ing li:first-child { border-top: 0; }
.ing .ing-name { flex: 1; font-weight: 600; }
.ing .ing-qty { color: var(--muted); font-size: .92rem; white-space: nowrap; text-align: right; }
.ing li.ing-sec { display: block; font-weight: 700; color: var(--primary); padding-left: 0; border-left: 0; margin-top: 6px; }
.ing li.have { border-left-color: var(--ok); }
.ing li.staple { border-left-color: var(--staple); }
.ing li.miss { border-left-color: var(--warn); background: var(--warn-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.legend i.lg { display: inline-block; width: 4px; height: 14px; margin-right: 5px; vertical-align: -2px; border-radius: 2px; }
.lg.have { background: var(--ok); } .lg.staple { background: var(--staple); } .lg.miss { background: var(--warn); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: st; }
.steps li.step { counter-increment: st; position: relative; padding: 8px 0 8px 40px; border-top: 1px solid var(--line); }
.steps li.step::before { content: counter(st); position: absolute; left: 0; top: 8px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.steps li.step-sec { font-weight: 700; color: var(--primary); padding: 10px 0 4px; }
.done-item { text-decoration: line-through; color: var(--muted); }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: .82rem; white-space: pre; }

.login-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
@media (min-width: 760px) {
  .bottom-nav { max-width: 680px; left: 50%; transform: translateX(-50%); border-radius: 18px 18px 0 0; border: 1px solid var(--line); }
}
.ing .ing-note { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
/* หมวดหมู่: ขึ้นบรรทัดใหม่แทนการเลื่อนแนวนอน (เลื่อนบนคอมด้วยเมาส์ไม่ได้) */
.subnav { flex-wrap: wrap; overflow-x: visible; padding-bottom: 12px; }
/* เลือกวัตถุดิบหลายอย่างในครั้งเดียว */
.chip.pick { position: relative; user-select: none; }
.chip.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chip.pick:has(input:checked) { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip.pick:has(input:checked) small { color: var(--primary-ink); opacity: .8; }
.chip.pick:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.pick-bar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; margin-top: 12px; }
.pick-bar .btn:disabled { opacity: .55; cursor: default; }
/* หัวข้อกลุ่มผลแนะนำ: ใช้ครบ N อย่าง / ใช้ N จาก M อย่าง */
.grp-head { font-size: .95rem; margin: 18px 4px 8px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
