/* Mobile app shell — phones & small tablets only */
@media (max-width: 991.98px) {
  :root {
    --app-header-h: 3.25rem;
    --app-header-total: calc(var(--app-header-h) + env(safe-area-inset-top, 0px));
    --app-nav-h: 4.25rem;
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-bg: #f4f4f5;
    --app-card: #ffffff;
    --app-radius: 16px;
  }

  body.storefront.has-mobile-app {
    background: var(--app-bg);
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(var(--app-nav-h) + var(--app-safe-bottom));
  }

  .app-main {
    min-height: calc(100vh - var(--app-header-h) - var(--app-nav-h));
  }

  /* Compact app header */
  .mobile-app-header {
    position: sticky;
    top: 0;
    z-index: 1040;
    background: var(--app-card);
    border-bottom: 1px solid #ebebeb;
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
  }

  .mobile-app-header-inner {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--app-header-h);
    padding: 0.35rem 0.75rem;
  }

  .mobile-app-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
  }

  .mobile-app-brand img {
    height: 34px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
  }

  .mobile-app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
  }

  .mobile-app-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.25rem;
    border-radius: 12px;
    text-decoration: none;
    position: relative;
  }

  .mobile-app-icon-btn:active {
    background: #f3f4f6;
  }

  .mobile-app-badge,
  .mobile-nav-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    font-style: normal;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-app-header .header-social-link {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.85rem;
  }

  /* Bottom tab bar */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    background: var(--app-card);
    border-top: 1px solid #e8e8e8;
    padding: 0.35rem 0.25rem calc(0.35rem + var(--app-safe-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-height: 3.25rem;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 12px;
    position: relative;
    padding: 0.25rem;
  }

  .mobile-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
  }

  .mobile-nav-item.active {
    color: var(--brand);
  }

  .mobile-nav-item:active {
    background: var(--brand-light);
  }

  /* Search sheet */
  .mobile-search-sheet,
  .mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .mobile-search-sheet[hidden],
  .mobile-sheet[hidden] {
    display: none !important;
  }

  .mobile-search-sheet-backdrop,
  .mobile-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
  }

  .mobile-search-sheet-panel {
    position: relative;
    background: var(--app-card);
    padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 1rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }

  .mobile-search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f3f4f6;
    border-radius: 14px;
    padding: 0.5rem 0.75rem;
  }

  .mobile-search-form input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    padding: 0.35rem 0;
  }

  .mobile-search-cancel {
    border: none;
    background: transparent;
    color: var(--brand);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .mobile-search-hint {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
  }

  /* Category bottom sheet */
  .mobile-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 78vh;
    overflow-y: auto;
    background: var(--app-card);
    border-radius: 20px 20px 0 0;
    padding: 0.75rem 1rem calc(1.25rem + var(--app-safe-bottom));
    animation: sheetUp 0.25s ease;
  }

  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .mobile-sheet-handle {
    width: 2.5rem;
    height: 4px;
    background: #d1d5db;
    border-radius: 999px;
    margin: 0 auto 1rem;
  }

  .mobile-sheet-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
  }

  .mobile-category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .mobile-category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 0.75rem 0.35rem;
    background: var(--app-bg);
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
  }

  .mobile-category-item .category-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 0;
  }

  .mobile-category-item:active {
    background: var(--brand-light);
    color: var(--brand);
  }

  /* Flash alerts */
  .flash-banner {
    margin: 0;
    border-radius: 0;
    border: none;
    text-align: center;
    font-size: 0.9rem;
    padding: 0.65rem 1rem;
  }

  /* Home & content — app cards */
  .hero-carousel .carousel-item,
  .hero-slide {
    min-height: 220px;
  }

  .hero-slide-content {
    padding: 2rem 0 2.5rem;
  }

  .hero-slide-content h1 {
    font-size: 1.65rem;
  }

  .hero-slide-content .lead {
    font-size: 0.95rem;
  }

  .trust-bar {
    background: var(--app-card);
    margin: 0.75rem 0.75rem 0;
    border-radius: var(--app-radius);
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  }

  .trust-bar .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .trust-bar h6 {
    font-size: 0.8rem;
  }

  .trust-bar .small {
    font-size: 0.7rem;
  }

  .app-main > section {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  .app-main > section .row.g-4 {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }

  .app-main > section .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .app-main > section.bg-light {
    background: transparent !important;
  }

  .section-title {
    font-size: 1.25rem;
    margin-bottom: 0.85rem !important;
    padding-left: 0.15rem;
  }

  .category-tile {
    background: var(--app-card);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    padding: 0.85rem 0.35rem;
  }

  .category-tile .category-icon {
    width: 64px;
    height: 64px;
  }

  .category-tile span {
    font-size: 0.8rem;
    font-weight: 600;
  }

  .product-card {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border-radius: 14px;
  }

  .product-image,
  .product-photo {
    height: 140px;
  }

  .product-body {
    padding: 0.75rem;
  }

  .product-title {
    font-size: 0.85rem;
    line-height: 1.3;
  }

  .product-price {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .product-body .btn {
    border-radius: 10px;
    font-size: 0.8rem;
    padding: 0.45rem 0.5rem;
  }

  /* Category & product pages */
  .page-banner {
    border-radius: 0 0 16px 16px;
    margin-bottom: 0.5rem;
  }

  .page-banner h1 {
    font-size: 1.5rem;
  }

  /* Cart & checkout */
  .order-summary {
    border-radius: 14px;
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  }

  /* Account */
  .account-section {
    background: var(--app-bg);
    padding-top: 0.5rem !important;
  }

  .account-sidebar {
    flex-direction: row;
    overflow-x: auto;
    padding: 0.5rem;
    gap: 0.35rem;
    -webkit-overflow-scrolling: touch;
  }

  .account-sidebar a {
    white-space: nowrap;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }

  .account-panel {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    padding: 1.25rem;
  }

  /* Footer */
  .site-footer {
    margin-top: 0;
    background: transparent;
    color: var(--muted);
  }

  .mobile-footer-mini {
    text-align: center;
    padding: 1rem 0.75rem 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
  }

  /* Chat above bottom nav */
  .shop-chat-root {
    right: 0.75rem;
    bottom: calc(var(--app-nav-h) + var(--app-safe-bottom) + 0.75rem);
  }

  .shop-chat-toggle {
    width: 3.25rem;
    height: 3.25rem;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .shop-chat-toggle-label {
    display: none !important;
  }

  .shop-chat-panel {
    bottom: calc(100% + 0.5rem);
    width: calc(100vw - 1.5rem);
    max-height: min(70vh, 480px);
  }

  /* Contact */
  .contact-location {
    background: var(--app-card);
    border: none;
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 0.75rem !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  }

  .app-main section .bg-light.rounded {
    background: var(--app-card) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  }

  /* Shop browse — category drawer (same tree as desktop sidebar) */
  .mobile-cat-drawer {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: flex;
  }
  .mobile-cat-drawer[hidden] {
    display: none !important;
  }
  .mobile-cat-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
  }
  .mobile-cat-drawer-panel {
    position: relative;
    width: min(88vw, 300px);
    max-width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    animation: drawerIn 0.22s ease;
    padding-top: env(safe-area-inset-top, 0px);
  }
  @keyframes drawerIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
  }
  .mobile-cat-drawer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
  }
  .mobile-cat-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-cat-drawer-body .browse-nav-item {
    font-size: 0.92rem;
  }

  /* ── Shop browse: All Products + Category pages ── */
  .shop-browse-page {
    padding-top: 0 !important;
    padding-bottom: 0.5rem !important;
    overflow-x: clip;
  }

  .shop-browse-container {
    max-width: 100%;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .shop-browse-main {
    min-width: 0;
    width: 100%;
  }

  /* Sticky category bar under app header */
  .mobile-browse-bar {
    position: sticky;
    top: var(--app-header-total);
    z-index: 1035;
    background: var(--app-bg);
    margin: 0 -0.75rem 0.75rem;
    padding: 0.5rem 0.75rem 0.55rem;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  }

  .mobile-browse-bar-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.45rem;
  }

  .mobile-browse-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #e5e7eb;
    background: var(--app-card);
    color: var(--text);
    border-radius: 12px;
    flex-shrink: 0;
    font-size: 1.2rem;
    padding: 0;
  }

  .mobile-browse-menu-btn:active {
    background: var(--brand-light);
    color: var(--brand);
  }

  .mobile-browse-title-wrap {
    flex: 1;
    min-width: 0;
  }

  .mobile-browse-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.25;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-browse-sub {
    margin: 0.1rem 0 0;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.2;
  }

  .browse-nav-mobile {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.1rem;
    margin: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .browse-nav-mobile::-webkit-scrollbar {
    display: none;
  }

  .browse-nav-sub {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  .browse-chip {
    flex: 0 0 auto;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: var(--app-card);
    color: var(--text);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.2;
  }

  .browse-chip.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
  }

  .browse-chip-sub {
    font-size: 0.76rem;
  }

  /* Product sections */
  .product-browse-section {
    scroll-margin-top: calc(var(--app-header-total) + 5.5rem);
    margin-bottom: 1.25rem;
    background: var(--app-card);
    border-radius: 14px;
    padding: 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  }

  .product-browse-section-head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
  }

  .product-browse-section-head .h5 {
    font-size: 0.95rem;
  }

  .product-browse-section .row {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }

  .shop-browse-main > .row {
    --bs-gutter-x: 0.5rem;
    --bs-gutter-y: 0.5rem;
  }

  .shop-browse-main .product-card {
    height: 100%;
  }

  .shop-browse-main .product-image,
  .shop-browse-main .product-photo {
    height: 120px;
  }

  .shop-browse-main .product-body {
    padding: 0.6rem;
  }

  .shop-browse-main .product-title {
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .shop-browse-main .product-price {
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
  }

  .shop-browse-main .product-body .btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.4rem;
  }

  /* Home quick shop shortcuts */
  .mobile-quick-shop {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.65rem 0.75rem 0;
  }

  .mobile-quick-shop-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 4.25rem;
    border: none;
    border-radius: 14px;
    background: var(--app-card);
    color: var(--text);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 0.5rem 0.35rem;
  }

  .mobile-quick-shop-btn i {
    font-size: 1.2rem;
    color: var(--brand);
  }

  .mobile-quick-shop-primary {
    background: var(--brand-light);
    color: var(--brand);
  }

  .mobile-quick-shop-btn:active {
    transform: scale(0.98);
  }

  /* Add-to-cart toast */
  .cart-toast {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(var(--app-nav-h) + var(--app-safe-bottom) + 0.65rem);
    z-index: 1055;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    background: #1f2937;
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    transform: translateY(120%);
    transition: transform 0.25s ease;
  }

  .cart-toast.is-visible {
    transform: translateY(0);
  }

  .cart-toast i {
    color: #4ade80;
    font-size: 1.1rem;
    flex-shrink: 0;
  }

  .cart-toast-text {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.3;
  }

  .cart-toast-link {
    color: #fdba74;
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
  }

  /* Cart — same table as desktop; easier taps on mobile */
  .table-responsive .table {
    font-size: 0.85rem;
  }

  .table-responsive .form-control-sm {
    min-width: 4rem;
  }

  .table-responsive + .btn-outline-secondary {
    width: 100%;
    margin-top: 0.5rem;
  }

  /* Search results */
  .shop-search-form {
    background: var(--app-card);
    border-radius: 14px;
    padding: 0.55rem 0.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  }

  .shop-search-form input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    min-width: 0;
  }

  /* Product sticky bar */
  .product-page {
    padding-bottom: 5rem !important;
  }

  .mobile-product-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--app-nav-h) + var(--app-safe-bottom));
    z-index: 1038;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--app-card);
    border-top: 1px solid #e8e8e8;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  }

  .mobile-product-bar-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
    min-width: 4.5rem;
  }

  .mobile-product-bar .btn {
    flex: 1;
    border-radius: 12px;
  }
}
