.preview-container {
    display: grid;
    grid-template-columns: repeat(3, 99px);
    gap: 8px;
    justify-content: center;
    min-height: 60px;
    /* ← разрешаем больше одной строки */
    grid-auto-rows: 132px;
    /* высота одной строки */
}

.preview,
.upload-controls {
    width: 99px;
    height: 132px;
}

.preview {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.upload-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.preview.add {
    background: url("../img/add_file.svg") no-repeat center;
    background-size: contain;
    cursor: pointer;
}

.preview.photo {
    background: url("../img/add_photo.svg") no-repeat center;
    background-size: contain;
    cursor: pointer;
}

.remove {
    position: absolute;
    display: flex;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background-image: url("../img/del_photo.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    cursor: pointer;
}

.preview.dragging {
    opacity: 0.5;
    z-index: 10;
}

.preview.over {
    border: 2px solid #007bff;
}

.drag-phantom {
    opacity: 0.8;
    z-index: 9999;
}

input[type="file"] {
    display: none;
}

/* === Редактор фото === */
.photo-editor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    touch-action: none;
    cursor: pointer;
}

.photo-editor-box {
    width: 90vw;
    max-width: 300px;
    height: 400px;
    overflow: hidden;
    background: #000;
    position: relative;
    border: 2px solid white;
    cursor: grab;
    pointer-events: auto;
    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: auto;
}

.photo-editor-box.grabbing {
    cursor: grabbing;
}

/* Loader */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loading.hide {
    display: none;
}

/* Модальное окно камеры */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 20px;
    box-sizing: border-box;
}

.camera-modal video {
    width: 100%;
    height: calc(100% - 80px);
    object-fit: cover;
}

/* Кнопки управления */
.camera-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px 0;
}

.camera-take-btn,
.camera-flip-btn,
.camera-switch-btn,
.camera-close-btn {
    padding: 10px 16px;
    font-size: 14px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

.camera-take-btn {
    background: white;
    color: black;
}

.camera-flip-btn,
.camera-switch-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.camera-close-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.camera-flip-btn:hover,
.camera-switch-btn:hover,
.camera-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}