/* Mobile app shell — storefront only */

html {
  -webkit-text-size-adjust: 100%;
}

@media (max-width: 860px) {
  :root {
    --header-h: 72px;
    --tabbar-h: calc(3.65rem + env(safe-area-inset-bottom, 0px));
  }

  html.admin-crm {
    --tabbar-h: 0px;
  }

  body {
    padding-bottom: var(--tabbar-h);
  }

  html.admin-crm body {
    padding-bottom: 0;
  }

  .shell {
    width: min(1180px, calc(100% - 1.25rem));
  }

  .site-header {
    padding-top: env(safe-area-inset-top, 0px);
  }

  .header-utility,
  .header-utility-inner {
    display: contents;
  }

  .header-utility-meta {
    display: none;
  }

  .header-stack {
    padding: 0.45rem 0;
  }

  .header-top {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.45rem;
  }

  .brand-logo {
    height: 2.05rem;
    max-width: 7.25rem;
  }

  .header-search {
    display: block;
  }

  .search-form.ghost-search input,
  .search-form input,
  .page-search input,
  .home-search input,
  input[type="search"],
  input[type="text"],
  input[type="tel"],
  input[type="email"],
  input[type="number"],
  textarea {
    font-size: 16px;
  }

  .header-actions .header-auth {
    display: none;
  }

  .header-city span {
    display: none;
  }

  .header-city {
    width: 44px;
    max-width: 44px;
    min-width: 44px;
    padding: 0;
    justify-content: center;
  }

  .header-cart-panel {
    display: none !important;
  }

  .nav-toggle {
    display: none !important;
  }

  .app-nav-title {
    display: block;
    margin: 0 0 0.35rem;
    font-family: var(--display);
    font-size: 1.15rem;
    color: var(--green-deep);
  }

  .app-nav-extra {
    display: grid;
    gap: 0.15rem;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--line);
  }

  .app-nav-city {
    appearance: none;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    text-align: left;
    padding: 0.65rem 0.2rem;
    cursor: pointer;
  }

  .app-scrim {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(8, 28, 18, 0.42);
    backdrop-filter: blur(4px);
  }

  .app-scrim[hidden] {
    display: none !important;
  }

  body.nav-open .site-header {
    z-index: 80;
  }

  .main-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: var(--tabbar-h);
    z-index: 1;
    max-height: min(82vh, 36rem);
    overflow: auto;
    padding: 1.15rem 1.15rem calc(1.15rem + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    background: #fff;
    box-shadow: 0 -18px 50px rgba(10, 92, 50, 0.16);
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
  }

  .main-nav.is-open {
    display: flex;
  }

  .main-nav a {
    padding: 0.78rem 0.15rem;
    font-size: 1.02rem;
  }

  .main-nav a::after {
    display: none;
  }

  .app-tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    min-height: 3.65rem;
    padding: 0.28rem max(0.15rem, env(safe-area-inset-right, 0px)) calc(0.28rem + env(safe-area-inset-bottom, 0px)) max(0.15rem, env(safe-area-inset-left, 0px));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px) saturate(1.15);
    box-shadow: 0 -8px 28px rgba(10, 92, 50, 0.08);
  }

  html.admin-crm .app-tabbar {
    display: none;
  }

  .app-tab {
    appearance: none;
    border: 0;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    min-height: 3.1rem;
    padding: 0.15rem 0.2rem;
    color: var(--muted);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .app-tab:hover,
  .app-tab.is-active {
    color: var(--green-deep);
  }

  .app-tab-icon {
    position: relative;
    display: grid;
    place-items: center;
  }

  .app-tab-badge {
    position: absolute;
    top: -0.35rem;
    right: -0.55rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.22rem;
    border-radius: 999px;
    background: var(--green);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.05rem;
    text-align: center;
  }

  .app-tab-badge:not(.is-on),
  .app-tab-badge[hidden] {
    display: none;
  }

  .section {
    padding: 1.15rem 0 1.5rem;
  }

  .section-tight {
    padding-top: 0.85rem;
  }

  .page-title {
    font-size: clamp(1.35rem, 7vw, 1.85rem);
  }

  .breadcrumbs {
    font-size: 0.82rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .home-stage-inner {
    gap: 0.65rem;
  }

  .home-banners-viewport {
    aspect-ratio: 16 / 9;
    min-height: 10.5rem;
    max-height: min(38svh, 16.5rem);
  }

  .home-round-btn {
    width: 2.15rem;
    height: 2.15rem;
  }

  .home-round-btn.is-prev {
    left: 0.4rem;
    transform: translateY(-50%);
  }

  .home-round-btn.is-next {
    right: 0.4rem;
    transform: translateY(-50%);
  }

  .home-banner-copy {
    width: min(16.5rem, 58%);
    max-width: calc(100% - 3.4rem);
    padding: 0.7rem 0.55rem 0.7rem 1.05rem;
  }

  .home-banner-copy h1,
  .home-banner-title {
    font-size: clamp(0.78rem, 4.6vw, 1.05rem);
  }

  .home-banner-lead {
    font-size: 0.78rem;
  }

  .home-actions {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .home-catalog-tile {
    padding: 0.9rem 0.9rem 0.4rem;
  }

  .home-search {
    padding: 0.55rem 0.7rem 0.8rem;
  }

  .home-search-row {
    flex-wrap: wrap;
    border-radius: 16px;
    padding: 0.35rem;
  }

  .home-search .ghost-search-field {
    flex: 1 1 8rem;
  }

  .home-search button {
    flex: 1 1 auto;
    min-width: 6.5rem;
  }

  .home-showcase .showcase-slide {
    flex: 0 0 calc((100% - 0.5rem) / 2);
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .category-tile {
    min-height: 72px;
    padding: 0.85rem 0.95rem;
    border-radius: 16px;
  }

  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .product-card {
    border-radius: 14px;
  }

  .product-card:hover {
    transform: none;
  }

  .product-card h3 {
    margin: 0.65rem 0.7rem 0.25rem;
    font-size: 0.88rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .product-card .muted,
  .product-card .price {
    margin-left: 0.7rem;
    margin-right: 0.7rem;
    font-size: 0.84rem;
  }

  .product-detail {
    padding: 0.85rem;
    border-radius: 16px;
  }

  .product-detail h1 {
    font-size: 1.28rem;
  }

  .product-buy {
    position: sticky;
    bottom: calc(var(--tabbar-h) + 0.45rem);
    z-index: 20;
    margin: 1rem -0.35rem 0;
    padding: 0.7rem 0.7rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 28px rgba(10, 92, 50, 0.12);
    flex-direction: column;
    align-items: stretch;
  }

  .product-buy .btn,
  .product-buy .btn-ghost {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
  }

  .page-search {
    display: grid;
    grid-template-columns: 1fr auto;
    max-width: none;
  }

  .cart-layout,
  .cart-row {
    gap: 0.75rem;
  }

  .cart-summary {
    position: sticky;
    bottom: calc(var(--tabbar-h) + 0.4rem);
    z-index: 15;
  }

  body.is-auth .app-tabbar,
  body.is-auth .site-footer {
    display: none !important;
  }

  body.is-auth .auth-stage {
    min-height: calc(100svh - 6.5rem);
    align-items: center;
    padding-top: 1.2rem;
  }

  .auth-card,
  .auth-frame {
    width: 100%;
    padding: 1.2rem 1rem 1.3rem;
    border-radius: 18px;
  }

  .site-footer {
    padding-bottom: 1rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.1rem;
  }

  .footer-legal {
    font-size: 0.72rem;
  }

  .support-widget {
    right: 0.75rem;
    bottom: calc(var(--tabbar-h) + 0.75rem);
  }

  .support-fab {
    width: 3.2rem;
    height: 3.2rem;
  }

  .support-panel {
    width: min(100vw - 1.5rem, 320px);
  }

  .city-modal {
    padding: 0;
    align-items: end;
  }

  .city-modal-card,
  .city-picker-card {
    width: 100%;
    max-height: min(88vh, 40rem);
    border-radius: 22px 22px 0 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .rfq-section {
    margin-inline: 0;
  }

  .rfq-drop {
    padding: 1.15rem 0.85rem 1.05rem;
  }

  .rfq-modes {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .rfq-text {
    min-height: 7rem;
  }

  .rfq-submit {
    width: 100%;
    justify-content: center;
  }

  .trail-crumbs {
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 640px) {
  .home-catalog-tile {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .home-catalog-go {
    display: none;
  }

  .home-banner-copy {
    width: min(15.5rem, 64%);
  }

  .cart-qty {
    transform: scale(0.96);
    transform-origin: left center;
  }
}

@media (max-width: 420px) {
  .product-grid {
    gap: 0.5rem;
  }

  .product-card a {
    padding-bottom: 0.75rem;
  }
}

@media (hover: none) {
  .product-card:hover,
  .category-tile:hover,
  .header-cart:hover {
    transform: none;
  }
}
