/* === Editor palette (audit U43) — the ONE place this skin's colours are declared ==============
   No rule below carries a literal. A design-system colour is read as var(--token, #fallback) with
   the fallback the rule used to hard-code, so the rendered colour cannot change; the editor's own
   VS-Code syntax/chrome colours are named here. EditorPaletteTokenGuardTests fails on a hex that
   is not one of these declarations or a var(...) fallback. */
:root {
    /* VS Code syntax colours */
    --jse-syntax-keyword: #C586C0;
    --jse-syntax-type: #569CD6;
    --jse-syntax-function: #DCDCAA;
    --jse-syntax-function-name: #6AA7E0;
    --jse-syntax-variable: #9CDCFE;
    --jse-syntax-string: #CE9178;
    --jse-syntax-number: #B5CEA8;
    --jse-syntax-comment: #6A9955;
    --jse-syntax-series: #4EC9B0;
    --jse-syntax-color: #F48771;

    /* Editor chrome */
    --jse-editor-foreground: #D4D4D4;
    --jse-gutter-foreground: #858585;
    --jse-cursor: #AEAFAD;
    --jse-selection: #264F78;
    --jse-active-line: #2A2D2E;
    --jse-matching-bracket: #3A3D41;
    --jse-matching-bracket-outline: #555;
    --jse-overlay-surface: #252526;
    --jse-overlay-border: #3C3C3C;
    --jse-completion-text: #C0C0C0;
    --jse-close-surface: #333;
    --jse-close-border: #4D4D4D;
    --jse-accent-foreground: #1E1E1E;
    --jse-debug-accent: #DCDCAA;
    --jse-break-dot: #E06C75;

    /* Severity — the editor's own hues; --danger/--warning/--error are different colours */
    --jse-error: #FF5252;
    --jse-error-soft: #E57373;
    --jse-warning: #FFC107;
    --jse-success-subtle: #1A2F1A;
    --jse-success-border: #2A4A2A;
}

/* === Editor Layout === */
.jadscript-editor {
    position: relative;
    display: flex;
    flex-direction: column;
    /* Fill the hosting region (JadScript widget panel, dev tools). min-height must stay 0 so
       the editor can SHRINK into a small widget — a hard min-height made the panel body
       overflow its window with the script's bottom unreachable. */
    flex: 1 1 auto;
    min-height: 0;
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    overflow: hidden;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.editor-title {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* A refused save is one line under the toolbar: the reader sees that nothing was stored, and the panel stays bound
   to the document it had. */
.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--jse-error);
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* The ONE piece of the toolbar's old skin that said something the design system's variants do not: the debug
   entry point wears the editor's own accent. It names the library class because `.jad-btn--outline[scope]` is
   two class-level selectors — the trap U42 recorded, and `PrimitiveStyleSpecificityGuardTests` computes it. */
button.jad-btn.btn-debug {
    color: var(--jse-debug-accent);
}

.debug-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
}

.editor-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.editor-pane {
    display: grid;
    grid-template-columns: 140px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
            "sidebar code"
            "help help";
    flex: 1;
    min-height: 0;
}

.editor-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    background: var(--surface-secondary);
    border-right: 1px solid var(--border-default);
    overflow-y: auto;
}

.editor-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.editor-tab {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.editor-tab.active {
    background: var(--accent);
    color: var(--text-primary);
    border-color: var(--accent);
}

.editor-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.editor-field label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.editor-field input[type="color"] {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
    cursor: pointer;
}

.editor-field input[type="number"] {
    width: 100%;
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--border-default);
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
}

.codemirror-container {
    grid-area: code;
    min-height: 0;
    overflow: hidden;
}

.editor-pane:has(.editor-sidebar) .codemirror-container {
    grid-column: code;
}

.editor-pane:not(:has(.editor-sidebar)) {
    grid-template-columns: 1fr;
    grid-template-areas:
            "code"
            "help";
}

.editor-help {
    grid-area: help;
}

