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

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #181b24;
    --bg-tertiary: #21252f;
    --bg-hover: #2a2f3b;
    --bg-active: #353b4a;
    --border-color: #2d3343;
    --text-primary: #e8ecf4;
    --text-secondary: #a0a8bc;
    --text-muted: #636d83;
    --accent-red: #ff6b6b;
    --accent-red-hover: #ff8a8a;
    --accent-green: #4ade80;
    --accent-blue: #60a5fa;
    --accent-yellow: #fbbf24;
    --accent-purple: #c084fc;
    --accent-cyan: #22d3ee;
    --accent-orange: #fb923c;
    --accent-pink: #f472b6;
    --glow-red: rgba(255, 107, 107, 0.2);
    --glow-blue: rgba(96, 165, 250, 0.2);
    --glow-green: rgba(74, 222, 128, 0.2);
}

/* 浅色模式 */
.light-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-hover: #dee2e6;
    --bg-active: #ced4da;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --accent-red: #dc3545;
    --accent-red-hover: #c82333;
    --accent-green: #28a745;
    --accent-blue: #007bff;
    --accent-yellow: #ffc107;
    --accent-purple: #6f42c1;
    --accent-cyan: #17a2b8;
    --accent-orange: #fd7e14;
    --accent-pink: #e83e8c;
    --glow-red: rgba(220, 53, 69, 0.15);
    --glow-blue: rgba(0, 123, 255, 0.15);
    --glow-green: rgba(40, 167, 69, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.app-logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #dc382d, #f97316);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.header-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

.connection-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-green);
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-search {
    position: relative;
}

.header-search input {
    width: 280px;
    height: 32px;
    padding: 0 12px 0 36px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.header-search input:focus {
    border-color: var(--accent-red);
}

.header-search input::placeholder {
    color: var(--text-muted);
}

.header-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.header-btn-primary {
    background-color: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

.header-btn-primary:hover {
    background-color: var(--accent-red-hover);
    border-color: var(--accent-red-hover);
    color: white;
}

.header-btn.nav-btn {
    background-color: var(--bg-secondary);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.header-btn.nav-btn:hover {
    background-color: var(--accent-blue);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(96, 165, 250, 0.3);
}

@media (max-width: 768px) {
    .header-btn.nav-btn {
        padding: 0 8px;
        font-size: 12px;
        height: 30px;
    }
}

/* ===== Main Layout ===== */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 300px;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar-icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-tree::-webkit-scrollbar {
    width: 6px;
}

.sidebar-tree::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-tree::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}

.sidebar-tree::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* ===== Tree Nodes ===== */
.tree-node {
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-left: 3px solid transparent;
}

.tree-node-header:hover {
    background-color: var(--bg-hover);
}

.tree-node-header.active {
    background-color: var(--bg-active);
    border-left-color: var(--accent-red);
}

.tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 10px;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.tree-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.tree-icon.project { color: var(--accent-purple); }
.tree-icon.group { color: var(--accent-blue); }
.tree-icon.item { color: var(--accent-yellow); }

.tree-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-count {
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.tree-children {
    overflow: hidden;
}

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

.tree-leaf .tree-node-header {
    padding-left: 32px;
}

.tree-group .tree-node-header {
    padding-left: 20px;
}

.tree-copy-btn {
    display: none;
    width: 22px;
    height: 22px;
    padding: 0;
    margin-left: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    border-radius: 4px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: all 0.15s;
    line-height: 1;
    align-items: center;
    justify-content: center;
}

.tree-node-header:hover .tree-copy-btn {
    display: inline-flex;
}

.tree-copy-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-blue);
}

/* ===== Content Area ===== */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    flex-shrink: 0;
}

.content-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.content-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.content-breadcrumb .separator {
    color: var(--text-muted);
}

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

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.content-body::-webkit-scrollbar {
    width: 8px;
}

.content-body::-webkit-scrollbar-track {
    background: transparent;
}

.content-body::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.empty-state-hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== Form Styles ===== */
.form-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 20px;
}

.form-section-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-section-body {
    padding: 16px;
}

.form-section-body.collapsed {
    display: none;
}

.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.collapsible-header .collapse-icon {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    margin-left: 8px;
}

.collapsible-header .collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-input:focus, .form-textarea:focus {
    border-color: var(--accent-red);
}

