@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Thin.ttf.woff2') format('woff2');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-ThinItalic.ttf.woff2') format('woff2');
    font-weight: 100;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-ExtraLight.ttf.woff2') format('woff2');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-ExtraLightItalic.ttf.woff2') format('woff2');
    font-weight: 200;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Light.ttf.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-LightItalic.ttf.woff2') format('woff2');
    font-weight: 300;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Regular.ttf.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Italic.ttf.woff2') format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Medium.ttf.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-MediumItalic.ttf.woff2') format('woff2');
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-SemiBold.ttf.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-SemiBoldItalic.ttf.woff2') format('woff2');
    font-weight: 600;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-Bold.ttf.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-BoldItalic.ttf.woff2') format('woff2');
    font-weight: 700;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-ExtraBold.ttf.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Maple Mono NF';
    src: url('font/MapleMono-ExtraBoldItalic.ttf.woff2') format('woff2');
    font-weight: 800;
    font-style: italic;
    font-display: swap;
}

/* ===== NON-THEME VARIABLES ===== */
:root {
    --font-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Maple Mono NF', 'Fira Code', 'Consolas', monospace;

    --editor-font-size: 15px;
    --editor-line-height: 24px;
    --editor-font-weight: 400;
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

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

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(108, 112, 134, 0.35) transparent;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    overflow: hidden;
}

.editor-column {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
}

/* ===== HEADER & TABS ===== */
.editor-header {
    display: flex;
    background: var(--bg-header);
    backdrop-filter: blur(12px);
    height: 36px;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.editor-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
    z-index: 1;
    pointer-events: none;
}

/* Sidebar reopen button â€” visible only when sidebar is collapsed */
.sidebar-reopen-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 36px;
    height: 100%;
    cursor: pointer;
    font-size: 16px;
    transition: 0.2s;
    flex-shrink: 0;
}

.sidebar-reopen-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-tab-hover);
}

.sidebar.collapsed~.editor-column .sidebar-reopen-btn {
    display: flex;
}

.tabs-container {
    display: flex;
    height: 100%;
    flex-grow: 1;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.tab {
    display: flex;
    align-items: center;
    padding: 0 5px 0 10px;
    height: 100%;
    background-color: var(--bg-tab);
    color: var(--text-muted);
    border-right: 1px solid var(--border-color);
    border-top: none;
    border-bottom: none;
    box-sizing: border-box;
    cursor: pointer;
    font-size: 12.5px;
    user-select: none;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    min-width: 80px;
    max-width: 180px;
    flex-shrink: 0;
}

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

.tab.active {
    background-color: var(--bg-main);
    color: var(--text-main);
    box-shadow: inset 0 1px 0 var(--accent-color);
    position: relative;
    z-index: 2;
}

.tab-name {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.tab:has(.tab-pin-icon) {
    padding: 0 5px 0 5px;
}

.tab-pin-icon {
    margin-right: 5px;
}


.tab-dot {
    color: var(--accent-color);
    margin-right: 5px;
    font-size: 10px;
    line-height: 1;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 15px;
    line-height: 0;
    padding-bottom: 2px;
    opacity: 0;
    transition: 0.15s ease-in-out;
    pointer-events: auto;
    margin-left: 10px;
}

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

.tab-close:hover {
    background-color: rgba(243, 139, 168, 0.15);
    color: var(--color-red);
}

.action-btns {
    display: flex;
    height: 100%;
    border-right: 1px solid var(--border-color);
    background: var(--bg-header);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 100%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

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

.toolbar {
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 15px;
    position: relative;
    height: 100%;
    background: var(--bg-header);
}

.save-status {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 90px;
}

.save-status.saved::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--color-green);
    border-radius: 50%;
}

.save-status.saving::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--color-yellow);
    border-radius: 50%;
    animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.settings-wrapper {
    position: relative;
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: 0.2s;
}

.settings-btn:hover {
    background: rgba(var(--surface-rgb), 0.1);
    color: var(--text-main);
}

