* {
    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: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(90deg, #2c3e50, #4a6491);
    color: white;
    padding: 25px 30px;
    text-align: center;
}

header h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 16px;
}

.app {
    display: flex;
    min-height: 700px;
}

/* Панель инструментов */
.toolbar {
    width: 300px;
    background: #f8f9fa;
    padding: 25px 20px;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
}

.toolbar-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eaeaea;
}

.toolbar-section:last-child {
    border-bottom: none;
}

.toolbar-section h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px 0;
    width: 100%;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

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

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219653;
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Рабочее поле */
.workspace {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

/* Обновляем стили для canvas-container */
.canvas-container {
    flex: 1;
    border: 2px dashed #bdc3c7;
    border-radius: 10px;
    position: relative;
    overflow: auto; /* Добавляем прокрутку если изображение большое */
    background: #fafafa;
    margin-bottom: 20px;
    max-height: 600px; /* Фиксируем максимальную высоту */
}

#mainCanvas {
    display: block;
    margin: 0 auto; /* Центрируем */
    /* Убираем max-width: 100% - оно вызывает проблемы */
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    color: #7f8c8d;
    font-size: 18px;
    text-align: center;
    z-index: 10; /* Чтобы было поверх */
}

.canvas-overlay p {
    padding: 30px;
}

.instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

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

.instructions ul {
    padding-left: 20px;
}

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

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.modal-header {
    background: #2c3e50;
    color: white;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close {
    font-size: 30px;
    cursor: pointer;
    color: white;
}

.close:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 25px;
}

.format-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.format-btn {
    padding: 8px 20px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.format-btn.active {
    background: #3498db;
    color: white;
}

#exportData {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    max-height: 400px;
    overflow: auto;
    margin-bottom: 20px;
    white-space: pre-wrap;
    word-break: break-all;
}

#copyBtn {
    width: auto;
    padding: 12px 30px;
}

footer {
    background: #ecf0f1;
    padding: 20px;
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .app {
        flex-direction: column;
    }
    
    .toolbar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
}
