/* ============================================
   VisuAlg Web IDE - Estilos
   Tema: Tokyo Night (Storm / Day)
   ============================================ */

/* === Fonts === */
@font-face {
    font-family: 'Meslo LG';
    src: url('../fonts/MesloLGS-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Meslo LG';
    src: url('../fonts/MesloLGS-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Fira Code';
    src: url('../fonts/FiraCode-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Fira Code';
    src: url('../fonts/FiraCode-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* === Theme Variables === */
:root,
[data-theme="dark"] {
    /* Tokyo Night Storm */
    --bg:            #24283b;
    --bg-dark:       #1f2335;
    --bg-darker:     #1b1e2d;
    --bg-highlight:  #292e42;
    --bg-visual:     #2e3c64;
    --fg:            #c0caf5;
    --fg-dark:       #a9b1d6;
    --fg-gutter:     #3b4261;
    --comment:       #6b7394;
    --dark3:         #545c7e;
    --dark5:         #8891b5;
    --border:        #292e42;
    --blue:          #7aa2f7;
    --cyan:          #7dcfff;
    --green:         #9ece6a;
    --green1:        #73daca;
    --yellow:        #e0af68;
    --orange:        #ff9e64;
    --red:           #f7768e;
    --magenta:       #bb9af7;
    --purple:        #9d7cd8;
    --teal:          #1abc9c;
    --blue5:         #89ddff;
    --panel-header-bg: #303447;
    --panel-header-fg: #bbc0d9;

    /* Syntax highlight */
    --syn-keyword:   #bb9af7;
    --syn-type:      #2ac3de;
    --syn-string:    #9ece6a;
    --syn-number:    #ff9e64;
    --syn-comment:   #6b7394;
    --syn-operator:  #89ddff;
    --syn-builtin:   #7aa2f7;
    --syn-atom:      #ff9e64;
    --syn-variable:  #c0caf5;
}

[data-theme="light"] {
    /* Tokyo Night Day (contraste melhorado) */
    --bg:            #e1e2e7;
    --bg-dark:       #d0d5e3;
    --bg-darker:     #c4c8da;
    --bg-highlight:  #d2d4dd;
    --bg-visual:     #b7c1e3;
    --fg:            #1e3a5f;
    --fg-dark:       #4e5f99;
    --fg-gutter:     #8890b5;
    --comment:       #6b739e;
    --dark3:         #7880a3;
    --dark5:         #505882;
    --border:        #c4c8da;
    --blue:          #2e7de9;
    --cyan:          #007197;
    --green:         #4a6530;
    --green1:        #2b5a52;
    --yellow:        #7a5c30;
    --orange:        #d97a00;
    --red:           #e02050;
    --magenta:       #8740e0;
    --purple:        #6a3aab;
    --teal:          #0e7a65;
    --blue5:         #007197;
    --panel-header-bg: #dadeec;
    --panel-header-fg: #1f395f;

    /* Syntax highlight */
    --syn-keyword:   #8740e0;
    --syn-type:      #006080;
    --syn-string:    #4a6530;
    --syn-number:    #9a4f00;
    --syn-comment:   #6b739e;
    --syn-operator:  #006080;
    --syn-builtin:   #2567d0;
    --syn-atom:      #9a4f00;
    --syn-variable:  #1e3a5f;
}

[data-theme="high-contrast"] {
    /* Tokyo Night Day — Alto Contraste */
    --bg:            #e1e2e7;
    --bg-dark:       #d0d5e3;
    --bg-darker:     #c4c8da;
    --bg-highlight:  #d2d4dd;
    --bg-visual:     #b7c1e3;
    --fg:            #101828;
    --fg-dark:       #283050;
    --fg-gutter:     #505882;
    --comment:       #6b739e;
    --dark3:         #505882;
    --dark5:         #303860;
    --border:        #b0b4c8;
    --blue:          #0055ff;
    --cyan:          #0099cc;
    --green:         #008800;
    --green1:        #009977;
    --yellow:        #bb8800;
    --orange:        #dd6600;
    --red:           #dd1144;
    --magenta:       #9900dd;
    --purple:        #7700cc;
    --teal:          #009977;
    --blue5:         #0099cc;
    --panel-header-bg: #dadeec;
    --panel-header-fg: #101828;

    /* Syntax highlight */
    --syn-keyword:   #9900dd;
    /*--syn-type:      #0099cc;*/
    --syn-type:      #0e91bd;
    --syn-string:    #008800;
    --syn-number:    #dd6600;
    --syn-comment:   #6b739e;
    --syn-operator:  #0055ff;
    --syn-builtin:   #0066ee;
    --syn-atom:      #dd6600;
    --syn-variable:  #101828;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg-darker);
    color: var(--fg);
    min-height: 100vh;
}

/* === Header / Toolbar === */
.header {
    height: 44px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.logo-icon {
    color: var(--blue);
    font-size: 18px;
}

.logo-text {
    color: var(--fg);
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
}

.logo-text small {
    color: #818ab2;
    font-weight: 400;
    font-size: 14px;
}

.beta-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--blue);
    background-color: var(--bg-highlight);
    border: 1px solid var(--blue);
    border-radius: 12px;
    vertical-align: middle;
    line-height: 1.4;
    cursor: pointer;
}

.beta-tag:hover {
    opacity: 0.85;
}

/* Changelog Modal */
.changelog-modal {
    max-width: 420px;
    width: 90%;
}

.changelog-section {
    margin-bottom: 16px;
}

.changelog-section:last-child {
    margin-bottom: 0;
}

.changelog-version {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--blue);
    background: var(--bg-highlight);
    border: 1px solid var(--blue);
    border-radius: 10px;
    margin-bottom: 8px;
}

.changelog-version.upcoming {
    color: var(--orange);
    border-color: var(--orange);
}

.changelog-list {
    margin: 0;
    padding-left: 20px;
    color: var(--fg-dark);
    font-size: 13px;
    line-height: 1.7;
}

.changelog-list li {
    margin-bottom: 2px;
}

.changelog-list li.changelog-item-old {
    margin-bottom: 5px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
    min-width: 0;
    overflow: visible;
}

.controls-exec,
.controls-file {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Hamburger menu - hidden on desktop */
.toolbar-btn.btn-menu {
    display: none;
}

.mobile-menu {
    display: none;
}

.toolbar-btn {
    background: var(--bg-highlight);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn svg {
    width: 14px;
    height: 14px;
    transition: background 0.15s;
}

.toolbar-btn:hover:not(:disabled) {
    background: var(--bg-visual);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-run {
    color: var(--green);
}

.btn-stop {
    color: var(--red);
}

.btn-step {
    color: var(--blue);
}

.btn-theme {
    color: var(--orange);
    font-size: 14px;
    padding: 4px 8px;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
    flex-shrink: 0;
}

/* === Button Group / Dropdown === */
.btn-group {
    display: inline-flex;
    position: relative;
}

.btn-group .toolbar-btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.btn-dropdown {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 4px 6px;
}

.btn-dropdown svg {
    width: 12px;
    height: 12px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 140px;
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    color: var(--fg);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--bg-highlight);
}

/* === Footer / Status Bar === */
.footer {
    height: 30px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin: 15px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    gap: 16px;
}

.footer-item {
    font-size: 12px;
    color: var(--dark5);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.footer-icon {
    width: 13px;
    height: 13px;
}

.footer-item#compiler-status {
    color: var(--green);
    font-weight: 500;
}

.footer-version {
    cursor: pointer;
    transition: color 0.15s;
}

.footer-version:hover {
    color: var(--blue);
}

/* === Tab Bar === */
.tab-bar {
    background-color: var(--panel-header-bg);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px;
    border-radius: 8px 8px 0 0;
    /* margin-bottom: 6px; */
    min-height: 28px;
    flex-shrink: 0;
}

.tab-list {
    display: flex;
    gap: 1px;
    /* gap: 6px; */
    overflow-x: auto;
    flex: 0 1 auto;
    min-width: 0;
    scrollbar-width: none;
}

.tab-list::-webkit-scrollbar {
    display: none;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    /*background: var(--bg-dark);*/
    border-radius: 8px;
    font-size: 12px;
    color: var(--comment);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.tab-item:hover {
    color: var(--fg-dark);
    background: var(--bg-highlight);
}

.tab-item.active {
    background: var(--bg);
    color: var(--fg);
    border-color: var(--border);
}

.tab-item.dragging {
    opacity: 0.4;
}

.tab-item.drag-over-left {
    box-shadow: -2px 0 0 0 var(--blue);
}

.tab-item.drag-over-right {
    box-shadow: 2px 0 0 0 var(--blue);
}

.tab-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0;
    opacity: 0.4;
    transition: opacity 0.15s;
    line-height: 1;
}

.tab-close:hover {
    opacity: 1;
    color: var(--red);
}

.tab-close svg {
    width: 12px;
    height: 12px;
}

.tab-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-dark);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--comment);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.tab-add:hover {
    background: var(--bg-highlight);
    color: var(--fg);
}

.tab-bar-indent {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    height: 28px;
    padding: 0 8px;
    background: var(--bg-dark);
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--comment);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.tab-bar-indent:hover {
    background: var(--bg-highlight);
    color: var(--fg);
}

.tab-bar-indent svg {
    width: 14px;
    height: 14px;
}

/* === Main Content === */
.main-content {
    padding: 80px 15px 55px 15px;
    /* padding: 90px 15px 75px 15px; */
    min-height: 100vh;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    /*height: calc(100vh - 165px);*/
    height: calc(100vh - 145px);

}

/* === Panels === */
.editor-panel,
.variables-panel,
.terminal-panel {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

/* Editor Column (tabs + editor) */
.editor-column {
    grid-row: 1 / -1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    min-width: 200px;
}

/* Editor Panel */
.editor-panel {
    background: var(--bg);
    flex: 1;
    min-height: 0;
    border-radius: 0 0 8px 8px;
}

#codemirror-host {
    height: 100%;
    width: 100%;
}

#codemirror-host .CodeMirror {
    height: 100%;
    font-size: 14px;
    font-family: Menlo, 'Meslo LG', 'Fira Code', Monaco, 'Courier New', monospace;
}

.CodeMirror-scroll{
    padding-top: 2px;
}

/* Variables Panel */
.variables-panel {
    background: var(--bg);
    display: flex;
    flex-direction: column;
    width: 350px;
    min-width: 150px;
    min-height: 240px;
}

/* Terminal Panel */
.terminal-panel {
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    width: 350px;
    min-width: 150px;
    min-height: 240px;
}

/* Panel Header */
.panel-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    background: var(--panel-header-bg);
    color: var(--panel-header-fg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header-btn {
    background: none;
    border: none;
    color: var(--panel-header-fg);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    opacity: 0.6;
}

.panel-header-btn:hover:not(:disabled) {
    opacity: 1;
}

.panel-header-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.panel-header-btn svg {
    width: 14px;
    height: 14px;
}

/* Panel Body */
.panel-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* === Variables Table === */
#variables-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: Menlo, 'Meslo LG', 'Fira Code', Monaco, 'Courier New', monospace;
}

#variables-table thead {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}

#variables-table th {
    text-align: left;
    padding: 4px 8px;
    color: var(--comment);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
}

#variables-table td {
    padding: 3px 8px;
    border-bottom: 1px solid var(--bg-highlight);
    color: var(--fg);
}