.settings-popup {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    width: 220px;
    background-color: var(--bg-tab-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 5px 0;
}

.settings-item {
    padding: 10px 15px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-main);
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-item:hover {
    background-color: rgba(var(--surface-rgb), 0.05);
}

.settings-item:has(.settings-select) {
    justify-content: space-between;
    cursor: default;
}

.settings-select {
    background: rgba(var(--surface-rgb), 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-family: var(--font-ui);
    cursor: pointer;
    outline: none;
}

.settings-select:hover {
    border-color: var(--accent-color);
}

.settings-select option {
    background: var(--bg-main);
    color: var(--text-main);
}

/* Settings accordion (shared by language + theme) */
.settings-accordion-toggle {
    justify-content: space-between;
}

.settings-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-accordion-badge {
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(var(--surface-rgb), 0.08);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-accordion-options {
    padding: 0;
}

.settings-accordion-options.hidden {
    display: none;
}

.settings-accordion-option {
    padding: 8px 15px 8px 30px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-main);
    transition: 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-accordion-option:hover {
    background-color: rgba(var(--surface-rgb), 0.05);
}

.accordion-check {
    width: 14px;
    font-size: 11px;
    color: var(--accent-color);
    flex-shrink: 0;
}

/* ===== SIDEBAR ===== */
.editor-main {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.editor-content {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar {
    width: 250px;
    min-width: 180px;
    max-width: 450px;
    height: 100%;
    background: var(--bg-tab);
    border-right: none;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease, min-width 0.2s ease, opacity 0.2s ease;
    overflow: hidden;
}

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

.sidebar.collapsed+.sidebar-resize-handle {
    display: none;
}

/* Edge resize handle */
.sidebar-resize-handle {
    width: 2px;
    cursor: col-resize;
    background: var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
    background: var(--accent-color);
}

/* Prevent text selection during drag */
body.sidebar-resizing {
    cursor: col-resize !important;
    user-select: none !important;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    flex-shrink: 0;
    height: 36px;
}

/* Toggle sidebar button â€” inside sidebar-header */
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    color: var(--text-main);
    background-color: rgba(var(--surface-rgb), 0.08);
}

.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
}

/* Sidebar tree area — position context for floating actions */
.sidebar-tree-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Sidebar actions — inline within root folder row (VS Code style) */
.sidebar-actions {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
    max-width: 0;
    overflow: hidden;
}

.sidebar-actions.hidden {
    display: none !important;
}

/* Expand actions on hover — takes space and pushes name into ellipsis */
.tree-root-folder:hover .sidebar-actions {
    max-width: 200px;
    overflow: visible;
}

.sidebar-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.15s;
    opacity: 0;
    pointer-events: auto;
    flex-shrink: 0;
}

/* Show actions when hovering root folder or the actions bar itself */
.tree-root-folder:hover .sidebar-actions .sidebar-btn,
.sidebar-actions:hover .sidebar-btn {
    opacity: 1;
}

.sidebar-btn:hover {
    background: rgba(var(--surface-rgb), 0.08);
    color: var(--text-main);
}

.sidebar-tree {
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 25px 0;
}

.sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    padding: 20px;
}

.sidebar-empty p {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-open-btn {
    background: rgba(137, 180, 250, 0.1);
    border: 1px solid rgba(137, 180, 250, 0.2);
    color: var(--accent-color);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: 0.2s;
}

.sidebar-open-btn:hover {
    background: rgba(137, 180, 250, 0.2);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.recent-folders {
    width: 100%;
    margin-top: 8px;
}

.recent-folders-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 6px;
    opacity: 0.7;
}

.recent-folder-item {
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-main);
    transition: background 0.15s;
    gap: 6px;
}

.recent-folder-item:hover {
    background: rgba(var(--surface-rgb), 0.06);
}

.recent-folder-item .recent-icon {
    font-size: 13px;
    flex-shrink: 0;
}

.recent-folder-item .recent-name {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-folder-item .recent-remove {
    opacity: 0;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: 0.15s;
    flex-shrink: 0;
}

.recent-folder-item:hover .recent-remove {
    opacity: 1;
}

.recent-folder-item .recent-remove:hover {
    background: rgba(255, 100, 100, 0.2);
    color: var(--color-red);
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    padding-right: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-main);
    user-select: none;
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 26px;
}

.tree-item:hover {
    background: rgba(var(--surface-rgb), 0.04);
}

/* Root folder sticky — opaque hover to prevent items bleeding through */
.tree-root-folder:hover {
    background: var(--bg-main);
}

.tree-item.active {
    background: rgba(137, 180, 250, 0.12);
    color: var(--accent-color);
}

.tree-item.drop-target {
    background: rgba(137, 180, 250, 0.2);
    outline: 1px solid var(--accent-color);
}

.tree-icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    margin-right: 0;
    font-size: 15px;
}

.tree-icon.folder-arrow {
    width: 16px;
    height: 16px;
    font-size: 0;
    color: transparent;
    background-color: var(--text-muted);
    -webkit-mask-image: url('icons/ui/chevron-right.svg');
    mask-image: url('icons/ui/chevron-right.svg');
    -webkit-mask-size: 16px 16px;
    mask-size: 16px 16px;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    transition: transform 0.15s;
}

.tree-icon.folder-arrow.expanded {
    transform: rotate(90deg);
}

