/* Overrides the legacy full-viewport mobile-chat sheet. Keep public chat controls
   below the fixed site header and size unauthenticated panels to their content. */
@media (max-width: 600px) {
  html body .ehqc .ehqc-panel:not([hidden]),
  html body.eh-map-page .ehqc .ehqc-panel:not([hidden]),
  html body.eh-map-page .ehqc.ehqc-on-map .ehqc-panel:not([hidden]),
  html body.eh-map-page .ehqc.ehqc-map-launch-moved .ehqc-panel:not([hidden]) {
    position: fixed !important;
    top: max(72px, calc(env(safe-area-inset-top) + 72px)) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    bottom: auto !important;
    left: max(8px, env(safe-area-inset-left)) !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: calc(100vh - 96px - env(safe-area-inset-bottom)) !important;
    max-height: calc(100dvh - 96px - env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    padding: 14px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 14px !important;
    z-index: 2147483001 !important;
  }

  html body .ehqc .ehqc-panel > header {
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    min-height: 52px !important;
    margin: -14px -14px 12px !important;
    padding: 8px 10px 8px 14px !important;
    background: #fff !important;
    border-bottom: 1px solid #e4e8ed !important;
  }

  html body .ehqc .ehqc-panel > header h2 {
    min-width: 0 !important;
    margin: 0 !important;
    font-size: 18px !important;
    line-height: 1.25 !important;
  }

  html body .ehqc .ehqc-window-actions {
    display: flex !important;
    flex: 0 0 auto !important;
    align-items: center !important;
    gap: 6px !important;
  }

  html body .ehqc .ehqc-window-actions button {
    display: inline-flex !important;
    flex: 0 0 42px !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    overflow: hidden !important;
    white-space: nowrap !important;
  }

  html body .ehqc .ehqc-panel[hidden] {
    display: none !important;
  }

  /* On map search, retain the requested full-height conversation, but start
     below the sticky site header so the title and controls cannot be covered. */
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-panel:not([hidden]),
  body.eh9:has(#eh9-map) .ehqc-map-launch-moved .ehqc-panel:not([hidden]) {
    top: max(72px, calc(env(safe-area-inset-top) + 72px)) !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 0 env(safe-area-inset-bottom) !important;
    border-radius: 0 !important;
  }

  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-panel > header,
  body.eh9:has(#eh9-map) .ehqc-map-launch-moved .ehqc-panel > header {
    top: 0 !important;
    flex: 0 0 auto !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 7px 12px !important;
  }
}
