/** APD534 — final mobile reference lock. */
@media (max-width: 767px) {
  /*
   * One deterministic visible summary.
   * The native summary nodes live inside the real #apd5-search form and are also
   * updated by the working marketplace engine.  They are the only painted nodes;
   * APD394 spans remain hidden compatibility mirrors.
   */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="location"] > button:first-child,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="dates"] > button:first-child {
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:12px !important;
  }

  /* Paint the engine-owned nodes.  This is the same state that is submitted. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="location"] > button:first-child > #apd5-location-summary,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="dates"] > button:first-child > #apd5-date-summary {
    display:block !important;
    position:static !important;
    flex:1 1 auto !important;
    width:auto !important;
    min-width:0 !important;
    max-width:72% !important;
    height:auto !important;
    margin:0 0 0 auto !important;
    padding:0 !important;
    color:#222 !important;
    opacity:1 !important;
    visibility:visible !important;
    font-size:16px !important;
    line-height:1.18 !important;
    font-weight:650 !important;
    letter-spacing:-.02em !important;
    text-align:right !important;
    white-space:nowrap !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
    pointer-events:none !important;
  }

  /* Compatibility mirrors are kept for integrations, never as a second layer. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="location"] > button:first-child > #apd394-location-summary,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="dates"] > button:first-child > #apd394-date-summary {
    display:none !important;
    visibility:hidden !important;
    width:0 !important;
    max-width:0 !important;
    height:0 !important;
    overflow:hidden !important;
    opacity:0 !important;
    pointer-events:none !important;
  }

  /* Disable the retired pseudo summary completely. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="location"] > button:first-child::after,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search#apd5-search > [data-search-field="dates"] > button:first-child::after {
    content:none !important;
    display:none !important;
  }

  /* Flexible: the month rail always exists in Alojamientos and is visibly scrollable. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-stays[data-active-panel="dates"]
  .apd15-date-view[data-apd-date-view="flexible"] {
    display:block !important;
    height:364px !important;
    min-height:364px !important;
    overflow:hidden !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-stays .apd15-flexible-months {
    display:flex !important;
    gap:10px !important;
    width:100% !important;
    min-height:122px !important;
    padding:0 1px 4px !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
    -webkit-overflow-scrolling:touch !important;
    touch-action:pan-x !important;
    scrollbar-width:none !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-stays .apd15-flexible-months > button {
    display:flex !important;
    flex:0 0 31.5% !important;
    min-width:108px !important;
    height:112px !important;
    flex-direction:column !important;
    align-items:center !important;
    justify-content:center !important;
    gap:3px !important;
    padding:12px 8px !important;
    border:1px solid #d7d7d7 !important;
    border-radius:20px !important;
    background:#fff !important;
    color:#222 !important;
  }

  /* Experiences + Services: exact same range language as Alojamientos. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button.is-in-range:not(.is-start):not(.is-end) {
    background:#f1f1f1 !important;
    color:#222 !important;
    border-radius:0 !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button:is(.is-start,.is-end) {
    position:relative !important;
    z-index:4 !important;
    color:#fff !important;
    background:transparent !important;
    border-radius:0 !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button:is(.is-start,.is-end)::after {
    content:"" !important;
    position:absolute !important;
    left:50% !important;
    top:50% !important;
    z-index:-1 !important;
    width:42px !important;
    height:42px !important;
    border-radius:50% !important;
    background:#222 !important;
    transform:translate(-50%,-50%) !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button.is-start:not(.is-end)::before,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button.is-end:not(.is-start)::before {
    content:"" !important;
    position:absolute !important;
    top:0 !important;
    bottom:0 !important;
    z-index:-2 !important;
    width:56% !important;
    background:#f1f1f1 !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button.is-start:not(.is-end)::before { right:-4px !important; }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)
  .apd5-calendar-days > button.is-end:not(.is-start)::before { left:-4px !important; }

  /* Dynamic quick-date subtitles must never be suppressed by old presentation rules. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:is(.apd380-context-experiences,.apd380-context-services)[data-active-panel="dates"]
  .apd141-date-shortcuts > button small {
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;
    min-height:14px !important;
  }

  /* Natural-height rounded cards; never visually touch the fixed footer. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-experiences[data-active-panel="guests"] > .apd5-guests-panel,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-services[data-active-panel="service"] > .apd5-service-panel {
    flex:0 0 auto !important;
    height:auto !important;
    min-height:0 !important;
    max-height:none !important;
    margin-bottom:18px !important;
    border-radius:29px !important;
    overflow:hidden !important;
  }
}


/* APD407 — Flexible choices stay physically tappable and visibly selected on iOS. */
@media (max-width: 767px) {
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-duration > button,
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-months > button {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-duration > button:is(.is-active,[aria-pressed="true"]),
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-months > button:is(.is-active,[aria-pressed="true"]) {
    border: 2px solid #222 !important;
    color: #222 !important;
    background: #fff !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-duration > button:not(.is-active):not([aria-pressed="true"]),
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search .apd15-flexible-months > button:not(.is-active):not([aria-pressed="true"]) {
    border: 1px solid #d7d7d7 !important;
  }
}


/* APD407 responsive safety contract. The mobile controller intentionally ends at
   767px; tablets and desktop retain the proven marketplace/desktop engine. These
   guards only prevent overflow/touch collisions and do not restyle those layouts. */
@media (min-width: 768px) {
  body.apd-marketplace-ui #apd5-search,
  body.apd-marketplace-ui #apd5-search * { box-sizing:border-box; }
  body.apd-marketplace-ui #apd5-search { min-width:0; }
  body.apd-marketplace-ui #apd5-search .apd5-search-panel {
    max-width:min(760px, calc(100vw - 32px));
  }
}
@media (min-width: 768px) and (max-width: 1024px) and (pointer: coarse) {
  body.apd-marketplace-ui #apd5-search button,
  body.apd-marketplace-ui #apd5-search input,
  body.apd-marketplace-ui #apd5-search [role="button"] {
    touch-action:manipulation;
  }
}

