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

body {
    font-family: 'Montserrat', sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 15px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 10px;
}

header h1 {
    font-size: 1.5rem;
    color: #fff;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 20px;
    background: #2a2a4a;
    border: none;
    border-radius: 8px;
    color: #aaa;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tab:hover {
    background: #3a3a5a;
    color: #fff;
}

.tab.active {
    background: #C90000;
    color: #fff;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr 350px;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

/* Left: Preview Section */
.preview-section {
    background: #2a2a4a;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.canvas-container {
    background: #111;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

#preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.2s;
}

.placeholder {
    color: #666;
    font-size: 1.1rem;
}

.image-controls {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.upload-btn, .download-btn {
    padding: 10px 16px;
    background: #C90000;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.upload-btn:hover, .download-btn:hover {
    background: #a00000;
}

.upload-btn input {
    display: none;
}

/* Center: JSON Section */
.json-section {
    background: #2a2a4a;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.json-section h3 {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 10px;
}

.json-section textarea {
    flex: 1;
    padding: 12px;
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
    border-radius: 8px;
    color: #ddd;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.7rem;
    resize: none;
    min-height: 0;
}

.json-section textarea:focus {
    outline: none;
    border-color: #C90000;
}

.json-section .CodeMirror {
    flex: 1;
    height: auto;
    border-radius: 8px;
    font-size: 0.75rem;
}

.apply-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: #4a4a6a;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.apply-btn:hover {
    background: #5a5a7a;
}

/* Right: Text Section */
.text-section {
    background: #2a2a4a;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.text-section h3 {
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 10px;
}

.elements-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.element-item {
    background: #3a3a5a;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.element-item:last-child {
    margin-bottom: 0;
}

.element-header {
    font-size: 0.75rem;
    color: #C90000;
    margin-bottom: 4px;
    font-weight: 600;
}

.element-desc {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 6px;
}

.element-item .control-group textarea {
    width: 100%;
    min-height: 45px;
    padding: 8px;
    background: #2a2a4a;
    border: 1px solid #4a4a6a;
    border-radius: 4px;
    color: #fff;
    font-family: inherit;
    font-size: 0.8rem;
    resize: vertical;
}

.element-item .control-group textarea:focus {
    outline: none;
    border-color: #C90000;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #2a2a4a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #4a4a6a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a5a7a;
}

@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
    .text-section {
        grid-column: 1 / -1;
        max-height: 300px;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .preview-section,
    .json-section,
    .text-section {
        max-height: 400px;
    }
}