.tree-item:hover>.tree-icon.folder-arrow {
    background-color: var(--text-color, #e0e0e0);
}

.tree-name {
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-folder-children {
    overflow: hidden;
}

.tree-folder-children.collapsed {
    display: none;
}

/* ===== STICKY SCROLL (VS Code-style tree sticky headers) ===== */
.sticky-scroll-container {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 6;
    overflow: hidden;
    pointer-events: none;
}

.sticky-scroll-container:empty {
    display: none;
}

.sticky-scroll-container:not(:empty) {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.sticky-scroll-item {
    pointer-events: auto;
    display: flex;
    align-items: center;
    padding: 3px 8px;
    padding-right: 10px;
    font-size: 13px;
    color: var(--text-main);
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 26px;
    background: var(--bg-tab);
    cursor: pointer;
}

.sticky-scroll-item:hover {
    background: var(--bg-tab-hover, var(--bg-main));
}

/* Icon spacing inside sticky items — match .tree-item > .fi */
.sticky-scroll-item > .fi {
    margin-right: 5px;
}

/* Tree inline rename input */
.tree-rename-input {
    background: var(--bg-main);
    border: 1px solid var(--accent-color);
    color: var(--text-main);
    font-size: 12px;
    font-family: var(--font-ui);
    padding: 1px 4px;
    border-radius: 3px;
    outline: none;
    width: 100%;
    min-width: 60px;
}

/* Filter textarea in settings */
.filter-textarea {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px;
    border-radius: 6px;
    outline: none;
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.filter-textarea:focus {
    border-color: var(--accent-color);
}

/* ===== IMAGE VIEWER ===== */
.image-viewer {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    overflow: hidden;
}

.image-viewer-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    /* Checkerboard background for transparency */
    background-image:
        linear-gradient(45deg, rgba(var(--surface-rgb), 0.03) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(var(--surface-rgb), 0.03) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(var(--surface-rgb), 0.03) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(var(--surface-rgb), 0.03) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.image-viewer-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.image-viewer-container img:hover {
    transform: scale(1.02);
}

.image-viewer-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: var(--bg-checkerboard);
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    gap: 12px;
    flex-shrink: 0;
}

/* ===== AUDIO PLAYER PANEL ===== */
.audio-player-panel {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    overflow: hidden;
}

.audio-player-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 48px;
    border-radius: 18px;
    background: var(--bg-header, rgba(30, 30, 46, 0.9));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(16px);
    box-shadow: 0 12px 48px rgba(var(--surface-rgb, 0, 0, 0), 0.2);
    width: 380px;
    max-width: 90vw;
    gap: 12px;
}

.audio-player-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 4px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
    animation: audio-pulse 2s ease-in-out infinite;
}

@keyframes audio-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.audio-player-panel .audio-player-icon.playing {
    animation: audio-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes audio-bounce {
    0% { transform: scale(1) rotate(-3deg); }
    100% { transform: scale(1.1) rotate(3deg); }
}

.audio-player-name {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-all;
    max-width: 100%;
}

.audio-player-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
    min-height: 1em;
    max-width: 100%;
    opacity: 0.7;
}

.audio-player-waveform {
    width: 100%;
    margin: 8px 0;
}

/* Custom range slider — progress */
.audio-progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(var(--surface-rgb), 0.12);
    outline: none;
    cursor: pointer;
    transition: height 0.15s;
}

.audio-progress:hover {
    height: 8px;
}

.audio-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color, #89b4fa);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(var(--surface-rgb), 0.2);
    transition: transform 0.15s, box-shadow 0.15s;
}

.audio-progress::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(var(--surface-rgb), 0.3);
}

.audio-progress::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color, #89b4fa);
    border: none;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(var(--surface-rgb), 0.2);
}

.audio-time {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    user-select: none;
}

.audio-player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.audio-btn {
    background: rgba(var(--surface-rgb), 0.06);
    border: 1px solid rgba(var(--surface-rgb), 0.1);
    color: var(--text-main);
    font-size: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.audio-btn:hover {
    background: rgba(var(--surface-rgb), 0.12);
    border-color: rgba(var(--surface-rgb), 0.2);
    transform: scale(1.08);
}

.audio-btn-play {
    width: 56px;
    height: 56px;
    font-size: 22px;
    background: linear-gradient(135deg, rgba(var(--surface-rgb), 0.06), rgba(var(--surface-rgb), 0.1));
    border-color: rgba(var(--surface-rgb), 0.12);
    box-shadow: 0 4px 20px rgba(var(--surface-rgb), 0.08);
}

.audio-btn-play:hover {
    background: linear-gradient(135deg, rgba(var(--surface-rgb), 0.1), rgba(var(--surface-rgb), 0.15));
    border-color: rgba(var(--surface-rgb), 0.2);
    box-shadow: 0 6px 24px rgba(var(--surface-rgb), 0.12);
    transform: scale(1.1);
}

.audio-volume-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 200px;
}

