/*
    The playground is one screen: a toolbar, an editor, and a pane for what the script produced.
    Nothing scrolls except the two panes, so the layout is a column of fixed chrome around a
    flexible middle.
*/

:root {
    --bg: #1e1e1e;
    --bg-raised: #252526;
    --bg-sunken: #1a1a1a;
    --border: #3c3c3c;
    --text: #d4d4d4;
    --text-dim: #8a8a8a;
    --accent: #4ec9b0;
    --accent-strong: #3aa88f;
    --error: #f14c4c;
    --warning: #cca700;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-code: "Cascadia Mono", "Fira Code", Consolas, "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    overflow: hidden;
}

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

/* Toolbar */

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    height: 46px;
    flex: 0 0 auto;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-right: 6px;
}

.brand-name {
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
}

.brand-tag {
    color: var(--text-dim);
    font-size: 12px;
}

.spacer {
    flex: 1 1 auto;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #333333;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.button:hover:not(:disabled) {
    background: #3d3d3d;
}

.button:disabled {
    opacity: 0.5;
    cursor: default;
}

.button.primary {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #08201c;
    font-weight: 600;
}

.button.primary:hover:not(:disabled) {
    background: var(--accent);
}

.button.primary.running {
    background: #6b6b6b;
    border-color: #6b6b6b;
    color: var(--text);
}

.button.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-dim);
    padding: 2px 8px;
}

.button.ghost:hover {
    color: var(--text);
    background: #333333;
}

.button[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

kbd {
    font-family: var(--font-code);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.25);
}

.field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-label {
    color: var(--text-dim);
    font-size: 12px;
}

select {
    background: #333333;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    font: inherit;
}

.status {
    color: var(--text-dim);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.status.error {
    color: var(--error);
}

.link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 12px;
}

.link:hover {
    color: var(--text);
}

/* Panes */

.panes {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.editor-pane {
    flex: 3 1 0;
    border-right: 1px solid var(--border);
}

.output-pane {
    flex: 1 1 0;
    background: var(--bg-sunken);
}

#editor {
    flex: 1 1 auto;
    min-height: 0;
}

.pane-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.pane-hint {
    text-transform: none;
    letter-spacing: 0;
    font-family: var(--font-code);
    opacity: 0.7;
}

.input-pane {
    display: flex;
    flex-direction: column;
    flex: 0 0 150px;
    border-top: 1px solid var(--border);
    background: var(--bg-sunken);
}

.input-pane[hidden] {
    display: none;
}

#input {
    flex: 1 1 auto;
    resize: none;
    border: 0;
    outline: none;
    padding: 8px 12px;
    background: transparent;
    color: var(--text);
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.5;
}

/* Output */

.output {
    flex: 1 1 auto;
    overflow: auto;
    padding: 10px 12px;
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.output .console {
    color: var(--text);
}

.output .result-label,
.output .meta {
    color: var(--text-dim);
}

.output .result {
    color: var(--accent);
}

.output .error {
    color: var(--error);
}

.output .warning {
    color: var(--warning);
}

.output .rule {
    height: 1px;
    background: var(--border);
    margin: 10px 0;
}

.output .placeholder {
    color: var(--text-dim);
    font-family: var(--font-ui);
}

/* Loader */

.loader {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 10;
    transition: opacity 200ms ease;
}

.loader.done {
    opacity: 0;
    pointer-events: none;
}

.loader-inner {
    text-align: center;
    max-width: 380px;
}

.loader-inner p {
    color: var(--text-dim);
    margin: 6px 0 0;
}

.loader-note {
    font-size: 12px;
    opacity: 0.7;
}

.loader-bar {
    height: 3px;
    width: 260px;
    margin: 0 auto 18px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.loader-fill {
    height: 100%;
    width: 40%;
    background: var(--accent);
    border-radius: 2px;
    animation: slide 1.2s ease-in-out infinite;
}

@keyframes slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

@media (max-width: 900px) {
    .panes {
        flex-direction: column;
    }

    .editor-pane {
        flex: 2 1 0;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .output-pane {
        flex: 1 1 0;
    }
}
