* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Верхняя панель управления (объединенная) */
.top-controls {
    background: white;
    border-radius: 15px;
    padding: 20px 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 30px;
}

/* Блок загрузки (80% ширины) */
.upload-section {
    flex: 0 0 80%;
    margin-bottom: 0;
}

.drop-zone {
    border: 3px dashed #ff005c;
    border-radius: 10px;
    padding: 25px 20px;
    text-align: center;
    transition: all 0.3s;
    background: #f8fafc;
    margin-bottom: 15px;
}

.drop-zone.drag-over {
    background: #ebf5fb;
    border-color: #2980b9;
    transform: scale(1.02);
}

.drop-zone span {
    display: block;
    margin: 8px 0;
    font-size: 16px;
    color: #7f8c8d;
}

.file-info {
    text-align: center;
    padding: 10px;
    background: #f1f2f6;
    border-radius: 5px;
    font-style: italic;
    color: #636e72;
    font-size: 14px;
}

/* Блок кнопок (20% ширины) */
.action-buttons {
    flex: 0 0 20%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 30px;
}

/* Контейнер для логотипа */
.logo-container {
    width: 100%;
    margin-bottom: 5px;
}

.logo {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

/* Кнопки */
.btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: #ff005c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    text-align: center;
    min-width: 0;
}

.btn:hover {
    background: #e00050;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn.primary {
    background: #ff005c;
}

.btn.primary:hover {
    background: #e00050;
    box-shadow: 0 5px 15px rgba(255, 0, 92, 0.3);
}

.btn.secondary {
    background: #95a5a6;
}

.btn.secondary:hover {
    background: #7f8c8d;
}

/* Контейнер для чекбокса */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    padding: 10px 5px;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #ff005c;
}

.checkbox-container label {
    font-size: 14px;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input[type="checkbox"]:checked + label {
    font-weight: 600;
    color: #333;
}

#fileInput {
    display: none;
}

/* Область редактора */
.editor-area {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    position: relative;
    min-height: 900px;
}

.image-container {
    width: 800px;
    height: 800px;
    margin: 0 auto;
    position: relative;
    border: 2px dashed #bdc3c7;
    border-radius: 10px;
    overflow: hidden;
    background-image: 
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Панель управления дополнительными слоями */
.extra-controls {
    position: absolute;
    right: 30px;
    top: 30px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    width: 240px;
    z-index: 100;
}

.extra-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.btn.extra-btn {
    background: #3498db;
    font-size: 15px;
    padding: 12px 15px;
    width: 100%;
    transition: all 0.3s;
}

.btn.extra-btn:hover {
    background: #2980b9;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn.extra-btn.active {
    background: #2ecc71;
    box-shadow: 0 0 0 2px #27ae60;
}

/* Блок управления пропорциями */
.proportion-controls {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.proportion-controls h4 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
}

.proportion-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

.proportion-btn {
    padding: 10px 15px;
    background: #ff005c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    flex: 1;
    justify-content: center;
}

.proportion-btn:hover {
    background: #e00050;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(255, 0, 92, 0.3);
}

.proportion-btn:active {
    transform: translateY(0);
}

.proportion-btn.locked {
    background: #ff005c;
}

.proportion-btn.unlocked {
    background: #3498db;
}

.proportion-btn.unlocked:hover {
    background: #2980b9;
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

.reset-btn {
    width: 50px;
    
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(149, 165, 166, 0.3);
}

.reset-btn:active {
    transform: translateY(0);
}

.proportion-info {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    padding: 5px;
    background: white;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    margin-top: 8px;
}

.extra-info {
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
    line-height: 1.4;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
}

/* Стили для слоёв */
.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Z-index для всех слоев - ПРАВИЛЬНЫЙ ПОРЯДОК:
   1. Черный фон (самый нижний)
   2. Пользовательское изображение
   3. Дополнительные слои (стикеры, лого)
   4. Маска (Кепа)
   5. Кнопка (самый верхний из картинок)
   6. Маркеры (самые верхние) */
.layer-1 { z-index: 1; } /* Черный фон */
.layer-2 { z-index: 2; } /* Пользовательское изображение */
.sticker-layer { z-index: 3; } /* Стикер */
.classic-logo-layer { z-index: 4; } /* КЛ Лого */
.graphic-logo-layer { z-index: 5; } /* ГР Лого */
.logo4-layer { z-index: 6; } /* Блеск */
.mask-layer { z-index: 7; } /* Маска (Кепа) */
.button-layer { z-index: 8; } /* Кнопка (самый верхний из картинок) */
.markers-layer { z-index: 9; } /* Маркеры (самые верхние) */

/* Контейнер для пользовательского изображения с маркерами */
.user-image-container {
    position: absolute;
    z-index: 2;
    pointer-events: auto;
}

#userImage {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: fill;
    border: 2px solid rgba(52, 152, 219, 0.8);
    border-radius: 5px;
    background: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    user-select: none;
    touch-action: none;
    cursor: move;
}

#userImage:hover {
    border-color: #ff005c;
    box-shadow: 0 0 0 2px rgba(255, 0, 92, 0.3);
}

