html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
    background: #fafbfc;
    color: #222;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid #e1e5e9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 10;
}

/* Mobile and portrait orientation - adjust header */
@media (max-width: 768px), (orientation: portrait) {
    .header {
        padding: 0.5rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header h1 {
        font-size: 1.4rem;
        margin: 0;
    }
    
    .download-buttons {
        gap: 0.25rem;
    }
    
    .download-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

.header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: #2c3e50;
}

.download-buttons {
    display: flex;
    gap: 0.5rem;
}

.download-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.download-btn:active {
    background: #f3f4f6;
}

.workbench-container {
    display: flex;
    flex-direction: row;
    gap: 2vw;
    width: 100%;
    max-width: none;
    margin: 0;
    background: #f5f6f7;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    padding: 0.5vw 0vw 0.5vw 0vw;
    min-height: calc(100vh - 80px);
    height: calc(100vh - 80px);
    position: relative;
    z-index: 1;
}

/* Mobile and portrait orientation - stack vertically */
@media (max-width: 768px), (orientation: portrait) {
    .workbench-container {
        flex-direction: column;
        gap: 2vh;
        padding: 2vh 2vw;
        min-height: calc(100vh - 80px);
        height: auto;
    }
}

.code-pane {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 50vw;
    width: 50vw;
    height: 100%;
    padding: 0.5vw;
}

/* Mobile and portrait orientation - adjust code pane */
@media (max-width: 768px), (orientation: portrait) {
    .code-pane {
        max-width: 100%;
        width: 100%;
        height: 50vh;
        min-height: 300px;
        padding: 1vh 1vw;
    }
}

.error-display {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    font-size: 0.875rem;
    font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
    display: none;
}

.error-display.show {
    display: block;
}

.canvas-pane {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    max-width: 50vw;
    width: 50vw;
    height: 100%;
    padding: 0.5vw;
    position: relative;
    overflow: hidden;
}

/* Mobile and portrait orientation - adjust canvas pane */
@media (max-width: 768px), (orientation: portrait) {
    .canvas-pane {
        max-width: 100%;
        width: 100%;
        height: 50vh;
        min-height: 300px;
        padding: 1vh 1vw;
    }
}

.code-editor {
    flex: 1 1 0;
    background: #f8f8fa;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 0.5vw 0.5vw 0.5vw 0.5vw;
    font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
    font-size: 1em;
    line-height: 1.6;
    color: #222;
    overflow: auto;
    min-height: 0;
    max-height: none;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.CodeMirror {
    flex: 1 1 auto;
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    font-size: 1em;
    line-height: 1.4;
    color: inherit;
}

.CodeMirror-code {
    font-size: inherit;
    line-height: inherit;
}

.run-button {
    margin-top: 10px;
    padding: 10px 15px;
    border: none;
    background-color: #61afef;
    color: white;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
}

.run-button:hover {
    background-color: #528ab9;
}

.pattern-container {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    flex: 1 1 0;
    aspect-ratio: 1;
}

/* Mobile and portrait orientation - adjust pattern container */
@media (max-width: 768px), (orientation: portrait) {
    .pattern-container {
        max-width: 90%;
        max-height: 90%;
        aspect-ratio: 1;
    }
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

#canvas-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 8px;
    position: relative;
    z-index: 1;
    /* Let canvas scale naturally with browser zoom */
    image-rendering: auto;
}

/* Editor Status Feedback */
.status-ok { 
    border: 4px solid #28a745 !important; 
    border-radius: 8px;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2) !important;
} /* Green */
.status-syntax-error { 
    border: 4px solid #dc3545 !important; 
    border-radius: 8px;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2) !important;
} /* Red */
.status-runtime-error { 
    border: 4px solid #ffc107 !important; 
    border-radius: 8px;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2) !important;
} /* Yellow */



.pattern-data-container h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #666;
}

.pattern-data {
    font-family: 'Fira Mono', 'Consolas', 'Menlo', monospace;
    font-size: 0.7rem;
    line-height: 1.2;
    color: #333;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}
