/**
 * MarketPlus — real mobile app shell
 * Only used when viewport ≤ 900px (.mp-mapp)
 */

.mp-mapp {
  display: none;
}

@media (max-width: 900px) {
  .mp-desktop,
  .mp-chat-fab {
    display: none !important;
  }

  .mp-mapp {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    overflow-x: hidden;
    background:
      radial-gradient(120% 80% at 50% -10%, #dcebff 0%, transparent 55%),
      linear-gradient(180deg, #f7f8fb 0%, #eef1f6 100%);
    color: #111827;
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  [data-theme="dark"] .mp-mapp {
    background: #0b0d12;
    color: #f3f4f6;
  }

  .mapp-top {
    position: sticky;
    top: 0;
    z-index: 30;
    width: 100%;
    max-width: 100%;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 12px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  [data-theme="dark"] .mapp-top {
    background: rgba(17, 20, 28, 0.94);
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }

  .mapp-top__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .mapp-logo {
    height: 32px;
    width: auto;
    display: block;
  }

  .mapp-icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: #eef2f7;
    font-size: 1.1rem;
    cursor: pointer;
  }

  [data-theme="dark"] .mapp-icon-btn {
    background: #1c2230;
  }

  .mapp-search {
    display: flex;
    align-items: center;
    background: #eef2f7;
    border-radius: 14px;
    overflow: hidden;
    min-height: 46px;
  }

  [data-theme="dark"] .mapp-search {
    background: #1c2230;
  }

  .mapp-search input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 12px 14px;
    font-size: 0.95rem;
    color: inherit;
    outline: none;
  }

  .mapp-hero__copy p {
    margin: 0;
    font-size: 0.82rem;
    opacity: 0.9;
    max-width: 28ch;
    line-height: 1.35;
  }

  .mapp-tab em {
    font-style: normal;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .mapp-search button {
    border: 0;
    background: #0A84FF;
    color: #fff;
    width: 48px;
    height: 46px;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mapp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 18px;
    padding: 14px 0 20px;
  }

  .mapp-hero {
    position: relative;
    margin: 0 16px;
    height: 180px;
    border-radius: 20px;
    overflow: hidden;
    isolation: isolate;
  }

  .mapp-hero__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .mapp-hero__copy {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
    padding: 18px;
    background: linear-gradient(180deg, transparent 20%, rgba(8, 12, 20, 0.78) 100%);
    color: #fff;
  }

  .mapp-hero__copy span {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #ffb070;
  }

  .mapp-hero__copy strong {
    font-size: 1.35rem;
    line-height: 1.2;
    font-weight: 800;
    max-width: 12ch;
  }

  .mapp-hero__cta {
    align-self: flex-start;
    margin-top: 6px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #111;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 8px 14px;
    cursor: pointer;
  }

  .mapp-cats {
    overflow: hidden;
  }

  .mapp-cats__track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 0 16px 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mapp-cats__track::-webkit-scrollbar { display: none; }

  .mapp-cat {
    flex: 0 0 auto;
    display: grid;
    justify-items: center;
    gap: 6px;
    width: 64px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
  }

  .mapp-cat__ico {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    background: #fff;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  }

  [data-theme="dark"] .mapp-cat__ico {
    background: #171b24;
  }

  .mapp-cat.is-active .mapp-cat__ico {
    box-shadow: 0 0 0 2px #0A84FF;
  }

  .mapp-cat span {
    font-size: 0.68rem;
    font-weight: 650;
    text-align: center;
    color: #4b5563;
  }

  [data-theme="dark"] .mapp-cat span { color: #9ca3af; }

  .mapp-block {
    padding: 0 16px;
  }

  .mapp-block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .mapp-block__head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  .mapp-timer {
    font-size: 0.78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #FF6A00;
    background: #fff0e6;
    padding: 6px 10px;
    border-radius: 999px;
  }

  [data-theme="dark"] .mapp-timer {
    background: #2a1a10;
  }

  .mapp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .mapp-tab__ico {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
  }

  .mapp-tab__ico svg {
    width: 20px;
    height: 20px;
  }

  .mapp-tab.is-active {
    color: #0A84FF;
  }

  .mapp-card {
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  }

  [data-theme="dark"] .mapp-card {
    background: #171b24;
  }

  .mapp-card__img {
    position: relative;
    aspect-ratio: 1;
    background: #eef2f7;
  }

  .mapp-card__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .mapp-card__badge {
    position: absolute;
    left: 8px;
    top: 8px;
    background: #FF6A00;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 4px 7px;
    border-radius: 8px;
  }

  .mapp-card__wish {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
  }

  .mapp-card__wish.is-active { color: #e53935; }

  .mapp-card__body {
    padding: 10px 10px 12px;
    display: grid;
    gap: 6px;
  }

  .mapp-card__title {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 650;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
  }

  .mapp-card__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mapp-card__price {
    font-size: 0.92rem;
    font-weight: 800;
    color: #0A84FF;
  }

  .mapp-card__old {
    display: block;
    font-size: 0.68rem;
    color: #9ca3af;
    text-decoration: line-through;
  }

  .mapp-card__cart {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 11px;
    background: #e8f3ff;
    cursor: pointer;
    font-size: 0.95rem;
  }

  [data-theme="dark"] .mapp-card__cart {
    background: #132238;
  }

  .mapp-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #6b7280;
    padding: 28px 8px;
    font-size: 0.9rem;
  }

  .mapp-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.08);
  }

  body.is-authed .mapp-tabbar {
    grid-template-columns: repeat(5, 1fr);
  }

  [data-theme="dark"] .mapp-tabbar {
    background: rgba(17, 20, 28, 0.96);
    border-top-color: rgba(255, 255, 255, 0.06);
  }

  .mapp-tab {
    position: relative;
    display: grid;
    place-items: center;
    gap: 2px;
    min-height: 50px;
    border: 0;
    background: transparent;
    color: #6b7280;
    text-decoration: none;
    font-size: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mapp-tab span {
    font-size: 1.15rem;
    line-height: 1;
  }

  .mapp-tab.is-active {
    color: #0A84FF;
  }

  .mapp-tab.is-active em {
    color: #0A84FF;
  }

  .mapp-tab__badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #FF6A00;
    color: #fff;
    font-size: 0.6rem;
    display: grid;
    place-items: center;
  }

  .mapp-near-status {
    margin: 0 16px 12px;
    color: #6b7280;
    font-size: 0.85rem;
  }

  .mapp-near-status.is-ready {
    color: #2563eb;
  }

  .mapp-link-btn {
    border: 0;
    background: transparent;
    color: #2563eb;
    font: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
  }

  .mapp-card__dist {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    max-width: calc(100% - 44px);
    padding: 3px 7px;
    border-radius: 7px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mapp-card__cart {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: #0A84FF;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
  }

  /* Shared drawers sit above mobile shell */
  .mp-drawer {
    z-index: 200;
  }

  .mp-drawer__panel {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: min(82dvh, 82vh) !important;
    border-radius: 22px 22px 0 0 !important;
    font-family: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  }

  .mp-drawer__panel header {
    padding: 18px 18px 12px !important;
  }

  .mp-drawer__panel header::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: #d1d5db;
    margin: 0 auto 14px;
  }

  .mp-coupon-hint {
    display: none !important;
  }

  .mp-empty-state {
    display: grid;
    place-items: center;
    text-align: center;
    gap: 8px;
    padding: 48px 24px;
    color: #6b7280;
  }

  .mp-empty-state__ico {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: #eef2f7;
    font-size: 1.6rem;
    margin-bottom: 4px;
  }

  .mp-empty-state strong {
    color: #111827;
    font-size: 1.05rem;
  }

  .mp-empty-state p {
    margin: 0;
    font-size: 0.88rem;
    max-width: 28ch;
    line-height: 1.4;
  }

  .mp-wish-list {
    display: grid;
    gap: 10px;
  }

  .mp-wish-line {
    display: grid;
    grid-template-columns: 64px 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 14px;
    background: #f8fafc;
  }

  .mp-wish-line__img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
  }

  .mp-wish-line__meta {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  .mp-wish-line__meta strong {
    font-size: 0.85rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .mp-wish-line__meta span {
    color: #0A84FF;
    font-weight: 700;
    font-size: 0.9rem;
  }

  .mp-wish-line__remove {
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    width: 32px;
    height: 32px;
  }
}

@media (min-width: 901px) {
  .mp-mapp {
    display: none !important;
  }
}

/* Admin + account sheet — mobile refinements */
@media (max-width: 900px) {
  body.mp-admin-open .mp-mapp,
  body.mp-admin-open .mp-desktop {
    visibility: hidden;
  }

  .mp-admin__top {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .mp-admin__nav {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mpa-kpis {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .mpa-kpi {
    flex: 0 0 46%;
    scroll-snap-align: start;
  }

  .mpa-btn,
  .mp-admin__menu button,
  .mp-admin__menu-btn {
    min-height: 44px;
  }

  .mp-account-sheet__panel {
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  }

  .mp-listing-detail__panel,
  .mp-sell-modal__panel {
    width: 100%;
    max-height: min(92vh, 900px);
    border-radius: 18px 18px 0 0;
    align-self: end;
  }

  .mp-listing-detail,
  .mp-sell-modal {
    place-items: end center;
    padding: 0;
  }

  .mp-listing-detail__actions .mp-btn {
    flex: 1 1 100%;
    min-height: 44px;
  }
}
