.modal {
  --modal-max-height: min(44rem, calc(100vh - 2 * var(--space-8)));
  width: min(34rem, calc(100vw - 2 * var(--space-4)));
  max-height: var(--modal-max-height);
  margin: auto;
  padding: 0;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-1);
  color: var(--color-text);
  box-shadow: var(--shadow-modal);
}

.modal::backdrop {
  background: var(--color-overlay);
}

.modal[open] {
  animation: modal-in var(--duration-base) var(--ease-standard);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.modal__panel {
  display: flex;
  flex-direction: column;
  /* The dialog's border is inside its max-height (border-box): without subtracting it, a tall
     dialog scrolled by 2px and showed a second scrollbar next to the body's own. */
  max-height: calc(var(--modal-max-height) - 2 * var(--border-width));
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.modal__title {
  font-size: var(--text-lg);
}

.modal__description {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.modal__close {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: calc(-1 * var(--space-1)) calc(-1 * var(--space-2)) 0 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
}

.modal__close:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.modal__body {
  overflow-y: auto;
  padding: 0 var(--space-3) var(--space-3);
}