#variables-table tr:hover td {
    background: var(--bg-highlight);
}

#variables-table td:first-child {
    color: var(--blue);
}

/* Cor do tipo - igual ao editor */
#variables-table td.var-type {
    color: var(--syn-type);
}

/* Cores dos valores por tipo - igual ao editor */
#variables-table td.var-value-inteiro,
#variables-table td.var-value-real {
    color: var(--syn-number);
}

#variables-table td.var-value-caractere {
    color: var(--syn-string);
}

#variables-table td.var-value-logico {
    color: var(--syn-atom);
}

.var-changed td {
    animation: var-flash 0.5s ease;
}

@keyframes var-flash {
    0% { background: rgba(158, 206, 106, 0.15); }
    100% { background: transparent; }
}

/* === Terminal === */
#terminal-output {
    padding: 6px 10px;
    font-family: Menlo, 'Meslo LG', 'Fira Code', Monaco, 'Courier New', monospace;
    font-size: 13px;
    color: var(--green1);
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 100%;
}

#terminal-input-area {
    display: flex;
    padding: 4px 8px;
    gap: 4px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
    flex-shrink: 0;
}

#terminal-input-area.hidden {
    display: none;
}

#terminal-input {
    flex: 1;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-family: Menlo, 'Meslo LG', 'Fira Code', Monaco, 'Courier New', monospace;
    font-size: 13px;
    outline: none;
    border-radius: 3px;
}

