/* ================================================================
   ChocolatePy — Main Stylesheet
   A warm chocolate-brown IDE theme
   ================================================================ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    /* Chocolate palette */
    --grape:          #8B5A2B;
    --grape-dark:     #6B3F1F;
    --grape-darker:   #553218;
    --grape-deep:     #3E2412;
    --grape-light:    #A0785A;
    --grape-soft:     #C4935A;
    --grape-faint:    #F5EDE4;
    --grape-glow:     rgba(139, 90, 43, 0.07);
    --grape-hover:    rgba(139, 90, 43, 0.11);
    --grape-ring:     rgba(139, 90, 43, 0.25);

    /* Surfaces */
    --bg:             #FFFFFF;
    --bg-1:           #FFFFFF;
    --bg-2:           #F8F6FB;
    --bg-side:        #F8F6FB;
    --bg-panel:       #FBFAFD;
    --bg-title:       #4A1858;
    --bg-topbar:      #F5F2F9;
    --bg-tab:         #FFFFFF;
    --bg-tab-off:     #EFECF3;
    --bg-input:       #FFFFFF;
    --bg-hover:       #F0ECF5;
    --bg-badge:       var(--grape);

    /* Borders */
    --border:         #E5E1EC;
    --border-lt:      #EFEDF4;
    --border-focus:   var(--grape);

    /* Text */
    --text:           #2D2640;
    --text-2:         #635A74;
    --text-3:         #9B94A8;
    --text-inv:       #FFFFFF;

    /* Semantic */
    --ok:             #2ECC71;
    --ok-bg:          rgba(46, 204, 113, 0.08);
    --err:            #E74C3C;
    --err-bg:         rgba(231, 76, 60, 0.08);
    --warn:           #F39C12;
    --warn-bg:        rgba(243, 156, 18, 0.08);
    --info:           #3498DB;
    --info-bg:        rgba(52, 152, 219, 0.08);

    /* Typography */
    --ui:             'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono:           'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

    /* Radii */
    --r-xs:           3px;
    --r-sm:           5px;
    --r-md:           8px;
    --r-lg:           12px;
    --r-xl:           16px;
    --r-full:         9999px;

    /* Shadows */
    --sh-xs:          0 1px 2px rgba(74, 24, 88, 0.05);
    --sh-sm:          0 2px 6px rgba(74, 24, 88, 0.07);
    --sh-md:          0 4px 16px rgba(74, 24, 88, 0.09);
    --sh-lg:          0 8px 32px rgba(74, 24, 88, 0.11);
    --sh-xl:          0 16px 48px rgba(74, 24, 88, 0.14);

    /* Motion */
    --ease:           cubic-bezier(0.4, 0, 0.2, 1);
    --t-fast:         0.1s var(--ease);
    --t-norm:         0.18s var(--ease);
    --t-slow:         0.3s var(--ease);
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--ui);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 13px;
    line-height: 1.5;
}

button {
    font-family: var(--ui);
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
}

button:focus-visible {
    outline: 2px solid var(--grape);
    outline-offset: -2px;
    border-radius: var(--r-sm);
}

::selection {
    background: rgba(139, 90, 43, 0.2);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--grape-light);
    background-clip: content-box;
}

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

/* ── App Shell ──────────────────────────────────────────────────── */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── SVG Icon Base ──────────────────────────────────────────────── */
.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm { width: 14px; height: 14px; }
.icon-xs { width: 12px; height: 12px; }
.icon-lg { width: 18px; height: 18px; }
.icon-filled { fill: currentColor; stroke: none; }

/* ================================================================
   TITLE BAR
   ================================================================ */
.titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 34px;
    padding: 0 14px;
    background: var(--bg-title);
    color: var(--text-inv);
    font-size: 12px;
    font-weight: 500;
    user-select: none;
    flex-shrink: 0;
}

.tb-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tb-logo {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.tb-logo .icon {
    width: 13px;
    height: 13px;
    stroke: var(--text-inv);
    opacity: 0.9;
}

.tb-brand {
    font-weight: 700;
    letter-spacing: 0.3px;
    font-size: 13px;
}

.brand-icon {
    flex-shrink: 0;
    margin-right: 6px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.tb-brand span {
    font-weight: 400;
    opacity: 0.6;
    font-size: 11px;
    margin-left: 2px;
}

.tb-center {
    font-size: 11px;
    opacity: 0.65;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 12px;
    border-radius: var(--r-full);
}

.tb-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.st-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #888;
    transition: all var(--t-norm);
}

.st-dot.ready {
    background: var(--ok);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.st-dot.loading {
    background: var(--warn);
    animation: pulse 1.4s infinite;
}

.st-dot.error {
    background: var(--err);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.4);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.st-label {
    font-size: 11px;
    opacity: 0.8;
}

/* ================================================================
   TOP NAVIGATION BAR
   ================================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 8px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.top-l, .top-r {
    display: flex;
    align-items: center;
    gap: 2px;
}

.tb-txt {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
    white-space: nowrap;
    letter-spacing: 0.01em;
    background: none;
    border: none;
    font-family: inherit;
}

.tb-txt:hover {
    background: var(--grape-hover);
    color: var(--grape);
}

.tb-div {
    width: 1px;
    height: 16px;
    background: var(--border);
    margin: 0 4px;
    opacity: 0.4;
}

.dd-font-display {
    font-size: 10px;
    color: var(--text-3);
    cursor: default;
    pointer-events: none;
    padding: 2px 12px;
}

/* Run button */
.run-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, var(--grape) 0%, var(--grape-light) 100%);
    color: var(--text-inv) !important;
    padding: 0 20px;
    font-weight: 600;
    border-radius: var(--r-md);
    box-shadow: 0 2px 10px var(--grape-ring);
    height: 32px;
    font-size: 12px;
    letter-spacing: 0.2px;
    transition: all var(--t-norm);
}