.audio-volume-icon {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.audio-volume {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(var(--surface-rgb), 0.12);
    outline: none;
    cursor: pointer;
}

.audio-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s;
}

.audio-volume::-webkit-slider-thumb:hover {
    background: var(--text-main);
}

.audio-volume::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-muted);
    border: none;
    cursor: pointer;
}

/* Audio button icons */
.audio-btn .fi-ui {
    width: 18px;
    height: 18px;
    background-color: var(--text-main);
    pointer-events: none;
}

.audio-btn-play .fi-ui {
    width: 24px;
    height: 24px;
}

.audio-volume-icon .fi-ui {
    width: 16px;
    height: 16px;
    background-color: var(--text-muted);
}

.audio-player-icon .fi-ui {
    background-color: var(--accent-color, #89b4fa);
}

/* ===== LOADING SPINNERS ===== */
/* 3 bouncing dots — for audio meta & binary size */
.dots-loader {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 1em;
}

.dots-loader span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: dots-bounce 1.2s ease-in-out infinite;
}

.dots-loader span:nth-child(2) { animation-delay: 0.15s; }
.dots-loader span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dots-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Spinning circle — for image viewer */
.spin-loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(var(--surface-rgb), 0.1);
    border-top-color: var(--accent-color, #89b4fa);
    border-radius: 50%;
    animation: spin-rotate 0.8s linear infinite;
    margin: 20px auto;
}

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

/* ===== BINARY FILE PANEL ===== */
.binary-file-panel {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
}

.binary-file-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 48px;
    border-radius: 14px;
    background: var(--bg-header, rgba(30, 30, 46, 0.9));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(var(--surface-rgb, 0, 0, 0), 0.15);
    max-width: 420px;
    gap: 6px;
}

.binary-file-icon {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 8px;
    filter: drop-shadow(0 2px 8px rgba(var(--surface-rgb), 0.15));
}

.binary-file-name {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-all;
}

.binary-file-size {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.binary-file-msg {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 10px 0 18px;
    max-width: 320px;
}

.binary-file-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.binary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(var(--surface-rgb), 0.1);
    background: rgba(var(--surface-rgb), 0.04);
    color: var(--text-main);
    font-size: 13px;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s;
}

.binary-btn:hover {
    background: rgba(var(--surface-rgb), 0.08);
    border-color: rgba(var(--surface-rgb), 0.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--surface-rgb), 0.12);
}

.binary-btn-icon {
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-mono);
    opacity: 0.7;
}

.binary-btn-code:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.binary-btn-code:hover .binary-btn-icon {
    opacity: 1;
    color: var(--accent-color);
}

.binary-btn-external:hover {
    border-color: hsl(150, 60%, 55%);
    color: hsl(150, 60%, 65%);
}

.binary-btn-external:hover .binary-btn-icon {
    opacity: 1;
    color: hsl(150, 60%, 65%);
}

/* ===== SVG FLOATING PREVIEW ===== */
/* ===== SPLIT PREVIEW SYSTEM ===== */

/* Floating preview toggle button â€” matches search panel style */
.preview-toggle-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    z-index: 10;
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(var(--surface-rgb), 0.1);
    border-radius: 6px;
    padding: 4px 12px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    box-shadow: var(--shadow-panel);
    transition: all 0.15s;
}

.preview-toggle-btn:hover {
    background: rgba(var(--surface-rgb), 0.08);
    color: var(--accent-color);
    border-color: rgba(var(--surface-rgb), 0.2);
}

.preview-toggle-btn.active {
    background: rgba(137, 180, 250, 0.15);
    color: var(--accent-color);
    border-color: rgba(137, 180, 250, 0.3);
}

.preview-toggle-btn.hidden {
    display: none !important;
}

/* Editor split container â€” horizontal flex */
.editor-split {
    display: flex;
    flex-grow: 1;
    width: 100%;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

/* Editor pane (left side) â€” code editor */
.editor-pane {
    display: flex;
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

/* Preview resize handle */
.preview-resize-handle {
    width: 2px;
    cursor: col-resize;
    background: var(--border-color);
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 5;
}

.preview-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    left: -3px;
    right: -3px;
    bottom: 0;
}

.preview-resize-handle:hover,
.preview-resize-handle.dragging {
    background: var(--accent-color);
}

/* Preview pane (right side) */
.preview-pane {
    display: flex;
    flex-direction: column;
    min-width: 180px;
    background: var(--bg-main);
    border-left: 1px solid var(--border-color);
    overflow: hidden;
}

.preview-pane.hidden {
    display: none !important;
}

/* Preview header */
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--bg-tab);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-width: 0;
}

.preview-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
}

/* Zoom controls */
.preview-zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.preview-zoom-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.15s;
    line-height: 1;
}