#terminal-input:focus {
    border-color: var(--blue);
}

#terminal-input-ok {
    background: var(--bg-highlight);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 12px;
}

#terminal-input-ok:hover {
    background: var(--bg-visual);
}

/* === Resize Handles === */
.resize-handle-horizontal {
    position: absolute;
    top: 0;
    right: -10px;
    width: 20px;
    height: 100%;
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.resize-handle-horizontal::before {
    content: '';
    width: 6px;
    height: 50px;
    background: repeating-linear-gradient(
        to right,
        var(--dark3) 0px,
        var(--dark3) 2px,
        transparent 2px,
        transparent 4px
    );
    border-radius: 3px;
    transition: background 0.2s;
}

.resize-handle-horizontal:hover::before,
.resize-handle-horizontal.dragging::before {
    background: repeating-linear-gradient(
        to right,
        var(--blue) 0px,
        var(--blue) 2px,
        transparent 2px,
        transparent 4px
    );
}

.resize-handle-vertical {
    display: none;
}

body.resizing {
    user-select: none;
    -webkit-user-select: none;
}

/* === Scrollbar Styling === */
.panel-body::-webkit-scrollbar,
#terminal-output::-webkit-scrollbar {
    width: 8px;
}

.panel-body::-webkit-scrollbar-track,
#terminal-output::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb,
#terminal-output::-webkit-scrollbar-thumb {
    background: var(--bg-highlight);
    border-radius: 4px;
}