.run-btn:hover {
    box-shadow: 0 4px 18px rgba(139, 90, 43, 0.38);
    transform: translateY(-1px);
    background: linear-gradient(135deg, var(--grape-dark) 0%, var(--grape) 100%) !important;
    color: var(--text-inv) !important;
}

.run-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px var(--grape-ring);
}

.run-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none;
}

.run-btn .icon {
    width: 12px;
    height: 12px;
}

/* ================================================================
   FILE TABS
   ================================================================ */
.tabs-bar {
    display: flex;
    align-items: flex-end;
    height: 37px;
    padding: 0 8px;
    background: var(--bg-tab-off);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    gap: 1px;
}

.tabs-bar::-webkit-scrollbar {
    height: 0;
}

.tab {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 35px;
    padding: 0 15px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg-tab-off);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
    position: relative;
    top: 1px;
}

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

.tab.active {
    background: var(--bg-tab);
    color: var(--text);
    border-color: var(--border) var(--border) transparent;
    border-top: 2px solid var(--grape);
    font-weight: 600;
}

.tab-icon {
    display: flex;
    align-items: center;
}

.tab-icon .icon {
    width: 14px;
    height: 14px;
    color: var(--grape-light);
}

.tab .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--grape-soft);
    display: none;
}

.tab.modified .dot {
    display: block;
}

.tab-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-xs);
    color: var(--text-3);
    margin-left: 4px;
    margin-right: -7px;
    opacity: 0;
    transition: all var(--t-fast);
}

.tab:hover .tab-close,
.tab.active .tab-close {
    opacity: 1;
}

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

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

.tab-add {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--text-3);
    margin-left: 6px;
    align-self: center;
    transition: all var(--t-fast);
}

.tab-add:hover {
    background: var(--grape-glow);
    color: var(--grape);
}

.tab-add .icon {
    width: 14px;
    height: 14px;
}

/* ================================================================
   WORKSPACE LAYOUT
   ================================================================ */
.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.22s var(--ease), opacity 0.22s var(--ease);
    overflow: hidden;
    z-index: 1;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

.side-hdr {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: var(--text-3);
    border-bottom: 1px solid var(--border-lt);
    display: flex;
    align-items: center;
    gap: 6px;
}

.side-hdr .icon {
    width: 13px;
    height: 13px;
    opacity: 0.5;
}

.side-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.fi {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
    border-left: 2px solid transparent;
}

.fi:hover {
    background: var(--grape-glow);
    color: var(--text);
}

.fi.active {
    background: var(--grape-hover);
    color: var(--grape);
    font-weight: 600;
    border-left-color: var(--grape);
}

.fi-icon {
    display: flex;
    align-items: center;
}

.fi-icon .icon {
    width: 14px;
    height: 14px;
    color: var(--grape-light);
}

.fi-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Center Column ───────────────────────────────────────────── */
.center-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
    position: relative;
}

.editor-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ── Resize Handles ──────────────────────────────────────────── */
.h-resize {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    transition: background var(--t-fast);
}

.h-resize::before {
    content: '';
    position: absolute;
    inset: 0 -2px;
}

.h-resize:hover,
.h-resize.active {
    background: var(--grape);
}

.v-resize {
    height: 4px;
    cursor: ns-resize;
    background: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    transition: background var(--t-fast);
}

.v-resize::before {
    content: '';
    position: absolute;
    inset: -2px 0;
}

.v-resize:hover,
.v-resize.active {
    background: var(--grape);
}

/* ── Right Panel ─────────────────────────────────────────────── */

/* ── REPL Toggle Button ───────────────────────────────────────── */
.repl-toggle {
    transition: all var(--t-fast);
    border-radius: var(--r-sm);
}
.repl-toggle.active {
    background: var(--grape) !important;
    color: #fff !important;
    box-shadow: 0 0 8px rgba(139,90,43,0.4);
}

/* ── Right Panel ─────────────────────────────────────────────── */
.right-panel {
    width: 380px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    flex-shrink: 0;
    transition: width 0.22s var(--ease);
}

.right-panel.collapsed {
    width: 0;
    border-left: none;
    overflow: hidden;
}

.p-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
}

.p-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 7px;
}

.p-title .icon {
    width: 13px;
    height: 13px;
}

.p-acts {
    display: flex;
    gap: 2px;
}

.p-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--text-3);
    transition: all var(--t-fast);
}

.p-btn:hover {
    background: var(--grape-glow);
    color: var(--grape);
}

.p-btn .icon {
    width: 13px;
    height: 13px;
}

.res-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
}

.r-line {
    padding: 1px 0;
    animation: fadeIn 0.12s ease-out;
}

.r-line.stdout { color: var(--text); }
.r-line.stderr { color: var(--err); }
.r-line.info   { color: var(--grape-light); opacity: 0.75; }
.r-line.success { color: var(--ok); font-weight: 500; }

.res-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-3);
    text-align: center;
    gap: 10px;
}

.res-welcome .icon {
    width: 32px;
    height: 32px;
    opacity: 0.25;
    stroke-width: 1.5;
}

.res-welcome p {
    font-family: var(--ui);
    font-size: 12px;
}

.res-welcome kbd {
    display: inline-block;
    font-family: var(--mono);
    font-size: 10px;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--r-xs);
    border: 1px solid var(--border);
    box-shadow: var(--sh-xs);
    line-height: 1.6;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Bottom Panel ────────────────────────────────────────────── */
.bottom-panel {
    height: 180px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.bottom-panel.collapsed {
    height: 0;
    border-top: none;
    overflow: hidden;
}

.b-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    height: 32px;
    padding: 0 8px;
    border-bottom: 1px solid var(--border-lt);
    flex-shrink: 0;
    background: var(--bg);
}

.b-tab {
    padding: 0 14px;
    height: 32px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid transparent;
    transition: all var(--t-fast);
}

.b-tab .icon {
    width: 13px;
    height: 13px;
}

.b-tab:hover {
    color: var(--text-2);
}