.form-input::placeholder, .form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ===== Key-Value Display ===== */
.kv-pair {
    display: flex;
    margin-bottom: 12px;
}

.kv-key {
    width: 140px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-top: 8px;
}

.kv-value {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    padding: 8px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    word-break: break-all;
}

.kv-value.type-string { color: var(--accent-green); }
.kv-value.type-number { color: var(--accent-blue); }
.kv-value.type-bool { color: var(--accent-yellow); }

/* ===== Button Styles ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-hover) 100%);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    background: linear-gradient(135deg, var(--bg-hover) 0%, var(--bg-active) 100%);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8a8a 100%);
    border-color: #ff6b6b;
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff8a8a 0%, #ffaaaa 100%);
    border-color: #ff8a8a;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.35);
}

.btn-danger {
    color: #ef4444;
    border-color: #ef4444;
    background-color: transparent;
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.btn-success {
    color: var(--accent-green);
    border-color: var(--accent-green);
    background-color: transparent;
}

.btn-success:hover {
    background-color: rgba(34, 197, 94, 0.1);
}

.btn-sm {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

/* ===== Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-type-string {
    background-color: rgba(34, 197, 94, 0.15);
    color: var(--accent-green);
}

.badge-type-list {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
}

.badge-type-hash {
    background-color: rgba(168, 85, 247, 0.15);
    color: var(--accent-purple);
}

.badge-type-set {
    background-color: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

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

.tab.active {
    color: var(--accent-red);
    border-bottom-color: var(--accent-red);
}

/* ===== Editor Split ===== */
.editor-split {
    display: flex;
    height: calc(100vh - 240px);
    min-height: 400px;
}