.panel-body::-webkit-scrollbar-thumb:hover,
#terminal-output::-webkit-scrollbar-thumb:hover {
    background: var(--dark3);
}

/* === CodeMirror Tokyo Night Theme === */
.cm-s-tokyonight.CodeMirror {
    background: var(--bg);
    color: var(--fg);
}

.cm-s-tokyonight div.CodeMirror-selected {
    background: var(--bg-visual);
}

.cm-s-tokyonight .CodeMirror-line::selection,
.cm-s-tokyonight .CodeMirror-line > span::selection,
.cm-s-tokyonight .CodeMirror-line > span > span::selection {
    background: var(--bg-visual);
}

.cm-s-tokyonight .CodeMirror-gutters {
    background: var(--bg-dark);
    border-right: 1px solid var(--border);
}

.cm-s-tokyonight .CodeMirror-linenumber {
    color: var(--fg-gutter);
}

.cm-s-tokyonight .CodeMirror-cursor {
    border-left: 2px solid var(--fg);
}

.cm-s-tokyonight .CodeMirror-activeline-background {
    background: var(--bg-highlight);
}

[data-theme="light"] .cm-s-tokyonight .CodeMirror-activeline-background,
[data-theme="high-contrast"] .cm-s-tokyonight .CodeMirror-activeline-background {
    background: #e4e7f0;
}

.cm-s-tokyonight .CodeMirror-matchingbracket {
    color: var(--fg) !important;
    background: var(--bg-visual);
    font-weight: bold;
}

.cm-s-tokyonight .CodeMirror-nonmatchingbracket {
    color: var(--red) !important;
}

