.x-before-after {
    --xbac-position: 50%;
    --xbac-aspect-ratio: 16/9;
    --xbac-handle-size: 42px;
    --xbac-line-size: 3px;
    --xbac-label-bg: rgba(0, 0, 0, .55);
    --xbac-label-color: #fff;
    margin: 1.5em 0;
    max-width: 100%;
}

.xbac-stage {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: var(--xbac-aspect-ratio);
    background: #eee;
    user-select: none;
    touch-action: none;
}

.xbac-image,
.xbac-before-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.xbac-image {
    display: block;
    object-fit: cover;
    max-width: none;
}

.xbac-before-wrap {
    overflow: hidden;
    z-index: 2;
}

/* La imagen superior no se desplaza ni se reescala: se mantiene al 100%
   del escenario y solo se recorta la máscara. */
.xbac-orientation-horizontal .xbac-before-wrap {
    clip-path: inset(0 calc(100% - var(--xbac-position)) 0 0);
}

.xbac-orientation-vertical .xbac-before-wrap {
    clip-path: inset(0 0 calc(100% - var(--xbac-position)) 0);
}

.xbac-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    z-index: 5;
    margin: 0;
}

.xbac-orientation-vertical .xbac-range {
    cursor: ns-resize;
}

.xbac-divider {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}

.xbac-orientation-horizontal .xbac-divider {
    top: 0;
    bottom: 0;
    left: var(--xbac-position);
    width: var(--xbac-line-size);
    transform: translateX(-50%);
}

.xbac-orientation-vertical .xbac-divider {
    left: 0;
    right: 0;
    top: var(--xbac-position);
    height: var(--xbac-line-size);
    transform: translateY(-50%);
}

.xbac-handle {
    position: absolute;
    width: var(--xbac-handle-size);
    height: var(--xbac-handle-size);
    border: 3px solid #fff;
    border-radius: 999px;
    background: rgba(0, 0, 0, .35);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.xbac-orientation-horizontal .xbac-handle {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.xbac-orientation-vertical .xbac-handle {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.xbac-handle::before,
.xbac-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0;
    height: 0;
    transform: translateY(-50%);
}

.xbac-handle::before {
    left: 8px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 7px solid #fff;
}

.xbac-handle::after {
    right: 8px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 7px solid #fff;
}

.xbac-label {
    position: absolute;
    z-index: 3;
    top: 1rem;
    padding: .35rem .65rem;
    border-radius: 2px;
    color: var(--xbac-label-color);
    background: var(--xbac-label-bg);
    font-size: .875rem;
    line-height: 1.2;
}

.xbac-label-before { left: 1rem; }
.xbac-label-after { right: 1rem; }

.x-before-after-error {
    padding: .75em 1em;
    border-left: 4px solid #d63638;
    background: #fff5f5;
}