.b-tab.active {
    color: var(--grape);
    border-bottom-color: var(--grape);
}

.b-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.65;
    color: var(--text-2);
}

.d-line {
    padding: 2px 0;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.d-line .ts {
    color: var(--text-3);
    margin-right: 6px;
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0.7;
}

.d-line.error { color: var(--err); }
.d-line.warn  { color: var(--warn); }
.d-line.info  { color: var(--text-2); }

/* ================================================================
   CLI / TERMINAL
   ================================================================ */
.cli-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-dark, var(--bg));
    overflow: hidden;
}
.cli-output {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--text);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.cli-line {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 0;
    margin: 0;
    animation: fadeIn 0.08s ease-out;
}
.cli-echo    { color: var(--text-2); }
.cli-stdout  { color: var(--text); }
.cli-result  { color: var(--accent, var(--grape-soft)); }
.cli-error   { color: var(--err); }
.cli-success { color: var(--ok, #3fb950); }
.cli-info    { color: var(--text-2); }
.cli-muted   { color: var(--text-2); opacity: 0.65; }

.cli-input-row {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-darker, var(--bg-dark, var(--bg)));
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    gap: 4px;
}
.cli-prompt {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--grape-soft, #C4935A);
    margin-right: 6px;
    flex-shrink: 0;
    user-select: none;
}
.cli-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text);
    caret-color: var(--grape-soft, #C4935A);
    padding: 0;
    line-height: 1.5;
}
.cli-input::placeholder {
    color: var(--text-2);
    opacity: 0.4;
    font-size: 11px;
}
.cli-input:disabled {
    opacity: 0.5;
}
.cli-busy {
    font-size: 14px;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Completions panel */
.cli-completions {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg-dark, var(--bg));
    border-top: 1px solid var(--border);
}
.cli-comp-item {
    display: inline-block;
    padding: 2px 8px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.cli-comp-item:hover {
    background: var(--grape-soft);
    color: #fff;
}

/* Terminal body needs no padding since cli-container handles it */
#terminalBody {
    padding: 0 !important;
}
#terminalBody .cli-container {
    height: 100%;
}

/* ================================================================
   STATUS BAR
   ================================================================ */
.statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 26px;
    padding: 0 14px;
    background: linear-gradient(90deg, var(--grape-darker) 0%, var(--grape-deep) 100%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    flex-shrink: 0;
}