.codemirror-container .CodeMirror {
    height: 100%;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.toolbar-shortcuts {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shortcut-hint {
    font-size: 10px;
    color: var(--text-muted);
    cursor: help;
}

.editor-help {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.help-text {
    font-size: 10px;
    color: var(--text-muted);
}

.output-pane {
    min-height: 60px;
    max-height: 200px;
    overflow: auto;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
}

.debug-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: var(--jse-success-subtle);
    border-bottom: 1px solid var(--jse-success-border);
}

.debug-paused {
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

.debug-call-depth {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: auto;
}

/* === Debugger call stack + watch views (roadmap #66) === */
.debug-callstack {
    padding: 4px 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    max-height: 160px;
    overflow-y: auto;
}

.debug-frame {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.4;
}

.debug-frame.current {
    background: rgba(76, 175, 80, 0.08);
    border-left: 2px solid var(--success);
}

.debug-frame-name {
    color: var(--accent-primary);
    font-weight: 500;
}

.debug-frame-line {
    color: var(--text-muted);
}

.debug-watch {
    margin-top: 8px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    background: var(--surface-primary);
}

.debug-watch-add {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    align-items: center;
}

.debug-watch-input {
    flex: 1;
    min-width: 0;
    background: var(--surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    color: var(--text-primary);
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    padding: 3px 6px;
}

.debug-watch-add-btn {
    border: 1px solid var(--border, #3A3A3A);
    background: var(--surface-tertiary);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 12px;
    cursor: pointer;
}

.debug-watch-list {
    border-top: 1px solid var(--border-default);
    max-height: 160px;
    overflow-y: auto;
}

.debug-watch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.debug-watch-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.03);
}

.debug-watch-expr {
    color: var(--accent-primary);
    flex: 0 0 auto;
    font-weight: 500;
}

.debug-watch-value {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-watch-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.debug-watch-remove:hover {
    color: var(--jse-error-soft);
}

.debug-watch-clear {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 4px 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.debug-watch-hint {
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-default);
}

.output-placeholder {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.diagnostics-panel {
    padding: 8px 12px;
}

.diagnostic {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
}

.diagnostic:last-child {
    border-bottom: none;
}

.diagnostic.error {
    color: var(--jse-error);
}

.diagnostic.warning {
    color: var(--jse-warning);
}

.diagnostic.info {
    color: var(--accent-primary);
}

.diag-location {
    font-size: 10px;
    color: var(--text-muted);
}

.result-panel {
    padding: 12px;
}

.result-success {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--success);
}

.result-error {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--jse-error);
}

.result-plots {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-secondary);
}

/* === CodeMirror jadscript-dark Theme === */
.cm-s-jadscript-dark.CodeMirror {
    background: var(--surface-primary);
    color: var(--jse-editor-foreground);
}

.cm-s-jadscript-dark .CodeMirror-gutters {
    background: var(--surface-primary);
    border-right: 1px solid var(--border-subtle);
    color: var(--jse-gutter-foreground);
}

.cm-s-jadscript-dark .CodeMirror-linenumber {
    color: var(--jse-gutter-foreground);
    padding: 0 8px;
}

.cm-s-jadscript-dark .CodeMirror-cursor {
    border-left: 1px solid var(--jse-cursor);
}

.cm-s-jadscript-dark .CodeMirror-selected {
    background: var(--jse-selection);
}

.cm-s-jadscript-dark .CodeMirror-line::selection,
.cm-s-jadscript-dark .CodeMirror-line > span::selection,
.cm-s-jadscript-dark .CodeMirror-line > span > span::selection {
    background: var(--jse-selection);
}

.cm-s-jadscript-dark .cm-keyword {
    color: var(--jse-syntax-keyword);
    font-weight: 600;
}

.cm-s-jadscript-dark .cm-atom {
    color: var(--jse-syntax-variable);
}

.cm-s-jadscript-dark .cm-def {
    color: var(--jse-syntax-function);
}

.cm-s-jadscript-dark .cm-string {
    color: var(--jse-syntax-string);
}

.cm-s-jadscript-dark .cm-number {
    color: var(--jse-syntax-number);
}

.cm-s-jadscript-dark .cm-comment {
    color: var(--jse-syntax-comment);
    font-style: italic;
}

.cm-s-jadscript-dark .cm-operator {
    color: var(--jse-editor-foreground);
}

.cm-s-jadscript-dark .cm-variable {
    color: var(--jse-editor-foreground);
}

.cm-s-jadscript-dark .cm-property {
    color: var(--jse-editor-foreground);
}

/* Active line highlight */
.cm-s-jadscript-dark .CodeMirror-activeline-background {
    background: var(--jse-active-line);
}

.cm-s-jadscript-dark .CodeMirror-activeline-gutter {
    background: var(--jse-active-line);
}

/* Matching brackets */
.cm-s-jadscript-dark .CodeMirror-matchingbracket {
    background: var(--jse-matching-bracket);
    color: var(--text-primary);
    outline: 1px solid var(--jse-matching-bracket-outline);
}

/* Current execution line highlight */
.jadscript-current-line {
    background: rgba(51, 181, 229, 0.15) !important;
}

.jadscript-current-line::before {
    content: '▶';
    position: absolute;
    left: 2px;
    color: var(--accent-primary);
    font-size: 10px;
    line-height: 1.5;
}

/* Breakpoint gutter */
.jadscript-breakpoint {
    color: var(--jse-error);
    font-size: 10px;
    text-align: center;
    line-height: 1.5;
    cursor: pointer;
}

/* Diagnostic gutter markers */
.jadscript-gutter-marker {
    width: 12px;
    text-align: center;
    font-size: 10px;
    cursor: help;
}

.jadscript-gutter-error {
    color: var(--jse-error);
}

.jadscript-gutter-warning {
    color: var(--jse-warning);
}

.jadscript-gutter-info {
    color: var(--accent-primary);
}

/* Gutter spacing */
.cm-s-jadscript-dark .jadscript-diagnostics {
    width: 16px;
}

.cm-s-jadscript-dark .breakpoints {
    width: 14px;
}

/* === CodeMirror 6 Styles === */
.codemirror-container .cm-editor {
    background: var(--surface-primary);
    color: var(--jse-editor-foreground);
    height: 100%;
}

.codemirror-container .cm-scroller {
    font-family: 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: var(--jadscript-editor-font-size, 13px);
    line-height: 1.5;
}

.codemirror-container .cm-content {
    padding: 4px 0;
}

.codemirror-container .cm-gutters {
    background: var(--surface-primary);
    border-right: 1px solid var(--border-subtle);
    color: var(--jse-gutter-foreground);
}

.codemirror-container .cm-activeLine,
.codemirror-container .cm-activeLineGutter {
    background: var(--jse-active-line);
}

.codemirror-container .cm-selectionBackground {
    background: var(--jse-selection);
}

.codemirror-container .cm-cursor {
    border-color: var(--jse-cursor);
}

.codemirror-container .cm-matchingBracket {
    background: var(--jse-matching-bracket);
    color: var(--text-primary);
    outline: 1px solid var(--jse-matching-bracket-outline);
}

.codemirror-container .cm-nonmatchingBracket {
    color: var(--jse-error);
}

/* Inline value preview badges (roadmap #46, §3.3) */
.codemirror-container .jadscript-inline-preview {
    color: var(--text-muted);
    font-style: italic;
    background: rgba(139, 148, 158, 0.14);
    border-radius: 3px;
    padding: 0 5px;
    margin-left: 8px;
    font-size: 11px;
    white-space: nowrap;
    user-select: none;
    pointer-events: none;
}

/* Smart semantic highlighting (roadmap #47, §3.3) — colors identifiers by meaning. !important
   wins over the base StreamLanguage token colors applied to inner spans. */
.codemirror-container .jadscript-sem-ambientseries {
    color: var(--jse-syntax-series) !important;
}

.codemirror-container .jadscript-sem-function {
    color: var(--jse-syntax-function-name) !important;
}

.codemirror-container .jadscript-sem-constant {
    color: var(--jse-syntax-function) !important;
}

.codemirror-container .jadscript-sem-localvariable {
    color: var(--jse-syntax-variable) !important;
}

.codemirror-container .jadscript-sem-globalvariable {
    color: var(--jse-syntax-comment) !important;
}

.codemirror-container .jadscript-sem-persistentvariable {
    color: var(--jse-syntax-keyword) !important;
}

.codemirror-container .jadscript-sem-sharedvariable {
    color: var(--jse-syntax-string) !important;
}

.codemirror-container .jadscript-sem-member {
    color: var(--jse-editor-foreground) !important;
    font-style: italic;
}

.codemirror-container .jadscript-sem-color {
    color: var(--jse-syntax-color) !important;
}

.codemirror-container .jadscript-sem-type {
    color: var(--jse-syntax-type) !important;
}

/* Ctrl+K natural-language search palette (roadmap #50, §3.3) */
.jadscript-search-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: min(340px, 90%);
    z-index: 20;
    background: var(--jse-overlay-surface);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    font-size: 12px;
}

.jadscript-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    background: var(--surface-primary);
    border: none;
    border-bottom: 1px solid var(--border-default);
    color: var(--jse-editor-foreground);
    outline: none;
}

