:root {
    color-scheme: dark;

    --bg: #282a36;
    --bg-elev: #21222c;
    --bg-panel: #21222c;
    --bg-hover: #343746;
    --border: #191a21;
    --border-strong: #44475a;
    --text: #f8f8f2;
    --text-muted: #98a3c7;
    --text-dim: #6272a4;
    --accent: #bd93f9;
    --accent-bg: rgba(189, 147, 249, 0.16);
    --accent-strong: #bd93f9;
    --ok: #50fa7b;
    --ok-bg: rgba(80, 250, 123, 0.12);
    --warn: #ffb86c;
    --warn-bg: rgba(255, 184, 108, 0.14);
    --err: #ff5555;
    --err-bg: rgba(255, 85, 85, 0.15);

    --scrollbar-size: 10px;
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(98, 114, 164, 0.34);
    --scrollbar-thumb-hover: rgba(152, 163, 199, 0.52);
    --scrollbar-thumb-active: rgba(189, 147, 249, 0.68);

    --syn-comment: #6272a4;
    --syn-keyword: #ff79c6;
    --syn-type: #8be9fd;
    --syn-string: #f1fa8c;
    --syn-number: #bd93f9;
    --syn-symbol: #ffb86c;
    --syn-namespace: #8bfd8b;
    --syn-payload: #f1fa8c;
    --syn-self: #f2fd8b;
    --syn-unsafe: #fd8b8b;
    --syn-escape: #fd8be0;
    --syn-op: #ff79c6;

    --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --editor-font-size: 13.5px;
    --editor-line-height: 21px;
}

* {
    box-sizing: border-box;
}