.editor-pane {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.editor-pane-body {
    flex: 1;
    overflow: auto;
    border-radius: 0 0 12px 12px;
}

.editor-pane-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.editor-pane-body {
    flex: 1;
    overflow: auto;
}

.editor-pane-body textarea {
    width: 100%;
    height: 100%;
    padding: 14px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
}

/* ===== Markdown Preview ===== */
.markdown-preview {
    padding: 30px 40px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.8;
    background: transparent;
    max-width: 900px;
    margin: 0 auto;
    box-sizing: border-box;
}

.markdown-preview h1 {
    font-size: 1.8em;
    color: var(--accent-red);
    text-align: center;
    padding: 16px 0 12px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
}

.markdown-preview h2 {
    font-size: 1.4em;
    color: var(--accent-blue);
    text-align: left;
    padding: 12px 0 8px;
    margin: 28px 0 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.markdown-preview h3 {
    font-size: 1.2em;
    color: var(--accent-green);
    text-align: left;
    padding: 8px 0 4px;
    margin: 22px 0 12px;
    font-weight: 700;
}

.markdown-preview p {
    margin-bottom: 12px;
}

.markdown-preview pre {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.markdown-preview code {
    background-color: var(--bg-primary);
    color: var(--accent-green);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
}

.markdown-preview pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

/* Mermaid 图渲染区域 */
.mermaid-render {
    margin: 12px 0;
    overflow-x: auto;
    text-align: center;
    background: transparent;
}

.mermaid-render svg {
    max-width: 100%;
    height: auto;
}

.mermaid-error pre {
    background: #2a0f1e;
    color: #fca5a5;
    padding: 12px 14px;
    border-radius: 6px;
    border: 1px solid rgba(248, 113, 113, 0.3);
    overflow-x: auto;
    font-size: 13px;
}

.mermaid-error code {
    background: none;
    color: inherit;
    white-space: pre;
}

.markdown-preview blockquote {
    border-left: 4px solid var(--accent-red);
    padding-left: 16px;
    color: var(--text-secondary);
    margin: 12px 0;
}

.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

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

.markdown-preview table th {
    background-color: var(--bg-tertiary);
    font-weight: 600;
}

.markdown-preview ul,
.markdown-preview ol {
    margin: 12px 0;
    padding-left: 24px;
}

.markdown-preview li {
    margin-bottom: 4px;
}

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

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

.markdown-preview strong {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px 0;
}

/* ===== Modal/Dialog ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
}

.modal-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Alert ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.alert-success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--accent-green);
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.context-menu-item {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.15s;
}

.context-menu-item:hover {
    background-color: var(--bg-hover);
}

.context-menu-item.danger {
    color: #ef4444;
}

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

/* ===== Status Bar ===== */
.status-bar {
    height: 24px;
    padding: 0 16px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.status-bar-left,
.status-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d23 0%, #2a2f3a 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(220, 56, 45, 0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
    border-radius: 50%;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, transparent 70%);
    bottom: -150px;
    left: -150px;
    border-radius: 50%;
}

.login-card {
    position: relative;
    z-index: 1;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #dc382d, #f97316);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
}

.login-form-group {
    margin-bottom: 20px;
}

.login-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(220, 56, 45, 0.15);
}

.login-input::placeholder {
    color: var(--text-muted);
}

.login-btn {
    width: 100%;
    height: 44px;
    background: linear-gradient(135deg, #dc382d, #e85a4f);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(220, 56, 45, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.login-error {
    padding: 10px 14px;
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #ef4444;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ===== Utility Classes ===== */
.d-none { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ===== Mobile Sidebar Toggle ===== */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-red);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    align-items: center;
    justify-content: center;
}

.mobile-sidebar-toggle:active {
    background: var(--accent-red-hover);
}

.mobile-only {
    display: none;
}

/* Mobile Editor/Preview Toggle */
.mobile-editor-toggle {
    display: none;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.mobile-toggle-btn {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-toggle-btn.active {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: white;
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    /* 基础调整 */
    body {
        font-size: 16px;
    }
    
    /* 头部优化 */
    .app-header {
        padding: 0 12px;
        height: 56px;
    }
    
    .app-header-left {
        gap: 8px;
    }
    
    .app-logo {
        font-size: 14px;
    }
    
    .header-search input {
        width: 100%;
        max-width: 200px;
    }
    
    .connection-info {
        display: none;
    }
    
    /* 主布局调整 */
    .app-main {
        flex-direction: column;
        position: relative;
    }
    
    /* 移动端侧边栏切换按钮显示 */
    .mobile-sidebar-toggle {
        display: flex !important;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    /* 移动端编辑/预览切换显示 */
    .mobile-editor-toggle {
        display: flex !important;
    }
    
    /* 侧边栏 - 移动端覆盖层 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        height: 100dvh; /* 动态视口高度，适配移动端浏览器 */
        z-index: 1000;
        border-right: 1px solid var(--border-color);
        transition: left 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .sidebar.mobile-open {
        left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
        pointer-events: none;
    }
    
    .sidebar-header {
        padding: 12px;
        position: sticky;
        top: 0;
        background-color: var(--bg-secondary);
        z-index: 10;
    }
    
    /* 内容区域 */
    .content-area {
        width: 100%;
    }
    
    .content-toolbar {
        padding: 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .content-toolbar-left {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .content-title {
        font-size: 18px;
        width: 100%;
    }
    
    .content-breadcrumb {
        font-size: 12px;
        width: 100%;
    }
    
    .content-toolbar-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .content-body {
        padding: 12px;
    }
    
    /* 编辑器分栏 - 移动端改为上下布局 */
    .editor-split {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }
    
    .editor-pane {
        min-height: 300px;
    }
    
    /* 表单布局 */
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    /* 键值对显示 */
    .kv-pair {
        flex-direction: column;
        gap: 4px;
    }
    
    .kv-key {
        width: auto;
        padding-top: 0;
    }
    
    /* 按钮优化 - 更大的触摸区域 */
    .btn {
        min-height: 44px;
        padding: 0 16px;
        font-size: 14px;
    }
    
    .btn-sm {
        min-height: 38px;
        padding: 0 12px;
        font-size: 13px;
    }
    
    /* 附件管理区域 */
    .attachment-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .attachment-item > div:last-child {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px !important;
    }
    
    .attachment-item .btn-sm {
        flex: 1;
        min-width: 120px;
    }
    
    /* 模态框 - 移动端全屏 */
    .modal {
        max-width: 95vw;
        max-height: 90vh;
        margin: 16px;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* 标签页 */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        white-space: nowrap;
        padding: 12px 16px;
    }
    
    /* Markdown 预览优化 */
    .markdown-preview {
        font-size: 15px;
        line-height: 1.8;
    }
    
    .markdown-preview pre {
        font-size: 13px;
        padding: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .markdown-preview table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 树形导航 */
    .tree-node-header {
        padding: 10px 12px;
        min-height: 44px;
    }
    
    .tree-label {
        font-size: 14px;
    }
    
    /* 状态栏 */
    .status-bar {
        height: auto;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .status-bar-left,
    .status-bar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    /* 登录页面 */
    .login-card {
        padding: 24px;
        margin: 16px;
        max-width: calc(100% - 32px);
    }
    
    .login-logo-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    .login-logo h1 {
        font-size: 20px;
    }
    
    /* 上下文菜单 */
    .context-menu {
        min-width: 200px;
        max-width: calc(100vw - 32px);
    }
    
    .context-menu-item {
        padding: 12px 16px;
        min-height: 44px;
    }
    
    /* 分享页面适配 */
    .share-layout {
        flex-direction: column;
    }
    
    .share-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .share-main {
        width: 100%;
    }
    
    .share-content {
        padding: 16px;
    }
    
    .share-section {
        margin-bottom: 24px;
    }
    
    /* 表格响应式 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 图片响应式 */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* 代码块优化 */
    code {
        word-break: break-word;
    }
    
    pre code {
        word-break: normal;
        white-space: pre;
    }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
    .app-header {
        padding: 0 8px;
    }
    
    .header-search input {
        max-width: 150px;
    }
    
    .sidebar {
        max-height: 40vh;
    }
    
    .content-body {
        padding: 8px;
    }
    
    .editor-pane {
        min-height: 250px;
    }
    
    .modal {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    
    .btn {
        font-size: 13px;
    }
    
    .attachment-item .btn-sm {
        min-width: 100px;
        font-size: 12px;
    }
}

/* 横屏优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        max-height: 100%;
    }
    
    .editor-split {
        flex-direction: row;
        height: calc(100vh - 120px);
    }
    
    .editor-pane {
        min-height: auto;
    }
    
    .modal {
        max-height: 95vh;
    }
    
    .modal-body {
        max-height: 70vh;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    .btn,
    .btn-sm,
    .sidebar-icon-btn,
    .tree-node-header,
    .context-menu-item,
    .tab {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 移除 hover 效果 */
    .btn:hover,
    .btn-sm:hover,
    .sidebar-icon-btn:hover,
    .header-btn:hover {
        transform: none;
    }
    
    /* 优化点击反馈 */
    .btn:active,
    .btn-sm:active,
    .sidebar-icon-btn:active,
    .tree-node-header:active {
        opacity: 0.7;
    }
}

/* ===== 卡片组件样式 ===== */
.card-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.12) 0%, rgba(167, 139, 250, 0.08) 100%);
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 12px;
    margin: 14px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.card-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-item:hover {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2) 0%, rgba(167, 139, 250, 0.14) 100%);
    border-color: rgba(96, 165, 250, 0.55);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(96, 165, 250, 0.3);
}

.card-item:hover::before {
    opacity: 1;
}

.card-item.file-card {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.12) 0%, rgba(34, 211, 238, 0.08) 100%);
    border-color: rgba(52, 211, 153, 0.28);
}

.card-item.file-card:hover {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.2) 0%, rgba(34, 211, 238, 0.14) 100%);
    border-color: rgba(52, 211, 153, 0.55);
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.3);
}

