.container {
    max-width: 1400px;
    margin: 0 auto;
}

header h1 {
    color: #b6a9a9;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.controls-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.upload-section {
    flex: 0 0 auto;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.upload-icon {
    font-size: 1.2rem;
}

.dimensions-section {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    flex: 1;
}

.dimension-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dimension-group label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.dimension-group input[type="number"] {
    width: 100px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.dimension-group input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.checkbox-group {
    margin-left: auto;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid #667eea;
    border-radius: 6px;
    display: inline-block;
    position: relative;
    transition: all 0.3s;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: #667eea;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    color: white;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    font-weight: bold;
}

.download-btn {
    padding: 15px 35px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(17, 153, 142, 0.4);
}

.canvas-container {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: auto;
}

.canvas {
    position: relative;
    margin: 0 auto;
    background: 
        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;
    background-color: white;
    border: 3px dashed #ccc;
    overflow: hidden;
}

.canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    text-align: center;
    font-size: 1.1rem;
    pointer-events: none;
}

.canvas-item {
    position: absolute;
    cursor: move;
    user-select: none;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.canvas-item:hover {
    border-color: #667eea;
}

.canvas-item.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.canvas-item img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    bottom: -10px;
    right: -10px;
    cursor: nwse-resize;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.canvas-item.selected .resize-handle {
    display: block;
}

.status-bar {
    background: white;
    border-radius: 15px;
    padding: 15px 25px;
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#statusText {
    color: #666;
    font-weight: 500;
}

.clear-btn {
    padding: 10px 20px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: #ff6b7a;
    transform: scale(1.05);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }

    .controls-panel {
        padding: 15px;
        flex-direction: column;
        gap: 15px;
    }

    .upload-btn {
        width: 100%;
        justify-content: center;
    }

    .dimensions-section {
        width: 100%;
        flex-direction: column;
    }

    .dimension-group {
        width: 100%;
        justify-content: space-between;
    }

    .dimension-group input[type="number"] {
        flex: 1;
        max-width: 150px;
    }

    .checkbox-group {
        margin-left: 0;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }

    .canvas-container {
        padding: 10px;
    }

    .status-bar {
        flex-direction: column;
        gap: 10px;
    }

    .clear-btn {
        width: 100%;
    }
    .guide {
        padding: 20px;
    }

    .guide h2 {
        font-size: 1.3rem;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }
    .base64-section {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
    }
    .base64-input {
        min-height: 80px;
    }

    .autofit-btn {
        width: 100%;
        justify-content: center;
    }
   .item-controls {
        top: -40px;
        padding: 5px;
        gap: 6px;
    }

    .item-ctrl-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .controls-panel {
        padding: 12px;
    }

    .upload-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .dimension-group input[type="number"] {
        width: 80px;
        padding: 8px;
    }
}

/* Секция ручного ввода base64 */
.base64-section {
    background: white;
    border-radius: 15px;
    padding: 15px 25px;
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.base64-label {
    font-weight: 500;
    color: #333;
}

.base64-input {
    flex: 1;
    min-width: 200px;
    min-height: 42px;
    max-height: 100px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
    transition: border-color 0.3s;
}

.base64-input:focus {
    outline: none;
    border-color: #667eea;
}

.add-base64-btn {
    padding: 12px 22px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-base64-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

/* Кнопка "Автоподбор" */
.autofit-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.autofit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(245, 87, 108, 0.4);
}

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

/* Руководство пользователя */
.guide {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-top: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.guide h2 {
    color: #333;
    font-size: 1.6rem;
    margin-bottom: 20px;
    text-align: center;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.guide-step {
    position: relative;
    padding: 20px 18px 18px;
    background: #f8f9ff;
    border-radius: 12px;
    border: 1px solid #eaeaff;
}

.guide-num {
    position: absolute;
    top: -12px;
    left: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.guide-step h3 {
    color: #333;
    font-size: 1.05rem;
    margin: 8px 0 10px;
}

.guide-step p {
    color: #555;
    font-size: 0.92rem;
    line-height: 1.55;
}

.guide-step strong {
    color: #667eea;
}

.guide-note {
    margin-top: 22px;
    padding: 14px 18px;
    background: #fff8e1;
    border-left: 4px solid #ffc107;
    border-radius: 8px;
    color: #6b5b1a;
    font-size: 0.92rem;
    line-height: 1.55;
}
/* Панель управления картинкой (z-порядок) */
.item-controls {
    position: absolute;
    top: -34px;
    left: 0;
    display: none;
    gap: 4px;
    background: rgba(102, 126, 234, 0.95);
    padding: 4px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 100;
    pointer-events: auto;
}

.canvas-item.selected .item-controls {
    display: flex;
}

.item-ctrl-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #667eea;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.item-ctrl-btn:hover {
    background: #38ef7d;
    color: white;
    transform: scale(1.1);
}

.item-ctrl-btn:active {
    transform: scale(0.95);
}