/* Syntax tokens */
.cm-s-tokyonight span.cm-keyword {
    color: var(--syn-keyword);
}

.cm-s-tokyonight span.cm-type {
    color: var(--syn-type);
}

.cm-s-tokyonight span.cm-string {
    color: var(--syn-string);
}

.cm-s-tokyonight span.cm-number {
    color: var(--syn-number);
}

.cm-s-tokyonight span.cm-comment {
    color: var(--syn-comment);
    font-style: italic;
}

.cm-s-tokyonight span.cm-operator {
    color: var(--syn-operator);
}

.cm-s-tokyonight span.cm-builtin {
    color: var(--syn-builtin);
}

.cm-s-tokyonight span.cm-atom {
    color: var(--syn-atom);
}

.cm-s-tokyonight span.cm-variable-2 {
    color: var(--syn-variable);
}

/* Line highlight for step debug */
.cm-highlight-line {
    background: var(--bg-visual) !important;
}

/* === Settings Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
}

.modal-header button {
    background: none;
    border: none;
    color: var(--comment);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    display: flex;
    align-items: center;
}

.modal-header button svg {
    width: 18px;
    height: 18px;
}

.modal-header button:hover {
    color: var(--fg);
}

.modal-body {
    padding: 16px 16px 32px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-body p {
    font-size: 13px;
    color: var(--fg-dark);
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.modal-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}

.modal-btn-secondary {
    background: var(--bg-highlight);
    color: var(--fg);
}

.modal-btn-secondary:hover {
    background: var(--border);
}

.modal-btn-danger {
    background: var(--red);
    color: #fff;
}

.modal-btn-danger:hover {
    opacity: 0.85;
}

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    gap: 0;
}

.modal-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--comment);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.modal-tab:hover {
    color: var(--fg);
}

.modal-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.modal-tab-panel {
    display: none;
    flex-direction: column;
    gap: 18px;
}

.modal-tab-panel.active {
    display: flex;
}

/* Docs modal */
.docs-modal {
    width: 720px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.docs-modal .modal-tabs {
    flex-wrap: wrap;
}

.docs-modal .modal-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.docs-body .modal-tab-panel {
    gap: 0;
}

.docs-body h1 {
    font-size: 20px;
    color: var(--fg);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.docs-body h2 {
    font-size: 16px;
    color: var(--fg);
    margin: 20px 0 8px 0;
}

.docs-body h3 {
    font-size: 14px;
    color: var(--fg-dark);
    margin: 16px 0 6px 0;
}

.docs-body p {
    font-size: 13px;
    color: var(--fg-dark);
    line-height: 1.6;
    margin: 6px 0;
}

.docs-body code {
    background: var(--bg-highlight);
    color: var(--blue5);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

.docs-body pre {
    position: relative;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.docs-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    color: var(--comment);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.docs-copy-btn:hover {
    color: var(--fg);
}

.docs-copy-btn svg {
    width: 14px;
    height: 14px;
}

.docs-body pre code {
    background: none;
    padding: 0;
    color: var(--fg);
    font-size: 12px;
    line-height: 1.5;
}

.docs-body ul,
.docs-body ol {
    font-size: 13px;
    color: var(--fg-dark);
    line-height: 1.6;
    padding-left: 20px;
    margin: 6px 0;
}

.docs-body li {
    margin: 3px 0;
}

.docs-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 8px 0;
}

.docs-body th {
    background: var(--bg-highlight);
    color: var(--fg);
    text-align: left;
    padding: 6px 10px;
    border: 1px solid var(--border);
    font-weight: 600;
}

.docs-body td {
    padding: 5px 10px;
    border: 1px solid var(--border);
    color: var(--fg-dark);
}

.docs-body blockquote {
    border-left: 3px solid var(--blue);
    margin: 8px 0;
    padding: 6px 12px;
    color: var(--comment);
    font-size: 13px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-group label {
    font-size: 12px;
    color: var(--comment);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.setting-group select {
    background: var(--bg-highlight);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.setting-group select:focus {
    border-color: var(--blue);
}

.font-size-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.font-size-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-font-input {
    background: var(--bg-highlight);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 64px;
    -moz-appearance: textfield;
}

.setting-font-input::-webkit-inner-spin-button,
.setting-font-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.setting-font-input:focus {
    border-color: var(--blue);
}

.font-size-unit {
    font-size: 13px;
    color: var(--comment);
}

.setting-font-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-highlight);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.setting-font-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--blue);
    border-radius: 50%;
    cursor: pointer;
}

.setting-font-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--blue);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.setting-checkboxes {
    display: flex;
    gap: 12px;
}

.setting-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--fg);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.setting-checkbox input[type="checkbox"] {
    accent-color: var(--blue);
    cursor: pointer;
}

#variables-table .col-hidden {
    display: none;
}

