:root{
  --bg:#faf7f2; --card:#fff; --ink:#1d2b2a; --muted:#6c7a78; --line:#e9e3d8;
  --brand:#0f766e; --brand-d:#0b5a54; --wa:#25d366; --wa-d:#1ebe5a; --price:#b45309; --danger:#b42318;
  --r:16px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:'Cairo','Segoe UI',Tahoma,system-ui,sans-serif;line-height:1.6;padding-bottom:96px}
body.lock{overflow:hidden}
h1,h2,p{margin:0}
button,input,textarea{font:inherit;color:inherit}

.hero{background:linear-gradient(135deg,var(--brand),var(--brand-d));color:#fff;padding:22px 16px 26px;border-radius:0 0 28px 28px}
.hero-in{max-width:960px;margin:0 auto;display:flex;align-items:center;gap:14px}
.hero h1{font-size:1.45rem;font-weight:700;line-height:1.3}
.hero .sub{opacity:.9;font-size:.95rem}
.logo{width:64px;height:64px;border-radius:50%;object-fit:cover;background:#fff;border:3px solid rgba(255,255,255,.55);flex:none}

.shop{max-width:960px;margin:0 auto;padding:16px}
.tools{margin-bottom:14px}
#q{width:100%;padding:12px 16px;border:1.5px solid var(--line);border-radius:999px;background:#fff;font-size:1rem;outline:none}
#q:focus{border-color:var(--brand)}
.chips{display:flex;gap:8px;overflow-x:auto;padding:10px 0 2px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{flex:none;border:1.5px solid var(--line);background:#fff;border-radius:999px;padding:5px 14px;cursor:pointer;font-size:.92rem}
.chip.on{background:var(--brand);border-color:var(--brand);color:#fff}

.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
@media(min-width:640px){.grid{grid-template-columns:repeat(3,1fr);gap:16px}}
@media(min-width:900px){.grid{grid-template-columns:repeat(4,1fr)}}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;display:flex;flex-direction:column}
.card[hidden]{display:none}
.card .img{position:relative;aspect-ratio:1/1;background:#f1ece2;display:flex;align-items:center;justify-content:center}
.card .img img{width:100%;height:100%;object-fit:cover;display:block}
.card .ph{font-size:2.4rem;opacity:.5}
.card .tag{position:absolute;top:8px;inset-inline-start:8px;background:rgba(29,43,42,.85);color:#fff;font-size:.78rem;padding:2px 10px;border-radius:999px}
.card.out .img img{filter:grayscale(1);opacity:.55}
.card .body{padding:10px 12px 12px;display:flex;flex-direction:column;gap:4px;flex:1}
.card .name{font-weight:700;font-size:.98rem;line-height:1.35}
.card .desc{color:var(--muted);font-size:.82rem;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.card .price{color:var(--price);font-weight:700}
.card .price small{color:var(--muted);font-weight:400}
.card .ctrl{margin-top:auto;padding-top:8px}

.btn{border:0;border-radius:12px;padding:11px 18px;font-weight:700;cursor:pointer;background:var(--brand);color:#fff;font-size:1rem;display:inline-flex;align-items:center;justify-content:center;gap:8px;text-decoration:none}
.btn:active{transform:scale(.98)}
.btn:disabled{opacity:.6;cursor:default}
.btn.add{width:100%;background:#e7f3f1;color:var(--brand-d)}
.btn.add:hover{background:#d6ebe7}
.btn.wa{width:100%;background:var(--wa);color:#073b1a;font-size:1.08rem;padding:14px}
.btn.wa:hover{background:var(--wa-d)}
.btn.go{background:#fff;color:var(--brand-d)}
.btn.na{width:100%;background:#eee;color:#999;cursor:default}

.stepper{display:flex;align-items:center;justify-content:space-between;background:#e7f3f1;border-radius:12px;padding:3px}
.stepper button{width:38px;height:36px;border:0;border-radius:10px;background:#fff;color:var(--brand-d);font-size:1.3rem;font-weight:700;cursor:pointer;line-height:1}
.stepper span{min-width:30px;text-align:center;font-weight:700}

.cartbar{position:fixed;inset-inline:0;bottom:0;z-index:20;padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:var(--brand-d);color:#fff;box-shadow:0 -6px 20px rgba(0,0,0,.15)}
.cartbar[hidden]{display:none}
.cartbar-in{max-width:960px;margin:0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px}
.cartinfo strong{font-size:1.1rem}

.backdrop{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:30}
.backdrop[hidden]{display:none}
.sheet{position:fixed;inset-inline:0;bottom:0;z-index:40;background:#fff;border-radius:22px 22px 0 0;max-height:92vh;overflow-y:auto;padding:16px 16px calc(18px + env(safe-area-inset-bottom));max-width:620px;margin:0 auto;box-shadow:0 -10px 40px rgba(0,0,0,.25)}
.sheet[hidden]{display:none}
.sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.sheet h2{font-size:1.2rem}
.x{border:0;background:#f1ece2;width:34px;height:34px;border-radius:50%;cursor:pointer}

.line{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px dashed var(--line)}
.line .t{flex:1;min-width:0}
.line .t b{display:block;font-size:.95rem;line-height:1.35}
.line .t small{color:var(--muted)}
.line .sub{font-weight:700;color:var(--price);white-space:nowrap}
.line .stepper{flex:none;width:112px}
.line .stepper button{width:30px;height:30px;font-size:1.1rem}
.sum{display:flex;justify-content:space-between;align-items:center;font-size:1.15rem;padding:12px 0 6px}
.sum strong{color:var(--price);font-size:1.3rem}

form label{display:block;margin-top:12px;font-weight:600;font-size:.92rem}
form input,form textarea,form select{display:block;width:100%;margin-top:4px;padding:11px 13px;border:1.5px solid var(--line);border-radius:12px;background:#fffdf9;font-size:1rem;outline:none;font-weight:400}
form input:focus,form textarea:focus,form select:focus{border-color:var(--brand)}
.hp{position:absolute!important;left:-9999px;width:1px;height:1px;opacity:0}
form .btn.wa{margin-top:16px}
.err{margin-top:12px;background:#fdeceb;color:var(--danger);padding:10px 12px;border-radius:10px;font-size:.92rem}
.err[hidden]{display:none}
.hint{margin-top:10px;color:var(--muted);font-size:.84rem;text-align:center}

#done{text-align:center;padding:16px 4px}
#done .ok{font-size:2.6rem}
#done h3{margin:6px 0 4px;font-size:1.2rem}
#done p{color:var(--muted);margin-bottom:14px}

.empty{text-align:center;color:var(--muted);padding:40px 10px}
.msgpage{max-width:420px;margin:18vh auto;padding:20px;text-align:center}
.msgpage h1{font-size:1.4rem;margin-bottom:8px}
.msgpage p{color:var(--muted)}

/* تفاصيل السلعة */
.tap{cursor:pointer}
.card .more{border:0;background:none;padding:0;margin-top:2px;text-align:start;color:var(--brand);font-size:.82rem;font-weight:600;cursor:pointer}
.psheet{padding-top:10px}
.pimg{background:#f1ece2;border-radius:14px;overflow:hidden;display:flex;justify-content:center;margin-bottom:12px}
.pimg img{display:block;width:100%;max-height:min(38vh,380px);object-fit:contain}
.pname{font-size:1.25rem;line-height:1.35;margin:0 0 4px}
.pcat{display:inline-block;background:#e7f3f1;color:var(--brand-d);font-size:.8rem;padding:1px 10px;border-radius:999px;margin-bottom:6px}
.pprice{color:var(--price);font-weight:700;font-size:1.25rem;margin:2px 0 8px}
.pprice small{color:var(--muted);font-weight:400;font-size:.9rem}
.pdesc{white-space:pre-line;line-height:1.8;color:#34423f;margin:0 0 14px}
/* النافذة: رأس ثابت + محتوى قابل للتمرير + زر الإضافة ثابت في الأسفل */
.sheet{max-height:92vh;max-height:92dvh;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}
.psheet{display:flex;flex-direction:column;overflow:hidden;padding-bottom:0}
.psheet .sheet-head{flex:none;margin-bottom:6px}
#pbody{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-inline-end:6px;scrollbar-width:thin;scrollbar-color:var(--brand) #eee}
#pbody::-webkit-scrollbar,.sheet::-webkit-scrollbar{width:6px}
#pbody::-webkit-scrollbar-thumb,.sheet::-webkit-scrollbar-thumb{background:var(--brand);border-radius:6px}
#pbody::-webkit-scrollbar-track,.sheet::-webkit-scrollbar-track{background:#eee;border-radius:6px}
.pctrl{flex:none;background:#fff;border-top:1px solid var(--line);padding:10px 0 10px}
.pctrl .btn.add{padding:13px;font-size:1.05rem}

/* علامة السلعة المضافة إلى السلة */
.card{transition:border-color .15s, box-shadow .15s}
.card.incart{border:2px solid var(--brand);box-shadow:0 0 0 3px rgba(15,118,110,.12);background:#f3faf8}
.incart-badge{position:absolute;top:8px;inset-inline-end:8px;background:var(--brand);color:#fff;font-size:.8rem;font-weight:700;padding:3px 10px;border-radius:999px;box-shadow:0 2px 6px rgba(0,0,0,.2)}
.incart-badge[hidden]{display:none}

/* الأحجام / الأوزان */
.card .price small{color:var(--muted);font-weight:400;font-size:.8rem}
.card .vcount{color:var(--muted);font-size:.78rem;line-height:1.4}
.pprice small{color:var(--muted);font-weight:400;font-size:.9rem}
.vlist{display:flex;flex-direction:column;gap:8px;max-height:42vh;overflow-y:auto}
.vtitle{font-weight:700;font-size:.92rem}
.vlist .vrow{display:flex;align-items:center;justify-content:space-between;gap:10px;border:1.5px solid var(--line);border-radius:12px;padding:8px 10px}
.vlist .vrow.on{border-color:var(--brand);background:#f3faf8}
.vlist .vt{display:flex;flex-direction:column;line-height:1.35}
.vlist .vp{color:var(--price);font-weight:700}
.vlist .stepper{width:120px;flex:none}
.vlist .vadd{width:auto;flex:none;padding:8px 16px}
/* تفاصيل المجموع */
.sumrow{display:flex;justify-content:space-between;color:var(--muted);font-size:.95rem;padding-top:6px}
.sumrow + .sum{border-top:1px solid var(--line);margin-top:6px}

/* شريط التأكيد أسفل نافذة السلعة */
.pfoot{flex:none;background:#fff;border-top:1px solid var(--line);padding:10px 0 calc(10px + env(safe-area-inset-bottom))}
.pf-info{text-align:center;font-weight:700;color:var(--brand-d);margin-bottom:8px;font-size:.95rem}
.pf-btns{display:flex;gap:8px}
.pf-btns .btn{flex:1;padding:12px 10px}
.btn.checkout{background:var(--brand-d);color:#fff}
.pfoot.bump .pf-info{animation:bump .5s ease}
@keyframes bump{0%{transform:scale(1)}40%{transform:scale(1.08);color:var(--wa-d)}100%{transform:scale(1)}}
.btn.ghost{background:#e7f3f1;color:var(--brand-d)}
.btn.ghost:hover{background:#d6ebe7}
