* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: #f0f0f0;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.compiler-container {
    max-width: 98%;
    width: 100%;
    flex: 1;
    min-height: 0;
    margin: 0 auto 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: background 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
}

.compiler-top-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    width: 98%;
    margin: 0 auto 16px;
    background: white;
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.compiler-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.language-select,
.run-btn,
.download-btn,
.clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    padding: 9px 19px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: inherit;
    font-weight: bold;
    line-height: normal;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.language-select {
    background: white;
    color: #333;
    border-color: #ddd;
}

.language-select:focus {
    outline: none;
    border-color: #3b5998;
}

.run-btn {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

.run-btn:hover {
    background: #45a049;
    border-color: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.download-btn {
    background: #2196F3;
    color: white;
    border-color: #2196F3;
}

.download-btn:hover {
    background: #1976D2;
    border-color: #1976D2;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.clear-btn {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.clear-btn:hover {
    background: #da190b;
    border-color: #da190b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.main-editor-area {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
    zoom: 1.25;
}

.code-panel {
    flex: 3;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.code-panel .editor-label {
    margin-bottom: 5px;
}

.code-editor {
    width: 100%;
    flex: 1;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    color: #333;
    resize: none;
    line-height: 1.5;
    tab-size: 4;
}

.code-editor:focus {
    outline: none;
    border-color: #3b5998;
    background: white;
}

.io-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 250px;
}

.input-container,
.expected-container,
.output-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.editor-label {
    font-weight: bold;
    margin-bottom: 5px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    flex-shrink: 0;
}

.input-field,
.expected-field {
    width: 100%;
    flex: 1;
    padding: 10px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    color: #333;
    resize: none;
    min-height: 80px;
}

.input-field:focus,
.expected-field:focus {
    outline: none;
    border-color: #3b5998;
    background: white;
}

.output-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.output-label {
    font-weight: bold;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
}

.output-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background: #e0e0e0;
    color: #666;
}

.output-status.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.output-status.error {
    background: #ffebee;
    color: #c62828;
}

.output-status.mismatch,
.output-status.timeout,
.output-status.memory {
    background: #fff3e0;
    color: #e65100;
}

.output-box {
    width: 100%;
    flex: 1;
    padding: 10px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f5f5f5;
    color: #333;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
    margin: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 18px;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .theme-toggle {
    background: rgba(255, 255, 255, 0.12);
    color: #f0f0f0;
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
}

body.dark-mode .compiler-container {
    background: #1e1e1e;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body.dark-mode .compiler-top-bar {
    background: #1e1e1e;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

body.dark-mode .language-select,
body.dark-mode .code-editor,
body.dark-mode .input-field,
body.dark-mode .expected-field,
body.dark-mode .output-box {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}

body.dark-mode .code-editor:focus,
body.dark-mode .input-field:focus,
body.dark-mode .expected-field:focus {
    background: #333;
    border-color: #66b0ff;
}

body.dark-mode .editor-label,
body.dark-mode .output-label {
    color: #aaa;
}

body.dark-mode .run-btn {
    background: #1e1e1e;
    color: #4CAF50;
    border: 1px solid #4CAF50;
}

body.dark-mode .run-btn:hover {
    background: #4CAF50;
    color: white;
}

body.dark-mode .download-btn {
    background: #1e1e1e;
    color: #2196F3;
    border: 1px solid #2196F3;
}

body.dark-mode .download-btn:hover {
    background: #2196F3;
    color: white;
}

body.dark-mode .clear-btn {
    background: #1e1e1e;
    color: #f44336;
    border: 1px solid #f44336;
}

body.dark-mode .clear-btn:hover {
    background: #f44336;
    color: white;
}

body.dark-mode .output-status {
    background: #333;
    color: #aaa;
}

body.dark-mode .output-status.success {
    background: #1b3b1b;
    color: #81c784;
}

body.dark-mode .output-status.error {
    background: #3b1b1b;
    color: #e57373;
}

body.dark-mode .output-status.mismatch,
body.dark-mode .output-status.timeout,
body.dark-mode .output-status.memory {
    background: #3b2e1b;
    color: #ffb74d;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .compiler-top-bar {
        width: 100%;
    }

    .compiler-container {
        height: auto;
        min-height: 90vh;
    }

    .main-editor-area {
        flex-direction: column;
    }

    .code-editor {
        min-height: 400px;
    }

    .io-panel {
        min-width: auto;
    }

    .controls {
        flex-direction: column;
    }

    .run-btn,
    .download-btn,
    .clear-btn {
        width: 100%;
        justify-content: center;
    }
}
