/* =========================================================
   V265 — Edit Profile fixed action dock
   Use the same layout principle as Group Details:
   header / independently scrolling form / permanently visible actions.
   ========================================================= */

.profile-modal.profile-editing-active,
.profile-modal.plus-profile-shell-active.profile-editing-active,
.profile-modal:has(#profileEditSection:not(.hidden)),
.profile-modal.plus-profile-shell-active:has(#profileEditSection:not(.hidden)) {
  position: relative !important;
  box-sizing: border-box !important;
  width: min(780px, calc(100vw - 48px)) !important;
  max-width: 780px !important;
  min-width: 0 !important;
  height: min(90dvh, 820px) !important;
  max-height: min(90dvh, 820px) !important;
  margin: auto !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid color-mix(in srgb, var(--primary) 38%, var(--border)) !important;
  border-radius: 42px !important;
  background: var(--card) !important;
  box-shadow: 0 24px 70px var(--shadow), inset 0 1px 0 rgba(255,255,255,.14) !important;
}

.profile-modal.profile-editing-active #profileEditSection,
.profile-modal.plus-profile-shell-active.profile-editing-active #profileEditSection,
.profile-modal:has(#profileEditSection:not(.hidden)) #profileEditSection,
.profile-modal.plus-profile-shell-active:has(#profileEditSection:not(.hidden)) #profileEditSection {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
  box-sizing: border-box !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: inherit !important;
  background: transparent !important;
  box-shadow: none !important;
}

.profile-modal.profile-editing-active #profileEditSection > h2,
.profile-modal:has(#profileEditSection:not(.hidden)) #profileEditSection > h2 {
  grid-row: 1 !important;
  display: flex !important;
  align-items: center !important;
  min-height: 76px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 24px 84px 14px 30px !important;
  color: var(--text) !important;
  font-size: 25px !important;
  line-height: 1.1 !important;
  text-align: left !important;
}

.profile-modal.profile-editing-active .profile-edit-scroll,
.profile-modal:has(#profileEditSection:not(.hidden)) .profile-edit-scroll {
  grid-row: 2 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  box-sizing: border-box !important;
  padding: 0 30px 16px !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-gutter: stable !important;
}

/* This is a real dock: it is a separate non-scrolling grid row. */
.profile-modal.profile-editing-active .profile-edit-persistent-actions,
.profile-modal:has(#profileEditSection:not(.hidden)) .profile-edit-persistent-actions {
  grid-row: 3 !important;
  position: relative !important;
  inset: auto !important;
  z-index: 20 !important;
  flex: none !important;
  box-sizing: border-box !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 10px 30px max(12px, env(safe-area-inset-bottom)) !important;
  border: 0 !important;
  border-top: 1px solid color-mix(in srgb, var(--border) 78%, transparent) !important;
  border-radius: 0 !important;
  background: color-mix(in srgb, var(--card) 96%, transparent) !important;
  box-shadow: 0 -10px 24px color-mix(in srgb, var(--shadow) 32%, transparent) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

.profile-edit-persistent-actions #profileEditMessage {
  min-height: 0 !important;
  margin: 0 0 7px !important;
  text-align: center !important;
}

.profile-edit-persistent-actions #profileEditMessage:empty {
  display: none !important;
}

.profile-edit-persistent-actions .profile-edit-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.profile-edit-persistent-actions .profile-edit-actions > button {
  width: 100% !important;
  min-width: 0 !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  margin: 0 !important;
  padding: 0 16px !important;
  border-radius: 999px !important;
}

/* Keep the modal X independent from the scrolling form. */
.profile-modal.profile-editing-active > #closeProfileButton.modal-close-button,
.profile-modal:has(#profileEditSection:not(.hidden)) > #closeProfileButton.modal-close-button {
  position: absolute !important;
  top: 16px !important;
  right: 16px !important;
  left: auto !important;
  bottom: auto !important;
  z-index: 50 !important;
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 50% !important;
}

@media (max-width: 700px) {
  .profile-overlay:has(#profileEditSection:not(.hidden)) {
    align-items: center !important;
    justify-content: center !important;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)) !important;
    overflow: hidden !important;
  }

  .profile-modal.profile-editing-active,
  .profile-modal.plus-profile-shell-active.profile-editing-active,
  .profile-modal:has(#profileEditSection:not(.hidden)),
  .profile-modal.plus-profile-shell-active:has(#profileEditSection:not(.hidden)) {
    width: min(94vw, 560px) !important;
    max-width: 560px !important;
    height: calc(100dvh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    border-radius: 34px !important;
  }

  .profile-modal.profile-editing-active #profileEditSection > h2,
  .profile-modal:has(#profileEditSection:not(.hidden)) #profileEditSection > h2 {
    min-height: 66px !important;
    padding: 18px 72px 10px 18px !important;
    font-size: 23px !important;
  }

  .profile-modal.profile-editing-active .profile-edit-scroll,
  .profile-modal:has(#profileEditSection:not(.hidden)) .profile-edit-scroll {
    padding: 0 18px 14px !important;
  }

  .profile-modal.profile-editing-active .profile-edit-persistent-actions,
  .profile-modal:has(#profileEditSection:not(.hidden)) .profile-edit-persistent-actions {
    padding: 9px 18px max(11px, env(safe-area-inset-bottom)) !important;
  }

  .profile-modal.profile-editing-active > #closeProfileButton.modal-close-button,
  .profile-modal:has(#profileEditSection:not(.hidden)) > #closeProfileButton.modal-close-button {
    top: 12px !important;
    right: 12px !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
  }
}

@media (max-width: 360px) {
  .profile-edit-persistent-actions .profile-edit-actions {
    grid-template-columns: 1fr !important;
  }
}
