/* Header fixes (desktop) + mobile app layer: compact top bar, bottom tab bar, aisles menu, search sheet, sheets. */

/* ---------- desktop header ---------- */
.hdr .wrap { min-height: 82px; }
.hdr-act { align-items: center; }
.hdr-act .icon-btn { height: 46px; }
.hdr .m-search { display: none; }
.cats .wrap { flex-wrap: nowrap; align-items: center; overflow: visible; gap: 2px; }
.cats-list { display: flex; gap: 2px; min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; }
.cats-list a { flex: none; }
.cats-more { position: relative; flex: none; }
.cats-more[hidden] { display: none; }
.cats-more > button { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 3px; background: #fff; font: 600 14px var(--body); cursor: pointer; }
.cats-more > button:hover, .cats-more.on > button { border-color: var(--ink); }
.cats-more.on > button svg { transform: rotate(180deg); }
.cats-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 240px; padding: 8px; background: #fff; border: 2px solid var(--ink); box-shadow: 0 20px 40px -14px rgba(0,0,0,.3); display: none; }
.cats-more.on .cats-pop { display: grid; }
.cats-pop a { padding: 9px 10px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.cats-pop a::after { display: none; }
.cats-pop a:hover, .cats-pop a.on { background: var(--mist); color: var(--red-ink); }

/* app layer is mobile/tablet only */
.tabbar, .appmenu, .srch { display: none; }

@media (max-width: 900px) {
  :root { --tab-h: 66px; --safe: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--tab-h) + 22px + var(--safe)); }
  body.app-lock { overflow: hidden; }

  /* compact app top bar */
  .util, .cats, .hdr .search, .hdr-act .acct-btn, .mega { display: none !important; }
  .hdr { transition: transform .35s var(--ease), box-shadow .3s; background: rgba(255,255,255,.92); backdrop-filter: blur(14px) saturate(1.4); }
  .hdr.hide { transform: translateY(-110%); }
  .hdr.raised { box-shadow: 0 10px 30px -18px rgba(0,0,0,.35); }
  .hdr .wrap { grid-template-columns: 1fr auto; min-height: 62px; gap: 10px; }
  .logo img { height: 40px; }
  .hdr-act { gap: 8px; }
  .hdr .m-search { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 14px; border: 0; background: var(--mist); color: var(--ink); }
  .hdr .cart-btn { height: 44px; border-radius: 14px; padding: 0 12px; }
  .hdr .cart-btn .lbl { display: none; }

  /* bottom tab bar */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; z-index: 85; left: 10px; right: 10px; bottom: calc(10px + var(--safe)); height: var(--tab-h); padding: 0 6px 8px; border-radius: 24px; background: rgba(20,20,20,.94); backdrop-filter: blur(16px) saturate(1.5); box-shadow: 0 18px 40px -16px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06) inset; }
  .tab { position: relative; display: grid; justify-items: center; gap: 4px; padding: 6px 0 0; border: 0; background: none; color: #9b9ba1; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  .tab svg { width: 23px; height: 23px; transition: transform .3s var(--ease); }
  .tab > span { font: 600 9.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; }
  .tab.on { color: #fff; }
  .tab.on::before { content: ''; position: absolute; top: -1px; width: 18px; height: 3px; border-radius: 3px; background: var(--red); }
  .tab:active svg { transform: scale(.88); }
  .tab-order .fab { position: relative; display: grid; place-items: center; width: 58px; height: 58px; margin-top: -30px; border-radius: 50%; background: var(--red); color: #fff; box-shadow: 0 10px 24px -6px rgba(235,29,39,.65), 0 0 0 5px rgba(20,20,20,.94); transition: transform .3s var(--ease); }
  .tab-order .fab svg { width: 25px; height: 25px; }
  .tab-order .btg-count { position: absolute; top: -2px; right: -4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #fff; color: var(--red-ink); font: 700 11px/22px var(--mono); text-align: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
  .tab-order:active .fab { transform: scale(.92); }
  .tab-order.bump .fab { animation: bump .6s var(--ease); }
  @keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.18) rotate(-6deg); } 60% { transform: scale(.96); } 100% { transform: scale(1); } }

  /* full-screen aisles menu */
  .appmenu { display: block; position: fixed; inset: 0; z-index: 120; background: #fff; transform: translateY(102%); transition: transform .5s cubic-bezier(.2,.9,.2,1); overflow: hidden; }
  .appmenu.on { transform: none; }
  .am-track { position: relative; height: 100%; }
  .am-panel { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(40px + var(--safe)); background: #fff; transition: transform .45s cubic-bezier(.2,.9,.2,1); }
  .am-panel[hidden] { display: block; transform: translateX(100%); visibility: hidden; }
  .am-sub { transform: translateX(100%); box-shadow: -20px 0 40px -20px rgba(0,0,0,.25); }
  .am-sub.on { transform: none; visibility: visible; }
  .appmenu.sub-on [data-am-root] { transform: translateX(-28%); }
  .am-hd { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 -16px; padding: 12px 16px; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
  .am-logo { height: 36px; width: auto; }
  .am-hd-title { flex: 1; font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 24px; text-align: center; }
  .am-ic { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 14px; background: var(--mist); color: var(--ink); cursor: pointer; flex: none; }
  .am-ic svg { width: 20px; height: 20px; }
  .am-search { display: flex; align-items: center; gap: 10px; width: 100%; height: 52px; margin-top: 6px; padding: 0 16px; border: 0; border-radius: 16px; background: var(--mist); color: var(--road); font-size: 15px; text-align: left; cursor: pointer; }
  .am-search svg { width: 20px; height: 20px; color: var(--ink); }
  .am-ways { display: flex; gap: 8px; margin: 12px 0 4px; overflow-x: auto; scrollbar-width: none; }
  .am-ways span { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: #FFF0F0; color: var(--red-ink); font-size: 12.5px; font-weight: 600; }
  .am-ways svg { width: 15px; height: 15px; }
  .am-title { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 26px; margin: 22px 0 12px; }
  .am-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .am-aisle { position: relative; display: grid; grid-template-rows: 86px auto auto; align-content: start; gap: 2px; padding: 12px; border: 0; border-radius: 18px; background: var(--mist); color: var(--ink); text-align: left; cursor: pointer; text-decoration: none; overflow: hidden; }
  .am-aisle img { width: 100%; height: 86px; object-fit: contain; mix-blend-mode: multiply; transition: transform .4s var(--ease); }
  .am-aisle b { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 19px; line-height: 1; margin-top: 6px; }
  .am-aisle span { font: 500 10.5px var(--mono); color: var(--road); text-transform: uppercase; }
  .am-aisle:active { transform: scale(.97); }
  .am-aisle:active img { transform: scale(1.06); }
  .appmenu.on .am-aisle { animation: am-in .5s both cubic-bezier(.2,.9,.2,1); animation-delay: calc(var(--i) * 25ms + 120ms); }
  @keyframes am-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
  .am-links { display: grid; border-radius: 18px; background: var(--mist); overflow: hidden; }
  .am-links a { display: grid; grid-template-columns: 22px 1fr 18px; gap: 12px; align-items: center; padding: 15px 16px; font-weight: 600; color: var(--ink); border-bottom: 1px solid rgba(0,0,0,.06); }
  .am-links a:last-child { border-bottom: 0; }
  .am-links svg { width: 20px; height: 20px; color: var(--road); }
  .am-links svg:last-child { width: 16px; }
  .am-call { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  .am-call a { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 16px; background: var(--red); color: #fff; font: 700 14px var(--mono); }
  .am-call a + a { background: var(--ink); }
  .am-call svg { width: 20px; height: 20px; flex: none; }
  .am-call small { display: block; font: 500 10px var(--mono); text-transform: uppercase; opacity: .8; }
  .am-pickup { margin-top: 12px; padding: 18px; border-radius: 18px; background: var(--ink); color: #fff; }
  .am-pickup .mono { color: #aaa; font-size: 10px; }
  .am-pickup b { display: block; font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 28px; margin: 4px 0; }
  .am-pickup p { margin: 0; color: #d0d0d4; font-size: 14px; }
  .am-hero { display: grid; grid-template-columns: 76px 1fr 20px; gap: 14px; align-items: center; margin: 8px 0 14px; padding: 14px; border-radius: 18px; background: var(--red); color: #fff; }
  .am-hero img { width: 76px; height: 76px; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; }
  .am-hero small { display: block; font: 500 10.5px var(--mono); text-transform: uppercase; opacity: .85; }
  .am-hero b { font-family: var(--display); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 24px; line-height: .95; }
  .am-hero svg { width: 20px; height: 20px; }
  .am-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
  .am-list a { display: grid; grid-template-columns: 56px 1fr 18px; gap: 12px; align-items: center; padding: 8px 12px 8px 8px; border-radius: 16px; background: var(--mist); color: var(--ink); }
  .am-th { width: 56px; height: 56px; border-radius: 12px; background: #fff; display: grid; place-items: center; overflow: hidden; }
  .am-th img { width: 88%; height: 88%; object-fit: contain; }
  .am-nm { font-weight: 700; font-size: 15px; line-height: 1.2; }
  .am-nm small { display: block; font: 500 10.5px var(--mono); color: var(--road); text-transform: uppercase; margin-top: 3px; }
  .am-list svg, .am-links svg:last-child { color: var(--road); }
  .am-sub.on .am-list li { animation: am-in .45s both cubic-bezier(.2,.9,.2,1); }
  .am-sub.on .am-list li:nth-child(2) { animation-delay: .04s; } .am-sub.on .am-list li:nth-child(3) { animation-delay: .08s; } .am-sub.on .am-list li:nth-child(4) { animation-delay: .12s; } .am-sub.on .am-list li:nth-child(5) { animation-delay: .16s; } .am-sub.on .am-list li:nth-child(n+6) { animation-delay: .2s; }

  /* search sheet */
  .srch { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 125; background: #fff; opacity: 0; visibility: hidden; transform: translateY(16px); transition: opacity .3s, transform .4s var(--ease), visibility 0s .4s; }
  .srch.on { opacity: 1; visibility: visible; transform: none; transition: opacity .3s, transform .4s var(--ease); }
  .srch-form { display: flex; align-items: center; gap: 10px; height: auto; max-width: none; margin: 0; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: #fff; }
  .srch-form > svg { width: 20px; height: 20px; flex: none; color: var(--road); }
  .srch-form input[type=search] { flex: 1; height: 48px; padding: 0 14px; border-radius: 14px; background: var(--mist); font-size: 17px; }
  .srch-form .srch-x { height: 44px; padding: 0 4px; border: 0; background: none; color: var(--red-ink); font: 700 15px var(--body); text-transform: none; font-style: normal; }
  .srch-form .srch-x:hover { background: none; color: var(--ink); }
  .srch-form .suggest { display: none !important; }
  .srch-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(30px + var(--safe)); }
  .srch-chips { display: flex; flex-wrap: wrap; gap: 8px; }
  .srch-chips a, .srch-chips button { padding: 10px 14px; border: 0; border-radius: 999px; background: var(--mist); color: var(--ink); font: 600 14px var(--body); cursor: pointer; }
  .srch-aisles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .srch-aisles a { display: grid; gap: 6px; justify-items: center; padding: 12px 6px; border-radius: 16px; background: var(--mist); text-align: center; font: 700 12px var(--body); color: var(--ink); }
  .srch-aisles img { width: 56px; height: 56px; object-fit: contain; mix-blend-mode: multiply; }
  .srch-results:empty { display: none; }
  .srch-results { display: grid; gap: 8px; padding-top: 12px; }
  .srch-results a.r { display: grid; grid-template-columns: 60px 1fr auto; gap: 12px; align-items: center; padding: 8px 12px 8px 8px; border-radius: 16px; background: var(--mist); color: var(--ink); }
  .srch-results img { width: 60px; height: 60px; object-fit: contain; border-radius: 12px; background: #fff; }
  .srch-results b { display: block; font-size: 14px; line-height: 1.25; }
  .srch-results .mono { color: var(--road); font-size: 10.5px; }
  .srch-results em { font: 700 14px var(--mono); font-style: normal; }
  .srch-results .all { display: block; padding: 14px; border-radius: 16px; background: var(--ink); color: #fff; font-weight: 700; text-align: center; }
  .srch-results .none { padding: 18px 4px; color: var(--ink-2); }
  .srch.has-results .srch-idle { display: none; }

  /* sheets sit above the tab bar */
  .toast { bottom: calc(var(--tab-h) + 52px + var(--safe)); }
  .stickybuy { bottom: calc(var(--tab-h) + 46px + var(--safe)); left: 10px; right: 10px; border-radius: 18px; transform: translateY(16px); opacity: 0; visibility: hidden; transition: transform .4s var(--ease), opacity .3s, visibility 0s .4s; }
  .stickybuy.on { transform: none; opacity: 1; visibility: visible; transition: transform .4s var(--ease), opacity .3s; }
  .stickybuy .wrap { width: auto; padding: 8px 8px 8px 12px; }
  .stickybuy .add { border-radius: 12px; }
}

@media (max-width: 640px) {
  /* order ticket becomes a bottom sheet */
  .drawer { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-height: 86vh; border-radius: 24px 24px 0 0; transform: translateY(105%); padding-bottom: var(--safe); }
  .drawer::before { content: ''; position: absolute; left: 50%; top: 8px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: #d4d1ca; }
  .drawer::after { display: none; }
  .dr-hd { padding-top: 22px; }
  body.cart-open .drawer { transform: none; }
  .qv { align-items: end; padding: 0; }
  .qv-box { border-radius: 24px 24px 0 0; max-height: 88vh; }
}

/* toast: hidden by visibility, not just by sliding (it sits above the tab bar on mobile) */
.toast { opacity: 0; visibility: hidden; transition: transform .5s var(--ease), opacity .3s, visibility 0s .5s; }
.toast.on { opacity: 1; visibility: visible; transition: transform .5s var(--ease), opacity .3s; }
