/* ═══════════════════════════════════════════
   Editor Surface — Dual Layer (textarea + pre)
   ═══════════════════════════════════════════ */

.editor__lines {
    width: var(--line-number-width);
    background: var(--bg-editor);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-editor);
    line-height: var(--line-height);
    text-align: right;
    padding: var(--gap-sm) var(--gap-sm) var(--gap-sm) 0;
    user-select: none;
    overflow: hidden;
    border-right: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.editor__lines .line-number {
    padding-right: var(--gap-sm);
    height: calc(var(--font-size-editor) * var(--line-height));
}

.editor__lines .line-number.active {
    color: var(--text-primary);
}

.editor__surface {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.editor__input,
.editor__highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: var(--gap-sm);
    border: none;
    font-family: var(--font-mono);
    font-size: var(--font-size-editor);
    line-height: var(--line-height);
    tab-size: 2;
    white-space: pre;
    word-wrap: normal;
    overflow: auto;
    resize: none;
}

.editor__input {
    color: transparent;
    caret-color: var(--text-primary);
    background: transparent;
    z-index: 2;
    outline: none;
}

.editor__input::selection {
    background: var(--selection);
    color: transparent;
}

.editor__highlight {
    color: var(--text-primary);
    background: var(--bg-editor);
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

/* Prevent the <pre> from adding extra whitespace */
.editor__highlight code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.editor__placeholder {
    position: absolute;
    top: var(--gap-sm);
    left: var(--gap-sm);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--font-size-editor);
    pointer-events: none;
    z-index: 1;
}

/* Error line highlighting */
.editor__highlight .error-line {
    background: rgba(255, 0, 0, 0.1);
    display: block;
}

/* ═══════════════════════════════════════════
   Syntax Highlighting Spans
   ═══════════════════════════════════════════ */

.syn-keyword    { color: var(--syn-keyword); }
.syn-string     { color: var(--syn-string); }
.syn-template   { color: var(--syn-template); }
.syn-number     { color: var(--syn-number); }
.syn-comment    { color: var(--syn-comment); font-style: italic; }
.syn-function   { color: var(--syn-function); }
.syn-class      { color: var(--syn-class); }
.syn-operator   { color: var(--syn-operator); }
.syn-property   { color: var(--syn-property); }
.syn-regex      { color: var(--syn-regex); }
.syn-punctuation { color: var(--syn-punctuation); }
.syn-boolean    { color: var(--syn-boolean); }
.syn-builtin    { color: var(--syn-builtin); }

/* ═══════════════════════════════════════════
   Tab Bar
   ═══════════════════════════════════════════ */

.tab {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    padding: 0 var(--gap-md);
    height: var(--tab-height);
    background: var(--bg-tab-inactive);
    border-right: 1px solid var(--border);
    cursor: pointer;
    font-size: var(--font-size-small);
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

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

.tab.active {
    background: var(--bg-tab-active);
    color: var(--text-primary);
    border-bottom: 1px solid var(--bg-tab-active);
    margin-bottom: -1px;
}

.tab__icon {
    font-size: 10px;
    font-weight: bold;
    opacity: 0.7;
}

.tab__name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab__close {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}

.tab:hover .tab__close,
.tab.active .tab__close {
    opacity: 0.7;
}

.tab__close:hover {
    opacity: 1 !important;
    background: var(--bg-hover);
}

/* Empty state */
.editor__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 16px;
    flex-direction: column;
    gap: var(--gap-md);
}

.editor__empty-title {
    color: var(--text-accent);
    font-size: 24px;
    font-weight: bold;
}