.jadscript-search-list {
    max-height: 220px;
    overflow-y: auto;
}

.jadscript-search-item {
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    align-items: baseline;
}

.jadscript-search-item:hover {
    background: var(--jse-active-line);
}

.jadscript-search-item.selected {
    background: var(--jse-active-line);
}

.jadscript-search-item-name {
    color: var(--jse-syntax-function-name);
    font-weight: 600;
}

.jadscript-search-item-doc {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Completion / hover tooltips */
.cm-tooltip {
    background: var(--jse-overlay-surface);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    color: var(--jse-editor-foreground);
    max-width: 360px;
}

.cm-tooltip-autocomplete {
    padding: 4px 0;
}

.cm-tooltip-autocomplete ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cm-tooltip-autocomplete li {
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-tooltip-autocomplete li[aria-selected="true"] {
    background: var(--accent-primary);
    color: var(--jse-accent-foreground);
}

.cm-completionLabel {
    font-weight: 500;
}

.cm-completionDetail {
    color: var(--text-secondary);
    font-style: italic;
    margin-left: auto;
}

.cm-completionInfo {
    padding: 8px 10px;
    border-top: 1px solid var(--border-default);
    font-size: 12px;
    color: var(--jse-completion-text);
}

.jadscript-cm6-hover {
    padding: 8px 10px;
    font-size: 12px;
}

.jadscript-cm6-hover-title {
    font-weight: 600;
    color: var(--jse-syntax-function);
    margin-bottom: 4px;
}

.jadscript-cm6-hover-body {
    color: var(--jse-editor-foreground);
    margin-bottom: 6px;
    white-space: pre-wrap;
}

.jadscript-cm6-hover-example {
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    padding: 4px 6px;
    margin: 6px 0;
    font-family: 'Fira Code', Consolas, monospace;
    font-size: 11px;
    color: var(--jse-syntax-string);
}

.jadscript-cm6-hover-return {
    color: var(--jse-syntax-variable);
    font-style: italic;
}

.jadscript-cm6-signature {
    padding: 6px 10px;
    font-size: 12px;
    font-family: 'Fira Code', Consolas, monospace;
}

/* Ctrl/Cmd+click documentation overlay */
.jadscript-doc-overlay {
    position: fixed;
    z-index: 9999;
    top: 96px;
    right: 28px;
    width: min(460px, calc(100vw - 56px));
    max-height: 70vh;
    overflow-y: auto;
    background: var(--jse-overlay-surface);
    border: 1px solid var(--jse-overlay-border);
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
    padding: 12px 14px;
    font-size: 12px;
    color: var(--jse-editor-foreground);
    font-family: 'Segoe UI', sans-serif;
}

.jadscript-doc-overlay-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--jse-syntax-function);
    margin-bottom: 6px;
    font-family: 'Fira Code', Consolas, monospace;
}

