.media-crop {
    display: grid;
    gap: .85rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 1rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 82%, var(--bg));
}

.media-crop[hidden] {
    display: none !important;
}

.media-crop-stage-wrap {
    display: flex;
    justify-content: center;
    min-width: 0;
    width: 100%;
    overflow: auto;
    border-radius: 10px;
    background:
        linear-gradient(45deg, #202922 25%, transparent 25%),
        linear-gradient(-45deg, #202922 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #202922 75%),
        linear-gradient(-45deg, transparent 75%, #202922 75%),
        #111713;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.media-crop-stage {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 100%;
    line-height: 0;
    touch-action: none;
    user-select: none;
}

.media-crop-stage img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: min(54vh, 520px);
}

.media-crop-box {
    position: absolute;
    border: 2px solid #f0cf8c;
    outline: 9999px solid rgb(0 0 0 / 55%);
    box-shadow: 0 0 0 1px rgb(0 0 0 / 65%);
    cursor: move;
    line-height: normal;
}

.media-crop-box::before,
.media-crop-box::after {
    position: absolute;
    content: "";
    pointer-events: none;
}

.media-crop-box::before {
    inset: 33.333% 0;
    border-block: 1px solid rgb(255 255 255 / 45%);
}

.media-crop-box::after {
    inset: 0 33.333%;
    border-inline: 1px solid rgb(255 255 255 / 45%);
}

.media-crop-handle {
    position: absolute;
    z-index: 2;
    width: 24px;
    height: 24px;
    min-width: 0;
    padding: 0;
    border: 2px solid #171b17;
    border-radius: 50%;
    background: #f0cf8c;
}

.media-crop-handle[data-crop-handle="nw"] { inset: -12px auto auto -12px; cursor: nwse-resize; }
.media-crop-handle[data-crop-handle="ne"] { inset: -12px -12px auto auto; cursor: nesw-resize; }
.media-crop-handle[data-crop-handle="sw"] { inset: auto auto -12px -12px; cursor: nesw-resize; }
.media-crop-handle[data-crop-handle="se"] { inset: auto -12px -12px auto; cursor: nwse-resize; }

.media-crop-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .75rem;
    align-items: end;
}

.media-grid article,
.media-grid details {
    min-width: 0;
}

.media-crop-summary {
    color: var(--muted);
    font-size: .86rem;
}

@media (max-width: 640px) {
    .media-crop-controls {
        grid-template-columns: 1fr;
    }
}
