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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: white;
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-right {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-icon {
    padding: 8px;
    background: #f3f4f6;
    color: #374151;
}

.btn-icon:hover:not(:disabled) {
    background: #e5e7eb;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-large {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    gap: 16px;
    padding: 16px;
    overflow: hidden;
}

.left-sidebar, .right-sidebar {
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.tool-section {
    margin-bottom: 24px;
}

.tool-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tool-btn {
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

.tool-btn.active {
    border-color: #3b82f6;
    background: #3b82f6;
    color: white;
}

.layers-list {
    max-height: 200px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
}

.layer-toggle, .layer-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px;
}

.layer-toggle:hover, .layer-delete:hover {
    background: #f3f4f6;
    border-radius: 2px;
}

.canvas-area {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-controls {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 8px;
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #f9fafb;
    background-image: 
        linear-gradient(45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(-45deg, #f3f4f6 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f3f4f6 75%),
        linear-gradient(-45deg, transparent 75%, #f3f4f6 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

#mainCanvas {
    display: block;
    margin: 20px auto;
    border: 2px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    transform-origin: center center;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #6b7280;
}

.empty-state p {
    font-size: 18px;
    margin-bottom: 16px;
}

.ai-section {
    margin-bottom: 24px;
}

.ai-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
}

#aiPrompt {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
}

#aiPrompt:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    width: 0%;
    animation: progress 2s infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

.quick-actions h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #374151;
}

.quick-actions .btn {
    width: 100%;
    margin-bottom: 8px;
}

.bottom-toolbar {
    background: white;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
}

.tool-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

.tool-controls label {
    font-weight: 500;
    color: #374151;
}

.tool-controls input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.tool-controls input[type="range"] {
    width: 80px;
}

#currentTool {
    font-weight: 600;
    color: #3b82f6;
    margin-left: auto;
}

.footer {
    background: white;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    font-size: 12px;
    color: #6b7280;
}

.footer a {
    color: #3b82f6;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    width: 400px;
}

.modal-content h3 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.modal-content input, .modal-content select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
}

.modal-content input[type="range"] {
    margin-bottom: 4px;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-buttons .btn {
    flex: 1;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 200px 1fr 200px;
    }
    
    .tool-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .left-sidebar, .right-sidebar {
        padding: 12px;
    }
    
    .tool-controls {
        flex-wrap: wrap;
        gap: 8px;
    }
}