.overlay,
:global(.modal-overlay) {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: var(--overlay-backdrop);
}

.card,
:global(.modal-card) {
  display: flex;
  width: min(100%, 480px);
  min-width: min(400px, 100%);
  max-height: calc(100vh - var(--sp-16));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--surface-overlay-border);
  border-radius: var(--radius-overlay);
  background: var(--material-overlay);
  box-shadow: var(--surface-overlay-shadow);
  outline: none;
}

.sm {
  width: min(100%, 400px);
}

.md {
  width: min(100%, 480px);
}

.lg,
:global(.modal-card-lg) {
  width: min(100%, 720px);
}

.full {
  width: min(100%, 1080px);
  max-height: calc(100vh - var(--sp-8));
}

.header,
:global(.modal-header) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-default);
}

.dialogHeader,
:global(.dialog-header) {
  align-items: flex-start;
}

:global(.dialog-header__leading) {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-width: 0;
  flex: 1;
}

:global(.dialog-header__copy) {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: var(--gap-control);
}

:global(.dialog-header__icon) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: var(--surface-hover);
  color: var(--text-secondary);
}

:global(.dialog-header__description) {
  margin: 0;
  font-size: var(--type-body-5-size);
  line-height: var(--type-body-5-line-height);
  font-weight: var(--type-body-5-weight);
  color: var(--text-tertiary);
}

.title,
:global(.modal-title) {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  font-size: var(--type-heading-4-size);
  line-height: var(--type-heading-4-line-height);
  font-weight: var(--type-heading-4-weight);
  color: var(--text-primary);
}

.body,
:global(.modal-body) {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  overflow-y: auto;
}

.footer,
:global(.modal-footer) {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-default);
}

:global(.modal-close) {
  border-radius: var(--radius-sm);
}

:global(.modal-close:hover) {
  background: var(--surface-hover);
}

@media (max-width: 640px) {
  .overlay,
  :global(.modal-overlay) {
    padding: var(--sp-3);
  }

  .card,
  :global(.modal-card),
  .sm,
  .md,
  .lg,
  :global(.modal-card-lg),
  .full {
    min-width: 0;
    width: 100%;
    max-height: calc(100vh - var(--sp-6));
  }

  .header,
  :global(.modal-header),
  .dialogHeader,
  :global(.dialog-header),
  .body,
  :global(.modal-body),
  .footer,
  :global(.modal-footer) {
    padding-left: var(--sp-4);
    padding-right: var(--sp-4);
  }
}
