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

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a0a0f;
    color: #e0e0e0;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(20, 20, 30, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    flex-shrink: 0;
}

.title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(90deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow 3s linear infinite;
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.toolbar {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

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

.btn-small {
    padding: 0.25rem 0.5rem;
    background: rgba(255, 0, 255, 0.1);
    border: 1px solid rgba(255, 0, 255, 0.5);
    color: #ff00ff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
}

.btn-small:hover {
    background: rgba(255, 0, 255, 0.2);
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.editor-panel {
    width: 40%;
    display: flex;
    flex-direction: column;
    background: rgba(15, 15, 20, 0.9);
    border-right: 1px solid rgba(0, 255, 255, 0.2);
    overflow: hidden;
    min-height: 0;
}

/* Editor Tabs */
.editor-tabs {
    display: flex;
    background: rgba(20, 20, 30, 0.8);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    flex-shrink: 0;
}

.editor-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #a0a0a0;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.editor-tab:hover {
    color: #00ffff;
    background: rgba(0, 255, 255, 0.05);
}

.editor-tab.active {
    color: #00ffff;
    border-bottom-color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
}

.editor-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Shader Preview Container (Mobile) */
.shader-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

#glCanvasMobile {
    flex: 1;
    width: 100%;
    min-height: 0;
}

.mobile-controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(20, 20, 30, 0.9);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(20, 20, 30, 0.8);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    flex-shrink: 0;
}

#codeEditor {
    flex: 1;
    padding: 1rem;
    background: #0f0f14;
    color: #e0e0e0;
    border: none;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    width: 100%;
    min-height: 0;
    overflow-y: auto;
}

.error-display {
    display: none;
    padding: 0.75rem;
    background: rgba(255, 0, 100, 0.1);
    border-top: 1px solid rgba(255, 0, 100, 0.5);
    color: #ff6b9d;
    font-family: monospace;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Generate Section */
.generate-section {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.generate-section h4 {
    color: #ff00ff;
    margin-bottom: 1rem;
}

#promptInput {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.generate-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.generate-options select {
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: #e0e0e0;
    border-radius: 4px;
}

.generate-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #a0a0a0;
}

/* Analysis Section */
.analysis-section {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.analysis-section h4 {
    color: #ff00ff;
    margin-bottom: 1rem;
}

.analysis-output {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 0, 255, 0.3);
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 600px;
    overflow-y: auto;
}

/* Markdown styling for analysis output */
.analysis-output h1,
.analysis-output h2,
.analysis-output h3,
.analysis-output h4 {
    color: #ff00ff;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.analysis-output h1 {
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(255, 0, 255, 0.3);
    padding-bottom: 0.5rem;
}

.analysis-output h2 {
    font-size: 1.3rem;
}

.analysis-output h3 {
    font-size: 1.1rem;
}

.analysis-output p {
    margin-bottom: 0.75rem;
}

.analysis-output ul,
.analysis-output ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.analysis-output li {
    margin-bottom: 0.25rem;
}

.analysis-output code {
    background: rgba(0, 255, 255, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    color: #00ffff;
}

.analysis-output pre {
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(0, 255, 255, 0.2);
}

.analysis-output pre code {
    background: none;
    padding: 0;
}

.analysis-output blockquote {
    border-left: 3px solid rgba(255, 0, 255, 0.5);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 0.75rem;
    color: #c0c0c0;
}

.analysis-output a {
    color: #00ffff;
    text-decoration: underline;
}

.analysis-output a:hover {
    color: #ff00ff;
}

.analysis-output::-webkit-scrollbar {
    width: 8px;
}

.analysis-output::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.analysis-output::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 255, 0.5);
    border-radius: 4px;
}

.analysis-output::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 0, 255, 0.7);
}

.preview-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
    background: #000;
    position: relative;
    min-height: 0;
}

#glCanvas {
    flex: 1;
    width: 100%;
    min-height: 0;
}

.controls {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: rgba(20, 20, 30, 0.9);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.btn-control {
    padding: 0.5rem;
    background: rgba(255, 255, 0, 0.1);
    border: 1px solid rgba(255, 255, 0, 0.5);
    color: #ffff00;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-control:hover {
    background: rgba(255, 255, 0, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.speed-control label {
    font-size: 0.8rem;
    color: #ffff00;
}

.speed-control input[type="range"] {
    width: 150px;
}

.fps-counter {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    font-family: monospace;
    border-radius: 4px;
    pointer-events: none;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
}

.settings-modal-content {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(30, 30, 40, 0.9);
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}

.modal-header h3 {
    color: #00ffff;
}

.modal-body {
    padding: 1.5rem;
}

.modal-body label {
    display: block;
    margin-bottom: 1rem;
    color: #ffff00;
}

.modal-body label small {
    display: block;
    color: #a0a0a0;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
}

.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: #e0e0e0;
    border-radius: 4px;
    font-family: inherit;
}

.modal-body textarea {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    resize: vertical;
    line-height: 1.5;
}

.share-url-container {
    display: flex;
    gap: 0.5rem;
}

.share-url-container input {
    flex: 1;
    margin-top: 0;
}

.copy-success {
    margin-top: 1rem;
    padding: 0.5rem;
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid rgba(0, 255, 0, 0.5);
    color: #00ff00;
    border-radius: 4px;
    text-align: center;
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preset-item {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 0, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.preset-item:hover {
    background: rgba(255, 0, 255, 0.1);
    border-color: rgba(255, 0, 255, 0.6);
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

.preset-item h4 {
    color: #ff00ff;
    margin-bottom: 0.5rem;
}

.preset-item p {
    color: #a0a0a0;
    font-size: 0.9rem;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

.settings-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: #a0a0a0;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.settings-tab:hover {
    color: #00ffff;
}

.settings-tab.active {
    color: #00ffff;
    border-bottom-color: #00ffff;
}

.settings-tab-content {
    display: block;
}

/* Footer */
.footer {
    padding: 1rem;
    background: rgba(20, 20, 30, 0.8);
    border-top: 1px solid rgba(0, 255, 255, 0.2);
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.footer a {
    color: #00ffff;
    text-decoration: none;
}

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

/* Wide screen layout */
@media (min-width: 1024px) {
    .editor-panel {
        width: 40%;
    }
    
    .preview-panel {
        width: 60%;
        display: flex !important;
    }
}

/* Responsive */
@media (max-width: 1023px) {
    .editor-panel {
        width: 100% !important;
        border-right: none;
    }
    
    .preview-panel {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .title {
        font-size: 1.5rem;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .editor-tab {
        font-size: 0.85rem;
        padding: 0.6rem 0.5rem;
    }
    
    #codeEditor {
        font-size: 0.8rem;
    }
    
    .controls {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .mobile-controls {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .speed-control input[type="range"] {
        width: 100px;
    }
    
    .settings-modal-content {
        max-width: 95%;
    }
    
    .generate-section,
    .analysis-section {
        padding: 1rem;
    }
    
    .generate-options {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .analysis-output {
        max-height: 400px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.2rem;
    }
    
    .editor-tab {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }
    
    .controls {
        justify-content: center;
    }
    
    .mobile-controls {
        justify-content: center;
    }
    
    .btn-control {
        font-size: 0.9rem;
        padding: 0.4rem;
    }
}