/* Для остальных изображений оставляем contain */
.layer img:not(#userImage) {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Стили для маркеров изменения размера */
.resize-handle {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #3498db;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: auto;
    cursor: nwse-resize;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    transition: all 0.2s;
    z-index: 10;
    opacity: 1;
    visibility: visible;
}

.resize-handle:hover {
    background: #ff005c;
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.resize-handle.top-left {
    top: -12px;
    left: -12px;
    cursor: nwse-resize;
}

.resize-handle.top-right {
    top: -12px;
    right: -12px;
    cursor: nesw-resize;
}

.resize-handle.bottom-left {
    bottom: -12px;
    left: -12px;
    cursor: nesw-resize;
}

.resize-handle.bottom-right {
    bottom: -12px;
    right: -12px;
    cursor: nwse-resize;
}

/* Боковые маркеры */
.resize-handle.top-center {
    top: -12px;
    left: 50%;
    margin-left: -12px;
    cursor: ns-resize;
}

.resize-handle.bottom-center {
    bottom: -12px;
    left: 50%;
    margin-left: -12px;
    cursor: ns-resize;
}

.resize-handle.left-center {
    top: 50%;
    left: -12px;
    margin-top: -12px;
    cursor: ew-resize;
}

.resize-handle.right-center {
    top: 50%;
    right: -12px;
    margin-top: -12px;
    cursor: ew-resize;
}

/* Рамка вокруг изображения */
.image-outline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px dashed #3498db;
    border-radius: 5px;
    pointer-events: none;
    z-index: 1;
}

/* Подсказка при наведении на изображение */
.user-image-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    z-index: 99;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.user-image-hint.visible {
    opacity: 1;
}

/* Кнопка показа/скрытия маркеров */
.markers-toggle-btn {
    background: #9b59b6;
    margin-top: 10px;
}

.markers-toggle-btn:hover {
    background: #8e44ad;
}

/* Контейнер инструкции */
.instructions-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border-left: 5px solid #ff005c;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.instructions ul {
    list-style-position: inside;
    color: #555;
}

.instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Адаптивность */
@media (max-width: 1100px) {
    .image-container {
        width: 600px;
        height: 600px;
    }
    
    .extra-controls {
        position: static;
        width: 100%;
        margin-top: 20px;
    }
}

@media (max-width: 900px) {
    .image-container {
        width: 500px;
        height: 500px;
    }
    
    .top-controls {
        flex-direction: column;
        gap: 20px;
    }
    
    .upload-section {
        flex: 0 0 100%;
        width: 100%;
    }
    
    .action-buttons {
        flex: 0 0 100%;
        width: 100%;
        flex-direction: row;
        justify-content: center;
        padding: 20px 30px 0 30px;
        border-top: 2px solid #eee;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .logo-container {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }
    
    .logo {
        max-width: 250px;
        height: 50px;
    }
    
    .btn {
        width: auto;
        min-width: 180px;
        margin: 0;
    }
    
    .checkbox-container {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
        order: 3;
    }
    
    .extra-buttons {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .btn.extra-btn {
        width: auto;
        min-width: 150px;
    }
    
    .proportion-controls {
        margin-top: 20px;
    }
}

@media (max-width: 600px) {
    .image-container {
        width: 100%;
        height: 400px;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        max-width: 250px;
        margin: 0;
    }
    
    .checkbox-container {
        width: auto;
        margin-top: 5px;
    }
    
    .drop-zone {
        padding: 20px 15px;
    }
    
    .drop-zone span {
        font-size: 14px;
    }
    
    .extra-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn.extra-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .proportion-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .proportion-btn {
        width: 100%;
    }
    
    .reset-btn {
        width: 100%;
        height: 45px;
    }
}