.sb-l, .sb-r {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sb-i {
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color var(--t-fast);
}

.sb-i:hover {
    color: rgba(255, 255, 255, 0.95);
}

.sb-i .icon {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

/* ================================================================
   CODEMIRROR OVERRIDES
   ================================================================ */
.CodeMirror {
    height: 100% !important;
    font-family: var(--mono) !important;
    font-size: 14px !important;
    line-height: 1.75 !important;
    background: var(--bg) !important;
    color: var(--text) !important;
    padding: 6px 0;
}

/* Prevent code text from rendering behind the minimap */
.editor-wrap .CodeMirror-scroll {
    padding-right: 105px;
}

.CodeMirror-gutters {
    background: var(--bg-side) !important;
    border-right: 1px solid var(--border) !important;
    padding-right: 8px;
}

.CodeMirror-linenumber {
    color: var(--text-3) !important;
    font-size: 11px !important;
    font-family: var(--mono) !important;
    padding: 0 8px 0 14px !important;
}

.CodeMirror-activeline-background {
    background: var(--grape-glow) !important;
}

.CodeMirror-cursor {
    border-left: 2px solid var(--grape) !important;
}

.CodeMirror-selected {
    background: rgba(139, 90, 43, 0.1) !important;
}

.CodeMirror-focused .CodeMirror-selected {
    background: rgba(139, 90, 43, 0.16) !important;
}

.CodeMirror-matchingbracket {
    color: var(--grape) !important;
    font-weight: 700 !important;
    background: rgba(139, 90, 43, 0.08) !important;
    border-bottom: 2px solid var(--grape) !important;
}

/* Syntax colors */
.cm-s-default .cm-keyword    { color: var(--grape) !important; font-weight: 600; }
.cm-s-default .cm-def        { color: #2980B9 !important; }
.cm-s-default .cm-variable   { color: var(--text) !important; }
.cm-s-default .cm-variable-2 { color: #6C3483 !important; }
.cm-s-default .cm-string     { color: #27AE60 !important; }
.cm-s-default .cm-string-2   { color: #27AE60 !important; }
.cm-s-default .cm-number     { color: #E67E22 !important; }
.cm-s-default .cm-comment    { color: var(--text-3) !important; font-style: italic; }
.cm-s-default .cm-builtin    { color: #8E44AD !important; }
.cm-s-default .cm-atom       { color: #C0392B !important; }
.cm-s-default .cm-operator   { color: var(--grape-dark) !important; }
.cm-s-default .cm-meta       { color: var(--text-3) !important; }
.cm-s-default .cm-property   { color: #2980B9 !important; }

/* Autocomplete hints */
.CodeMirror-hints {
    font-family: var(--mono) !important;
    font-size: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-md) !important;
    background: var(--bg) !important;
    box-shadow: var(--sh-lg) !important;
    padding: 4px !important;
    z-index: 100;
    max-height: 240px !important;
}

.CodeMirror-hint {
    padding: 5px 12px !important;
    border-radius: var(--r-sm) !important;
    color: var(--text-2) !important;
    transition: all var(--t-fast);
}

.CodeMirror-hint-active {
    background: var(--grape-faint) !important;
    color: var(--grape) !important;
}

.CodeMirror-vscrollbar::-webkit-scrollbar,
.CodeMirror-hscrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.CodeMirror-vscrollbar::-webkit-scrollbar-thumb,
.CodeMirror-hscrollbar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ================================================================
   LOADING OVERLAY
   ================================================================ */
.load-ov {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s var(--ease);
    gap: 16px;
}

.load-ov.hidden {
    opacity: 0;
    pointer-events: none;
}

.load-sp {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--grape);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.load-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--grape);
}

.load-sub {
    font-size: 12px;
    color: var(--text-3);
}

/* ================================================================
   COMMAND PALETTE
   ================================================================ */
.pal-ov {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42, 36, 54, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    padding-top: 80px;
}

.pal-ov.open {
    display: flex;
}

.pal-box {
    width: 500px;
    max-height: 380px;
    background: var(--bg);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl);
    overflow: hidden;
    animation: palIn 0.14s ease-out;
    border: 1px solid var(--border);
}

@keyframes palIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.pal-box input {
    width: 100%;
    padding: 14px 20px;
    border: none;
    outline: none;
    font-family: var(--ui);
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border-lt);
    background: transparent;
}

.pal-box input::placeholder {
    color: var(--text-3);
}

.pal-list {
    overflow-y: auto;
    max-height: 300px;
    padding: 4px;
}

.pal-i {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
}

.pal-i:hover,
.pal-i.active {
    background: var(--grape-faint);
    color: var(--grape);
}

.pal-i .sc {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-3);
    background: var(--bg-side);
    padding: 2px 8px;
    border-radius: var(--r-xs);
    border: 1px solid var(--border-lt);
}

/* ================================================================
   DROPDOWNS
   ================================================================ */
.dd {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--sh-lg);
    min-width: 210px;
    padding: 4px;
    z-index: 500;
    display: none;
    animation: ddIn 0.1s ease-out;
}

.dd.open {
    display: block;
}

@keyframes ddIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dd-i {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
}

.dd-i:hover {
    background: var(--grape-faint);
    color: var(--grape);
}

.dd-i .icon {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.dd-div {
    height: 1px;
    background: var(--border-lt);
    margin: 4px 0;
}

/* ================================================================
   BADGE
   ================================================================ */
.badge {
    font-size: 9px;
    font-weight: 700;
    background: var(--grape);
    color: var(--text-inv);
    padding: 0 6px;
    border-radius: var(--r-full);
    min-width: 18px;
    text-align: center;
    line-height: 17px;
    letter-spacing: 0.3px;
}

/* ================================================================
   UTILITY
   ================================================================ */
.hidden { display: none !important; }

/* ================================================================
   FIND BAR
   ================================================================ */
.find-bar {
    position: absolute;
    top: 0;
    right: 20px;
    z-index: 50;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--r-md) var(--r-md);
    box-shadow: var(--sh-md);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.find-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.find-row input {
    font-family: var(--mono);
    font-size: 12px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    width: 200px;
}

.find-row input:focus {
    border-color: var(--grape);
    box-shadow: 0 0 0 2px var(--grape-ring);
}

.find-count {
    font-size: 11px;
    color: var(--text-3);
    min-width: 60px;
    text-align: center;
}

.find-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    color: var(--text-3);
    transition: all var(--t-fast);
}

.find-btn:hover {
    background: var(--grape-glow);
    color: var(--grape);
}

.find-btn.text {
    width: auto;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ================================================================
   SPLIT EDITOR
   ================================================================ */
.editor-split-container {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.editor-split-container .editor-wrap {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.editor-split-container.split-active .editor-wrap {
    flex: 0 0 50%;
}

.split-resize {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    transition: background var(--t-fast);
}

.split-resize::before {
    content: '';
    position: absolute;
    inset: 0 -2px;
}

.split-resize:hover,
.split-resize.active {
    background: var(--grape);
}

.split-pane .CodeMirror {
    border-left: 1px solid var(--border);
}

.split-file-picker {
    position: absolute;
    top: 4px;
    left: 8px;
    z-index: 10;
    font-family: var(--ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 2px 8px;
    outline: none;
    cursor: pointer;
}

.split-file-picker:focus {
    border-color: var(--grape);
}

/* ================================================================
   MINIMAP (enhanced)
   ================================================================ */
.minimap {
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    overflow: hidden;
    opacity: 0.6;
    transition: opacity var(--t-norm);
    cursor: pointer;
    z-index: 4;
}

.minimap:hover {
    opacity: 1;
}

.minimap canvas {
    display: block;
    width: 100%;
}

.minimap-viewport {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--grape-glow);
    border: 1px solid var(--grape-ring);
    border-radius: 2px;
    pointer-events: none;
    transition: top 0.1s ease;
}

/* ================================================================
   SNIPPET MANAGER
   ================================================================ */
.snippet-modal {
    width: 720px;
    max-height: 520px;
    background: var(--bg);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl);
    overflow: hidden;
    animation: palIn 0.14s ease-out;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.snippet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.snippet-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--grape);
}

.snippet-action-btn {
    font-family: var(--ui);
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-side);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
}

.snippet-action-btn:hover {
    background: var(--grape-glow);
    color: var(--grape);
    border-color: var(--grape);
}

.snippet-action-btn.primary {
    background: var(--grape);
    color: var(--text-inv);
    border-color: var(--grape);
}

.snippet-action-btn.primary:hover {
    background: var(--grape-dark);
}

.snippet-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.snippet-sidebar {
    width: 200px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 6px 0;
    flex-shrink: 0;
}

.snippet-item {
    padding: 8px 14px;
    cursor: pointer;
    transition: all var(--t-fast);
    border-left: 2px solid transparent;
}

.snippet-item:hover {
    background: var(--grape-glow);
}

.snippet-item.active {
    background: var(--grape-hover);
    border-left-color: var(--grape);
}

.snippet-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.snippet-item-shortcut {
    font-size: 10px;
    font-family: var(--mono);
    color: var(--text-3);
    margin-top: 2px;
}

.snippet-editor {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
}

.snippet-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-3);
    font-size: 13px;
}

.snip-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    margin-top: 10px;
}

.snip-label:first-child {
    margin-top: 0;
}

.snip-input {
    width: 100%;
    font-family: var(--ui);
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
}

