.cpx-photo {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    height: calc(100dvh - 70px - 48px);
    min-height: 0;
}

.cpx-photo__body {
    display: flex;
    flex: 1;
    gap: 16px;
    min-height: 0;
}

.cpx-photo__side,
.cpx-photo__board {
    padding: 12px;
    border-radius: 20px;
    background-color: var(--cpx-grey-1);
    border: 1px solid var(--cpx-grey-2);
}

.cpx-photo__board {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    min-height: 0;
}

.cpx-photo__board-wait {
    display: none;
}

.cpx-photo__board.is-busy .cpx-photo__board-wait {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    background: rgb(0 0 0 / 40%);
}

.cpx-photo__board.is-busy .cpx-photo__board-wait .cpx-loader .cpx-loader__svg {
    height: 80px;
}

.cpx-photo__toolbar,
.cpx-photo__bar {
    flex-shrink: 0;
}

.cpx-photo__bar {
    display: flex;
    gap: 40px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.cpx-photo__totals {
    display: flex;
    gap: 20px;
}

.cpx-photo__summary {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, auto);
    gap: 8px 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cpx-photo__totals-line {
    background: var(--cpx-brand-grey);
    width: 2px;
}

.cpx-photo__total {
    margin: 0;
}

.cpx-photo__sum {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-self: center;
}

.cpx-photo__sum [data-cpx-photo-min] {
    margin: 0;
}

.cpx-photo__sum [data-cpx-photo-min][hidden] {
    display: none;
}

.cpx-photo__toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.cpx-photo__toolbar:has(> .cpx-photo__filters > [hidden]) {
    justify-content: center;
}

.cpx-photo__toolbar > [data-cpx-album-add],
.cpx-photo__toolbar > [data-cpx-photo-clear] {
    flex-shrink: 0;
}

.cpx-photo__filters {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
}

.cpx-photo__filters:has(> [hidden]) {
    display: none;
}

.cpx-photo__filters > div {
    min-width: 0;
    max-width: 100%;
}

.cpx-photo__filters .cpx-switch {
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.cpx-photo__filters .cpx-switch::-webkit-scrollbar {
    display: none;
    height: 0;
}

.cpx-photo__filters .cpx-switch__item {
    flex: 0 0 auto;
    max-width: none;
}

.cpx-photo__toolbar > [data-cpx-photo-clear][hidden] {
    display: none;
}

.cpx-photo__side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 196px;
    box-shadow: 0 0 0 0 transparent;
    transition: box-shadow 0.3s linear;
}

.cpx-photo__side.is-alert {
    box-shadow: 0 0 0 5px var(--cpx-brand-yellow);
}

.cpx-photo__group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cpx-photo__sizes,
.cpx-photo__papers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cpx-photo__panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cpx-photo__upload {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: 20px;
    background-color: var(--cpx-brand-grey);
}

.cpx-photo__form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cpx-photo__workspace {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.cpx-photo__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, 252px);
    grid-auto-rows: 342px;
    align-items: start;
    justify-content: center;
    gap: 8px;
    height: 100%;
    min-height: 0;
    overflow: auto;
}

.cpx-photo__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    box-sizing: border-box;
    height: 100%;
    width: 100%;
    min-height: 0;
    border-radius: 4px;
    background-color: var(--cpx-white-1);
    padding: 8px;
}

.cpx-photo__remove-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    order: -1;
}

.cpx-photo__stage {
    position: relative;
    width: 100%;
    height: 198px;
    flex: 0 0 auto;
    overflow: hidden;
    background-color: var(--cpx-grey-1);
}

.cpx-photo__photo {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    max-width: none;
    touch-action: none;
    user-select: none;
}

.cpx-photo__photo.is-movable {
    cursor: grab;
}

.cpx-photo__move {
    display: none;
}

.cpx-photo__move-icon {
    display: inline-flex;
}

.cpx-photo__move-box {
    display: none;
}

.cpx-photo__move-label {
    box-sizing: border-box;
    height: 17px;
    margin: 0;
    padding: 0 8px 3px;
    background: url("photo-tip.svg") center / 100% 100% no-repeat;
    color: #2a2a2b;
    white-space: nowrap;
}