::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:active {
    background: var(--scrollbar-thumb-active);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--scrollbar-thumb) transparent;
    }
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.topbar {
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.brand-mark {
    color: var(--accent);
    font-size: 17px;
    line-height: 1;
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.status-pill {
    font-size: 11.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--bg);
    white-space: nowrap;
}

.status-pill.status-ready {
    color: var(--ok);
    border-color: rgba(80, 250, 123, 0.30);
    background: var(--ok-bg);
}

.status-pill.status-error {
    color: var(--err);
    border-color: rgba(255, 85, 85, 0.35);
    background: var(--err-bg);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.layout-toggle {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 2px;
    gap: 2px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
}

.layout-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    width: 26px;
    height: 24px;
    padding: 0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.layout-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.layout-btn.active {
    color: var(--accent);
    background: var(--accent-bg);
}

.layout-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

select,
.btn,
.cfg-input {
    font-family: var(--font-sans);
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    height: 30px;
}

select {
    padding: 0 26px 0 10px;
    cursor: pointer;
}

select:focus,
.btn:focus-visible,
.cfg-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

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

.btn {
    padding: 0 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: #6272a4;
}

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

.btn-primary {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: #282a36;
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background: #d6acff;
    border-color: #d6acff;
}

.btn-icon {
    font-size: 10px;
}

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

.workspace[data-layout="vertical"] {
    flex-direction: column;
}

body.is-resizing {
    user-select: none;
    cursor: col-resize;
}

body.is-resizing.is-resizing-vertical {
    cursor: row-resize;
}

.pane {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    min-width: 0;
    min-height: 0;
}

.pane-editor {
    flex: 0 0 52%;
    overflow: hidden;
}

.pane-output {
    display: block;
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: var(--bg);
}

.pane-output-inner {
    display: flex;
    flex-direction: column;
    min-width: 100%;
    width: max-content;
    height: 100%;
    min-height: 180px;
}

.splitter {
    flex: 0 0 5px;
    background: var(--bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    cursor: col-resize;
    transition: background 0.12s ease;
}

.workspace[data-layout="vertical"] > .splitter {
    cursor: row-resize;
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.splitter:hover,
.splitter.dragging,
.splitter:focus-visible {
    background: var(--accent-bg);
    outline: none;
}

.pane-header {
    height: 36px;
    flex: 0 0 36px;
    display: flex;
    flex-direction: row;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    gap: 8px;
}

.pane-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
}

.pane-meta {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11.5px;
    white-space: nowrap;
    padding: 6px;
}

.sep {
    display: block;
    flex-grow: 1;
}

.hint {
    color: var(--text-dim);
}

.editor-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

.gutter {
    flex: 0 0 46px;
    padding: 12px 10px calc(12px + var(--scrollbar-size)) 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    color: var(--text-dim);
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    user-select: none;
    overflow: hidden;
}

.gutter-line {
    height: var(--editor-line-height);
    padding-right: 2px;
    cursor: default;
}

.gutter-line.has-error {
    color: var(--err);
    font-weight: 700;
    background: rgba(255, 85, 85, 0.14);
    cursor: pointer;
}

.gutter-line.has-warn {
    color: var(--warn);
    font-weight: 700;
    background: rgba(255, 184, 108, 0.12);
    cursor: pointer;
}

.live-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
}

.live-toggle input {
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.editor-stage {
    flex: 1 1 auto;
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.diag-layer,
.highlight-layer,
.code-input {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 12px 14px;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    tab-size: 4;
    white-space: pre;
    overflow: auto;
    border: 0;
    letter-spacing: 0;
    word-spacing: 0;
    font-variant-ligatures: none;
}

.diag-layer {
    pointer-events: none;
    color: transparent;
    background: transparent;
    overflow: hidden;
    padding-right: calc(14px + var(--scrollbar-size));
    padding-bottom: calc(12px + var(--scrollbar-size));
}

.diag-line {
    display: block;
    height: var(--editor-line-height);
    line-height: var(--editor-line-height);
    margin: 0 -14px;
    padding: 0 14px;
}

.diag-line.diag-line-fail {
    background: rgba(255, 85, 85, 0.10);
}

.diag-line.diag-line-warn {
    background: rgba(255, 184, 108, 0.09);
}

.diag-squiggle-fail {
    color: transparent;
    background: rgba(255, 85, 85, 0.24);
    border-radius: 2px;
    text-decoration: underline wavy var(--err);
    text-decoration-skip-ink: none;
    text-underline-offset: 2px;
}

.diag-squiggle-warn {
    color: transparent;
    background: rgba(255, 184, 108, 0.20);
    border-radius: 2px;
    text-decoration: underline wavy var(--warn);
    text-decoration-skip-ink: none;
    text-underline-offset: 2px;
}

.diag-inline-msg {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    padding: 1px 7px;
    margin-left: 16px;
    border-radius: 4px;
    vertical-align: baseline;
}

.diag-inline-msg.fail {
    color: #ff6e6e;
    background: rgba(255, 85, 85, 0.16);
}

.diag-inline-msg.warn {
    color: #ffb86c;
    background: rgba(255, 184, 108, 0.15);
}

.editor-diag-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: #2f2029;
    border-top: 1px solid rgba(255, 85, 85, 0.38);
    font-size: 12.5px;
    line-height: 1.4;
}

.editor-diag-bar.is-warn {
    background: #2f2822;
    border-top-color: rgba(255, 184, 108, 0.38);
}

.editor-diag-bar[hidden] {
    display: none;
}

.diag-bar-badge {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--err-bg);
    color: var(--err);
    letter-spacing: 0.04em;
}

.editor-diag-bar.is-warn .diag-bar-badge {
    background: var(--warn-bg);
    color: var(--warn);
}

.diag-bar-loc {
    flex: 0 0 auto;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
}

.diag-bar-msg {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.diag-bar-jump {
    flex: 0 0 auto;
    font-family: var(--font-sans);
    font-size: 11.5px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
}

.diag-bar-jump:hover {
    background: var(--bg-hover);
}

.highlight-layer {
    pointer-events: none;
    color: var(--text);
    background: transparent;
    overflow: hidden;
    padding-right: calc(14px + var(--scrollbar-size));
    padding-bottom: calc(12px + var(--scrollbar-size));
}

.code-input {
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    resize: none;
    outline: none;
}

.code-input::selection {
    background: rgba(68, 71, 90, 0.75);
}

.tok-comment {
    color: var(--syn-comment);
}

.tok-keyword {
    color: var(--syn-keyword);
}

.tok-type {
    color: var(--syn-type);
}

.tok-string {
    color: var(--syn-string);
}

.tok-number {
    color: var(--syn-number);
}

.tok-symbol {
    color: var(--syn-symbol);
    font-style: italic;
}

.tok-namespace {
    color: var(--syn-namespace);
}

.tok-payload {
    color: var(--syn-payload);
}

.tok-self {
    color: var(--syn-self);
}

.tok-unsafe {
    color: var(--syn-unsafe);
}

.tok-escape {
    color: var(--syn-escape);
}

.tok-op {
    color: var(--syn-op);
}

.run-config {
    flex: 0 0 auto;
    max-height: 35%;
    overflow: auto;
    padding: 8px 12px;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.run-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cfg-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 54px;
}

.cfg-select {
    height: 26px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.cfg-fields {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cfg-field {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

.cfg-field code {
    font-family: var(--font-mono);
    color: var(--text);
}

.cfg-input {
    height: 26px;
    width: 92px;
    padding: 0 7px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.tabs {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
}

.tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 5px;
    white-space: nowrap;
    flex: 0 0 auto;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--accent);
    background: var(--accent-bg);
}

.run-badge {
    font-size: 11.5px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.run-badge:empty {
    display: none;
}

.run-badge.ok {
    color: var(--ok);
    background: var(--ok-bg);
}

.run-badge.err {
    color: var(--err);
    background: var(--err-bg);
}

.output-body {
    flex: 1 1 auto;
    min-height: 0;
    width: 0;
    min-width: 100%;
    overflow: auto;
    padding: 14px;
    background: var(--bg);
}

.panel[hidden] {
    display: none;
}

.empty-state {
    color: var(--text-muted);
    padding: 24px 8px;
    line-height: 1.6;
}

.empty-state kbd {
    font-family: var(--font-mono);
    font-size: 11.5px;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elev);
    color: var(--text);
}

.output-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.out-card {
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-elev);
    overflow: hidden;
}

.out-card.card-err {
    border-color: rgba(255, 85, 85, 0.35);
}

.out-card.card-warn {
    border-color: rgba(255, 184, 108, 0.35);
}

.out-card.card-ok {
    border-color: rgba(80, 250, 123, 0.28);
}

.out-card-head {
    padding: 6px 11px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.out-card.card-err .out-card-head {
    color: var(--err);
    background: var(--err-bg);
}

.out-card.card-warn .out-card-head {
    color: var(--warn);
    background: var(--warn-bg);
}

.out-card.card-ok .out-card-head {
    color: var(--ok);
    background: var(--ok-bg);
}

.out-pre {
    margin: 0;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
}

.ir-view {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    white-space: pre;
    color: var(--text);
}

.stats-bar {
    height: 28px;
    flex: 0 0 28px;
    width: 0;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11.5px;
    gap: 12px;
    white-space: nowrap;
    overflow: hidden;
}

.stats-bar > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-right {
    flex: 0 2 auto;
}

.stats-bar code {
    font-family: var(--font-mono);
    color: var(--text);
}