.preview-zoom-btn:hover {
    background: rgba(var(--surface-rgb), 0.08);
    color: var(--text-main);
    border-color: rgba(var(--surface-rgb), 0.1);
}

.preview-close-btn:hover {
    background: rgba(255, 80, 80, 0.2);
    color: var(--color-red);
}

.preview-zoom-level {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 38px;
    text-align: center;
    user-select: none;
}

/* Full-width preview mode — hides editor, preview takes all space */
.preview-fullwidth .editor-pane {
    display: none !important;
}

.preview-fullwidth .preview-resize-handle {
    display: none !important;
}

.preview-fullwidth .preview-pane {
    width: 100% !important;
    flex-basis: 100% !important;
    flex-grow: 1 !important;
}

.preview-zoom-btn.active {
    background: rgba(var(--surface-rgb), 0.12);
    color: var(--accent-color);
}

/* Lottie preview */
.lottie-preview {
    position: relative;
}

.lottie-preview #lottie-container {
    flex-grow: 0;
    flex-shrink: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: auto;
}

.lottie-preview #lottie-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.lottie-controls {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-overlay);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(var(--surface-rgb), 0.08);
    z-index: 5;
}

.lottie-frame-info {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 4px;
}

/* Preview content area */
.preview-content {
    flex-grow: 1;
    overflow: auto;
    padding: 20px;
    /* Checkerboard for SVG transparency */
    background-image:
        linear-gradient(45deg, rgba(var(--surface-rgb), 0.02) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(var(--surface-rgb), 0.02) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(var(--surface-rgb), 0.02) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(var(--surface-rgb), 0.02) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* SVG preview content */
.preview-content svg {
    max-width: 100%;
    display: block;
    margin: 0 auto;
}

/* HTML preview content */
.preview-content.html-preview {
    background-image: none;
    background: #ffffff;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.html-preview-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    display: block;
    transform-origin: top left;
    transition: transform 0.15s;
}

/* Markdown preview content */
.preview-content.markdown-preview {
    background-image: none;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
}

.preview-content.markdown-preview h1 {
    font-size: 2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
    margin: 0.67em 0;
}

.preview-content.markdown-preview h2 {
    font-size: 1.5em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
    margin: 0.83em 0;
}

.preview-content.markdown-preview h3 {
    font-size: 1.25em;
    margin: 1em 0;
}

.preview-content.markdown-preview h4 {
    font-size: 1em;
    margin: 1em 0;
}

.preview-content.markdown-preview h5 {
    font-size: 0.875em;
    margin: 1em 0;
}

.preview-content.markdown-preview h6 {
    font-size: 0.85em;
    color: var(--text-muted);
    margin: 1em 0;
}

.preview-content.markdown-preview code {
    background: rgba(var(--surface-rgb), 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    font-variant-ligatures: normal;
    font-feature-settings: "liga" 1, "calt" 1;
}

.preview-content.markdown-preview pre {
    background: rgba(var(--surface-rgb), 0.06);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    margin: 1em 0;
}

.preview-content.markdown-preview pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    font-variant-ligatures: normal;
    font-feature-settings: "liga" 1, "calt" 1;
    white-space: pre;
    display: block;
    letter-spacing: normal;
    word-spacing: normal;
    tab-size: 4;
}

.preview-content.markdown-preview pre code span {
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    word-spacing: inherit;
    white-space: inherit;
}

.preview-content.markdown-preview blockquote {
    border-left: 4px solid var(--accent-color);
    margin: 1em 0;
    padding: 0.5em 1em;
    color: var(--text-muted);
    background: rgba(var(--surface-rgb), 0.02);
    border-radius: 0 6px 6px 0;
}

.preview-content.markdown-preview a {
    color: var(--accent-color);
    text-decoration: none;
}

.preview-content.markdown-preview a:hover {
    text-decoration: underline;
}

.preview-content.markdown-preview img {
    max-width: 100%;
    border-radius: 6px;
}

.preview-content.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.preview-content.markdown-preview th,
.preview-content.markdown-preview td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.preview-content.markdown-preview th {
    background: rgba(var(--surface-rgb), 0.04);
    font-weight: 600;
}

.preview-content.markdown-preview hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5em 0;
}

.preview-content.markdown-preview ul,
.preview-content.markdown-preview ol {
    padding-left: 2em;
    margin: 0.5em 0;
}

.preview-content.markdown-preview li {
    margin: 0.25em 0;
}

.preview-content.markdown-preview input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--accent-color);
}

