/* XiaomiGlobal mobile final fixes — 2.41.0
 * Loaded after all legacy layout files so desktop rules cannot cover mobile copy.
 */

/* Mobile-only controls remain completely absent on desktop. */
body > .hsp-css-drawer-state,
body > .hsp-css-drawer-backdrop,
body > .hsp-css-mobile-drawer {
  display: none !important;
}

@media (max-width: 767px) {
  /* Cache-proof mobile drawer: it is a direct body child and opens through a
   * native checkbox, so it does not depend on the external JavaScript bundle. */
  body > .hsp-css-drawer-state {
    position: fixed !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body > .hsp-css-drawer-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483600 !important;
    display: none !important;
    margin: 0 !important;
    background: rgba(15, 23, 42, .48) !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
  }

  body > .hsp-css-mobile-drawer {
    position: fixed !important;
    top: max(10px, env(safe-area-inset-top)) !important;
    right: 10px !important;
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    left: 10px !important;
    z-index: 2147483640 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 12px !important;
    display: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 22px !important;
    background: #fff !important;
    color: #181818 !important;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .32) !important;
    direction: rtl !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  body > .hsp-css-drawer-state:checked + .hsp-css-drawer-backdrop,
  body > .hsp-css-drawer-state:checked + .hsp-css-drawer-backdrop + .hsp-css-mobile-drawer {
    display: block !important;
  }

  html:has(body > .hsp-css-drawer-state:checked),
  body:has(> .hsp-css-drawer-state:checked) {
    overflow: hidden !important;
  }

  body > .hsp-css-mobile-drawer .hsp-css-drawer-head {
    position: sticky !important;
    top: -12px !important;
    z-index: 3 !important;
    min-height: 58px !important;
    margin: 0 0 8px !important;
    padding: 8px 4px 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    border-bottom: 1px solid #eceef1 !important;
    background: #fff !important;
  }

  body > .hsp-css-mobile-drawer .hsp-css-drawer-head strong {
    font-size: 18px !important;
    line-height: 1.6 !important;
  }

  body > .hsp-css-mobile-drawer .hsp-css-drawer-head label {
    width: 42px !important;
    height: 42px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: #f1f3f5 !important;
    color: #181818 !important;
    font-size: 32px !important;
    line-height: 1 !important;
    cursor: pointer !important;
  }

  body > .hsp-css-mobile-drawer nav {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 6px !important;
  }

  body > .hsp-css-mobile-drawer nav a {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 50px !important;
    padding: 11px 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border: 1px solid #edf0f2 !important;
    border-radius: 13px !important;
    background: #fff !important;
    color: #181818 !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.7 !important;
    text-align: right !important;
    text-decoration: none !important;
    white-space: normal !important;
  }

  body > .hsp-css-mobile-drawer nav a:first-child,
  body > .hsp-css-mobile-drawer nav a:nth-child(2) {
    background: #181818 !important;
    border-color: #181818 !important;
    color: #fff !important;
  }

  html,
  body {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body {
    padding-bottom: calc(104px + env(safe-area-inset-bottom)) !important;
  }

  /* Keep every homepage heading and its supporting copy visually centred. */
  body .hsp-section-headline,
  body .hsp-hotspot-headline,
  body .hsp-weekly-deal-head,
  body .hsp-trust-panel-head {
    width: 100% !important;
    display: grid !important;
    justify-items: center !important;
    align-items: center !important;
    text-align: center !important;
  }

  body .hsp-section-headline > div,
  body .hsp-hotspot-headline > div,
  body .hsp-weekly-deal-head > div,
  body .hsp-trust-panel-head > div,
  body .hsp-section-headline h2,
  body .hsp-section-headline p,
  body .hsp-section-headline span,
  body .hsp-hotspot-headline h2,
  body .hsp-hotspot-headline p,
  body .hsp-weekly-deal-head h2,
  body .hsp-trust-panel-head h2 {
    width: 100% !important;
    max-width: 100% !important;
    margin-right: auto !important;
    margin-left: auto !important;
    text-align: center !important;
  }

  body .hsp-section-headline .hsp-erna-view-all,
  body .hsp-section-headline > a {
    width: min(100%, 390px) !important;
    min-height: 48px !important;
    margin: 8px auto 0 !important;
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
  }

  /* End-of-page category banners: image and copy are separate rows.
   * The old desktop layer was absolute and covered the title on phones. */
  body .hsp-milana-expand-section {
    padding-bottom: 112px !important;
    overflow: visible !important;
  }

  body .hsp-milana-expand-grid {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 18px !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body .hsp-milana-expand-card,
  body .hsp-milana-expand-card:first-child,
  body .hsp-milana-expand-grid:hover .hsp-milana-expand-card,
  body .hsp-milana-expand-grid:focus-within .hsp-milana-expand-card {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    overflow: hidden !important;
    border-radius: 24px !important;
    background: #fff !important;
  }

  body .hsp-milana-expand-link {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  body .hsp-milana-expand-link::before,
  body .hsp-milana-expand-link::after {
    display: none !important;
    content: none !important;
  }

  body .hsp-milana-expand-media,
  body .hsp-milana-expand-card:hover .hsp-milana-expand-media,
  body .hsp-milana-expand-card:focus-within .hsp-milana-expand-media {
    position: relative !important;
    inset: auto !important;
    z-index: 1 !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 16 / 9 !important;
    margin: 0 !important;
    transform: none !important;
    opacity: 1 !important;
    background-color: #f7f8fa !important;
    background-image: var(--hsp-expand-bg) !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
  }

  body .hsp-milana-expand-media::before,
  body .hsp-milana-expand-media::after {
    display: none !important;
    content: none !important;
  }

  body .hsp-milana-expand-content {
    position: relative !important;
    inset: auto !important;
    z-index: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 16px 18px 18px !important;
    overflow: visible !important;
    color: #181818 !important;
    background: #fff !important;
    text-align: center !important;
    transform: none !important;
    opacity: 1 !important;
  }

  body .hsp-milana-expand-content strong,
  body .hsp-milana-expand-content small {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #181818 !important;
    text-align: center !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    transform: none !important;
    opacity: 1 !important;
  }

  body .hsp-milana-expand-content strong {
    font-size: 21px !important;
    line-height: 1.55 !important;
  }

  body .hsp-milana-expand-content small {
    font-size: 13px !important;
    line-height: 1.8 !important;
  }

  body .hsp-milana-expand-content em {
    position: static !important;
    width: 100% !important;
    min-height: 44px !important;
    margin: 4px 0 0 !important;
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    border: 1px solid #e4e7eb !important;
    border-radius: 999px !important;
    background: #fff !important;
    color: #181818 !important;
    text-align: center !important;
    transform: none !important;
    opacity: 1 !important;
  }

  /* The fixed contact buttons must not cover the final card. */
  body .hsp-mobile-contact-bar {
    bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  }

  /* Main banner supports vertical page scrolling and horizontal JS swipes. */
  body [data-hsp-slider],
  body .hsp-fresh-hero,
  body .hsp-fresh-hero-slides,
  body .hsp-fresh-hero-slide {
    touch-action: pan-y !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }

  /* Full-width, scrollable mobile navigation drawer. These rules deliberately
   * override all legacy desktop mega-menu positioning. */
  body .site-header.hsp-fashion-menu-header .hsp-department-navigation {
    position: fixed !important;
    inset: 76px 10px calc(82px + env(safe-area-inset-bottom)) 10px !important;
    z-index: 100000 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 12px !important;
    display: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    border: 1px solid #e6e8eb !important;
    border-radius: 20px !important;
    background: #fff !important;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24) !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    direction: rtl !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-department-navigation.is-open {
    display: block !important;
  }

  /* The drawer is portalled to body while open. Keeping the familiar header
   * classes on this isolated host preserves all mega-menu rules without
   * inheriting the real header's grid, overflow or transformed ancestors. */
  body > .hsp-mobile-nav-portal {
    position: fixed !important;
    inset: calc(64px + env(safe-area-inset-top)) 10px calc(82px + env(safe-area-inset-bottom)) 10px !important;
    z-index: 100020 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
  }

  body > .hsp-mobile-nav-portal .hsp-department-navigation,
  body > .hsp-mobile-nav-portal .hsp-department-navigation.is-open {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    display: block !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body > .hsp-mobile-nav-portal .hsp-mobile-nav-close {
    position: sticky !important;
    top: -12px !important;
    z-index: 8 !important;
    width: 100% !important;
    min-height: 52px !important;
    margin: 0 0 6px !important;
    padding: 8px 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    border: 0 !important;
    border-bottom: 1px solid #eceef1 !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: #181818 !important;
    font: inherit !important;
    cursor: pointer !important;
  }

  body > .hsp-mobile-nav-portal .hsp-mobile-nav-close span {
    width: 38px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: #f3f4f6 !important;
    font-size: 30px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
  }

  body > .hsp-mobile-nav-portal .hsp-mobile-nav-close b {
    font-size: 16px !important;
    line-height: 1.6 !important;
  }

  body.hsp-mobile-nav-open::before {
    content: "" !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 99990 !important;
    display: block !important;
    background: rgba(15, 23, 42, .38) !important;
    backdrop-filter: blur(2px) !important;
    -webkit-backdrop-filter: blur(2px) !important;
  }

  body.hsp-mobile-nav-open #masthead,
  body.hsp-mobile-nav-open #masthead .hsp-fashion-menu-inner,
  body.hsp-mobile-nav-open #masthead .hsp-menu-toggle {
    position: relative !important;
    z-index: 100010 !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-department-menu {
    width: 100% !important;
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-department-menu > li,
  body .site-header.hsp-fashion-menu-header .hsp-dept-menu-wrap,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-wrap {
    position: relative !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-department-menu > li > a,
  body .site-header.hsp-fashion-menu-header .hsp-all-categories-toggle {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 50px !important;
    height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 12px 14px !important;
    overflow: hidden !important;
    border: 0 !important;
    border-bottom: 1px solid #eef0f2 !important;
    border-radius: 12px !important;
    background: #fff !important;
    color: #171717 !important;
    font-size: 14px !important;
    line-height: 1.7 !important;
    text-align: right !important;
    white-space: normal !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-department-menu > li > a em,
  body .site-header.hsp-fashion-menu-header .hsp-department-menu > li > a span {
    flex: 0 0 auto !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-dept-mega,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-panel {
    position: static !important;
    inset: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    z-index: auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    margin: 5px 0 10px !important;
    padding: 10px !important;
    display: none !important;
    overflow: hidden !important;
    border: 1px solid #eceef1 !important;
    border-radius: 14px !important;
    background: #fafafa !important;
    box-shadow: none !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-dept-menu-wrap.is-open > .hsp-dept-mega,
  body .site-header.hsp-fashion-menu-header .hsp-all-categories-toggle[aria-expanded="true"] + .hsp-dept-mega,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-wrap.is-open > .hsp-nav-mega-panel {
    display: block !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-dept-main,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-shop,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-products,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-deals,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-blog {
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: 0 !important;
    height: auto !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-shop-by-panel,
  body .site-header.hsp-fashion-menu-header .hsp-top-rated-panel,
  body .site-header.hsp-fashion-menu-header .hsp-dept-strip {
    width: 100% !important;
    min-width: 0 !important;
    padding: 12px 8px !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-shop-by-grid,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-cats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-dept-rounds,
  body .site-header.hsp-fashion-menu-header .hsp-top-rated-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-shop-by-grid > a,
  body .site-header.hsp-fashion-menu-header .hsp-dept-rounds > a,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-cats > a,
  body .site-header.hsp-fashion-menu-header .hsp-top-rated-grid > a,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-panel > a {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-align: center !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-shop-by-grid span,
  body .site-header.hsp-fashion-menu-header .hsp-dept-rounds span,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-cats span {
    width: 64px !important;
    height: 64px !important;
    max-width: 100% !important;
    margin: 0 auto 6px !important;
  }

  body .site-header.hsp-fashion-menu-header .hsp-shop-by-grid img,
  body .site-header.hsp-fashion-menu-header .hsp-dept-rounds img,
  body .site-header.hsp-fashion-menu-header .hsp-nav-mega-panel img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
  }
}
