/*
  ═══════════════════════════════════════════════════════════════════
  I-PETS — RESPONSIVE SUB-PAGES (product, checkout, subcategory, etc.)
  Target: iPhone 7 (375px) baseline, scales up to 768px.
  Scope: body.product-page, body.checkout-page, body.subcategory-page
  ═══════════════════════════════════════════════════════════════════
*/

@media screen and (max-width: 768px) {

  /* ┌──────────────────────────────────────────────────────────────┐
     │  GLOBAL — container, overflow, text-size-adjust             │
     └──────────────────────────────────────────────────────────────┘ */
  html { overflow-x: clip !important; -webkit-text-size-adjust: 100%; }
  body { overflow-x: clip !important; -webkit-tap-highlight-color: transparent; }
  @supports not (overflow: clip) {
    html, body { overflow-x: hidden !important; }
  }

  .subcategory-page .container,
  .product-page .container,
  .checkout-page .container {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: max(16px, env(safe-area-inset-left, 16px)) !important;
    padding-right: max(16px, env(safe-area-inset-right, 16px)) !important;
    box-sizing: border-box !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  SUB-HEADER — compact sticky bar, hide desktop tool icons   │
     │  Keep only: back-link, brand, cart (+ count), theme toggle? │
     └──────────────────────────────────────────────────────────────┘ */
  .sub-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 8px 0 !important;
  }

  .sub-header .container.sub-header-row {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    align-items: center !important;
    gap: 8px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }

  .sub-back-link {
    grid-column: 1;
    font-size: 13px !important;
    padding: 6px 8px !important;
    white-space: nowrap;
  }

  .sub-catalog-btn {
    grid-column: 1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  .sub-catalog-btn:hover,
  .sub-catalog-btn:focus-visible {
    background: color-mix(in srgb, var(--primary) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  }

  .sub-catalog-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.6;
    fill: none;
    color: var(--primary-strong, var(--text));
  }

  .sub-brand {
    display: inline-flex !important;
    grid-column: 2;
    justify-self: center !important;
    align-items: center;
  }

  .sub-brand img {
    width: 68px !important;
    max-width: 22vw !important;
    height: auto;
    display: block;
  }

  .sub-header-tools {
    grid-column: 3;
    display: flex !important;
    align-items: center;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
  }

  /* Hide secondary icons on sub-pages — keep only cart as main action */
  .sub-header-tools > #productThemeToggle,
  .sub-header-tools > #checkoutThemeToggle,
  .sub-header-tools > .control-group,
  .sub-header-tools > .wiki-btn,
  .sub-header-tools > .top-social-btn,
  .sub-header-tools > .pet-profile-btn,
  .sub-header-tools > .profile-btn,
  .sub-header-tools > [id$="CompareBtn"],
  .sub-header-tools > [id$="FavoriteBtn"] {
    display: none !important;
  }

  .sub-header-tools .cart-btn,
  .sub-header-tools .top-icon-btn {
    width: 38px !important;
    height: 38px !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  BREADCRUMBS — horizontally scrollable, compact             │
     └──────────────────────────────────────────────────────────────┘ */
  .sub-breadcrumbs {
    font-size: 12px !important;
    padding: 10px 0 4px !important;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }

  .sub-breadcrumbs::-webkit-scrollbar { display: none; }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  MAIN + PANELS                                               │
     └──────────────────────────────────────────────────────────────┘ */
  .sub-main {
    padding-top: 8px !important;
    padding-bottom: 80px !important; /* room for sticky CTA */
  }

  .panel {
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  PRODUCT PAGE — stack everything vertically                  │
     └──────────────────────────────────────────────────────────────┘ */
  .product-page .product-summary {
    display: flex !important;
    flex-direction: column !important;
    padding: 12px !important;
    gap: 14px !important;
  }

  .product-page .product-media {
    margin: 0 !important;
    width: 100% !important;
    aspect-ratio: 1 / 1;
    max-height: 340px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-soft);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .product-page .product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block;
  }

  .product-page .product-content {
    width: 100% !important;
    padding: 0 !important;
  }

  .product-page .product-content h1,
  .product-page #productTitle {
    font-size: 20px !important;
    line-height: 1.25 !important;
    margin: 0 0 10px !important;
    word-wrap: break-word;
  }

  .product-page .product-specs-brief {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  .product-page .product-specs-main {
    width: 100% !important;
  }

  .product-page .product-specs-title {
    font-size: 13px !important;
    margin: 0 0 6px !important;
  }

  .product-page .product-specs-list {
    font-size: 13px !important;
  }

  .product-page .product-specs-list dt {
    font-size: 12px !important;
  }

  .product-page .product-specs-list dd {
    font-size: 13px !important;
    margin: 0 0 6px !important;
  }

  .product-page .product-specs-more {
    font-size: 13px !important;
    padding: 8px 12px !important;
  }

  .product-page .product-qr-inline {
    display: grid !important;
    grid-template-columns: auto 1fr !important;
    gap: 10px !important;
    align-items: center;
    padding: 10px !important;
    border-radius: 10px;
    background: var(--surface-soft);
  }

  .product-page .product-qr-image {
    width: 72px !important;
    height: 72px !important;
  }

  .product-page .product-qr-inline .product-price-label {
    grid-column: 1 / span 2;
    margin: 0 !important;
    font-size: 12px !important;
  }

  .product-page .product-stats {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px !important;
  }

  .product-page .product-stat {
    padding: 8px 6px !important;
    text-align: center;
  }

  .product-page .product-stat span {
    font-size: 11px !important;
  }

  .product-page .product-stat strong {
    font-size: 15px !important;
  }

  .product-page .product-features {
    font-size: 13px !important;
    padding: 0 0 0 18px !important;
    margin: 8px 0 0 !important;
  }

  .product-page .product-price-box {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .product-page .product-subscription-card,
  .product-page .product-best-offer-card,
  .product-page .product-range-card {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .product-page .product-price-range {
    font-size: 22px !important;
    margin: 4px 0 !important;
  }

  .product-page .product-price-range-small {
    font-size: 18px !important;
  }

  .product-page .product-price-label {
    font-size: 12px !important;
  }

  /* All CTAs in product page must be touch-friendly */
  .product-page .sub-buy-btn {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 15px !important;
    padding: 11px 14px !important;
    border-radius: 10px !important;
  }

  /* ── Product tabs — horizontal scroll ── */
  .product-page .product-tabs {
    gap: 4px !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    padding: 6px 4px !important;
    scrollbar-width: none;
  }

  .product-page .product-tabs::-webkit-scrollbar { display: none; }

  .product-page .product-tab {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    min-height: 40px;
  }

  .product-page .product-tab-panel {
    padding: 12px !important;
    font-size: 14px !important;
    line-height: 1.5;
  }

  /* ── Seller offers list — card-style on mobile ── */
  .product-page .product-offers {
    padding: 12px !important;
  }

  .product-page .product-offers-head h2 {
    font-size: 17px !important;
    margin: 0 0 6px !important;
  }

  .product-page .product-seller-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  /* ── Viewed products track — horizontal scroll snap ── */
  .product-page .viewed-products-track {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .product-page .viewed-products-track::-webkit-scrollbar { display: none; }

  .product-page .viewed-products-grid {
    display: flex !important;
    gap: 10px !important;
    grid-template-columns: none !important;
  }

  .product-page .viewed-products-grid > * {
    flex: 0 0 48vw !important;
    min-width: 48vw !important;
    scroll-snap-align: start;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  CHECKOUT PAGE — single-column form, iOS-safe inputs        │
     └──────────────────────────────────────────────────────────────┘ */
  .checkout-page .checkout-heading {
    padding: 12px 0 8px !important;
  }

  .checkout-page .checkout-heading h1 {
    font-size: 20px !important;
    margin: 0 0 6px !important;
  }

  .checkout-page .checkout-heading p {
    font-size: 13px !important;
    margin: 0 !important;
  }

  .checkout-page .checkout-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    grid-template-columns: none !important;
  }

  .checkout-page .checkout-left,
  .checkout-page .checkout-right {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .checkout-page .checkout-card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .checkout-page .checkout-card-head h2 {
    font-size: 16px !important;
    margin: 0 0 10px !important;
  }

  .checkout-page .checkout-link-btn {
    font-size: 13px !important;
    padding: 4px 8px !important;
  }

  /* Two-column form fields → single column on mobile */
  .checkout-page .checkout-fields,
  .checkout-page .checkout-fields-two {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .checkout-page .checkout-field {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
  }

  .checkout-page .checkout-field span {
    font-size: 12px !important;
    color: var(--muted);
    font-weight: 500;
  }

  /* iOS: font-size ≥ 16px prevents auto-zoom on focus */
  .checkout-page .checkout-field input,
  .checkout-page .checkout-field textarea,
  .checkout-page .checkout-field select {
    font-size: 16px !important;
    padding: 12px 14px !important;
    border-radius: 10px !important;
    min-height: 44px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
  }

  /* Delivery / payment radio cards — full width, comfortable tap */
  .checkout-page .checkout-choice-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .checkout-page .checkout-choice-card {
    display: grid !important;
    grid-template-columns: 20px 1fr !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 12px !important;
    align-items: start;
    cursor: pointer;
    min-height: 56px;
  }

  .checkout-page .checkout-choice-card input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
  }

  .checkout-page .checkout-choice-main strong {
    font-size: 14px !important;
    line-height: 1.3;
    display: block;
  }

  .checkout-page .checkout-choice-main p {
    font-size: 12px !important;
    margin: 4px 0 0 !important;
    color: var(--muted);
  }

  .checkout-page .checkout-hint-box,
  .checkout-page .checkout-warning-box {
    font-size: 12px !important;
    padding: 10px !important;
    border-radius: 8px !important;
    margin-bottom: 10px !important;
  }

  .checkout-page .checkout-order-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
  }

  /* Primary CTA — sticky at bottom for conversion */
  .checkout-page .checkout-primary-btn,
  .checkout-page .checkout-submit-btn {
    width: 100% !important;
    min-height: 48px !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    padding: 13px 16px !important;
    border-radius: 12px !important;
  }

  /* Totals panel — compact summary */
  .checkout-page .checkout-totals,
  .checkout-page .checkout-summary {
    padding: 14px !important;
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 0 !important;
    border-radius: 14px 14px 0 0 !important;
  }

  /* Empty-state */
  .checkout-page .checkout-empty {
    padding: 20px !important;
    text-align: center;
  }

  .checkout-page .checkout-empty h2 {
    font-size: 18px !important;
  }

  .checkout-page .checkout-empty p {
    font-size: 13px !important;
    margin: 8px 0 14px !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  FLOATING AI + SCROLL TOP — avoid overlapping sticky CTA    │
     └──────────────────────────────────────────────────────────────┘ */
  .floating-ai-btn,
  .scroll-top-btn {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    width: 48px !important;
    height: 48px !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  ALL BUTTONS — minimum touch target 44×44 (Apple HIG)        │
     └──────────────────────────────────────────────────────────────┘ */
  .subcategory-page button:not(.checkout-choice-card):not(.sub-back-link):not(.checkout-link-btn):not(.product-tab):not(.product-specs-more):not(.top-icon-btn):not(.icon-btn),
  .product-page button:not(.checkout-choice-card):not(.sub-back-link):not(.checkout-link-btn):not(.product-tab):not(.product-specs-more):not(.top-icon-btn):not(.icon-btn),
  .checkout-page button:not(.checkout-choice-card):not(.sub-back-link):not(.checkout-link-btn):not(.product-tab):not(.product-specs-more):not(.top-icon-btn):not(.icon-btn) {
    min-height: 40px;
  }

} /* END @media max-width: 768px */

/* ═══════════════════════════════════════════════════════════════════
   BASELINE — generic sub-page mobile rules for subcategory/article/
   seller/shelter/events/interesting/social/cabinet pages.
   Applied at ≤768px.
   ═══════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 768px) {

  /* ── SUBCATEGORY + GROUP ── */
  .subcategory-page .subcategory-layout,
  .subcategory-group-page .subcategory-group-layout,
  .interesting-page .interesting-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    grid-template-columns: none !important;
  }

  .subcategory-page .subcategory-filters,
  .subcategory-group-page .subcategory-group-filters {
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    padding: 12px !important;
    order: -1;
  }

  .subcategory-page .subcategory-products-grid,
  .subcategory-group-page .subcategory-group-products,
  .interesting-page .interesting-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .subcategory-page .product-card,
  .subcategory-group-page .product-card {
    min-height: auto !important;
    border-radius: 12px !important;
  }

  .subcategory-page .product-card-title {
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  .subcategory-page .product-card-price {
    font-size: 15px !important;
  }

  .subcategory-page .product-card-btn,
  .subcategory-group-page .product-card-btn {
    width: 100% !important;
    min-height: 40px !important;
    font-size: 13px !important;
  }

  /* ── ARTICLE PAGE ── */
  .article-page .article-layout,
  .article-page .article-main {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    grid-template-columns: none !important;
  }

  .article-page .article-hero img,
  .article-page .article-hero picture img {
    width: 100% !important;
    height: auto !important;
    max-height: 260px !important;
    object-fit: cover !important;
    border-radius: 12px !important;
  }

  .article-page .article-body {
    padding: 14px !important;
    font-size: 15px !important;
    line-height: 1.6 !important;
  }

  .article-page .article-body h1 {
    font-size: 22px !important;
    line-height: 1.2 !important;
  }

  .article-page .article-body h2 {
    font-size: 18px !important;
  }

  .article-page .article-body h3 {
    font-size: 16px !important;
  }

  .article-page .article-body img,
  .article-page .article-body picture {
    max-width: 100% !important;
    height: auto !important;
    border-radius: 10px;
  }

  .article-page .article-aside {
    width: 100% !important;
    padding: 14px !important;
  }

  /* ── SELLER PAGE ── */
  .seller-page .seller-hero,
  .seller-page .seller-header {
    padding: 16px !important;
    text-align: center;
  }

  .seller-page .seller-hero h1 {
    font-size: 20px !important;
  }

  .seller-page .seller-meta {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }

  .seller-page .seller-products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .seller-page .seller-tabs {
    display: flex !important;
    gap: 4px !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none;
  }

  .seller-page .seller-tabs::-webkit-scrollbar { display: none; }

  .seller-page .seller-tab {
    flex: 0 0 auto !important;
    min-height: 40px;
    font-size: 13px !important;
    padding: 8px 12px !important;
    white-space: nowrap;
  }

  /* ── SHELTER PAGE ── */
  .shelter-page .shelter-hero {
    padding: 16px !important;
    text-align: center;
  }

  .shelter-page .shelter-hero h1 {
    font-size: 20px !important;
  }

  .shelter-page .shelter-pets-grid,
  .shelter-page .shelter-needs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .shelter-page .shelter-donate-card,
  .shelter-page .shelter-contact-card {
    padding: 14px !important;
  }

  /* ── EVENTS / EVENT-DETAIL ── */
  .events-page .events-grid,
  .events-page .events-list {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .events-page .event-card,
  .events-page .event-list-item {
    padding: 12px !important;
  }

  .events-page .event-card-media,
  .events-page .event-list-media {
    aspect-ratio: 16 / 9;
    max-height: 180px;
    border-radius: 10px;
  }

  .event-detail-page .event-detail-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    grid-template-columns: none !important;
  }

  .event-detail-page .event-hero img,
  .event-detail-page .event-hero picture img {
    width: 100% !important;
    height: auto !important;
    max-height: 240px !important;
    object-fit: cover !important;
    border-radius: 12px !important;
  }

  /* ── INTERESTING PAGE (content feed) ── */
  .interesting-page .interesting-card {
    padding: 12px !important;
  }

  .interesting-page .interesting-card-title {
    font-size: 16px !important;
  }

  /* ── SOCIAL PAGE ── */
  .social-page .social-container,
  .social-page .social-layout,
  .social-page .social-feed-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    grid-template-columns: none !important;
    padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
  }

  .social-page .social-sidebar,
  .social-page .social-aside {
    display: none !important;
  }

  .social-page .social-post {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .social-page .social-post-media img,
  .social-page .social-post-media picture {
    max-width: 100% !important;
    border-radius: 10px;
  }

  .social-page .social-compose-field,
  .social-page .social-compose-field textarea {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px 12px !important;
  }

  /* ── CABINET (B2B dashboard) ── */
  .cabinet-page .cabinet-layout {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }

  .cabinet-page .cabinet-sidebar {
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    padding: 8px !important;
    overflow-x: auto !important;
  }

  .cabinet-page .cabinet-nav {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 4px !important;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .cabinet-page .cabinet-nav::-webkit-scrollbar { display: none; }

  .cabinet-page .cabinet-nav-item,
  .cabinet-page .cabinet-nav-link {
    flex: 0 0 auto !important;
    min-height: 40px;
    font-size: 13px !important;
    padding: 8px 12px !important;
    white-space: nowrap;
  }

  .cabinet-page .cabinet-content,
  .cabinet-page .cabinet-main {
    padding: 12px !important;
  }

  .cabinet-page .cabinet-card,
  .cabinet-page .cabinet-panel {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  .cabinet-page .cabinet-stats-grid,
  .cabinet-page .cabinet-dashboard-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .cabinet-page table {
    font-size: 12px !important;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* ── FORMS — iOS-safe inputs everywhere on sub-pages ── */
  .subcategory-page input[type="text"],
  .subcategory-page input[type="email"],
  .subcategory-page input[type="tel"],
  .subcategory-page input[type="number"],
  .subcategory-page input[type="search"],
  .subcategory-page input[type="password"],
  .subcategory-page textarea,
  .subcategory-page select,
  .social-page input[type="text"],
  .social-page input[type="email"],
  .social-page textarea,
  .cabinet-page input[type="text"],
  .cabinet-page input[type="email"],
  .cabinet-page input[type="tel"],
  .cabinet-page input[type="number"],
  .cabinet-page textarea,
  .cabinet-page select {
    font-size: 16px !important; /* prevents iOS focus zoom */
    min-height: 44px !important;
    padding: 10px 12px !important;
    border-radius: 10px !important;
    width: 100%;
    box-sizing: border-box !important;
  }

  /* ── BUTTONS — touch target baseline ── */
  .subcategory-page button,
  .social-page button,
  .cabinet-page button {
    min-height: 40px;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  CAROUSEL DOTS — round 5px circles on sub-pages mobile.      │
     │  The Apple-HIG min-height:40px rule above stretched the      │
     │  9×9 dots into vertical ellipses; force 5×5 round shape and  │
     │  expose a 44px tap target via the ::before pseudo.           │
     └──────────────────────────────────────────────────────────────┘ */
  .subcategory-page .ads-carousel-dot,
  .subcategory-page .ads-carousel-dots button,
  .subcategory-page .brands-carousel-dots button,
  .product-page .ads-carousel-dot,
  .product-page .ads-carousel-dots button,
  .product-page .brands-carousel-dots button,
  .checkout-page .ads-carousel-dot,
  .checkout-page .ads-carousel-dots button,
  .checkout-page .brands-carousel-dots button,
  .ads-carousel-dots .ads-carousel-dot,
  .brands-carousel-dots .ads-carousel-dot {
    min-height: 0 !important;
    width: 8px !important;
    height: 8px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    flex: 0 0 auto;
    position: relative;
  }

  .ads-carousel-dots,
  .brands-carousel-dots {
    gap: 8px;
    padding: 10px 0 2px;
  }

  .ads-carousel-dots .ads-carousel-dot::before,
  .brands-carousel-dots .ads-carousel-dot::before {
    content: "";
    position: absolute;
    inset: -18px -6px;
  }

  .ads-carousel-dot.is-active,
  .brands-carousel-dots .ads-carousel-dot.is-active {
    background: var(--primary);
    transform: none !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  SCROLL-TO-TOP BUTTON — show on scroll on sub-pages          │
     │  (overrides the global mobile display:none for sub-pages)    │
     └──────────────────────────────────────────────────────────────┘ */
  .scroll-top-btn.show {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    bottom: calc(124px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .floating-ai-btn,
  .floating-ai-btn.with-scroll,
  .floating-ai-btn.is-always-visible {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px;
  }


  .subcategory-page .icon-btn,
  .subcategory-page .top-icon-btn,
  .social-page .icon-btn,
  .cabinet-page .icon-btn {
    min-height: 38px;
    min-width: 38px;
  }

}

/* ═══════════════════════════════════════════════════════════════════
   Tier 1: compact phones (max-width: 479px) — iPhone 7 primary
   ═══════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 479px) {

  .product-page .product-media {
    max-height: 300px;
  }

  .product-page .product-stats {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .product-page .product-stat strong {
    font-size: 14px !important;
  }

  .product-page .product-qr-image {
    width: 64px !important;
    height: 64px !important;
  }

  .checkout-page .checkout-card {
    padding: 12px !important;
  }

  /* Tighter product grid on narrow viewports */
  .subcategory-page .subcategory-products-grid,
  .seller-page .seller-products-grid,
  .shelter-page .shelter-pets-grid {
    gap: 6px !important;
  }

  .cabinet-page .cabinet-stats-grid {
    grid-template-columns: 1fr !important;
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  MOBILE CATALOG SIDEBAR — mirrors the home page behavior:    │
     │  hidden by default; opens as floating dropdown anchored to   │
     │  the top nav via the .sub-catalog-btn trigger                │
     └──────────────────────────────────────────────────────────────┘ */
  .sub-mobile-sidebar {
    display: none;
  }

  .sub-mobile-sidebar.is-mobile-open {
    display: block !important;
    position: fixed;
    top: var(--mobile-catalog-top, 64px);
    left: 8px;
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100vh - var(--mobile-catalog-top, 64px) - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    padding: 14px;
    animation: subCatalogIn 0.18s ease-out;
  }

  .sub-mobile-sidebar.is-mobile-open .sidebar-title-btn {
    font-size: 18px;
    margin: 0 0 4px;
  }

  .sub-mobile-sidebar.is-mobile-open .hint {
    font-size: 12px;
    margin: 0 0 10px;
    color: var(--muted);
  }

  .sub-mobile-sidebar.is-mobile-open .sidebar-search {
    width: 100%;
    font-size: 14px;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    box-sizing: border-box;
  }

  .sub-mobile-sidebar.is-mobile-open .tree-view {
    max-height: none;
  }

  .sidebar-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.28);
    z-index: 999;
    animation: subCatalogBackdropIn 0.18s ease-out;
  }

  @keyframes subCatalogIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes subCatalogBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }

  /* ┌──────────────────────────────────────────────────────────────┐
     │  MOBILE BOTTOM NAV — copied verbatim from index.html's        │
     │  responsive-mobile.css so sub-pages match the home visually.  │
     │  Auto-hide on scroll is layered on top via .is-hidden.        │
     └──────────────────────────────────────────────────────────────┘ */
  .mobile-bottom-nav.sub-mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
    z-index: 200;
    justify-content: space-around;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    grid-template-columns: none;
    transition: transform 0.25s ease;
    will-change: transform;
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav.is-hidden {
    transform: translateY(110%);
    pointer-events: none;
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 10px;
    padding: 4px 8px;
    cursor: pointer;
    min-width: 52px;
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn.is-active {
    color: var(--primary);
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    transform-origin: center;
    width: 28px;
    height: 2px;
    border-radius: 0 0 3px 3px;
    background: var(--primary);
    transition: transform 0.2s ease;
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn.is-active::before {
    transform: translateX(-50%) scaleX(1);
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn.is-active .mobile-bottom-nav-ico {
    transform: translateY(-1px);
  }

  .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-ico {
    font-size: 20px;
    line-height: 1;
    transition: transform 0.2s ease;
  }

  @media (prefers-reduced-motion: reduce) {
    .mobile-bottom-nav.sub-mobile-bottom-nav,
    .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn,
    .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-btn::before,
    .mobile-bottom-nav.sub-mobile-bottom-nav .mobile-bottom-nav-ico {
      transition: none !important;
    }
  }

}

/* ┌──────────────────────────────────────────────────────────────┐
   │  DESKTOP — hide the mobile bottom nav AND the injected mobile │
   │  catalog drawer on sub-pages (both are mobile-only). Mobile   │
   │  keeps them via the @media (max-width: 768px) block.          │
   └──────────────────────────────────────────────────────────────┘ */
@media (min-width: 769px) {
  .mobile-bottom-nav.sub-mobile-bottom-nav,
  .sub-mobile-sidebar,
  #subSidebarPanel {
    display: none !important;
  }
}