.card-icon {
    font-size: 30px;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.card-item:hover .card-icon {
    transform: scale(1.05);
}

.card-content {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.card-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

.card-url {
    font-size: 12px;
    color: var(--accent-blue);
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
}

.card-copy-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.12) 0%, rgba(167, 139, 250, 0.08) 100%);
    color: var(--accent-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    z-index: 1;
}

.card-copy-btn:hover {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.28) 0%, rgba(167, 139, 250, 0.18) 100%);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 14px rgba(96, 165, 250, 0.35);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 10000;
    animation: toastSlideUp 0.3s ease;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Upload progress indicator (bottom-right) */
.upload-progress-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.upload-progress-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: uploadSlideIn 0.3s ease;
}

.upload-progress-item .upload-filename {
    font-size: 12px;
    color: var(--text-primary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-progress-item .upload-bar-bg {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-item .upload-bar-fill {
    height: 100%;
    background: var(--accent-blue, #60a5fa);
    border-radius: 2px;
    transition: width 0.2s ease;
    width: 0%;
}

.upload-progress-item .upload-percent {
    font-size: 11px;
    color: var(--text-secondary, #999);
    text-align: right;
    margin-top: 4px;
}

.upload-progress-item.upload-done {
    animation: uploadFadeOut 0.5s ease 1s forwards;
}

.upload-progress-item.upload-error .upload-bar-fill {
    background: #f87171;
}

@keyframes uploadSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes uploadFadeOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* ===== AI 助手面板（常驻占用空间，可调宽度） ===== */
.ai-panel {
    flex: 0 0 auto;
    min-width: 0;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease;
}

body.resizing .ai-panel,
body.resizing .sidebar {
    transition: none;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    flex-shrink: 0;
}

.ai-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.ai-panel-sub {
    flex: 1;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-panel-close {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ai-panel-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* 引用区 */
.ai-refs {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    background: var(--bg-primary);
}

.ai-refs-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.ai-refs-count {
    background: var(--accent-red);
    color: #fff;
    font-size: 10px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 10px;
}

.ai-refs-clear {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
}

.ai-refs-clear:hover {
    color: var(--accent-red);
    background: var(--bg-hover);
}

.ai-refs-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    padding: 6px 4px;
    display: none;
}

/* ===== 引用复制编辑器 ===== */
.ai-refs-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-refs-editor {
    flex: 1;
    min-height: 80px;
    max-height: 400px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 0 12px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
    overflow-y: auto;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-word;
    resize: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-refs-editor:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.15);
}

.ai-refs-editor:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
    pointer-events: none;
}

.ai-refs-editor:empty:focus::before {
    content: "";
}

/* Tags inside editor */
.ai-ref-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px 6px;
    margin: 0 2px;
    font-size: 12px;
    color: var(--accent-blue);
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
}

.ai-ref-tag:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

.ai-ref-tag-icon {
    flex-shrink: 0;
}

.ai-ref-tag-remove {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.ai-ref-tag-remove:hover {
    color: var(--accent-red);
    background: var(--bg-hover);
}

/* ===== 复制按钮 ===== */
.ai-copy-wrap {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.ai-copy-btn {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: var(--accent-red);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.ai-copy-btn:hover {
    background: var(--accent-red-hover);
    transform: translateY(-1px);
}

/* 树节点拖拽提示 */
.tree-node-header[draggable="true"] {
    cursor: grab;
}

.tree-node-header[draggable="true"]:active {
    cursor: grabbing;
}

/* ===== 面板宽度调节手柄 ===== */
.sidebar-resizer,
.ai-resizer {
    width: 6px;
    flex: 0 0 6px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 5;
    transition: background 0.15s;
}

.sidebar-resizer:hover,
.sidebar-resizer.active,
.ai-resizer:hover,
.ai-resizer.active {
    background: rgba(255, 107, 107, 0.25);
}

body.resizing {
    user-select: none;
    cursor: col-resize;
}

/* ===== index 页面：左侧树常驻（非抽屉） ===== */
/* 覆盖移动端把 .sidebar 变成抽屉的规则，让左侧树始终占用布局空间 */
.memkv-index .app-main {
    flex-direction: row;
}

.memkv-index .sidebar {
    position: relative;
    left: auto;
    top: auto;
    width: 300px;
    max-width: none;
    height: auto;
    border-right: 1px solid var(--border-color);
    transition: none;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

.memkv-index .mobile-sidebar-toggle,
.memkv-index .sidebar-overlay,
.memkv-index .mobile-only {
    display: none !important;
}

/* AI 面板在窄屏下不超过视口宽 */
.memkv-index .ai-panel {
    max-width: 60vw;
}

/* 常驻侧栏布局下内容区自动伸缩 */
.memkv-index .content-area {
    width: auto;
    flex: 1;
    min-width: 0;
}

/* ===== 窄屏：引用复制面板移到主体编辑器下方（左侧栏保持不变） ===== */
@media (max-width: 1100px) {
    .memkv-index .app-main {
        display: grid;
        grid-template-columns: auto 6px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
    }

    /* 左侧栏纵向贯通两行，行为与宽屏一致 */
    .memkv-index .sidebar {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .memkv-index .sidebar-resizer {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    .memkv-index .content-area {
        grid-column: 3;
        grid-row: 1;
        min-height: 0;
    }

    /* 右侧宽度手柄在窄屏下无意义，隐藏 */
    .memkv-index .ai-resizer {
        display: none;
    }

    .memkv-index .ai-panel {
        grid-column: 3;
        grid-row: 2;
        width: 100% !important;
        max-width: none !important;
        height: clamp(180px, 32vh, 320px);
        border-left: none;
        border-top: 1px solid var(--border-color);
        transition: none;
    }
}