.snip-input:focus {
    border-color: var(--grape);
    box-shadow: 0 0 0 2px var(--grape-ring);
}

.snip-textarea {
    width: 100%;
    min-height: 120px;
    font-family: var(--mono);
    font-size: 12px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    resize: vertical;
    line-height: 1.6;
}

.snip-textarea:focus {
    border-color: var(--grape);
    box-shadow: 0 0 0 2px var(--grape-ring);
}

/* ================================================================
   VARIABLE INSPECTOR
   ================================================================ */
.var-inspector {
    position: fixed;
    bottom: 26px;
    right: 0;
    width: 400px;
    max-height: 300px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-right: none;
    border-bottom: none;
    border-radius: var(--r-lg) 0 0 0;
    box-shadow: var(--sh-lg);
    display: flex;
    flex-direction: column;
    z-index: 60;
    animation: fadeIn 0.14s ease-out;
}

.var-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.var-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--grape);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.var-body {
    flex: 1;
    overflow: auto;
    padding: 8px;
}

.var-empty {
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    padding: 30px 10px;
}

.var-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: var(--mono);
}

.var-table th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--ui);
    position: sticky;
    top: 0;
    background: var(--bg);
}

.var-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-lt);
    vertical-align: top;
}

.var-table tr:hover td {
    background: var(--grape-glow);
}

.var-name {
    font-weight: 600;
    color: var(--grape);
}

.var-type {
    font-size: 10px;
    padding: 1px 6px !important;
    border-radius: var(--r-full);
    font-family: var(--ui) !important;
    font-weight: 600;
}

.var-type-int, .var-type-float, .var-type-complex {
    color: #E67E22;
    background: rgba(230, 126, 34, 0.08);
}

.var-type-str {
    color: #27AE60;
    background: rgba(39, 174, 96, 0.08);
}

.var-type-list, .var-type-tuple, .var-type-set, .var-type-dict {
    color: #2980B9;
    background: rgba(41, 128, 185, 0.08);
}

.var-type-bool {
    color: #C0392B;
    background: rgba(192, 57, 43, 0.08);
}

.var-type-function {
    color: var(--grape);
    background: var(--grape-glow);
}

.var-value {
    color: var(--text-2);
    word-break: break-all;
    max-width: 200px;
}

/* ================================================================
   THEME EDITOR
   ================================================================ */
.theme-modal {
    width: 780px;
    max-height: 560px;
    background: var(--bg);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xl);
    overflow: hidden;
    animation: palIn 0.14s ease-out;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.theme-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.theme-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--grape);
}

.theme-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.theme-presets {
    width: 180px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 10px 0;
    flex-shrink: 0;
}

.theme-presets-title,
.theme-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-3);
    padding: 0 14px 8px;
}

.theme-preset-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-2);
    transition: all var(--t-fast);
}

.theme-preset-item:hover {
    background: var(--grape-glow);
    color: var(--grape);
}

.theme-preset-swatch {
    width: 16px;
    height: 16px;
    border-radius: var(--r-sm);
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.theme-colors {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.theme-color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.theme-color-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.theme-color-item label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.theme-color-input-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.theme-color-input {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    padding: 0;
    background: none;
}

.theme-color-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.theme-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

.theme-color-hex {
    flex: 1;
    font-family: var(--mono);
    font-size: 11px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    width: 80px;
}

.theme-color-hex:focus {
    border-color: var(--grape);
}

.theme-preview {
    width: 200px;
    border-left: 1px solid var(--border);
    padding: 14px;
    overflow-y: auto;
    flex-shrink: 0;
}

.theme-preview-box {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    font-size: 10px;
}

.tp-titlebar {
    padding: 6px 10px;
    color: var(--text-inv);
    font-weight: 700;
    font-size: 10px;
    background: var(--bg-title);
}

.tp-topbar {
    padding: 4px 10px;
    font-size: 9px;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
}

.tp-editor {
    padding: 10px;
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.6;
    min-height: 60px;
}

.tp-kw { font-weight: 700; }
.tp-fn { color: #2980B9; }
.tp-str { color: #27AE60; }

.tp-statusbar {
    padding: 3px 10px;
    color: var(--text-inv);
    font-size: 9px;
    background: var(--bg-title);
}

/* Modal overlay shared for snippets, themes, shortcuts, history */
#snippetOv, #themeOv {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42, 36, 54, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}

#snippetOv.open, #themeOv.open {
    display: flex;
}

/* Generic modal-ov open state (shortcuts, history, go-to-line, about, etc.) */
.modal-ov.open {
    display: flex;
}

/* ================================================================
   RENAME INPUT
   ================================================================ */
.rename-input {
    font-family: var(--ui);
    font-size: 12px;
    padding: 1px 6px;
    border: 1px solid var(--grape);
    border-radius: var(--r-xs);
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    width: 100%;
    box-shadow: 0 0 0 2px var(--grape-ring);
}

/* ================================================================
   GO TO LINE MODAL
   ================================================================ */
.modal-ov {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42, 36, 54, 0.45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--sh-xl);
    width: 300px;
}

.modal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--grape);
    margin-bottom: 12px;
}

.modal-box input {
    width: 100%;
    padding: 8px 12px;
    font-family: var(--mono);
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    outline: none;
    background: var(--bg-input);
    color: var(--text);
}

.modal-box input:focus {
    border-color: var(--grape);
    box-shadow: 0 0 0 2px var(--grape-ring);
}

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

.modal-btn {
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg-side);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--t-fast);
}

.modal-btn:hover {
    background: var(--grape-glow);
    color: var(--grape);
}

.modal-btn.primary {
    background: var(--grape);
    color: var(--text-inv);
    border-color: var(--grape);
}

.modal-btn.primary:hover {
    background: var(--grape-dark);
}

/* ================================================================
   DRAG/DROP FILE LIST
   ================================================================ */
.fi.dragging { opacity: 0.4; }
.fi.drag-over { border-top: 2px solid var(--grape); }