.setting-font-unit-select {
    background: var(--bg-highlight);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 6px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.setting-font-unit-select:focus {
    border-color: var(--blue);
}

/* === Responsive / Mobile === */
@media (max-width: 768px) {
    .header {
        margin: 10px;
        padding: 0 8px;
    }

    .header-logo {
        gap: 4px;
    }

    .logo-text {
        font-size: 16px;
    }

    .logo-text small {
        font-size: 12px;
    }

    .beta-tag {
        padding: 1px 5px;
        font-size: 9px;
        margin-left: 4px;
    }

    /* Hide file controls + separator on mobile */
    .controls-file,
    .header-controls .toolbar-separator {
        display: none;
    }

    .tab-bar-indent-label {
        display: none;
    }

    .docs-modal {
        max-height: 90vh;
    }

    .docs-modal .modal-tab {
        font-size: 11px;
        padding: 8px 6px;
    }

    .header-controls {
        gap: 2px;
    }

    .controls-exec {
        gap: 1px;
    }

    /* Icon-only for exec buttons */
    .controls-exec .toolbar-btn {
        padding: 4px 6px;
        font-size: 0;
    }

    .controls-exec .toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    /* Hide settings button (goes into mobile menu) */
    .header-actions #btn-settings {
        display: none;
    }

    .header-actions {
        gap: 2px;
    }

    /* Show hamburger */
    .toolbar-btn.btn-menu {
        display: flex;
    }

    /* Mobile menu dropdown - hidden by default, shown with .open */
    .mobile-menu.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 4px;
        background: var(--bg-dark);
        border: 1px solid var(--border);
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
        z-index: 200;
        min-width: 180px;
        padding: 4px 0;
    }

    .mobile-menu-item {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        background: none;
        border: none;
        color: var(--fg);
        font-size: 13px;
        font-family: inherit;
        cursor: pointer;
        text-align: left;
    }

    .mobile-menu-item:hover {
        background: var(--bg-highlight);
    }

    .mobile-menu-item svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .footer {
        height: auto;
        min-height: 30px;
        margin: 10px;
        flex-wrap: wrap;
        padding: 6px 12px;
        gap: 4px 16px;
    }

    .main-content {
        padding: 70px 10px 80px 10px;
    }

    .grid-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
    }

    .editor-column {
        grid-row: auto;
    }

    .editor-panel {
        height: 350px;
        max-height: 80vh;
        overflow: auto;
    }

    .variables-panel {
        width: 100%;
        order: 3;
    }

    .terminal-panel {
        width: 100%;
        order: 2;
    }

    .resize-handle-horizontal {
        display: none;
    }

    .resize-handle-vertical {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 60px;
        height: 28px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 8px 8px 0 0;
        cursor: ns-resize;
        touch-action: none;
        z-index: 10;
    }

    .resize-handle-vertical::before {
        content: '';
        width: 30px;
        height: 12px;
        background: repeating-linear-gradient(
            to bottom,
            var(--fg-dark) 0px,
            var(--fg-dark) 2px,
            transparent 2px,
            transparent 5px
        );
        border-radius: 2px;
    }

    .resize-handle-vertical:active,
    .resize-handle-vertical.dragging {
        background: rgba(0, 0, 0, 0.5);
    }
}
