/**
 * Identity / account switch modal — tablets 768–1199 (incl. exact 1024).
 * Problem: vertical center (top:50% + translate) pushes a tall popup so low
 * that profile options sit below the fold. Fix: pin under top edge + scroll.
 * Closed overlay must not cover the page (blue header menu clicks).
 * PC ≥1200 and phone ≤767 unchanged (this file’s media excludes them).
 * Does not edit custom.css.
 */
@media (min-width: 768px) and (max-width: 1199.98px) {
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay:not(.cotinder-rating-popup-overlay--visible) {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    inset: 0 !important;
    padding: 12px 16px 16px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    pointer-events: auto !important;
    z-index: 10060 !important;
  }

  /* Top-anchored: do NOT use top:50% / translateY(-50%) — that hides profiles */
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-rating-popup.cotinder-identity-modal,
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal.cotinder-rating-popup {
    position: fixed !important;
    top: 12px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
    margin: 0 !important;
    width: min(400px, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex-shrink: 0 !important;
    z-index: 1 !important;
    box-sizing: border-box !important;
  }

  /* Bitrix admin bar: clear the panel when present */
  html:has(#bx-panel) body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-rating-popup.cotinder-identity-modal,
  html:has(#bx-panel) body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal.cotinder-rating-popup,
  html.bx-panel-fixed body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-rating-popup.cotinder-identity-modal,
  html.bx-panel-fixed body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal.cotinder-rating-popup {
    top: 52px !important;
    max-height: calc(100vh - 64px) !important;
    max-height: calc(100dvh - 64px) !important;
  }

  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-rating-popup__icon {
    display: none !important;
  }

  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-rating-popup__content {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-rating-popup__actions,
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-rating-popup__actions--stacked {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .js-cotinder-identity-option,
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-identity-modal__cabinet,
  html body #cotinder-identity-modal.cotinder-rating-popup-overlay--visible .cotinder-identity-modal .cotinder-identity-modal__notifications {
    width: 100% !important;
    box-sizing: border-box !important;
  }
}