/* APD410 — desktop preservation for the context-agnostic date DOM.
   The correction is mobile-first, but the server now emits one complete date
   structure so mobile tabs can switch in place. These rules reproduce the
   previous desktop markup behavior without changing the desktop interaction. */
@media (min-width: 768px) {
  body.apd141-manual-ui .apd141-date-panel.is-stays .apd141-date-shortcuts {
    display: none !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd15-date-mode,
  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd15-date-flexibility,
  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd15-date-view[data-apd-date-view="flexible"] {
    display: none !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd15-date-view[data-apd-date-view="exact"] {
    display: grid !important;
    grid-template-columns: 145px minmax(0,1fr) !important;
    gap: 24px !important;
    align-items: start !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar {
    position: relative !important;
    min-height: 285px !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar .apd5-calendar-nav {
    position: absolute !important;
    top: -5px !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    justify-content: space-between !important;
    z-index: 2 !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar .apd5-calendar-months {
    display: block !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar .apd5-calendar-month h3 {
    margin: 0 0 14px !important;
  }

  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar .apd5-calendar-days > span,
  body.apd141-manual-ui .apd141-date-panel:not(.is-stays) .apd410-shared-calendar .apd5-calendar-days button {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
  }
}

/* APD434 — canonical Dónde contract. No APD411/APD425 geometry remains below this point. */
@media (max-width: 767px) {
  /* The current step is a normal flex card, never a viewport-sized blank sheet. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="location"] > .apd5-location-panel {
    box-sizing: border-box !important;
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 24px 22px 38px !important;
    border-radius: 30px !important;
    background: #fff !important;
    overflow: hidden !important;
  }

  /* Collapsed rows below Dónde are part of the location step, not hidden siblings. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="location"] > [data-search-field="dates"],
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-stays[data-active-panel="location"] > [data-search-field="guests"],
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-experiences[data-active-panel="location"] > [data-search-field="guests"],
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-services[data-active-panel="location"] > [data-search-field="service"] {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 64px !important;
    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;
  }

  /* Compact geometry is keyed only by the form-owned APD434 state. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-stays[data-active-panel="location"] > .apd5-location-panel {
    flex: 0 0 414px !important;
    height: 414px !important;
    min-height: 414px !important;
    max-height: 414px !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-experiences[data-active-panel="location"] > .apd5-location-panel {
    flex: 0 0 180px !important;
    height: 180px !important;
    min-height: 180px !important;
    max-height: 180px !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-services[data-active-panel="location"] > .apd5-location-panel {
    flex: 0 0 370px !important;
    height: 370px !important;
    min-height: 370px !important;
    max-height: 370px !important;
  }

  /* First-paint fallback before JS adds data-apd-location-mode. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-stays[data-active-panel="location"]:not([data-apd-location-mode]) > .apd5-location-panel {
    height: 414px !important; min-height: 414px !important; max-height: 414px !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-experiences[data-active-panel="location"]:not([data-apd-location-mode]) > .apd5-location-panel {
    height: 180px !important; min-height: 180px !important; max-height: 180px !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search.apd380-context-services[data-active-panel="location"]:not([data-apd-location-mode]) > .apd5-location-panel {
    height: 370px !important; min-height: 370px !important; max-height: 370px !important;
  }

  /* Compact content by context. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-stays[data-active-panel="location"]
  #apd26-recent-destination-list > *:nth-child(n+3) { display: none !important; }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-stays[data-active-panel="location"]
  #apd5-destination-list { display: none !important; }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-experiences[data-active-panel="location"]
  :is(#apd26-recent-destinations,.apd26-destination-section-title,[data-nearby],#apd5-destination-list,.apd226-smart-results) {
    display: none !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-services[data-active-panel="location"]
  #apd26-recent-destination-list > *:nth-child(n+3) { display: none !important; }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search:not([data-apd-location-mode="expanded"]).apd380-context-services[data-active-panel="location"]
  :is(.apd26-destination-section-title,[data-nearby],#apd5-destination-list,.apd226-smart-results) {
    display: none !important;
  }

  /* One real expand control. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="location"] .apd370-location-collapse {
    box-sizing: border-box !important;
    position: absolute !important;
    left: 22px !important;
    right: 22px !important;
    bottom: 0 !important;
    z-index: 20 !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: auto !important;
    height: 34px !important;
    min-height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    border-top: 1px solid #ebebeb !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-apd-location-mode="expanded"][data-active-panel="location"] > .apd5-location-panel {
    position: fixed !important;
    inset: 88px 12px calc(92px + env(safe-area-inset-bottom,0px)) 12px !important;
    z-index: 12002 !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 22px 22px 44px !important;
    border-radius: 28px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: #fff !important;
    box-shadow: 0 18px 56px rgba(15,23,42,.14) !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-apd-location-mode="expanded"][data-active-panel="location"] .apd370-location-collapse {
    position: sticky !important;
    left: 0 !important;
    right: 0 !important;
    bottom: -1px !important;
    width: 100% !important;
    margin-top: 8px !important;
  }

  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-apd-location-mode="expanded"][data-active-panel="location"] .apd384-location-chevron {
    transform: rotate(180deg) !important;
  }

  /* Empty state copy on the right of the summary rows. */
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="location"] #apd5-date-summary:empty::after {
    content: "Agregá fechas" !important;
  }
  html body.apd380-mobile-search-canonical.apd186-search-modal-open
  #apd5-search[data-active-panel="location"] #apd5-date-summary:empty {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    max-width: 72% !important;
    height: auto !important;
  }
}

/* APD 531 — terminal closed-state quarantine.
   The canonical search form is portaled while open. When X closes it and the
   form returns to the discovery header, ONLY the compact "Empezá tu búsqueda"
   trigger may remain visible. This prevents stale Fechas/Viajeros/¿Qué? summary
   rows from leaking over the category chips even if an older observer mutates
   their inline styles after the canonical close cycle. */
@media (max-width: 767px) {
  html body.apd380-mobile-search-canonical.apd531-search-closed #apd5-search > *:not(.apd10-mobile-search-trigger):not(input[type="hidden"]) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  html body.apd380-mobile-search-canonical.apd531-search-closed #apd5-search > .apd10-mobile-search-trigger {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  html body.apd380-mobile-search-canonical.apd531-search-closed .apd186-search-portal,
  html body.apd380-mobile-search-canonical.apd531-search-closed .apd186-search-topbar {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* The close path must restore the discovery page to the exact horizontal
     origin and never leave a hidden search surface affecting layout geometry. */
  html body.apd380-mobile-search-canonical.apd531-search-closed #apd5-search {
    overflow: visible !important;
    transform: none !important;
    zoom: 1 !important;
  }
}


/* APD 532 — form-local terminal close lock.
   Body classes can be changed by historical context observers after the X tap.
   The canonical form therefore carries its own closed flag. This is deliberately
   visual-only: it does not clear any confirmed search data or alter category logic. */
@media (max-width: 767px) {
  html body.apd380-mobile-search-canonical #apd5-search[data-apd532-closed="1"] > *:not(.apd10-mobile-search-trigger):not(input[type="hidden"]) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  html body.apd380-mobile-search-canonical #apd5-search[data-apd532-closed="1"] > .apd10-mobile-search-trigger {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  html body.apd380-mobile-search-canonical #apd5-search[data-apd532-closed="1"] {
    overflow: visible !important;
    transform: none !important;
    zoom: 1 !important;
  }
}