.cpx-photo__item:has(.is-editing) .cpx-photo__move-icon--edit,
.cpx-photo__item:has(.is-editing) .cpx-photo__move-label--edit,
.cpx-photo__item:not(:has(.is-editing)) .cpx-photo__move-icon--ok,
.cpx-photo__item:not(:has(.is-editing)) .cpx-photo__move-label--ok {
    display: none;
}

.cpx-photo__move-icon--ok {
    color: var(--cpx-green-1);
}

.cpx-photo__frame {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 1;
    box-sizing: border-box;
    border: 2px solid var(--cpx-red);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.cpx-photo__controls {
    display: contents;
}

.cpx-photo__options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.cpx-photo__borders,
.cpx-photo__controls > .cpx-counter {
    align-self: flex-start;
}

.cpx-photo__borders {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
}

.cpx-photo__borders label {
    display: flex;
    align-items: center;
    gap: 7px;
}

.cpx-photo__add {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 28px;
    border: 1px solid var(--cpx-grey-2);
    border-radius: 4px;
    background-color: var(--cpx-white-1);
    padding: 64px 32px;
}

.cpx-photo__add-title {
    display: flex;
    flex-direction: column;
}

.cpx-photo__add-title .cpx-icon svg {
    width: 56px;
    height: 56px;
}

.cpx-photo__add-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

@media (max-width: 768px) {
    .cpx-photo {
        height: auto;
        overflow: visible;
    }

    .cpx-photo__side {
        flex-direction: row;
        max-width: none;
    }

    .cpx-photo__group,
    .cpx-photo__panel {
        flex: 1;
    }

    .cpx-photo__toolbar {
        flex-wrap: wrap;
        gap: 12px;
        min-width: 0;
    }

    .cpx-photo__filters {
        order: -1;
        flex: 1 0 100%;
        align-items: stretch;
        min-width: 0;
    }

    .cpx-photo__toolbar > [data-cpx-album-add],
    .cpx-photo__toolbar > [data-cpx-photo-clear] {
        flex: 1 1 calc(50% - 6px);
        width: auto;
        min-width: 0;
    }

    .cpx-photo__body {
        flex-direction: column;
    }

    .cpx-photo__list {
        grid-template-columns: repeat(auto-fill, 100%);
        grid-auto-rows: auto;
        overflow: visible;
    }

    .cpx-photo__item {
        display: grid;
        grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
        grid-template-rows: auto 1fr auto;
        align-items: stretch;
        height: 252px;
    }

    .cpx-photo__stage {
        grid-column: 1;
        grid-row: 1 / -1;
        width: 100%;
        height: 100%;
        min-height: 148px;
    }

    .cpx-photo__remove-row {
        grid-column: 2;
        grid-row: 1;
        width: auto;
        justify-content: flex-end;
    }

    .cpx-photo__options {
        grid-column: 2;
        grid-row: 2;
        flex-direction: column;
        align-items: flex-end;
        align-self: center;
        width: auto;
        position: relative;
    }

    .cpx-photo__controls > .cpx-counter {
        grid-column: 2;
        grid-row: 3;
        justify-self: end;
        align-self: end;
    }

    .cpx-photo__item:has(.cpx-photo__photo.is-movable) .cpx-photo__move-box {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        position: absolute;
        top: -60px;
    }

    .cpx-photo__item:has(.cpx-photo__photo.is-movable) .cpx-photo__move {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: var(--cpx-white-1);
        color: var(--cpx-text);
        box-shadow: 0 1px 4px rgb(0 0 0 / 16%);
        cursor: pointer;
    }

    .cpx-photo__move .cpx-icon svg {
        width: 16px;
        height: 16px;
    }

    .cpx-photo__photo.is-movable {
        pointer-events: none;
    }

    .cpx-photo__stage.is-editing .cpx-photo__photo.is-movable {
        pointer-events: auto;
    }

    .cpx-photo__add {
        flex-direction: row;
        padding: 14px;
    }

    .cpx-photo__add-buttons {
        width: 50%;
    }

    .cpx-photo__bar {
        flex-direction: column;
        gap: 16px;
    }

    .cpx-photo__summary {
        display: flex;
        flex-direction: column;
    }

    .cpx-photo__totals {
        width: 100%;
    }

    .cpx-photo__bar button {
        width: 100%;
    }

    .cpx-photo__board.is-busy .cpx-photo__board-wait {
        position: fixed;
    }
}
