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

body {
    background-color: #121212;
    color: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 10px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}
:root{
    --header-bg: #e6e5e5;
    --code-header-bg: #ededed;
    --code-header-color: #333;
}
.dark{
    --header-bg: #252526;
    --code-header-bg: #2d2d2d;
    --code-header-color: #ccc;
}

.sandbox-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* --- TOOLBAR --- */
.sandbox-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-bg);
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    gap: 10px;
}

.view-toggles {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.toggle-btn {
    background-color: transparent;
    color: #888;
    border: 1px solid #444;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.toggle-btn.active {
    background-color: #007fd4;
    color: white;
    border-color: #007fd4;
}

.action-btns { display: flex; gap: 8px; }

.run-btn {
    background-color: #28a745;
    color: #ffffff;
    border: none;
    padding: 6px 15px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.run-btn:hover { background-color: #218838; }

/* --- PANELS & SPLITTERS --- */
.sandbox-workspace {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
    background-color: #333; /* Background shows through splitters */
}

.panel {
    display: flex;
    flex-direction: column;
    background-color: #1e1e1e;
    min-width: 50px;
    min-height: 50px;
    flex: 1; /* Distribute evenly by default */
}

.panel.hidden { display: none !important; }

.panel-header {
    padding: 6px 10px;
    font-size: 12px;
    background-color: var(--code-header-bg);
    color: var(--code-header-color);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.html-header { border-top: 2px solid #e34c26; }
.css-header { border-top: 2px solid #264de4; }
.js-header { border-top: 2px solid #f0db4f; }
.output-header { border-top: 2px solid #00ff1e; }

/* CodeMirror Override Styles */
.CodeMirror {
    height: 100%;
    width: 100%;
    font-family: monospace, monospace;
    font-size: 14px;
    z-index: 1;
    flex-grow: 1;
}

.code-editor {
    flex-grow: 1;
    width: 100%;
    background-color: #1e1e1e;
    color: #d4d4d4;
    font-family: monospace;
    font-size: 14px;
    padding: 10px;
    border: none;
    resize: none;
    outline: none;
}

.output-frame {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    border: none;
    background-color: #ffffff;
}

/* The Drag Handle (Splitter) */
.resizer {
    width: 6px;
    background-color: #333;
    cursor: col-resize;
    flex-shrink: 0;
    transition: background-color 0.2s;
    z-index: 10;
}
.resizer:hover, .resizer.dragging { background-color: #007fd4; }
.resizer.hidden { display: none !important; }

/* Responsive - Switch to vertical stacking on mobile */
@media (max-width: 768px) {
    .sandbox-workspace { flex-direction: column; }
    .resizer {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }
}

body.is-dragging iframe {
    pointer-events: none;
}