/* MarketPlus — mobile multi-screen navigation */

#mobileApp.ui-m {
  position: relative;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: none;
  flex-direction: column;
  background: var(--bg, #F6F7FB);
}

@media (max-width: 900px) {
  #mobileApp.ui-m { display: flex; }
  html.is-shell-m,
  html.is-shell-m body {
    height: 100%;
    overflow: hidden;
  }
}

.m-stack {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.m-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg, #F6F7FB);
  z-index: 1;
  transform: translate3d(0, 0, 0);
  opacity: 1;
}
.m-screen[hidden] { display: none !important; }
.m-screen.is-active { z-index: 2; }

.m-screen.is-enter-right { transform: translate3d(108%, 0, 0); opacity: .96; }
.m-screen.is-enter-left { transform: translate3d(-28%, 0, 0); opacity: .88; }
.m-screen.is-exit-left { transform: translate3d(-22%, 0, 0); opacity: .75; z-index: 1; }
.m-screen.is-exit-right { transform: translate3d(108%, 0, 0); opacity: .9; z-index: 3; }

.m-screen.is-anim {
  will-change: transform, opacity;
  transition:
    transform .32s cubic-bezier(.22, 1, .36, 1),
    opacity .28s ease;
}

.m-screen__head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0,0,0,.05);
  z-index: 5;
}

.m-screen__head h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.03em;
  flex: 1;
  min-width: 0;
}

.m-screen__back {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: #F3F4F8;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.m-screen__back svg { width: 20px; height: 20px; }

.m-screen__scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.m-screen--home .m-screen__scroll { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

/* Sub-pages (no tabbar): tighter bottom inset */
#mobileApp.is-subpage .m-screen__scroll {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* Home keeps sticky search header inside screen */
.m-screen--home .ui-m__top {
  position: sticky;
  top: 0;
  z-index: 6;
}

#bottomNav.is-subpage {
  transform: translate3d(0, 120%, 0);
  pointer-events: none;
  opacity: 0;
  transition: transform .28s cubic-bezier(.22,1,.36,1), opacity .22s ease;
}

#bottomNav {
  transition: transform .28s cubic-bezier(.22,1,.36,1), opacity .22s ease;
}

.m-page {
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.m-page__card {
  background: var(--card, #fff);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
  border: 1px solid rgba(15,23,42,.04);
}

.m-page__empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-weight: 600;
}

.m-page__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.m-page__list a,
.m-page__list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 0;
  background: var(--card, #fff);
  border-radius: 16px;
  padding: 14px 14px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
  transition: transform .15s ease, background .15s ease;
}

.m-page__list a:active,
.m-page__list button:active { transform: scale(.98); }

.m-page__list .ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pink-soft, #FFE4EE);
  color: var(--pink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.m-page__list .ico svg { width: 20px; height: 20px; }
.m-page__list .chev { margin-left: auto; color: var(--muted); opacity: .7; }

.m-cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.m-cat-tile {
  border: 0;
  border-radius: 18px;
  padding: 14px 12px;
  background: var(--card, #fff);
  box-shadow: 0 8px 22px rgba(15,23,42,.05);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font: inherit;
  color: var(--ink);
}

.m-cat-tile__ico {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--tone, #F3F4F8);
  color: var(--pink);
}

.m-cat-tile__ico svg { width: 22px; height: 22px; }
.m-cat-tile strong { font-size: .95rem; font-weight: 800; }
.m-cat-tile span { font-size: .75rem; color: var(--muted); font-weight: 600; }

.m-account__hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, #1B1030, #FF2D6B 70%);
  color: #fff;
}

.m-account__avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: rgba(255,255,255,.2);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.3rem;
}

.m-account__hero strong { display: block; font-size: 1.15rem; }
.m-account__hero small { opacity: .88; }

.m-screen__cart-foot {
  position: sticky;
  bottom: 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 4;
}

.m-screen__cart-foot .ui-cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .m-screen.is-anim { transition: none !important; }
}
