/* Shared shell rules for profile, community, and agent modals. */
.shared-modal {
  width: min(100% - 28px, 620px);
  max-width: calc(100% - 28px);
  max-height: calc(100dvh - 28px);
  overflow-x: hidden;
  overflow-y: auto;
}

.shared-modal.modal-compact { width: min(100% - 28px, 430px); }
.shared-modal.modal-standard { width: min(100% - 28px, 500px); }
.shared-modal.modal-medium { width: min(100% - 28px, 560px); }
.shared-modal.modal-wide { width: min(100% - 28px, 620px); }
.shared-modal.modal-extra-wide { width: min(100% - 28px, 720px); }

.shared-modal > .dialog-card {
  min-width: 0;
  gap: 18px;
  padding: 25px;
}

.shared-modal .dialog-heading { min-width: 0; }
.shared-modal .dialog-heading h2 { overflow-wrap: anywhere; }
.shared-modal .dialog-actions { flex-wrap: wrap; }
.shared-modal .dialog-actions > button { flex: 0 1 auto; }
#profileDialog.shared-modal,
#agentsDialog.shared-modal,
#communityDialog.shared-modal {
  width: min(100% - 28px, 620px);
  height: min(660px, calc(100dvh - 40px));
  overflow-y: hidden;
}
#profileDialog.shared-modal > .dialog-card,
#agentsDialog.shared-modal > .dialog-card,
#communityDialog.shared-modal > .dialog-card {
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.shared-modal[open] { animation: dialog-pop-in .3s cubic-bezier(.22, .8, .28, 1) both; }
.shared-modal.is-closing { animation: dialog-pop-out .18s ease both; }
.modal-tab-list { position: relative; }
.modal-tab-list > [role="tab"] { position: relative; z-index: 1; }
.modal-tabs-indicator { position: absolute; z-index: 0; top: 0; left: 0; width: 0; height: 0; border: 1px solid var(--mint-dark); border-bottom: 3px solid var(--mint-dark); border-radius: 6px; background: #f8fbf7; box-shadow: 0 1px 4px rgba(55,54,43,.08); transition: top .28s ease, left .28s ease, width .28s ease, height .28s ease; pointer-events: none; }
.modal-tabs-indicator.is-positioning { transition: none; }
.modal-tab-list-vertical .modal-tabs-indicator { border-bottom-width: 1px; border-left: 3px solid var(--ink); }
.modal-tab-list > [role="tab"][aria-selected="true"] { border-color: transparent; background: transparent; box-shadow: none; outline: none; }
@keyframes modal-tab-panel-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.modal-tab-panel-enter { animation: modal-tab-panel-enter .24s cubic-bezier(.22, .8, .28, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .modal-tabs-indicator { transition: none; }
  .modal-tab-panel-enter { animation: none; }
}

@media (max-width: 520px) {
  .shared-modal > .dialog-card { gap: 16px; padding: 19px; }
  #profileDialog.shared-modal,
  #agentsDialog.shared-modal,
  #communityDialog.shared-modal { height: calc(100dvh - 28px); }
  .shared-modal .dialog-actions > button { flex: 1 1 auto; }
}

/* Account creation can be taller than the fixed settings shell. */
#profileDialog.shared-modal.profile-required {
  width: min(100% - 28px, 430px);
  height: auto;
  height: fit-content;
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#profileDialog.shared-modal.profile-required > .dialog-card {
  height: auto;
  overflow: visible;
}
