:root {
    --bg: #090e1a;
    --bg-soft: #111a2f;
    --panel: #17233f;
    --border: #2c3f67;
    --text: #e4ebff;
    --text-soft: #9caed3;
    --primary: #4f7cff;
    --accent: #ff9f43;
    --success: #22c55e;
    --muted: #64748b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Inter, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 20% 0%, #243862 0%, var(--bg) 45%);
    min-height: 100vh;
}

.shell {
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.brand h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: 0.3px;
}

.brand p {
    margin: 8px 0 0;
    color: var(--text-soft);
    font-size: 14px;
}

.status {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-soft);
    background: #121c34;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(380px, 1.1fr) minmax(340px, 0.9fr);
    gap: 16px;
}

.editor-pane,
.results-pane {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
}

.editor-pane {
    display: flex;
    flex-direction: column;
    min-height: 82vh;
}

.pane-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.pane-head h2 {
    margin: 0;
    font-size: 15px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 9px 12px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(1.1);
}

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

.btn-primary { background: linear-gradient(135deg, #3b82f6, var(--primary)); }
.btn-accent { background: linear-gradient(135deg, #f59e0b, var(--accent)); }
.btn-success { background: linear-gradient(135deg, #16a34a, var(--success)); }
.btn-muted { background: #475569; }

#codeEditor {
    flex: 1;
    border: 0;
    outline: none;
    resize: none;
    background: #0b1326;
    color: #dbeafe;
    font-family: Menlo, Consolas, Monaco, monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 14px;
}

.results-pane {
    padding: 12px;
    display: grid;
    gap: 10px;
    max-height: 82vh;
    overflow: auto;
}

.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    padding: 10px;
}

.card h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

pre,
#fixedCodePreview,
#aiPrompt {
    margin: 0;
    width: 100%;
    border: 1px solid #25385e;
    border-radius: 8px;
    background: #0b1326;
    color: #dbeafe;
    font-family: Menlo, Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 10px;
    min-height: 60px;
}

#fixedCodePreview,
#aiPrompt {
    resize: vertical;
    min-height: 110px;
}

#aiPrompt {
    margin-bottom: 8px;
}

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

.meta-grid {
    display: grid;
    grid-template-columns: 108px 1fr;
    gap: 6px 10px;
    margin-bottom: 8px;
    font-size: 13px;
}

.meta-grid .label {
    color: var(--text-soft);
}

#explanationPanel {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: #dbeafe;
}

.highlight-line {
    display: block;
    border-left: 3px solid var(--danger);
    background: rgba(239, 68, 68, 0.15);
    padding-left: 8px;
}

.loader {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 999;
    background: #111827;
    color: #dbeafe;
    border: 1px solid #374151;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
}

.hidden {
    display: none;
}

@media (max-width: 1120px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .editor-pane,
    .results-pane {
        min-height: 0;
        max-height: none;
    }
}
