:root{
  --bg:#f4f5f2; --surface:#fff; --surface2:#eef0ec; --text:#1b1f1c; --muted:#6b736d; --line:#e2e5df;
  --accent:#1f7a5c; --accent-ink:#fff; --accent-soft:#dff0e8; --danger:#c8372d; --danger-soft:#fbe6e3;
  --star:#e0a100; --shadow:0 8px 30px rgba(20,30,25,.12);
  --r:18px; --tap:56px;
  --font:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Arial,sans-serif;
}
:root[data-theme="dark"]{
  --bg:#101412; --surface:#1a201d; --surface2:#242b27; --text:#eef2ee; --muted:#93a097; --line:#2b332e;
  --accent:#3fbf93; --accent-ink:#06261b; --accent-soft:#1c3a2e; --danger:#ff7a6e; --danger-soft:#3a1f1c;
  --star:#f2c14b; --shadow:0 8px 30px rgba(0,0,0,.5);
}
@media (prefers-color-scheme:dark){
  :root[data-theme="auto"]{
    --bg:#101412; --surface:#1a201d; --surface2:#242b27; --text:#eef2ee; --muted:#93a097; --line:#2b332e;
    --accent:#3fbf93; --accent-ink:#06261b; --accent-soft:#1c3a2e; --danger:#ff7a6e; --danger-soft:#3a1f1c;
    --star:#f2c14b; --shadow:0 8px 30px rgba(0,0,0,.5);
  }
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--bg);color:var(--text);font-family:var(--font);font-size:17px;-webkit-text-size-adjust:100%}
body{display:flex;justify-content:center}
button{font:inherit;color:inherit;background:none;border:0;padding:0;cursor:pointer}
input,select{font:inherit;color:var(--text)}
svg{width:24px;height:24px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
#app{width:100%;max-width:520px;height:100dvh;display:flex;flex-direction:column;position:relative;background:var(--bg);overflow:hidden}
@media(min-width:560px){#app{border-left:1px solid var(--line);border-right:1px solid var(--line)}}

/* header */
.hdr{padding:calc(env(safe-area-inset-top) + 14px) 18px 8px;display:flex;align-items:center;gap:10px}
.hdr h1{font-size:30px;line-height:1.1;margin:0;letter-spacing:-.02em;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ibtn{width:46px;height:46px;border-radius:50%;display:grid;place-items:center;background:var(--surface);border:1px solid var(--line)}
.ibtn:active{background:var(--surface2)}
.avatar{width:46px;height:46px;border-radius:50%;background:var(--accent);color:var(--accent-ink);font-weight:700;display:grid;place-items:center}
.back{display:flex;align-items:center;gap:2px;color:var(--accent);font-weight:600;height:46px;padding-right:8px}
.sub{padding:0 18px 6px;color:var(--muted);font-size:15px;display:flex;align-items:center;gap:10px}
.bar{flex:1;height:8px;background:var(--surface2);border-radius:8px;overflow:hidden}
.bar i{display:block;height:100%;background:var(--accent);border-radius:8px;transition:width .3s}

/* scroll area */
.main{flex:1;overflow-y:auto;padding:6px 14px 120px;-webkit-overflow-scrolling:touch}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r)}

/* add box */
.addwrap{position:relative;margin:6px 0 10px}
.addbox{display:flex;align-items:center;gap:10px;height:var(--tap);padding:0 16px;background:var(--surface);border:2px solid var(--line);border-radius:var(--r)}
.addbox:focus-within{border-color:var(--accent)}
.addbox input{flex:1;border:0;outline:0;background:none;font-size:18px;min-width:0}
.addbox svg{color:var(--muted)}
.sugg{position:absolute;left:0;right:0;top:calc(var(--tap) + 6px);z-index:20;box-shadow:var(--shadow);overflow:hidden}
.sugg button{display:flex;width:100%;align-items:center;gap:12px;min-height:56px;padding:6px 16px;text-align:left;border-bottom:1px solid var(--line)}
.sugg button:last-child{border-bottom:0}
.sugg button:active{background:var(--surface2)}
.sugg .t{flex:1;min-width:0}.sugg .t small{display:block;color:var(--muted);font-size:13px}
.sugg .new{color:var(--accent);font-weight:600}
.chiprow{display:flex;gap:8px;overflow-x:auto;padding:2px 0 10px;scrollbar-width:none}
.chiprow::-webkit-scrollbar{display:none}
.allchips{display:flex;flex-wrap:wrap;gap:8px;max-height:280px;overflow-y:auto;overscroll-behavior:contain;padding:12px;background:var(--surface);border:1px solid var(--line);border-radius:var(--r);-webkit-overflow-scrolling:touch}
.rowlabel{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:6px 4px 6px}
.chip{flex:none;display:flex;align-items:center;gap:6px;height:44px;padding:0 16px;border-radius:30px;background:var(--surface);border:1px solid var(--line);font-size:16px;white-space:nowrap}
.chip:active{background:var(--surface2)}
.chip.on{background:var(--accent-soft);border-color:transparent;color:var(--accent)}
.chip svg{width:18px;height:18px}
.chip.act{background:var(--accent);color:var(--accent-ink);border-color:transparent}

/* items */
.grp{margin:14px 4px 6px;font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;display:flex;justify-content:space-between}
.list{overflow:hidden}
.item{display:flex;align-items:center;min-height:64px;border-bottom:1px solid var(--line)}
.item:last-child{border-bottom:0}
.item .main-hit{flex:1;display:flex;align-items:center;gap:14px;padding:8px 6px 8px 16px;text-align:left;min-height:64px;min-width:0}
.check{width:32px;height:32px;border-radius:50%;border:2.5px solid #b5bcb6;display:grid;place-items:center;flex:none;transition:.15s}
.check svg{width:18px;height:18px;stroke-width:3.2;stroke:var(--accent-ink);opacity:0}
.item.done .check{background:var(--accent);border-color:var(--accent)}
.item.done .check svg{opacity:1}
.item.done .nm{text-decoration:line-through;color:var(--muted)}
.nm{font-size:18px;font-weight:500;overflow-wrap:anywhere}
.meta{font-size:13px;color:var(--muted);margin-top:1px}
.qty{min-width:56px;height:44px;margin-right:8px;padding:0 12px;border-radius:12px;background:var(--surface2);display:flex;align-items:center;justify-content:center;gap:4px;color:var(--muted);font-size:15px;font-weight:600}
.qty:active{background:var(--line)}
.item.done .qty{background:transparent}
.star{color:var(--star)}.star svg{fill:var(--star);stroke:var(--star);width:14px;height:14px}
.donehdr{display:flex;align-items:center;justify-content:space-between;margin:22px 4px 8px}
.donehdr button.tg{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;height:44px}
.link{color:var(--accent);font-weight:600;font-size:15px;height:44px;padding:0 6px}
.empty{text-align:center;color:var(--muted);padding:44px 20px}
.empty b{display:block;color:var(--text);font-size:20px;margin-bottom:6px}

/* tab bar */
.tabs{position:absolute;left:0;right:0;bottom:0;display:flex;background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid var(--line);padding:6px 10px calc(env(safe-area-inset-bottom) + 6px);z-index:30}
.tab{flex:1;height:60px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-radius:14px;color:var(--muted);font-size:12.5px;font-weight:600}
.tab.on{color:var(--accent)}
.tab .badge{position:absolute;margin:-30px -34px 0 0;min-width:20px;height:20px;border-radius:10px;background:var(--accent);color:var(--accent-ink);font-size:12px;display:grid;place-items:center;padding:0 5px}
.tab.on .badge{background:var(--accent)}

/* stores */
.stores{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:8px}
.store{padding:16px;text-align:left;min-height:120px;display:flex;flex-direction:column;justify-content:space-between}
.store:active{background:var(--surface2)}
.sbadge{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;font-weight:800;color:#fff;font-size:18px}
.store .sn{font-weight:700;font-size:18px;margin-top:10px}.store .sc{color:var(--muted);font-size:14px}
.store.add{align-items:center;justify-content:center;border-style:dashed;color:var(--accent);font-weight:600;gap:6px}

/* sheet */
.scrim{position:absolute;inset:0;background:rgba(0,0,0,.4);z-index:50;animation:fade .2s}
.sheet{position:absolute;left:0;right:0;bottom:0;z-index:60;background:var(--surface);border-radius:26px 26px 0 0;padding:10px 20px calc(env(safe-area-inset-bottom) + 20px);max-height:92%;overflow-y:auto;box-shadow:var(--shadow);animation:up .25s cubic-bezier(.2,.9,.3,1)}
.grab{width:42px;height:5px;border-radius:3px;background:var(--line);margin:0 auto 14px}
.sheet h2{margin:0 0 14px;font-size:22px;letter-spacing:-.01em}
@keyframes up{from{transform:translateY(100%)}to{transform:none}}
@keyframes fade{from{opacity:0}to{opacity:1}}
.field{margin-bottom:14px}
.field label{display:block;font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:6px}
.inp,.sel{width:100%;height:var(--tap);border-radius:14px;border:2px solid var(--line);background:var(--bg);padding:0 14px;font-size:18px;outline:0}
.inp:focus,.sel:focus{border-color:var(--accent)}
.two{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.stepper{display:flex;align-items:center;height:var(--tap);border:2px solid var(--line);border-radius:14px;background:var(--bg);overflow:hidden}
.stepper button{width:56px;height:100%;display:grid;place-items:center;color:var(--accent)}
.stepper button:active{background:var(--surface2)}
.stepper input{flex:1;min-width:0;border:0;background:none;text-align:center;font-size:20px;font-weight:700;outline:0;height:100%}
.btn{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;height:var(--tap);border-radius:16px;background:var(--accent);color:var(--accent-ink);font-weight:700;font-size:18px}
.btn:active{filter:brightness(.92)}
.btn.sec{background:var(--surface2);color:var(--text)}
.btn.dng{background:var(--danger-soft);color:var(--danger)}
.btn+.btn{margin-top:10px}
.row{display:flex;align-items:center;gap:12px;min-height:60px;width:100%;text-align:left;border-bottom:1px solid var(--line)}
.row:last-child{border-bottom:0}
.row .grow{flex:1;min-width:0}
.row small{display:block;color:var(--muted);font-size:13px}
.seg{display:flex;background:var(--surface2);border-radius:14px;padding:4px}
.seg button{flex:1;height:44px;border-radius:11px;font-weight:600;color:var(--muted)}
.seg button.on{background:var(--surface);color:var(--text);box-shadow:0 1px 4px rgba(0,0,0,.12)}
.switch{width:52px;height:32px;border-radius:16px;background:#b5bcb6;position:relative;flex:none;transition:.2s}
.switch::after{content:"";position:absolute;top:3px;left:3px;width:26px;height:26px;border-radius:50%;background:#fff;transition:.2s}
.switch.on{background:var(--accent)}.switch.on::after{left:23px}
.note{font-size:13px;color:var(--muted);margin:6px 2px 0;line-height:1.4}

/* toast */
.toast{position:absolute;left:14px;right:14px;bottom:calc(env(safe-area-inset-bottom) + 84px);z-index:80;background:#222a26;color:#fff;border-radius:16px;padding:6px 8px 6px 18px;display:flex;align-items:center;gap:8px;min-height:52px;animation:up .25s;box-shadow:var(--shadow)}
.toast span{flex:1;font-size:15px}.toast button{color:#7be0b8;font-weight:700;height:44px;padding:0 12px}

/* page overlay (registry) */
.page{position:absolute;inset:0;background:var(--bg);z-index:40;display:flex;flex-direction:column}
.regrow{display:flex;align-items:center;min-height:62px;border-bottom:1px solid var(--line)}
.regrow:last-child{border-bottom:0}
.regrow .hit{flex:1;display:flex;flex-direction:column;justify-content:center;padding:8px 6px 8px 16px;text-align:left;min-height:62px;min-width:0}
.favbtn{width:52px;height:52px;display:grid;place-items:center;color:var(--muted)}
.favbtn.on{color:var(--star)}.favbtn.on svg{fill:var(--star)}
.pill{display:inline-flex;align-items:center;height:22px;padding:0 8px;border-radius:11px;background:var(--accent-soft);color:var(--accent);font-size:12px;font-weight:700;margin-left:6px}

/* login */
.login{position:absolute;inset:0;z-index:100;background:var(--bg);padding:calc(env(safe-area-inset-top) + 60px) 24px 30px;display:flex;flex-direction:column}
.logo{width:72px;height:72px;border-radius:22px;background:var(--accent);display:grid;place-items:center;color:var(--accent-ink);margin-bottom:20px}
.logo svg{width:38px;height:38px}
.login h1{font-size:34px;margin:0 0 6px;letter-spacing:-.02em}
.login p{color:var(--muted);margin:0 0 28px}
.usercard{display:flex;align-items:center;gap:14px;padding:14px;min-height:76px;margin-bottom:12px;text-align:left;width:100%;border:2px solid var(--line)}
.usercard.on{border-color:var(--accent);background:var(--accent-soft)}
.proto{margin-top:auto;background:var(--surface2);border-radius:14px;padding:12px 14px;font-size:13.5px;color:var(--muted);line-height:1.45}
.sync{margin-left:auto;font-size:13px;font-weight:600;color:var(--muted);display:flex;align-items:center;gap:6px;white-space:nowrap}
.sync::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--accent)}
.sync.off{color:#b26b00}.sync.off::before{background:#e09b2d}
.sync.busy::before{background:var(--muted);animation:pulse 1s infinite}
@keyframes pulse{50%{opacity:.25}}
.errtxt{color:var(--danger);font-size:15px;margin:-4px 2px 12px;min-height:20px}