/* ================================================================
   DRAG/DROP TABS
   ================================================================ */
.tab.tab-dragging {
    opacity: 0.4;
    border: 1px dashed var(--grape);
}

.tab.tab-drag-over {
    border-left: 3px solid var(--grape) !important;
}

/* ================================================================
   JUMP TO ERROR LINE
   ================================================================ */
.clickable-error {
    cursor: pointer !important;
    position: relative;
    padding-left: 14px !important;
}

.clickable-error::before {
    content: '\27A4';
    position: absolute;
    left: 0;
    top: 2px;
    font-size: 10px;
    color: var(--err);
    opacity: 0.6;
}

.clickable-error:hover {
    background: var(--err-bg);
    border-radius: var(--r-xs);
}

.error-line-highlight {
    background: rgba(231, 76, 60, 0.15) !important;
    border-bottom: 2px solid var(--err) !important;
    animation: errorPulse 0.5s ease-out;
}

.error-line-gutter {
    background: rgba(231, 76, 60, 0.08) !important;
}

.error-line-gutter .CodeMirror-linenumber {
    color: var(--err) !important;
    font-weight: 700 !important;
}

@keyframes errorPulse {
    0% { background: rgba(231, 76, 60, 0.35); }
    100% { background: rgba(231, 76, 60, 0.15); }
}

/* ================================================================
   COPY OUTPUT FLASH
   ================================================================ */
.copy-flash {
    background: var(--ok-bg) !important;
    color: var(--ok) !important;
    animation: copyBounce 0.4s ease-out;
}

@keyframes copyBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ================================================================
   PARAMETER HINT TOOLTIP
   ================================================================ */
.param-hint {
    position: fixed;
    z-index: 200;
    background: var(--bg);
    color: var(--grape);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-md);
    white-space: nowrap;
    pointer-events: none;
    animation: fadeIn 0.1s ease-out;
}

/* ================================================================
   AUTOCOMPLETE HINT ENHANCED
   ================================================================ */
.CodeMirror-hint {
    padding: 5px 12px !important;
    border-radius: var(--r-sm) !important;
    color: var(--text-2) !important;
    transition: all var(--t-fast);
    font-size: 11px !important;
    line-height: 1.5 !important;
    max-width: 450px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .sidebar { width: 180px; }
    .right-panel { width: 280px; }
    .var-inspector { width: 300px; }
    .snippet-modal { width: 90vw; }
    .theme-modal { width: 95vw; }
    .theme-preview { display: none; }
}

/* ── Tablet (768px and below) ──────────────────────────────── */
@media (max-width: 768px) {
    /* Topbar: hide text labels, icon-only buttons */
    .tb-txt {
        padding: 2px 5px;
        font-size: 10px;
    }
    .tb-div { margin: 0 2px; }
    .run-btn { padding: 0 10px; font-size: 12px; }

    /* Sidebar: overlay drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 900;
        width: 260px !important;
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
    }
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        width: 260px !important;
        opacity: 1;
        pointer-events: auto;
        transform: translateX(-100%);
        border-right: none;
    }
    .mobile-sidebar-backdrop {
        display: none;
    }

    /* Right output panel: full-width bottom drawer */
    .right-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: 45vh;
        z-index: 800;
        border-left: none;
        border-top: 2px solid var(--grape);
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
        transition: transform .25s var(--ease);
    }
    .right-panel:not(.collapsed) {
        transform: translateY(0);
    }
    .right-panel.collapsed {
        width: 100% !important;
        transform: translateY(100%);
    }

    /* Var inspector: full width bottom */
    .var-inspector {
        width: 100% !important;
        max-width: none;
        right: 0;
        left: 0;
        height: 40vh;
        bottom: 0;
        top: auto;
        border-radius: 12px 12px 0 0;
    }

    /* Modals: full screen on tablet */
    .snippet-modal, .theme-modal, .shortcuts-modal,
    .about-modal, .welcome-modal, .welcome-card {
        width: 95vw !important;
        max-width: none !important;
        max-height: 85vh;
    }

    /* Bottom panel: shorter */
    .bottom-panel { height: 120px; }

    /* Resize handles: hide on mobile (no mouse dragging) */
    .h-resize { display: none; }
    .v-resize { display: none; }

    /* Editor: remove minimap padding */
    .editor-wrap .CodeMirror-scroll { padding-right: 0 !important; }

    /* Split editor: stack vertically */
    .editor-split-container.split-active {
        flex-direction: column !important;
    }
    .split-resize {
        width: 100% !important;
        height: 8px !important;
        cursor: row-resize !important;
    }

    /* Minimap: hide on tablet */
    .minimap { display: none !important; }

    /* Breadcrumbs: scrollable */
    .breadcrumb-bar { overflow-x: auto; flex-wrap: nowrap; }

    /* Status bar: wrap better */
    .statusbar { padding: 0 8px; font-size: 10px; }
    .sb-l, .sb-r { gap: 8px; }
}

