:root{
  --bg:#f7f3ec; --surface:#ffffff; --surface2:#efe9df; --ink:#2a2622; --muted:#857b70; --line:#e4dccf;
  --primary:#2f7d6d; --primary-ink:#ffffff; --accent:#c0587e; --gold:#d39a2c; --danger:#c2412d;
  --shadow:0 1px 2px rgba(60,40,20,.06),0 4px 14px rgba(60,40,20,.06);
  --radius:16px; --nav-h:64px;
  --safe-b:env(safe-area-inset-bottom,0px); --safe-t:env(safe-area-inset-top,0px);
  color-scheme:light;
}
@media (prefers-color-scheme:dark){
  :root{--bg:#161412; --surface:#211e1b; --surface2:#2b2723; --ink:#f2ede6; --muted:#a39889; --line:#36312b;
    --primary:#4fae99; --primary-ink:#0f1513; --accent:#e07ea2; --gold:#e5b04a; --danger:#e8705c;
    --shadow:0 1px 2px rgba(0,0,0,.3); color-scheme:dark;}
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,system-ui,sans-serif;overflow-x:hidden}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
h1,h2,h3{margin:0;line-height:1.2}
a{color:var(--primary)}

/* ---------- header ---------- */
#hdr{position:sticky;top:0;z-index:20;background:var(--bg);padding:calc(10px + var(--safe-t)) 16px 8px;display:flex;align-items:center;gap:8px;min-height:56px}
#hdr h1{font-size:24px;font-weight:750;letter-spacing:-.01em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.iconbtn{border:0;background:transparent;width:40px;height:40px;border-radius:12px;display:grid;place-items:center;font-size:20px;flex:none}
.iconbtn:active{background:var(--surface2)}
.iconbtn svg{width:22px;height:22px}
.sync{width:10px;height:10px;border-radius:50%;background:var(--muted);flex:none}
.sync.ok{background:#3aa66b}.sync.wait{background:var(--gold)}

main{padding:0 16px calc(var(--nav-h) + var(--safe-b) + 90px);max-width:720px;margin:0 auto}

/* ---------- bottom nav ---------- */
#nav{position:fixed;left:0;right:0;bottom:0;z-index:30;background:var(--surface);border-top:1px solid var(--line);display:flex;padding-bottom:var(--safe-b)}
#nav button{flex:1;border:0;background:none;height:var(--nav-h);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-size:12px;color:var(--muted);font-weight:600}
#nav button svg{width:24px;height:24px}
#nav button.on{color:var(--primary)}

/* ---------- common ---------- */
.card{background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow)}
.btn{border:0;border-radius:12px;padding:12px 16px;font-weight:650;background:var(--surface2);min-height:46px}
.btn.primary{background:var(--primary);color:var(--primary-ink)}
.btn.danger{background:transparent;color:var(--danger)}
.btn.block{width:100%}
.btn:disabled{opacity:.5}
.row{display:flex;gap:8px;align-items:center}
.muted{color:var(--muted)}
.small{font-size:13px}
.empty{text-align:center;color:var(--muted);padding:40px 16px}
.empty .big{font-size:42px;margin-bottom:8px}
.chips{display:flex;gap:8px;overflow-x:auto;padding:4px 0 10px;scrollbar-width:none;margin:0 -16px;padding-left:16px;padding-right:16px}
.chips::-webkit-scrollbar{display:none}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:7px 14px;white-space:nowrap;font-weight:600;font-size:14px}
.chip.on{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.fab{position:fixed;right:18px;bottom:calc(var(--nav-h) + var(--safe-b) + 16px);z-index:25;width:58px;height:58px;border-radius:50%;border:0;background:var(--primary);color:var(--primary-ink);font-size:30px;box-shadow:0 6px 18px rgba(0,0,0,.2);display:grid;place-items:center}
.sectiontitle{font-size:13px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:18px 4px 8px;display:flex;align-items:center;gap:8px}
.sectiontitle .grow{flex:1}
.linkbtn{border:0;background:none;color:var(--primary);font-weight:700;font-size:13px;text-transform:none;letter-spacing:0;padding:4px}

/* ---------- forms ---------- */
label.f{display:block;margin-bottom:12px}
label.f>span{display:block;font-size:13px;font-weight:650;color:var(--muted);margin:0 2px 5px}
.in{width:100%;border:1px solid var(--line);background:var(--surface);border-radius:12px;padding:12px 14px;min-height:46px;outline:none}
.in:focus{border-color:var(--primary)}
textarea.in{resize:vertical;min-height:90px;line-height:1.5}
.seg{display:flex;background:var(--surface2);border-radius:12px;padding:3px;gap:3px}
.seg label{flex:1;min-width:0}
.seg input{display:none}
.seg span{display:block;text-align:center;padding:9px 6px;border-radius:9px;font-weight:650;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.seg input:checked+span{background:var(--surface);box-shadow:var(--shadow)}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.err{color:var(--danger);font-size:14px;margin:6px 2px}

/* ---------- lists ---------- */
.addbar{display:flex;gap:8px;margin:2px 0 6px;position:sticky;top:calc(56px + var(--safe-t));z-index:10;background:var(--bg);padding:6px 0}
.addbar .in{flex:1}
.addbar .btn{padding:0 18px}
.group{background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.item{display:flex;align-items:center;gap:12px;padding:0 6px 0 14px;min-height:54px;border-top:1px solid var(--line);user-select:none}
.item:first-child{border-top:0}
.item:active{background:var(--surface2)}
.check{width:26px;height:26px;border-radius:50%;border:2px solid var(--line);flex:none;display:grid;place-items:center;transition:.15s}
.item.done .check{background:var(--primary);border-color:var(--primary)}
.item.done .check::after{content:"";width:7px;height:12px;border:solid var(--primary-ink);border-width:0 3px 3px 0;transform:rotate(45deg) translate(-1px,-1px)}
.item .txt{flex:1;min-width:0;padding:10px 0;word-break:break-word}
.item .txt small{display:block;color:var(--muted);font-size:13px}
.item.done .txt{color:var(--muted);text-decoration:line-through}
.who{width:22px;height:22px;border-radius:50%;color:#fff;font-size:11px;font-weight:800;display:grid;place-items:center;flex:none}
.more{border:0;background:none;width:38px;height:44px;border-radius:10px;color:var(--muted);font-size:20px;flex:none}
.listcard{display:flex;align-items:center;gap:14px;padding:14px 16px;margin-bottom:10px;width:100%;border:0;text-align:left}
.listcard .ico{font-size:28px;width:44px;height:44px;border-radius:12px;background:var(--surface2);display:grid;place-items:center}
.listcard .nm{font-weight:700;font-size:17px}
.listcard .grow{flex:1;min-width:0}
.count{background:var(--primary);color:var(--primary-ink);border-radius:999px;min-width:28px;padding:3px 9px;text-align:center;font-weight:750;font-size:14px}
.count.zero{background:var(--surface2);color:var(--muted)}
.emojis{display:grid;grid-template-columns:repeat(8,1fr);gap:6px}
.emojis label input{display:none}
.emojis label span{display:grid;place-items:center;height:40px;border-radius:10px;font-size:22px;background:var(--surface2)}
.emojis label input:checked+span{outline:2px solid var(--primary);background:var(--surface)}

/* ---------- calendar ---------- */
.calhead{display:flex;align-items:center;gap:4px;margin:4px 0 10px}
.calhead h2{flex:1;font-size:20px}
.calgrid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;padding:8px;touch-action:pan-y}
.calgrid .wd{text-align:center;font-size:12px;font-weight:700;color:var(--muted);padding:2px 0 6px}
.day{border:0;background:none;border-radius:12px;height:50px;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding-top:5px;gap:4px;font-weight:600}
.day.out{color:var(--muted);opacity:.45}
.day.today .n{background:var(--accent);color:#fff}
.day.sel{background:var(--surface2)}
.day .n{width:28px;height:28px;border-radius:50%;display:grid;place-items:center;font-size:15px}
.dots{display:flex;gap:3px;height:6px}
.dots i{width:6px;height:6px;border-radius:50%}
.ev{display:flex;gap:12px;align-items:stretch;padding:12px 14px;border-top:1px solid var(--line);width:100%;border-left:0;border-right:0;border-bottom:0;background:none;text-align:left}
.ev:first-child{border-top:0}
.ev .bar{width:4px;border-radius:4px;flex:none}
.ev .tm{width:64px;flex:none;font-size:14px;color:var(--muted);font-weight:600;padding-top:1px}
.ev .tt{font-weight:650}
.ev .sub{font-size:13px;color:var(--muted)}
.dayhead{font-weight:700;margin:14px 4px 6px;font-size:15px}

/* ---------- recipes ---------- */
.search{margin:2px 0 6px}
.rcard{display:flex;align-items:center;gap:12px;padding:14px 16px;margin-bottom:10px;width:100%;border:0;text-align:left}
.rcard .grow{flex:1;min-width:0}
.rcard .nm{font-weight:700;font-size:17px}
.rcard .ico{font-size:26px;width:46px;height:46px;border-radius:12px;background:var(--surface2);display:grid;place-items:center;flex:none}
.star{border:0;background:none;font-size:22px;width:40px;height:40px;color:var(--gold)}
.rhead h2{font-size:26px;margin:4px 0 8px}
.meta{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px}
.meta span{background:var(--surface2);border-radius:999px;padding:5px 11px;font-size:13px;font-weight:650}
.actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:6px}
.ing{display:flex;gap:12px;align-items:flex-start;padding:11px 14px;border-top:1px solid var(--line);cursor:pointer}
.ing:first-child{border-top:0}
.ing.done{color:var(--muted);text-decoration:line-through}
.ing.hdr{font-weight:750;cursor:default;background:var(--surface2)}
.ing .check{width:22px;height:22px;margin-top:1px}
.ing.done .check{background:var(--primary);border-color:var(--primary)}
.steps{counter-reset:s;padding:0;margin:0;list-style:none}
.steps li{counter-increment:s;display:flex;gap:12px;padding:12px 14px;border-top:1px solid var(--line);cursor:pointer}
.steps li:first-child{border-top:0}
.steps li::before{content:counter(s);flex:none;width:26px;height:26px;border-radius:50%;background:var(--surface2);display:grid;place-items:center;font-weight:750;font-size:14px}
.steps li.cur{background:color-mix(in srgb,var(--primary) 12%,transparent)}
.steps li.cur::before{background:var(--primary);color:var(--primary-ink)}
.notes{padding:14px;white-space:pre-wrap}

/* ---------- sheet ---------- */
#sheetwrap{position:fixed;inset:0;z-index:50;display:none}
#sheetwrap.open{display:block}
#scrim{position:absolute;inset:0;background:rgba(0,0,0,.4);animation:fade .2s}
#sheet{position:absolute;left:0;right:0;bottom:0;max-height:92vh;overflow-y:auto;background:var(--bg);border-radius:22px 22px 0 0;padding:8px 16px calc(20px + var(--safe-b));animation:up .22s ease-out;max-width:720px;margin:0 auto;overscroll-behavior:contain}
#sheet .grab{width:40px;height:5px;border-radius:5px;background:var(--line);margin:4px auto 12px}
#sheet h2{font-size:21px;margin-bottom:14px}
.sheetbtns{display:flex;gap:8px;margin-top:16px}
.sheetbtns .btn{flex:1}
@keyframes up{from{transform:translateY(40px);opacity:0}}
@keyframes fade{from{opacity:0}}
.pick{display:flex;align-items:center;gap:12px;padding:10px 14px;border-top:1px solid var(--line)}
.pick:first-child{border-top:0}
.pick input{width:22px;height:22px;accent-color:var(--primary);flex:none}
.swatches{display:flex;gap:10px;flex-wrap:wrap}
.swatches input{display:none}
.swatches span{display:block;width:36px;height:36px;border-radius:50%}
.swatches input:checked+span{outline:3px solid var(--ink);outline-offset:2px}
.code{font-size:34px;font-weight:800;letter-spacing:.18em;text-align:center;padding:16px;font-family:ui-monospace,Menlo,Consolas,monospace}

/* ---------- auth ---------- */
.auth{max-width:420px;margin:0 auto;padding:calc(48px + var(--safe-t)) 20px 40px}
.logo{width:84px;height:84px;border-radius:24px;margin:0 auto 14px;display:block}
.auth h1{text-align:center;font-size:30px;margin-bottom:4px}
.auth .tag{text-align:center;color:var(--muted);margin-bottom:28px}
.auth .card{padding:18px;margin-bottom:14px}
.auth h2{font-size:18px;margin-bottom:12px}
.switch{text-align:center;margin-top:12px}
.switch button{border:0;background:none;color:var(--primary);font-weight:700}

#toast{position:fixed;left:50%;bottom:calc(var(--nav-h) + var(--safe-b) + 20px);transform:translateX(-50%);background:var(--ink);color:var(--bg);padding:11px 18px;border-radius:12px;font-weight:600;font-size:14px;z-index:60;opacity:0;pointer-events:none;transition:opacity .2s;max-width:calc(100vw - 32px);text-align:center}
#toast.show{opacity:1}
.splash{display:grid;place-items:center;height:100vh;color:var(--muted)}