/* CSV preview content */
.preview-content.csv-preview {
    background-image: none;
    background: var(--bg-main);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.csv-table-wrapper {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.csv-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.csv-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.csv-table th {
    background: var(--bg-tab, #181825);
    color: var(--accent-color);
    font-weight: 600;
    padding: 8px 14px;
    text-align: left;
    border-bottom: 2px solid var(--accent-color);
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.csv-table td {
    padding: 6px 14px;
    border-bottom: 1px solid rgba(var(--surface-rgb), 0.05);
    color: var(--text-main);
    white-space: nowrap;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csv-table tbody tr:nth-child(even) {
    background: rgba(var(--surface-rgb), 0.03);
}

.csv-table tbody tr:hover {
    background: rgba(137, 180, 250, 0.06);
}

.csv-info {
    padding: 10px 14px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--bg-tab, #181825);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

/* Root folder item — flex row with inline actions (VS Code style) */
.tree-root-folder {
    padding-bottom: 2px;
    display: flex;
    align-items: center;
    overflow: hidden;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-main);
    /* border-bottom: 1px solid var(--border-color); */
}

/* .tree-root-children { */
/* padding-top: 4px; */
/* } */

.tree-root-folder .tree-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== WELCOME SCREEN ===== */

.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-main);
    z-index: 5;
    text-align: center;
}

.welcome-screen.active {
    display: flex;
}

.cz-logo {
    font-size: 64px;
    font-weight: 300;
    letter-spacing: -2px;
    color: var(--text-main);
    margin-bottom: 8px;
    cursor: default;
    text-shadow: 0 0 60px rgba(137, 180, 250, 0.15);
}

.cz-highlight {
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-purple), var(--color-red));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient-shift 4s ease infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.cz-version {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 8px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.cz-description {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.5;
    font-family: var(--font-ui);
    margin-bottom: 28px;
    max-width: 420px;
    line-height: 1.5;
}

.cz-hints {
    text-align: center;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(137, 180, 250, 0.06);
    border: 1px solid rgba(137, 180, 250, 0.15);
    border-radius: 20px;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
}

.github-link .fi-ui-github {
    width: 18px;
    height: 18px;
    background-color: var(--text-muted);
    transition: background-color 0.25s ease;
}

.github-link:hover {
    color: var(--text-main);
    background: rgba(137, 180, 250, 0.12);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(137, 180, 250, 0.12);
    transform: translateY(-2px);
}

.github-link:hover .fi-ui-github {
    background-color: var(--text-main);
}

/* Fade-up entrance animation */
.anim-fade-up {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s ease forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PWA Install Button */
.pwa-install-btn {
    margin-top: 28px;
    padding: 10px 24px;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--text-main);
    background: rgba(137, 180, 250, 0.08);
    border: 1px solid rgba(137, 180, 250, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
}

.pwa-install-btn .fi-ui {
    background-color: var(--text-main);
}

.pwa-install-btn:hover {
    background: rgba(137, 180, 250, 0.15);
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(137, 180, 250, 0.15);
    transform: translateY(-2px);
}

.pwa-install-btn:hover .fi-ui {
    background-color: var(--text-main);
}

/* ===== EDITOR BODY ===== */
.editor-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
    background-color: var(--bg-main);
    overflow: hidden;
}

.line-numbers {
    min-width: 55px;
    box-sizing: border-box;
    background-color: var(--bg-line-numbers);
    color: var(--text-muted);
    padding: 20px 15px 20px 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    user-select: none;
    font-variant-ligatures: normal;
    font-feature-settings: "liga" 1, "calt" 1;
}

.code-wrapper {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

.active-line-highlight {
    position: absolute;
    left: 0;
    height: var(--editor-line-height);
    background: var(--active-line-bg);
    pointer-events: none;
    z-index: 0;
    display: none;
    min-width: 100%;
}

#editing,
#highlighting {
    margin: 0;
    border: 0;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    font-family: var(--font-mono) !important;
    font-size: var(--editor-font-size) !important;
    font-weight: var(--editor-font-weight) !important;
    line-height: var(--editor-line-height) !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    position: absolute;
    top: 0;
    left: 0;
    white-space: pre;
    tab-size: 4;
    font-variant-ligatures: contextual common-ligatures;
    font-feature-settings: "liga" 1, "calt" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#editing {
    padding: 20px;
    color: transparent;
    background: transparent;
    caret-color: var(--text-main);
    z-index: 1;
    resize: none;
    outline: none;
    overflow: auto;
}

/* During preload: make text visible and hide scrollbar until JS fully initializes */
#editing.preload-visible {
    color: var(--text-main);
    overflow: hidden !important;
}

#editing::selection {
    background-color: var(--selection-bg);
    color: transparent;
}

#highlighting {
    padding: 20px;
    z-index: 0;
    color: var(--text-main);
    pointer-events: none;
    overflow: hidden;
}

#highlighting-content {
    margin: 0;
    padding: 0;
    border: 0;
    display: block;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

