/* Mobile layout only. Desktop rules remain owned by the existing stylesheets. */
[data-lm-mobile-only] { display: none !important; }

@media (max-width: 900px) {
  html:root body .wrap,
  html:root body.lm-marketplace-page main.wrap,
  html:root body.lm-public-page main.wrap,
  html:root body.lm-v134-marketplace main.wrap {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box;
  }
  html:root body main, html:root body main > *,
  html:root body .panel, html:root body .product-info,
  html:root body .product-body, html:root body .lm-message-panel,
  html:root body .lm-product-detail-grid > * { min-width: 0; }
  html:root body main.wrap > header:not(.site-header) { flex-wrap: wrap; gap: 12px; }
  html:root body main.wrap > header:not(.site-header) > * { min-width: 0; max-width: 100%; }
  html:root body .product-hero-card { grid-template-columns: minmax(0, 1fr); border-radius: 18px; }
  html:root body .product-gallery { padding: 4px; background: #fff; }
  html:root body .product-main-image {
    display: block; width: 100%; max-width: none; max-height: none;
    aspect-ratio: 1; object-fit: contain; border-radius: 14px;
    border: 0; box-shadow: none; background: #fff;
  }
  html:root body .product-info { padding: 18px 12px; }
  html:root body .detail-title { font-size: clamp(23px, 6.2vw, 30px); overflow-wrap: anywhere; }
  html:root body .detail-price { font-size: clamp(28px, 7.5vw, 38px); }
  html:root body .product-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html:root body .hero-actions { gap: 8px; }
  html:root body .hero-actions .btn { min-height: 44px; }
  html:root body .panel { padding: 16px 12px; }
  html:root body .product-card .lm-card-location,
  html:root body .store-product-card .lm-card-location,
  html:root body .lm-react-product-card .lm-card-location,
  html:root body .card .lm-card-location { display: none !important; }
  html:root body .products-grid,
  html:root body.lm-marketplace-page main.wrap .products-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important;
  }
  html:root body .product-card .product-body { padding: 14px 12px !important; }
  html:root body .product-card .image-link { aspect-ratio: 4 / 3 !important; background: #fff; }
  html:root body .product-card .image-link img { width: 100%; height: 100%; object-fit: contain; }
  html:root body .product-card .product-title { font-size: 18px !important; min-height: 0 !important; }
  html:root body .product-card .price-chip { font-size: 16px !important; }
  html:root body .lm-react-product-card .lm-card-photo { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; }
  html:root body .lm-product-detail-mobile { padding: 12px 8px !important; }
  html:root body #root main:has(.lm-product-detail-mobile) { padding-left: 6px !important; padding-right: 6px !important; }
  html:root body .lm-product-detail-grid { grid-template-columns: minmax(0, 1fr); gap: 18px !important; }
  html:root body .lm-product-photo { width: 100%; height: 100%; object-fit: contain; background: #fff; }
  html:root body .lm-message-layout { grid-template-columns: minmax(0, 1fr); }
  html:root body .lm-message-hero, html:root body .lm-support-hero { padding: 20px 14px; border-radius: 18px; }
  html:root body .lm-message-thread { height: min(55dvh, 420px); min-height: 220px; }
  html:root body .lm-message-bubble { max-width: 92%; overflow-wrap: anywhere; }
  html:root body .lm-message-reply button { min-height: 44px; width: 100%; }
  html:root body .lm-mobile-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
  html:root body dialog { width: calc(100% - 24px); max-width: calc(100% - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; box-sizing: border-box; }
  html:root body iframe { max-width: 100%; }
  html:root body input:not([type=checkbox]):not([type=radio]), html:root body select, html:root body textarea { max-width: 100%; min-width: 0; font-size: 16px; box-sizing: border-box; }
  html:root body .lm-mobile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  html:root body .receipt { width: 100%; max-width: 100%; margin: 16px 0; padding: 18px 12px; box-sizing: border-box; }
  html:root body .receipt .top { flex-wrap: wrap; }
  html:root body main :is(p, a, h1, h2, h3, label, td, th),
  html:root body .receipt :is(p, a, h1, h2, h3, span) { overflow-wrap: anywhere; }
  html:root body [data-lm-mobile-header] { z-index: 1100 !important; overflow: visible !important; }
  html:root body [data-lm-mobile-header] .bar { display: flex !important; flex-wrap: nowrap !important; align-items: center !important; min-width: 0; padding: 10px 12px !important; }
  html:root body [data-lm-mobile-header] .mobile-menu-toggle {
    display: inline-flex !important; flex: 0 0 44px; width: 44px; height: 44px;
    align-items: center; justify-content: center; flex-direction: column; gap: 5px;
    border: 1px solid #dce2e8; border-radius: 12px; background: #fff; cursor: pointer;
  }
  html:root body [data-lm-mobile-header] .mobile-menu-toggle span { display: block; width: 20px; height: 2px; background: #172033; border-radius: 2px; }
  html:root body [data-lm-mobile-header] nav.lm-mobile-drawer.nav {
    position: fixed !important; inset: 0 0 0 auto !important;
    width: min(86vw, 360px) !important; min-width: 0 !important; max-width: calc(100vw - 24px) !important;
    height: 100dvh !important; max-height: 100dvh !important; margin: 0 !important;
    display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important;
    align-items: stretch !important; justify-content: flex-start !important; gap: 8px !important;
    padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)) !important;
    background: #fff !important; border-left: 1px solid #e5e7eb; z-index: 1202 !important;
    overflow-x: hidden !important; overflow-y: auto !important;
    transform: translateX(105%) !important; visibility: hidden; transition: transform .2s ease, visibility .2s;
    box-shadow: -12px 0 40px rgb(15 23 42 / 18%); box-sizing: border-box;
  }
  html:root body [data-lm-mobile-header][data-lm-mobile-open] nav.lm-mobile-drawer.nav { transform: translateX(0) !important; visibility: visible; }
  html:root body [data-lm-mobile-header] nav.lm-mobile-drawer.nav a,
  html:root body [data-lm-mobile-header] nav.lm-mobile-drawer.nav [data-lm-mobile-only] {
    display: flex !important; width: 100% !important; min-height: 46px !important;
    padding: 12px !important; align-items: center !important; justify-content: flex-start !important;
    white-space: normal !important; margin: 0 !important; box-sizing: border-box; line-height: 1.25 !important;
  }
  html:root body [data-lm-mobile-header] nav.lm-mobile-drawer.nav a.lm-mobile-dashboard-link { background: #eaf7ed !important; color: #166534 !important; font-weight: 800 !important; }
  html:root body [data-lm-mobile-header] .mobile-menu-close { display: flex !important; align-self: flex-end; justify-content: center; align-items: center; flex: 0 0 44px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: #f1f5f9; font-size: 26px; cursor: pointer; }
  html:root body [data-lm-mobile-header] .mobile-menu-backdrop { display: none !important; position: fixed !important; inset: 0 !important; z-index: 1201 !important; background: rgb(15 23 42 / 40%); }
  html:root body [data-lm-mobile-header][data-lm-mobile-open] .mobile-menu-backdrop { display: block !important; }
  html.lm-mobile-menu-open body { overflow: hidden !important; }
  html:root body .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 24px 16px !important; padding: 28px 16px !important; }
  html:root body .copyright { padding-left: 16px !important; padding-right: 16px !important; flex-wrap: wrap; }
}
@media (max-width: 480px) {
  html:root body .products-grid,
  html:root body.lm-marketplace-page main.wrap .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  html:root body .hero-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  html:root body .hero-actions > .btn { width: 100%; }
  html:root body .footer-grid { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  html:root body [data-lm-mobile-header] nav.lm-mobile-drawer.nav { transition: none; }
}

/* V176: compact marketplace, readable feed controls, and separate floating actions. */
@media (max-width: 900px) {
  html:root body .lm-marketplace-hero {
    min-height: 0 !important; padding: 24px 18px !important;
    border-radius: 24px !important; margin-bottom: 20px !important;
  }
  html:root body .lm-marketplace-hero h1 {
    font-size: clamp(26px, 7vw, 32px) !important;
    line-height: 1.12 !important; letter-spacing: -.035em !important;
    margin: 0 0 12px !important;
  }
  html:root body .lm-marketplace-hero p { font-size: 16px !important; line-height: 1.5 !important; }
  html:root body .lm-marketplace-hero .hero-actions { margin-top: 18px !important; gap: 10px !important; }
  html:root body .lm-marketplace-hero .hero-actions .btn {
    min-height: 46px !important; padding: 12px 16px !important;
    font-size: 15px !important; line-height: 1.25 !important;
  }
  html:root body .lm-feed-card { min-width: 0; border-radius: 16px; }
  html:root body .lm-feed-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: start; gap: 10px; padding: 14px 12px;
  }
  html:root body .lm-feed-seller { display: flex; min-width: 0; align-items: center; gap: 8px; }
  html:root body .lm-feed-seller > * { margin-left: 0 !important; }
  html:root body .lm-feed-avatar-button {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    flex: 0 0 44px; padding: 0; background: transparent; border: 0;
  }
  html:root body .lm-feed-seller-details { min-width: 0; }
  html:root body .lm-feed-seller-name {
    min-width: 0; min-height: 0; padding: 0; font-size: 14px !important;
    line-height: 1.35; text-align: left; white-space: normal;
    word-break: normal; overflow-wrap: anywhere;
  }
  html:root body .lm-feed-meta { flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
  html:root body .lm-feed-meta > * { margin: 0 !important; }
  html:root body .lm-feed-meta p { font-size: 10px; line-height: 1.4; }
  html:root body .lm-feed-follow, html:root body .lm-feed-shop {
    display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center;
    width: auto; min-height: 44px; padding: 8px 10px;
    font-size: 12px !important; line-height: 1.2;
    white-space: nowrap; overflow-wrap: normal; word-break: normal;
  }
  html:root body .lm-feed-follow { min-width: 88px; border-radius: 999px; }
  html:root body .lm-feed-copy { font-size: 14px; line-height: 1.6; }
  html:root body .lm-feed-product-preview {
    display: grid; grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 10px; align-items: center; margin: 12px 12px 0; padding: 10px;
  }
  html:root body .lm-feed-product-preview > * { margin-left: 0 !important; }
  html:root body .lm-feed-product-image {
    display: block; width: 56px; min-width: 56px; max-width: 56px;
    height: 56px; object-fit: contain; background: #fff; flex-shrink: 0;
  }
  html:root body .lm-feed-product-details { min-width: 0; }
  html:root body .lm-feed-product-details > p:first-child {
    font-size: 12px; line-height: 1.4; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  html:root body .lm-feed-product-details > p + p { font-size: 12px; margin-top: 4px; }
  html:root body .lm-feed-shop { min-width: 56px; border-radius: 10px; }
  html:root body .lm-feed-actionbar {
    display: flex; justify-content: space-around; gap: 8px; padding: 10px 12px;
  }
  html:root body .lm-feed-actionbar > * { margin-left: 0 !important; min-width: 0; }
  html:root body .lm-feed-actionbar button { min-width: 44px; min-height: 44px; padding: 8px; }
  html:root body .lm-feed-actionbar span { font-size: 10px; white-space: nowrap; overflow-wrap: normal; }
  html:root body .lm-feed-page > div:first-child { padding: 18px 12px; }
  html:root body .lm-feed-page > div:first-child > div:first-child { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
  html:root body .lm-feed-page > div:first-child .flex-shrink-0 { flex-wrap: wrap; gap: 12px; }
  html:root body .lm-feed-page > div:first-child .flex-shrink-0 > * { margin-left: 0 !important; }
  html:root body .lm-floating-chat {
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    z-index: 100 !important; max-width: calc(100vw - 24px);
  }
  html:root body .lm-chat-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; min-height: 56px; padding: 14px;
  }
  html:root body .lm-chat-panel {
    width: min(320px, calc(100vw - 24px));
    height: min(384px, calc(100dvh - 116px)); min-height: 0;
  }
  html:root body #lm-catalog-launcher {
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    z-index: 90 !important; width: auto; max-width: calc(100vw - 24px);
    min-height: 44px; padding: 10px 14px !important;
    font-size: 13px !important; line-height: 1.2 !important;
    white-space: nowrap; overflow-wrap: normal;
  }
  html:root body:has(.lm-floating-chat .lm-chat-panel) #lm-catalog-launcher {
    left: max(12px, env(safe-area-inset-left)) !important; right: auto !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 104px);
  }
}
@media (max-width: 480px) {
  html:root body .product-card .product-title { font-size: 14px !important; line-height: 1.35 !important; }
  html:root body .product-card .price-chip { font-size: 14px !important; }
  html:root body .product-card .product-body { padding: 10px 8px !important; }
  html:root body .product-card .card-actions .btn {
    width: 100%; min-width: 0; min-height: 42px; font-size: 12px !important;
    padding: 10px 6px !important; line-height: 1.25;
  }
}
