:root {
  --bg: #f6f1e7; --card: #fffdf8; --ink: #23201b; --soft: #6b655a; --line: #e3dccd; --accent: #c8502d; --on-accent: #fffdf8;
  --protein: #b8433a; --produce: #3f7d45; --dairy: #2f6fa3; --grain: #9a6a1f; --spice: #b08a00; --pantry: #7a4f9a; --other: #6b655a;
  --protein-bg: #f7dedb; --produce-bg: #dcecd9; --dairy-bg: #d9e7f3; --grain-bg: #f1e3c8; --spice-bg: #f6ecb8; --pantry-bg: #e8dcf0; --other-bg: #e9e5dc;
  --tab: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512; --card: #211e1a; --ink: #f1ebdf; --soft: #a59d8e; --line: #36322b; --accent: #ef7a55; --on-accent: #1b140f;
    --protein: #f0958c; --produce: #8ccb90; --dairy: #8cc0ea; --grain: #e2b76a; --spice: #ead36a; --pantry: #c9a5e3; --other: #b3ab9c;
    --protein-bg: #452421; --produce-bg: #213a24; --dairy-bg: #1d3447; --grain-bg: #3d2f14; --spice-bg: #3b3410; --pantry-bg: #33243f; --other-bg: #2d2a25;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--tab) + env(safe-area-inset-bottom) + 24px); }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.3px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .8px; color: var(--soft); margin: 28px 0 8px; font-weight: 700; }
p { margin: 0 0 8px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sub { color: var(--soft); font-size: 15px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: block; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.btn { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 700; min-height: 48px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn.small { padding: 8px 12px; min-height: 40px; font-size: 15px; }
.btn.wide { width: 100%; }
input[type=text], input[type=password], input[type=search], select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; min-height: 46px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 5; }
#tabs a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--soft); font-weight: 600; }
#tabs a.on { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
body.cooking #tabs { display: none; }

/* today */
.datenav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.datenav button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; width: 44px; height: 44px; font-size: 20px; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.meter b { font-size: 24px; }
.meter .bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter .bar i { display: block; height: 100%; background: var(--produce); border-radius: 4px; }
.meter .bar i.over { background: var(--accent); }
.macros { display: flex; gap: 14px; flex-wrap: wrap; color: var(--soft); font-size: 14px; margin-top: 6px; }
.macros b { color: var(--ink); }
.slot { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--accent); font-weight: 700; }
.meal b { font-size: 18px; display: block; }
.chev { color: var(--soft); font-size: 22px; }
.note { background: var(--spice-bg); border-radius: 10px; padding: 8px 10px; font-size: 15px; margin-top: 8px; }

/* category colors */
.c-protein { --c: var(--protein); --cb: var(--protein-bg); } .c-produce { --c: var(--produce); --cb: var(--produce-bg); }
.c-dairy { --c: var(--dairy); --cb: var(--dairy-bg); } .c-grain { --c: var(--grain); --cb: var(--grain-bg); }
.c-spice { --c: var(--spice); --cb: var(--spice-bg); } .c-pantry { --c: var(--pantry); --cb: var(--pantry-bg); }
.c-other { --c: var(--other); --cb: var(--other-bg); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--soft); margin: 6px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.cat-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .6px; margin: 14px 0 4px; }

/* checklists */
.check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; border: 2px solid var(--c, var(--soft)); border-radius: 8px; flex: none; margin: 1px 0 0; background: transparent; display: grid; place-content: center; }
.check input:checked { background: var(--c, var(--accent)); }
.check input:checked::after { content: ""; width: 7px; height: 13px; border: solid var(--card); border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input:checked ~ .grow { opacity: .45; text-decoration: line-through; }
.qty { font-weight: 700; white-space: nowrap; }
.inote { display: block; color: var(--soft); font-size: 14px; }

/* steps */
.step { counter-increment: step; }
.step .num::before { content: counter(step); }
.steps { counter-reset: step; }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--line); font-size: 14px; font-weight: 700; display: grid; place-content: center; flex: none; margin-top: 1px; }
.ing { background: var(--cb); color: var(--c); border-radius: 6px; padding: 1px 6px; font-weight: 600; white-space: nowrap; }
.ing small { font-weight: 500; opacity: .85; }
.act { background: none; border: 0; padding: 0 1px; color: var(--accent); font-weight: 800; border-bottom: 2px dashed var(--accent); border-radius: 0; line-height: 1.2; }
.time { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-weight: 600; white-space: nowrap; }
.time::before { content: "⏱ "; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--card); border: 0; padding: 8px 14px; min-height: 40px; font-weight: 600; }
.seg button.on { background: var(--ink); color: var(--bg); }
.sticky { position: sticky; bottom: calc(var(--tab) + env(safe-area-inset-bottom) + 12px); margin-top: 20px; }