/* ===== BRACKET MATCHING ===== */
.syn-bracket-match {
    background-color: rgba(var(--surface-rgb), 0.2);
    border-radius: 2px;
    color: var(--color-yellow);
    box-shadow: 0 0 0 1px rgba(249, 226, 175, 0.6);
}

/* ===== SEARCH & REPLACE PANEL ===== */
.search-panel {
    position: absolute;
    top: 0;
    right: 18px;
    z-index: 50;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(var(--surface-rgb), 0.1);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-panel);
    min-width: 340px;
    animation: searchSlideDown 0.15s ease-out;
}

@keyframes searchSlideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.search-panel.hidden {
    display: none !important;
}

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

.search-field {
    flex: 1;
    background: rgba(var(--surface-rgb), 0.06);
    border: 1px solid rgba(var(--surface-rgb), 0.08);
    border-radius: 4px;
    padding: 5px 8px;
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
    min-width: 0;
    transition: border-color 0.15s;
}

.search-field:focus {
    border-color: var(--accent-color);
}

.search-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
    padding: 0 4px;
}

.search-count.has-results {
    color: var(--accent-color);
}

.search-count.no-results {
    color: var(--color-red);
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    background: rgba(var(--surface-rgb), 0.05);
    border: 1px solid rgba(var(--surface-rgb), 0.08);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0 5px;
    font-family: var(--font-mono);
}

.search-btn:hover {
    background: rgba(var(--surface-rgb), 0.1);
    color: var(--text-main);
    border-color: rgba(var(--surface-rgb), 0.15);
}

.search-btn.active {
    background: rgba(137, 180, 250, 0.2);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.search-btn.search-close {
    color: var(--text-muted);
    font-size: 13px;
}

.search-btn.search-close:hover {
    color: var(--color-red);
    background: rgba(243, 139, 168, 0.1);
}

.replace-row {
    padding-left: 0;
}

/* Search match highlights in code */
.search-hl {
    background: rgba(249, 226, 175, 0.25);
    border-radius: 2px;
    color: inherit;
    outline: 1px solid rgba(249, 226, 175, 0.35);
    outline-offset: -1px;
}

/* ===== AUTOCOMPLETE POPUP ===== */
.autocomplete-popup {
    position: fixed;
    z-index: 9999;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-panel);
    max-height: 220px;
    min-width: 220px;
    max-width: 380px;
    overflow: hidden;
}

.autocomplete-list {
    overflow-y: auto;
    max-height: 220px;
    padding: 4px;
}

.autocomplete-list::-webkit-scrollbar {
    width: 5px;
}

.autocomplete-list::-webkit-scrollbar-thumb {
    background: rgba(var(--surface-rgb), 0.1);
    border-radius: 3px;
}

.ac-item {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12.5px;
    gap: 8px;
    transition: background 0.1s;
}

.ac-item:hover,
.ac-item.active {
    background: rgba(137, 180, 250, 0.12);
}

.ac-item.active {
    background: rgba(137, 180, 250, 0.2);
}

.ac-icon {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    font-family: var(--font-mono);
}

.ac-icon.keyword {
    background: rgba(203, 166, 247, 0.2);
    color: var(--accent-purple);
}

.ac-icon.function {
    background: rgba(137, 180, 250, 0.2);
    color: var(--accent-color);
}

.ac-icon.snippet {
    background: rgba(166, 227, 161, 0.2);
    color: var(--color-green);
}

.ac-icon.variable {
    background: rgba(243, 139, 168, 0.2);
    color: var(--color-red);
}

.ac-icon.property {
    background: rgba(249, 226, 175, 0.2);
    color: var(--color-yellow);
}

.ac-icon.emmet {
    background: rgba(250, 179, 135, 0.2);
    color: var(--color-orange);
}

