body.theme-dark .chat-records-container,
body.theme-dark .chat-tools-container,
body.theme-dark .chat-input-container,
body.theme-dark .agent-switcher-container,
body.theme-dark .chat-side-container,
body.theme-dark .input-container {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .chat-side-title,
body.theme-dark .upload-status,
body.theme-dark .chat-side-item-btn {
    color: #e2e8f0;
}

body.theme-dark .intro-title {
    color: #e2e8f0;
}

body.theme-dark .user .bubble {
    color: #dbeafe;
}

body.theme-dark .system .bubble {
    background: #1e293b;
    color: #cbd5e1;
}

body.theme-dark .chat-side-search-input,
body.theme-dark textarea,
body.theme-dark .upload-btn {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

body.theme-dark .chat-view {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-color: #334155;
}

body.theme-dark .chat-side-search-toggle {
    background: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}

body.theme-dark .chat-side-item-btn {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .chat-side-item-btn:hover {
    background: #1e293b;
    border-color: #475569;
}

body.theme-dark .chat-side-item-btn.active {
    background: #1d4f91;
    border-color: #60a5fa;
}

body.theme-dark .chat-side-item-text::after {
    background: linear-gradient(to right, rgba(15, 23, 42, 0), #0f172a 80%);
}

body.theme-dark .input-container {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .settings-card {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .settings-card-title,
body.theme-dark .settings-value,
body.theme-dark .settings-file-row,
body.theme-dark .settings-trash-row {
    color: #e2e8f0;
}

body.theme-dark .settings-label,
body.theme-dark .settings-files-head,
body.theme-dark .settings-trash-head,
body.theme-dark .settings-trash-tip,
body.theme-dark .settings-file-row-empty,
body.theme-dark .settings-progress-text {
    color: #94a3b8;
}

body.theme-dark .settings-files-head,
body.theme-dark .settings-trash-head {
    border-bottom-color: #334155;
}

body.theme-dark .settings-file-row,
body.theme-dark .settings-trash-row {
    border-bottom-color: #1e293b;
}

body.theme-dark .settings-trash-cleaned {
    color: #64748b;
}

body.theme-dark .settings-progress {
    background: #334155;
}

body.theme-dark .knowledge-shell {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-color: #334155;
}

body.theme-dark .database-shell {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
    border-color: #334155;
}

body.theme-dark .knowledge-topbar,
body.theme-dark .database-topbar,
body.theme-dark .knowledge-preview-pane {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .database-preview-pane {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .knowledge-current-title {
    color: #e2e8f0;
}

body.theme-dark .database-current-title {
    color: #e2e8f0;
}

body.theme-dark .database-path-label {
    color: #94a3b8;
}

body.theme-dark .knowledge-tree-wrap {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .database-tree-wrap {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .knowledge-tree-resizer {
    background: linear-gradient(90deg, transparent 0, transparent 3px, #334155 3px, #334155 4px, transparent 4px, transparent 100%);
}

body.theme-dark .database-tree-resizer {
    background: linear-gradient(90deg, transparent 0, transparent 3px, #334155 3px, #334155 4px, transparent 4px, transparent 100%);
}

body.theme-dark .knowledge-tree-title,
body.theme-dark .knowledge-file-empty {
    color: #94a3b8;
}

body.theme-dark .database-tree-title,
body.theme-dark .database-file-empty {
    color: #94a3b8;
}

body.theme-dark .knowledge-tabs {
    background: #1e293b;
}

body.theme-dark .knowledge-tab {
    color: #cbd5e1;
}

body.theme-dark .knowledge-tab.active {
    background: #334155;
    border-color: #475569;
    color: #dbeafe;
}

body.theme-dark .knowledge-tree-row {
    color: #cbd5e1;
}

body.theme-dark .database-tree-row {
    color: #cbd5e1;
}

body.theme-dark .knowledge-tree-row:hover {
    background: #1e293b;
}

body.theme-dark .database-tree-row:hover {
    background: #1e293b;
}

body.theme-dark .knowledge-tree-row.active {
    background: #1d4f91;
    color: #dbeafe;
}

body.theme-dark .database-tree-row.active {
    background: #1d4f91;
    color: #dbeafe;
}

body.theme-dark .knowledge-tree-arrow {
    color: #94a3b8;
}

body.theme-dark .database-tree-arrow {
    color: #94a3b8;
}

body.theme-dark .knowledge-file-icon {
    background: #334155;
    color: #cbd5e1;
}

body.theme-dark .database-file-icon {
    background: #334155;
    color: #cbd5e1;
}

body.theme-dark .knowledge-name-tooltip {
    background: #111827;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .database-name-tooltip {
    background: #111827;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .knowledge-context-menu {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .database-context-menu {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .knowledge-context-item {
    color: #e2e8f0;
}

body.theme-dark .database-context-item {
    color: #e2e8f0;
}

body.theme-dark .knowledge-context-item:hover {
    background: #1e293b;
    color: #bfdbfe;
}

body.theme-dark .database-context-item:hover {
    background: #1e293b;
    color: #bfdbfe;
}

body.theme-dark .knowledge-dialog-card {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .database-dialog-card {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .knowledge-dialog-title {
    color: #f1f5f9;
}

body.theme-dark .database-dialog-title {
    color: #f1f5f9;
}

body.theme-dark .knowledge-dialog-message {
    color: #94a3b8;
}

body.theme-dark .database-dialog-message {
    color: #94a3b8;
}

body.theme-dark .knowledge-dialog-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .database-dialog-input {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .knowledge-inline-editor {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .knowledge-markdown,
body.theme-dark .knowledge-pre,
body.theme-dark .knowledge-empty-state {
    color: #cbd5e1;
}

body.theme-dark .database-markdown,
body.theme-dark .database-pre,
body.theme-dark .database-empty-state {
    color: #cbd5e1;
}

body.theme-dark .knowledge-markdown h1,
body.theme-dark .knowledge-markdown h2,
body.theme-dark .knowledge-markdown h3 {
    color: #f1f5f9;
}

body.theme-dark .database-markdown h1,
body.theme-dark .database-markdown h2,
body.theme-dark .database-markdown h3 {
    color: #f1f5f9;
}

body.theme-dark .knowledge-pre {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .database-pre {
    background: #111827;
    border-color: #334155;
}

body.theme-dark .knowledge-image,
body.theme-dark .knowledge-iframe {
    border-color: #334155;
    background: #0f172a;
}

body.theme-dark .database-image,
body.theme-dark .database-iframe {
    border-color: #334155;
    background: #0f172a;
}

@media (max-width: 768px) {
    .chat-side-container {
        display: flex;
        position: fixed;
        top: 60px;
        right: 0;
        bottom: 0;
        width: min(78vw, 280px);
        margin: 0;
        border-radius: 12px 0 0 0;
        border-right-width: 0;
        z-index: 55;
        transform: translateX(100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .chat-mode:not(.chat-side-collapsed) .chat-side-container {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .chat-view {
        padding-left: 12px;
        padding-right: 12px;
    }

    .chat-records-container {
        padding: 10px 14px 0;
    }

    .chat-tools-container {
        padding: 10px 14px 0;
    }

    .chat-input-container {
        padding: 10px 14px 0;
    }

    .agent-switcher-container {
        padding: 10px 14px 14px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-files-head,
    .settings-file-row {
        grid-template-columns: 1.4fr 80px 130px 1fr;
    }

    .settings-trash-head,
    .settings-trash-row {
        grid-template-columns: 1.4fr 130px 80px;
    }

    .knowledge-panel {
        padding: 10px 12px 14px;
    }

    .knowledge-shell {
        --knowledge-tree-width: 230px;
    }

    .knowledge-tree-wrap {
        width: var(--knowledge-tree-width);
    }

    .knowledge-topbar {
        grid-template-columns: max-content minmax(0, 1fr);
    }

    .knowledge-preview-pane {
        padding: 12px;
    }

    .database-topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .database-topbar-left {
        max-width: 100%;
    }
}