.jadscript-doc-overlay-body {
    white-space: pre-wrap;
    margin-bottom: 8px;
}

.jadscript-doc-overlay-example {
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    padding: 6px 8px;
    margin: 0 0 8px;
    font-family: 'Fira Code', Consolas, monospace;
    font-size: 11px;
    color: var(--jse-syntax-string);
    white-space: pre-wrap;
}

.jadscript-doc-overlay-return {
    color: var(--jse-syntax-variable);
    font-style: italic;
    margin-bottom: 8px;
}

.jadscript-doc-overlay-close {
    display: block;
    margin-left: auto;
    background: var(--jse-close-surface);
    color: var(--jse-editor-foreground);
    border: 1px solid var(--jse-close-border);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 11px;
    cursor: pointer;
}

.jadscript-doc-overlay-close:hover {
    background: var(--jse-close-border);
}

/* Breakpoint gutter */
.jadscript-breakpoint-gutter {
    color: var(--jse-error);
    font-size: 12px;
    text-align: center;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

/* Lint panel */
.cm-panel-lint ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cm-panel-lint li {
    padding: 4px 8px;
    font-size: 12px;
}

.cm-panel-lint li[aria-selected] {
    background: var(--jse-selection);
}

/* Inputs sidebar (which edits the script's input() defaults) is collapsible via the ⚙
   toggle: code gets the full width when collapsed, and the defaults stay editable on
   phones too (collapsed by default there). */
.editor-pane.show-inputs {
    grid-template-columns: 140px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas: "sidebar code" "help help";
}

.editor-pane.show-inputs .editor-sidebar {
    display: flex;
}

.editor-pane:not(.show-inputs) {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas: "code" "help";
}

.editor-pane:not(.show-inputs) .editor-sidebar {
    display: none;
}

/* === Phone: icon-only toolbar === */
@
@media (max-width: 767px), (pointer: coarse) and (hover: none) and (max-height: 767px) {
    .editor-title,
    .toolbar-shortcuts {
        display: none;
    }

    /* Icon-only action buttons (labels hidden), kept on one scrollable row. */
    .btn-label {
        display: none;
    }

    .editor-toolbar {
        gap: 4px;
        padding: 6px 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .editor-toolbar::-webkit-scrollbar {
        display: none;
    }

    .editor-toolbar button {
        padding: 8px 9px;
        font-size: 15px;
        line-height: 1;
        white-space: nowrap;
    }
}

/* === Pine → JadScript importer === */
.pine-importer {
    border-bottom: 1px solid var(--border-default);
    background: var(--surface-secondary);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.pine-importer-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pine-importer-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

.pine-importer-hint {
    flex: 1;
    font-size: 11px;
    color: var(--text-muted);
}

.pine-importer-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pine-source {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    padding: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    box-sizing: border-box;
}

.pine-source:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.pine-importer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pine-result {
    margin: 0;
    padding: 8px 10px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    color: var(--jse-editor-foreground);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* === Smart Inspector (roadmap #52) === */
.output-pane.inspector-open {
    max-height: 46%;
    min-height: 0;
}

.js-inspector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 12px 12px;
}

.js-inspector-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.js-inspector-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.js-inspector-empty-hint {
    font-size: 10px;
    color: var(--text-muted);
}

.js-inspector-placeholder {
    padding: 12px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
}

.js-inspector-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.js-inspector-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.js-inspector-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.js-inspector-none {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 0;
}

.js-inspector-variable {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    text-align: left;
    cursor: pointer;
}

.js-inspector-variable:hover {
    background: var(--surface-tertiary);
}

.js-inspector-variable.selected {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.js-inspector-name {
    font-weight: 600;
}

.js-inspector-value {
    color: var(--text-primary);
}

.js-inspector-trend {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
}

.js-inspector-note {
    font-size: 10px;
    color: var(--text-muted);
}

.js-inspector-sample {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.js-inspector-sample-offset {
    color: var(--text-muted);
}

.js-inspector-sample-value {
    margin-left: auto;
    color: var(--text-primary);
}

.js-inspector-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.js-inspector-action {
    padding: 3px 8px;
    background: var(--surface-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
}

.js-inspector-action:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.js-inspector-trace {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
    width: 100%;
}

.js-inspector-trace:hover {
    background: var(--surface-tertiary);
}

/* === Live coding modes (roadmap #56) === */
.js-live-mode {
    display: flex;
    border: 1px solid var(--border-default);
    border-radius: 3px;
    overflow: hidden;
}

.js-live-btn {
    padding: 4px 8px;
    background: var(--surface-tertiary);
    border: none;
    border-right: 1px solid var(--border-default);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.js-live-btn:last-child {
    border-right: none;
}

.js-live-btn.active {
    background: var(--accent-primary);
    color: var(--text-primary);
}

.perf-line {
    margin-left: auto;
    color: var(--accent-primary);
    font-size: 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
}

/* === AI assistant (roadmap #57) === */
.js-assistant {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px 12px;
}

.js-assistant-status {
    font-size: 11px;
    color: var(--accent-primary);
}

.js-assistant-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.js-assistant-response {
    margin: 0;
    padding: 8px 10px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    color: var(--jse-editor-foreground);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.js-assistant-error {
    font-size: 11px;
    color: var(--jse-error);
}

/* === Adaptive focus mode (roadmap #59) === */
.jadscript-editor.focus-mode .output-pane,
.jadscript-editor.focus-mode .editor-sidebar,
.jadscript-editor.focus-mode .editor-help {
    display: none;
}

/* === Breakpoint gutter (roadmap #66) === */
.jadscript-breakpoints-gutter {
    width: 18px;
    cursor: pointer;
}

.jadscript-break-dot {
    color: var(--jse-break-dot);
    font-size: 11px;
    padding-left: 5px;
}

.jadscript-break-dot.conditional {
    color: var(--jse-warning);
}

/* === Problems panel (roadmap #62) === */
.js-problems-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 4px 12px 6px;
    border-bottom: 1px solid var(--border-subtle);
}

.js-problem-line {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: transparent;
    border: none;
    color: inherit;
    text-align: left;
    cursor: pointer;
    padding: 0;
}

.js-problem-line:hover .diag-message {
    text-decoration: underline;
}

/* === Profiler + Logger (roadmap #60 + #61) === */
.js-devtools {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 12px 12px;
}

.js-profile-row,
.js-log-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 6px;
    font-size: 11px;
}

.js-profile-name,
.js-log-message {
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
}

.js-profile-time,
.js-profile-note,
.js-log-field {
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: nowrap;
}

.js-log-field {
    margin-left: auto;
}

.js-log-badge {
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
}

.js-log-badge.debug {
    color: var(--text-muted);
    border: 1px solid var(--border-default);
}

.js-log-badge.info {
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.js-log-badge.warn {
    color: var(--jse-warning);
    border: 1px solid var(--jse-warning);
}

.js-log-badge.error,
.js-log-badge.critical {
    color: var(--jse-error);
    border: 1px solid var(--jse-error);
}

.js-inspector-trace-status {
    width: 14px;
    text-align: center;
}

.js-inspector-trace-time {
    margin-left: auto;
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', monospace;
}

.js-inspector-trace-line {
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', monospace;
}

/* === Object Navigator (roadmap #53) === */
.js-navigator {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 12px 12px;
    overflow-y: auto;
}

.js-nav-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 2px;
    flex-wrap: wrap;
}

.js-nav-meta-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.js-nav-badge {
    padding: 1px 6px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.js-nav-meta-note {
    font-size: 10px;
    color: var(--text-muted);
}

.js-nav-plot,
.js-nav-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.js-nav-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid var(--border-default);
    flex-shrink: 0;
}

.js-nav-plot-title {
    color: var(--text-primary);
}

.js-nav-plot-note,
.js-nav-input-kind {
    color: var(--text-muted);
    font-size: 10px;
}

.js-nav-eye {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 0 2px;
}

.js-nav-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    text-align: left;
    cursor: pointer;
    width: 100%;
}

.js-nav-input:hover {
    background: var(--surface-tertiary);
}

.js-nav-input-name {
    color: var(--text-primary);
    font-weight: 600;
}

.js-nav-input-value {
    margin-left: auto;
    color: var(--accent-primary);
}
