.crop-stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.crop-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 70vh;
  pointer-events: none;
}

.crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  cursor: move;
}

.crop-box:focus-visible {
  outline: 3px solid var(--form-accent-color);
  outline-offset: 2px;
}

.crop-handle {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 0 solid #fff;
}

.crop-handle[data-handle="nw"] { top: -2px; left: -2px; border-top-width: 5px; border-left-width: 5px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { top: -2px; right: -2px; border-top-width: 5px; border-right-width: 5px; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { bottom: -2px; left: -2px; border-bottom-width: 5px; border-left-width: 5px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { bottom: -2px; right: -2px; border-bottom-width: 5px; border-right-width: 5px; cursor: nwse-resize; }

.crop-edge {
  display: none;
}

.crop-stage.is-free .crop-edge {
  display: block;
}

.crop-handle[data-handle="n"],
.crop-handle[data-handle="s"] {
  left: calc(50% - 14px);
  cursor: ns-resize;
}

.crop-handle[data-handle="w"],
.crop-handle[data-handle="e"] {
  top: calc(50% - 14px);
  cursor: ew-resize;
}

.crop-handle[data-handle="n"] { top: -2px; border-top-width: 5px; }
.crop-handle[data-handle="s"] { bottom: -2px; border-bottom-width: 5px; }
.crop-handle[data-handle="w"] { left: -2px; border-left-width: 5px; }
.crop-handle[data-handle="e"] { right: -2px; border-right-width: 5px; }

.image-result img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 40vh;
  border: var(--border-size-1) solid var(--border-color);
  border-radius: var(--radius-sm);
}

.image-result img:not([src]) {
  display: none;
}

.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-4);
}

.compare figure {
  margin: 0;
}

.compare-pane {
  height: 16rem;
  overflow: hidden;
  border: var(--border-size-1) solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.compare-pane img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: none;
  object-position: center;
}

.compare-pane img:not([src]) {
  visibility: hidden;
}

.compare figcaption {
  padding-top: var(--space-2);
  font-size: var(--font-size-sm);
}

.compare-pane.is-fitted img,
.compare-pane.is-fitted canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