/* ── Phone (480px and below) ───────────────────────────────── */
@media (max-width: 480px) {
    /* Titlebar: compact */
    .titlebar { height: 32px; padding: 0 8px; font-size: 11px; }
    .titlebar .icon { width: 13px; height: 13px; }

    /* Topbar: scrollable, narrower */
    .topbar {
        height: 40px;
        padding: 0 4px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .topbar::-webkit-scrollbar { display: none; }
    .top-l { flex-shrink: 0; }
    .top-r { flex-shrink: 0; }
    .tb-txt { padding: 2px 4px; font-size: 9.5px; }
    .tb-div { display: none; }
    .run-btn { padding: 0 8px; height: 28px; font-size: 11px; border-radius: 6px; }

    /* Tabs bar: scrollable */
    .tabs-bar {
        overflow-x: auto;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
    }
    .tabs-bar::-webkit-scrollbar { display: none; }
    .tab { min-width: 80px; max-width: 120px; font-size: 11px; padding: 0 8px; }

    /* Sidebar drawer: full-width on phone */
    .sidebar {
        width: 100vw !important;
    }
    .sidebar.collapsed {
        width: 100vw !important;
    }

    /* Right panel: taller on phone */
    .right-panel {
        height: 55vh;
        width: 100% !important;
    }
    .right-panel.collapsed {
        width: 100% !important;
    }

    /* Bottom panel: minimal */
    .bottom-panel { height: 100px; }
    .b-tab { padding: 0 8px; font-size: 10px; }

    /* Editor: tighter padding, no minimap gap */
    .CodeMirror { font-size: 13px !important; }
    .CodeMirror-gutters { width: 32px !important; }
    .editor-wrap .CodeMirror-scroll { padding-right: 0 !important; }

    /* Dropdown menus: full-width bottom sheet */
    .dd {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 60vh;
        border-radius: 12px 12px 0 0;
        z-index: 9999;
    }
    .dd-i { padding: 14px 18px; font-size: 14px; }

    /* Modals: near-fullscreen */
    .snippet-modal, .theme-modal, .shortcuts-modal,
    .about-modal, .welcome-modal, .welcome-card,
    .modal-box, .pal-box {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Var inspector: full phone */
    .var-inspector {
        height: 50vh;
    }

    /* Status bar: compact */
    .statusbar { height: 22px; }
    .s-left, .s-right { gap: 6px; }
    .s-left span, .s-right span { font-size: 10px; }
    .sb-l, .sb-r { gap: 4px; }
    .sb-i { font-size: 9px; }

    /* Word count bar */
    .wc-bar { font-size: 10px; padding: 0 6px; }

    /* Loading overlay */
    .load-ov { font-size: 12px; }

    /* FAB Run Button (floating action button for quick access) */
    .mobile-fab-run {
        display: flex;
    }

    /* Prevent body scroll when panels open */
    .workspace { touch-action: pan-y; }
}

/* ── Mobile sidebar backdrop ─────────────────────────────────── */
.mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 899;
    backdrop-filter: blur(2px);
}

/* ── Mobile FAB Run button ───────────────────────────────────── */
.mobile-fab-run {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--grape);
    color: white;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(139,90,43,.5);
    z-index: 700;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    border: none;
}
.mobile-fab-run:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(139,90,43,.6);
}
.mobile-fab-run:active {
    transform: scale(0.95);
}
.mobile-fab-run svg {
    width: 22px;
    height: 22px;
    fill: white;
}

/* ================================================================
   INDENT GUIDES
   ================================================================ */
.cm-indent-guide {
    position: relative;
}
.cm-indent-guide::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
    opacity: 0.5;
}

/* ================================================================
   WORD COUNT & AUTO-SAVE IN STATUS BAR
   ================================================================ */
.sb-wordcount {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    opacity: 0.8;
}
.autosave-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
    transition: background var(--t-base);
}
.autosave-dot.dirty {
    background: var(--warn, #F39C12);
    animation: pulse-dot 1s ease infinite;
}
.autosave-dot.saved {
    background: var(--ok);
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Modified dot on tab */
.tab .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: none;
    margin-left: 2px;
}
.tab .dot.modified {
    display: inline-block;
    background: var(--warn, #F39C12);
}

/* ================================================================
   SHORTCUTS MODAL
   ================================================================ */
.shortcuts-modal {
    background: var(--bg);
    border-radius: var(--r-lg);
    width: 560px;
    max-width: 94vw;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sh-lg);
    border: 1px solid var(--border);
}
.shortcuts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.shortcuts-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}
.shortcut-group {
    margin-bottom: 16px;
}
.shortcut-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--grape);
    margin-bottom: 8px;
}
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.shortcut-row:last-child {
    border-bottom: none;
}
.shortcut-desc {
    font-size: 13px;
    color: var(--text);
}
.shortcut-row kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 2px 8px;
    color: var(--text-2);
    min-width: 60px;
    text-align: center;
}

/* ================================================================
   STANDARD INPUT (stdin) PANEL
   ================================================================ */
.stdin-section {
    border-bottom: 1px solid var(--border);
    background: var(--bg-side);
}
.stdin-hdr {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.stdin-hdr:hover {
    background: rgba(139, 90, 43, 0.06);
}
.stdin-hdr svg {
    transition: transform 0.2s;
    flex-shrink: 0;
}
.stdin-hint {
    font-weight: 400;
    color: var(--text-3);
    font-size: 10px;
    margin-left: auto;
}
.stdin-body {
    padding: 0 8px 8px;
}
.stdin-body textarea {
    width: 100%;
    min-height: 50px;
    max-height: 120px;
    resize: vertical;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg);
    color: var(--text);
    outline: none;
    line-height: 1.5;
    box-sizing: border-box;
}
.stdin-body textarea:focus {
    border-color: var(--grape);
    box-shadow: 0 0 0 2px rgba(139, 90, 43, 0.12);
}
.stdin-body textarea::placeholder {
    color: var(--text-3);
    font-size: 11px;
}

/* ================================================================
   EXECUTION HISTORY
   ================================================================ */
.history-list {
    width: 260px;
    min-width: 200px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: 50vh;
}
.history-preview {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.history-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px;
    overflow: auto;
    max-height: 300px;
    white-space: pre;
    color: var(--text);
    flex: 1;
    margin-bottom: 10px;
}

/* ================================================================
   RAINBOW BRACKETS (no extra CSS needed — inline styles used)
   ================================================================ */

/* ================================================================
   WELCOME / ONBOARDING OVERLAY
   ================================================================ */
#welcomeOverlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0,0,0,0.55);
    display: none;
    align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease;
}
.welcome-card,
.welcome-modal {
    background: var(--bg);
    border-radius: 14px;
    width: 400px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    overflow: hidden;
    animation: slideUp 0.35s ease;
}
.welcome-header {
    background: linear-gradient(135deg, var(--grape), #C4935A);
    color: #fff;
    padding: 32px 28px 24px;
    text-align: center;
}
.welcome-header h2 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
.welcome-header p { margin: 0; opacity: 0.8; font-size: 13px; font-weight: 400; }
.welcome-body {
    padding: 20px 24px;
    background: var(--bg);
}
.welcome-tip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text);
}
.welcome-tip kbd {
    display: inline-block;
    background: var(--bg-side);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-2);
    min-width: 110px;
    text-align: center;
    flex-shrink: 0;
}
.welcome-tip span { color: var(--text-2); }
.welcome-actions {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.welcome-check { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.welcome-check input { accent-color: var(--grape); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
#toastContainer {
    position: fixed;
    top: 52px; right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-1);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    font-size: 13px;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 340px;
}
.toast-show { opacity: 1; transform: translateX(0); }
.toast-hide { opacity: 0; transform: translateX(20px); }
.toast-icon { font-size: 15px; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.3; }
.toast-close {
    background: none; border: none; color: var(--text-3); cursor: pointer;
    font-size: 16px; padding: 0 0 0 8px; line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-warn { border-left: 3px solid #f59e0b; }
.toast-info { border-left: 3px solid var(--grape); }

/* ================================================================
   BREADCRUMBS
   ================================================================ */
.breadcrumbs-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 12px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-3);
    min-height: 24px;
    overflow: hidden;
    white-space: nowrap;
}
.bc-item { color: var(--text-2); padding: 2px 4px; border-radius: 3px; cursor: default; }
.bc-item:last-child { color: var(--text); font-weight: 600; }
.bc-item:hover { background: var(--bg-3); }
.bc-sep { color: var(--text-3); margin: 0 1px; font-size: 14px; }

/* ================================================================
   COLLAPSIBLE SIDEBAR SECTIONS
   ================================================================ */
.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.sidebar-section-header:hover { background: var(--bg-3); }
.sidebar-section-header .chevron {
    transition: transform 0.2s;
    flex-shrink: 0;
}
.collapsed-section .sidebar-section-header .chevron {
    transform: rotate(-90deg);
}
.collapsed-section #fileListEl,
.collapsed-section .import-row { display: none !important; }

.import-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
}
.import-btn {
    background: var(--grape);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.import-btn:hover { opacity: 0.85; }

/* ================================================================
   FILE TYPE ICONS (in sidebar)
   ================================================================ */
.fi-icon { display: inline-flex; align-items: center; margin-right: 6px; flex-shrink: 0; }

/* ================================================================
   FULLSCREEN OUTPUT
   ================================================================ */
.right-panel.fullscreen-output {
    position: fixed !important;
    inset: 0 !important;
    z-index: 8000 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    max-width: none !important;
}
.fullscreen-output .res-body { height: calc(100vh - 40px) !important; }

/* ================================================================
   FOCUS MODE INDICATOR
   ================================================================ */
.panel-focused {
    box-shadow: inset 0 0 0 1.5px var(--grape) !important;
    transition: box-shadow 0.2s ease;
}

/* ================================================================
   VERSION BADGE
   ================================================================ */
.version-badge {
    background: rgba(139,90,43,0.15);
    color: var(--grape);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    margin-left: 6px;
    letter-spacing: 0.3px;
}

/* ================================================================
   LOADING SKELETON ANIMATION
   ================================================================ */
.skeleton-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.skeleton-bar {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, rgba(139,90,43,0.08) 25%, rgba(139,90,43,0.18) 50%, rgba(139,90,43,0.08) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s ease infinite;
}
@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================================================
   ABOUT / LEGAL MODAL
   ================================================================ */
#aboutOv { display: none; }
#aboutOv.open { display: flex; }
.about-modal {
    background: var(--bg);
    border-radius: 14px;
    width: 580px;
    max-width: 94vw;
    max-height: 85vh;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    border: 1px solid var(--border);
}
.about-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 12px;
}
.about-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}
.about-tab {
    background: none;
    border: none;
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-3);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    font-weight: 500;
}
.about-tab:hover { color: var(--text); }
.about-tab.active { color: var(--grape); border-bottom-color: var(--grape); }
.about-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-2);
}
.about-body h3 { margin: 0 0 12px; color: var(--text); font-size: 17px; }
.about-body h4 { margin: 16px 0 6px; color: var(--text); font-size: 14px; }
.about-body ul { padding-left: 20px; margin: 6px 0; }
.about-body li { margin-bottom: 4px; }
.about-body a { text-decoration: none; }
.about-body a:hover { text-decoration: underline; }

/* ================================================================
   DROP ZONE INDICATOR (drag & drop files)
   ================================================================ */
.workspace.drop-active::after {
    content: 'Drop files to import';
    position: absolute;
    inset: 8px;
    border: 2px dashed var(--grape);
    border-radius: 12px;
    background: rgba(139,90,43,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--grape);
    z-index: 500;
    pointer-events: none;
}
.workspace { position: relative; }

/* ================================================================
   PWA INSTALL BUTTON
   ================================================================ */
.install-app-btn {
    background: linear-gradient(135deg, var(--grape), #C4935A) !important;
    color: #fff !important;
    border-radius: 6px !important;
    padding: 4px 12px !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    gap: 5px;
    border: none !important;
    animation: installPulse 2s ease-in-out infinite;
    transition: transform 0.15s, box-shadow 0.15s;
}
.install-app-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139,90,43,0.4);
    animation: none;
}
.install-app-btn svg {
    width: 13px;
    height: 13px;
    stroke: #fff;
}

@keyframes installPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ================================================================
   PWA STANDALONE MODE ADJUSTMENTS (when installed as app)
   ================================================================ */
@media (display-mode: standalone) {
    .titlebar {
        -webkit-app-region: drag;
        user-select: none;
    }
    .titlebar button, .titlebar .dd {
        -webkit-app-region: no-drag;
    }
    .install-app-btn { display: none !important; }
}
