.photo-editor-lock {
    overflow: hidden !important;
}

.photo-editor {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: grid;
    place-items: center;
    padding: clamp(10px, 2vw, 24px);
    background: rgba(18, 15, 12, 0.72);
    backdrop-filter: blur(8px);
}

.photo-editor[hidden] {
    display: none !important;
}

.photo-editor__dialog {
    width: min(980px, 100%);
    max-height: calc(100dvh - 20px);
    overflow: auto;
    border: 1px solid rgba(201, 169, 110, 0.48);
    border-radius: 24px;
    background: #fffaf3;
    color: #29231d;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.photo-editor__header,
.photo-editor__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
}

.photo-editor__header {
    justify-content: space-between;
    border-bottom: 1px solid rgba(74, 58, 39, 0.12);
}

.photo-editor__heading {
    min-width: 0;
}

.photo-editor__heading h2,
.photo-editor__heading p {
    margin: 0;
}

.photo-editor__heading h2 {
    font-size: clamp(18px, 2.2vw, 25px);
}

.photo-editor__heading p {
    margin-top: 4px;
    color: #74685a;
    font-size: 13px;
}

.photo-editor__close,
.photo-editor__tool,
.photo-editor__ratio,
.photo-editor__button {
    border: 0;
    font: inherit;
    cursor: pointer;
}

.photo-editor__close {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eee4d7;
    color: #332a20;
    font-size: 26px;
    line-height: 1;
}

.photo-editor__body {
    display: grid;
    gap: 16px;
    padding: 20px 22px 12px;
}

.photo-editor__stage {
    display: grid;
    min-height: 300px;
    place-items: center;
    overflow: hidden;
    border-radius: 18px;
    background:
        linear-gradient(45deg, #e9e3da 25%, transparent 25%),
        linear-gradient(-45deg, #e9e3da 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e9e3da 75%),
        linear-gradient(-45deg, transparent 75%, #e9e3da 75%),
        #f5f1eb;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.photo-editor__viewport {
    position: relative;
    display: grid;
    max-width: 100%;
    max-height: min(58dvh, 660px);
    overflow: hidden;
}

.photo-editor__canvas {
    display: block;
    max-width: 100%;
    max-height: min(58dvh, 660px);
    touch-action: none;
    cursor: grab;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85),
        0 14px 38px rgba(0, 0, 0, 0.2);
}

.photo-editor__display-mask {
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
    border: 2px solid rgba(255, 255, 255, .96);
    box-shadow: inset 0 0 0 1px rgba(44, 33, 25, .25);
    transition: border-radius .2s ease, box-shadow .2s ease;
}

.photo-editor[data-display-shape="circle"] .photo-editor__display-mask {
    border-radius: 50%;
    box-shadow:
        inset 0 0 0 1px rgba(44, 33, 25, .25),
        0 0 0 9999px rgba(20, 16, 12, .52);
}

.photo-editor[data-display-shape="rounded"] .photo-editor__display-mask {
    border-radius: clamp(14px, 3vw, 34px);
    box-shadow:
        inset 0 0 0 1px rgba(44, 33, 25, .25),
        0 0 0 9999px rgba(20, 16, 12, .35);
}

.photo-editor[data-display-shape="rectangle"] .photo-editor__display-mask {
    border-radius: 0;
}

.photo-editor__display-hint {
    display:flex;
    align-items:center;
    gap:9px;
    margin:0;
    padding:10px 13px;
    border:1px solid rgba(184,141,73,.24);
    border-radius:12px;
    color:#665747;
    background:#fff7e9;
    font-size:13px;
}

.photo-editor__display-icon {
    color:#b88d49;
    font-size:18px;
}

.photo-editor__canvas.is-dragging {
    cursor: grabbing;
}

.photo-editor__ratios,
.photo-editor__tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.photo-editor__ratio,
.photo-editor__tool {
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid rgba(74, 58, 39, 0.16);
    border-radius: 12px;
    background: #fff;
    color: #3d342a;
}

.photo-editor__ratio.is-active,
.photo-editor__tool:hover,
.photo-editor__tool:focus-visible {
    border-color: #b88d49;
    background: #f3e3c8;
}

.photo-editor--ratio-locked .photo-editor__ratios::before {
    content: "Формат области на сайте:";
    color: #74685a;
    font-size: 13px;
}

.photo-editor__ratio[hidden] {
    display: none;
}

.photo-editor__zoom {
    display: grid;
    grid-template-columns: auto minmax(120px, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-width: min(100%, 310px);
    margin-left: auto;
}

.photo-editor__zoom input {
    width: 100%;
    accent-color: #b88d49;
}

.photo-editor__footer {
    justify-content: flex-end;
    border-top: 1px solid rgba(74, 58, 39, 0.12);
}

.photo-editor__button {
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 14px;
}

.photo-editor__button--secondary {
    background: #eee4d7;
    color: #3d342a;
}

.photo-editor__button--primary {
    background: linear-gradient(135deg, #d1ad70, #aa7c39);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(170, 124, 57, 0.25);
}

.photo-editor__button:disabled {
    cursor: wait;
    opacity: 0.62;
}

@media (max-width: 640px) {
    .photo-editor {
        padding: 0;
        place-items: stretch;
    }

    .photo-editor__dialog {
        width: 100%;
        max-height: 100dvh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .photo-editor__header,
    .photo-editor__footer {
        padding: 14px;
    }

    .photo-editor__body {
        padding: 14px;
    }

    .photo-editor__stage {
        min-height: 230px;
    }

    .photo-editor__tools {
        align-items: stretch;
    }

    .photo-editor__zoom {
        flex-basis: 100%;
        margin-left: 0;
    }

    .photo-editor__footer {
        position: sticky;
        bottom: 0;
        background: #fffaf3;
    }

    .photo-editor__button {
        flex: 1 1 0;
    }
}
