.member-photo-cropper-stage {
  width: 100%;
  max-width: min(720px, calc(100dvh - 15rem));
  max-height: calc(100dvh - 15rem);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #f8fafc;
  padding: 0.75rem;
  touch-action: none;
}

.member-photo-cropper-stage cropper-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.member-photo-cropper-stage cropper-image {
  width: 100%;
  height: 100%;
}

.member-photo-cropper-modal cropper-canvas {
  border-radius: 0.75rem;
}

.member-photo-cropper-modal cropper-selection {
  position: relative;
  border-radius: 50%;
}

.member-photo-cropper-modal cropper-grid,
.member-photo-cropper-modal cropper-crosshair,
.member-photo-cropper-modal cropper-selection::part(grid),
.member-photo-cropper-modal cropper-selection::part(crosshair) {
  display: none;
}

.member-photo-cropper-modal cropper-selection::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2) inset;
}

/* Keep preview colors faithful to source image. */
.member-photo-cropper-modal cropper-image,
.member-photo-cropper-modal cropper-image img {
  opacity: 1 !important;
  filter: none !important;
}

/* Keep this modal independent from KT modal init flags. */
.member-photo-cropper-modal.open {
  display: flex;
}

.member-photo-cropper-modal.open .kt-modal-dialog {
  display: block;
  position: relative;
  inset: auto;
  top: auto;
  translate: none;
  overflow: visible;
  padding: 0;
  width: 100%;
  max-width: 64rem;
  margin-inline: auto;
  max-height: calc(100dvh - 2rem);
}

.member-photo-cropper-modal .kt-modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 2rem);
}

.member-photo-cropper-modal .kt-modal-body {
  flex: 1 1 auto;
  overflow: auto;
}

.dark .member-photo-cropper-stage {
  border-color: rgba(148, 163, 184, 0.35);
  background: #0f172a;
}

.dark .member-photo-cropper-modal cropper-selection::after {
  border-color: rgba(148, 163, 184, 0.9);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.8) inset;
}

@media (max-width: 640px) {
  .member-photo-cropper-modal {
    padding: 0.5rem;
  }

  .member-photo-cropper-modal.open .kt-modal-dialog,
  .member-photo-cropper-modal .kt-modal-content {
    max-height: calc(100dvh - 1rem);
  }

  .member-photo-cropper-stage {
    max-width: min(100%, calc(100dvh - 12rem));
    max-height: calc(100dvh - 12rem);
    padding: 0.5rem;
  }
}
