.collective-modal {
  background: #fff;
  border: 0;
  border-radius: 8px;
  box-sizing: border-box;
  color: var(--black-color);
  margin: auto;
  max-height: calc(100dvh - 2rem);
  max-width: 520px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem;
  width: calc(100% - 2rem);
}

.collective-modal::backdrop {
  background: rgba(25, 25, 25, 0.72);
}

body:has(.collective-modal[open]) { overflow: hidden; }

.collective-modal h3 {
  font-size: 1.17rem;
  font-weight: 700;
  line-height: 1.6;
  margin: 0 0 0.5rem;
}

.collective-modal:has(> .collective-modal-close) > h3 {
  padding-right: 1.5rem;
}

.collective-modal .collective-modal-close {
  background: transparent;
  border: 0;
  color: var(--black-color);
  cursor: pointer;
  font-size: 34px;
  font-weight: bold;
  line-height: 1;
  padding: 0;
  position: absolute;
  right: 0.95rem;
  top: 0.65rem;
}

.collective-modal-close:focus-visible {
  outline: 3px solid rgba(25, 25, 25, 0.35);
  outline-offset: 3px;
}

.collective-modal [hidden] { display: none; }

.collective-modal-form,
.collective-modal .collective-signup-grid {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

/* Keep the existing normal CAPTCHA reachable on narrow screens without
   widening the dialog or changing the widget's presentation mode. */
.collective-modal .collective-signup-recaptcha {
  min-width: 0;
  overflow-x: auto;
}

.collective-modal .collective-signup-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.collective-modal .collective-signup-grid .form-group:nth-child(-n + 5) {
  grid-column: 1 / -1;
}

.collective-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.collective-modal-actions button {
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 8px;
  color: var(--black-color);
  cursor: pointer;
  font-weight: 700;
  padding: 0.55rem 0.75rem;
}

.collective-modal-actions button:not([data-modal-close]),
.collective-modal-actions button:only-child {
  background: var(--black-color);
  border-color: var(--black-color);
  color: var(--white-color);
}

.collective-modal-actions button:disabled {
  background: #777;
  border-color: #777;
  color: var(--white-color);
  cursor: not-allowed;
  opacity: 0.8;
}

.collective-modal-actions button:focus-visible {
  outline: 3px solid rgba(25, 25, 25, 0.35);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .collective-modal-actions button { flex: 1 1 9rem; }
}

@media (max-width: 400px) {
  .collective-modal .collective-signup-grid { grid-template-columns: minmax(0, 1fr); }
}