/* cook mode */
.cook { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; }
.cook .top { display: flex; align-items: center; gap: 10px; }
.cook .top button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; min-width: 44px; height: 44px; padding: 0 12px; }
.prog { display: flex; gap: 4px; margin: 14px 0; }
.prog i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.prog i.done { background: var(--accent); }
.cook .big { font-size: 25px; line-height: 1.5; flex: 1; padding: 8px 0 20px; }
.cook .big .act { border-bottom-width: 3px; }
.cook .nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding-bottom: env(safe-area-inset-bottom); }
.cook .ask { margin-bottom: 10px; }

/* sheet */
#sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#sheet[hidden] { display: none; }
.panel { background: var(--card); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); }
.panel h3 { font-size: 24px; margin: 0 0 4px; color: var(--accent); }
.panel ol { padding-left: 22px; margin: 10px 0; }
.panel li { margin-bottom: 6px; }
.cue { background: var(--produce-bg); color: var(--produce); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.anim { width: 100%; max-width: 280px; display: block; margin: 4px auto 10px; }
.anim * { vector-effect: non-scaling-stroke; }
.x { float: right; background: var(--bg); border: 1px solid var(--line); border-radius: 50%; width: 40px; height: 40px; font-size: 18px; }

/* chat */
.chat { display: flex; flex-direction: column; height: 76dvh; }
.msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; font-size: 19px; }
.msg.err { align-self: center; color: var(--accent); font-size: 15px; }
.msg img { max-width: 180px; border-radius: 10px; display: block; margin-bottom: 6px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; height: 48px; }
.icon { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; width: 48px; height: 48px; flex: none; font-size: 20px; }
.icon.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.thumb { height: 56px; border-radius: 8px; margin-bottom: 6px; }

/* timer */
#timer { position: fixed; top: calc(env(safe-area-inset-top) + 10px); right: 12px; z-index: 15; background: var(--ink); color: var(--bg); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-variant-numeric: tabular-nums; border: 0; }
#timer.ring { background: var(--accent); animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

/* technique animations */
@keyframes chop { 0%, 100% { transform: translateY(-26px); } 45%, 55% { transform: translateY(0); } }
@keyframes rock { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(7deg); } }
@keyframes cutin { 0%, 12% { opacity: 0; } 20%, 100% { opacity: 1; } }
@keyframes flame { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.6); } }
@keyframes toss { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px) rotate(40deg); } }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stir { 0%, 100% { transform: rotate(-22deg); } 50% { transform: rotate(22deg); } }
@keyframes glow { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.a-chop { animation: chop 1s ease-in-out infinite; }
.a-rock { animation: rock .7s ease-in-out infinite; transform-origin: 30px 100px; }
.a-cut { animation: cutin 6s linear infinite; }
.a-flame { animation: flame .5s ease-in-out infinite; transform-origin: center bottom; transform-box: fill-box; }
.a-toss { animation: toss 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.a-rise { animation: rise 1.8s ease-in infinite; }
.a-spin { animation: spin 6s linear infinite; transform-origin: 100px 70px; }
.a-stir { animation: stir .8s ease-in-out infinite; transform-origin: 100px 20px; }
.a-glow { animation: glow 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .anim * { animation: none !important; } #timer.ring { animation: none; } }

/* steps tick by their number, not a second checkbox */
.check input[hidden] { display: none; }
.step input:checked + .num { background: var(--accent); color: var(--on-accent); }