.ac-label {
    flex-grow: 1;
    color: var(--text-main);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-label .ac-match {
    color: var(--accent-color);
    font-weight: 600;
}

.ac-detail {
    font-size: 10.5px;
    color: var(--text-muted);
    flex-shrink: 0;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== COMMAND PALETTE ===== */
.command-palette-content {
    width: 500px;
    margin: 80px auto 0;
    background: rgba(30, 30, 46, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

#command-palette-input {
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 14px;
    font-family: var(--font-ui);
    outline: none;
}

#command-palette-input::placeholder {
    color: var(--text-muted);
}

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

.cp-item {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s;
}

.cp-item:hover,
.cp-item.active {
    background: rgba(137, 180, 250, 0.12);
}

.cp-item .cp-shortcut {
    font-size: 10.5px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-tab-hover);
    border: 1px solid var(--border-color);
    width: 350px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.config-group select,
.config-group input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.config-group input:focus,
.config-group select:focus {
    border-color: var(--accent-color);
}

/* Prompt live validation */
.prompt-validation-error {
    font-size: 11px;
    color: var(--color-red);
    margin-top: 6px;
    min-height: 16px;
    line-height: 1.4;
}

.prompt-validation-error:empty {
    display: none;
}

.config-group input.input-invalid {
    border-color: var(--color-red);
}

.config-group input.input-invalid:focus {
    border-color: var(--color-red);
    box-shadow: 0 0 0 2px rgba(243, 139, 168, 0.15);
}

.close-modal {
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--color-red);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.btn-ok,
.btn-cancel,
.btn-danger {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: 0.2s;
}

.btn-ok {
    background-color: var(--accent-color);
    color: var(--bg-main);
    font-weight: bold;
}

.btn-ok:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-ok:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-cancel {
    background-color: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background-color: rgba(var(--surface-rgb), 0.05);
}

.btn-danger {
    background-color: var(--color-red);
    color: var(--bg-main);
    font-weight: bold;
}

.btn-danger:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Shortcuts modal */
.shortcuts-body {
    padding: 15px 20px;
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    font-size: 12.5px;
    border-bottom: 1px solid rgba(var(--surface-rgb), 0.03);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-keys {
    font-family: var(--font-mono);
    font-size: 11px;
    background: rgba(137, 180, 250, 0.1);
    border: 1px solid rgba(137, 180, 250, 0.15);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ===== FOOTER ===== */
.editor-footer {
    height: 25px;
    min-height: 25px;
    max-height: 25px;
    background-color: var(--bg-footer);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    font-size: 11px;
    color: var(--text-muted);
    z-index: 10;
}

.footer-left,
.footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-left span,
.footer-right span {
    cursor: default;
}

.footer-lang-btn {
    cursor: pointer !important;
    transition: color 0.2s;
    padding: 0 4px;
    border-radius: 3px;
}

.footer-lang-btn:hover {
    color: var(--accent-color);
    background: rgba(var(--surface-rgb), 0.08);
}

/* Binary/image/audio file mode — pickers become non-interactive info labels */
.editor-footer.footer-binary .footer-lang-btn {
    cursor: default !important;
    pointer-events: none;
}

.editor-footer.footer-binary .footer-lang-btn:hover {
    color: inherit;
    background: none;
}

.divider {
    width: 1px;
    height: 10px;
    background: rgba(var(--surface-rgb), 0.1);
    margin: 0 10px;
}

/* Language Picker Dropdown */
.lang-picker-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.lang-picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(var(--surface-rgb), 0.03);
    padding: 4px;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.lang-picker::-webkit-scrollbar {
    width: 5px;
}

.lang-picker::-webkit-scrollbar-track {
    background: transparent;
}

.lang-picker::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.lang-picker-item {
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.1s;
    display: flex;
    align-items: center;
}

.lang-picker-item:hover {
    background: rgba(var(--surface-rgb), 0.06);
}

.lang-picker-item.active {
    background: rgba(var(--surface-rgb), 0.1);
    color: var(--accent-color);
    font-weight: 600;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
    position: fixed;
    background: var(--bg-header, rgba(30, 30, 46, 0.95));
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 9999;
    padding: 5px 0;
    min-width: 160px;
}

.context-menu-item {
    padding: 8px 15px;
    font-size: 12px;
    color: var(--text-main);
    cursor: pointer;
    transition: 0.15s;
}

.context-menu-item:hover {
    background: rgba(var(--surface-rgb, 0, 0, 0), 0.06);
    color: var(--accent-color);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 5px 0;
}

/* ===== DROP OVERLAY ===== */
.drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-overlay, rgba(30, 30, 46, 0.92));
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    border: 4px dashed var(--accent-color);
}

.drop-overlay.active {
    opacity: 1;
}

/* ===== SYNTAX HIGHLIGHTING TOKENS ===== */
.syn-keyword {
    color: var(--syn-keyword);
}

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

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

.syn-doccomment {
    color: var(--syn-doccomment, var(--syn-comment));
    font-style: italic;
}

.syn-function {
    color: var(--syn-function);
}

.syn-tag {
    color: var(--syn-tag);
}

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

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

.syn-operator {
    color: var(--syn-operator);
}

.syn-class {
    color: var(--syn-class);
}

.syn-variable {
    color: var(--syn-variable);
}

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

.syn-property {
    color: var(--syn-property);
}

.syn-selector {
    color: var(--syn-selector);
}

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

.syn-pseudo {
    color: var(--syn-pseudo);
}

.syn-decorator {
    color: var(--syn-decorator);
}

.syn-punctuation {
    color: var(--syn-punctuation);
}

.syn-bold {
    color: var(--syn-bold);
    font-weight: bold;
}

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

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

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

.hidden {
    display: none !important;
}