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

/* ===== EDITOR PRODUCTIVITY TOOLS ===== */
.editor-find-panel {
    flex-shrink: 0;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.editor-find-panel[hidden], .editor-find-row[hidden],
.editor-replace-row[hidden], .editor-goto-row[hidden] { display: none; }
.editor-find-row, .editor-replace-row, .editor-goto-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.editor-replace-row, .editor-goto-row { margin-top: 6px; }
.editor-find-row input, .editor-replace-row input, .editor-goto-row input {
    width: min(360px, 42vw);
    height: 29px;
    box-sizing: border-box;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: 12px var(--font-mono);
}
.editor-find-row input:focus, .editor-replace-row input:focus,
.editor-goto-row input:focus { border-color: var(--accent); }
.editor-find-count {
    min-width: 54px;
    color: var(--text-muted);
    font: 11px var(--font-mono);
    text-align: center;
}
.editor-tool-toggle {
    min-width: 29px;
    height: 27px;
    padding: 0 5px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font: 600 11px var(--font-ui);
    cursor: pointer;
}
.editor-tool-toggle:hover, .editor-tool-toggle[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}
.editor-find-active {
    border-radius: 2px;
    outline: 1px solid var(--warning);
    background: var(--warning-soft-bg);
}
.editor-text-statusbar {
    display: flex;
    min-height: 25px;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 0 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font: 11px var(--font-mono);
    white-space: nowrap;
}
.editor-text-statusbar[hidden] { display: none; }

#editorModal .fullscreen-modal-inner { position: relative; }
#editorModal .CodeMirror.editor-minimap-enabled {
    box-sizing: border-box;
    padding-right: 96px;
}
.editor-minimap {
    position: absolute;
    z-index: 8;
    top: 0;
    right: 0;
    bottom: 0;
    width: 96px;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
}
.editor-minimap[hidden] { display: none; }
.editor-minimap canvas {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.editor-minimap-viewport {
    position: absolute;
    z-index: 1;
    top: 0;
    right: 2px;
    left: 2px;
    min-height: 18px;
    box-sizing: border-box;
    border: 1px solid var(--accent-soft-border);
    background: var(--accent-dim);
    pointer-events: none;
}
.editor-scroll-actions {
    position: absolute;
    z-index: 20;
    right: 14px;
    bottom: 34px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: right 0.15s;
}
.editor-scroll-actions[hidden] { display: none; }
.editor-minimap-active .editor-scroll-actions { right: 110px; }
.editor-scroll-actions button {
    display: flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--cyber-border);
    border-radius: 50%;
    background: var(--panel-bg);
    box-shadow: var(--shadow-md);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.editor-scroll-actions button[hidden] { display: none; }
.editor-scroll-actions button:hover {
    border-color: var(--cyber-primary);
    color: var(--cyber-primary);
    transform: translateY(-1px);
}

.quick-open-backdrop {
    position: fixed;
    inset: 0;
    z-index: 950;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 11vh;
    background: rgba(0, 0, 0, 0.42);
}
.quick-open-backdrop[hidden] { display: none; }
.quick-open-dialog {
    width: min(680px, calc(100vw - 48px));
    overflow: hidden;
    border: 1px solid var(--cyber-border);
    border-radius: 7px;
    background: var(--panel-bg);
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
}
.quick-open-input-row {
    display: flex;
    height: 46px;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border-bottom: 1px solid var(--border);
}
.quick-open-input-row > i { color: var(--text-muted); }
.quick-open-input-row input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: 14px var(--font-ui);
}
.quick-open-input-row kbd {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font: 10px var(--font-mono);
}
.quick-open-caption {
    padding: 7px 13px 4px;
    color: var(--text-muted);
    font-size: 11px;
}
.quick-open-results {
    max-height: min(440px, 58vh);
    overflow-y: auto;
    padding: 3px 6px 7px;
}
.quick-open-item {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    padding: 5px 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
}
.quick-open-item:hover { background: var(--control-hover-bg); color: var(--text-primary); }
.quick-open-item.selected { background: var(--control-selected-bg); color: var(--control-selected-text); }
.quick-open-item.selected:hover { background: var(--control-selected-hover-bg); }
.quick-open-item > i { width: 18px; color: var(--text-muted); text-align: center; }
.quick-open-item-text {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 2px;
}
.quick-open-item-text strong, .quick-open-item-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.quick-open-item-text strong { font-size: 13px; font-weight: 500; }
.quick-open-item-text small { color: var(--text-muted); font: 11px var(--font-mono); }
.quick-open-empty { padding: 24px 12px; color: var(--text-muted); font-size: 12px; text-align: center; }

.editor-conflict-dialog { width: min(560px, calc(100vw - 40px)); }
.editor-conflict-dialog .modal-header h2 i { margin-right: 7px; color: var(--warning); }
.editor-conflict-dialog .modal-body { padding: 18px 20px 8px; }
.editor-conflict-dialog .modal-body p { margin: 0 0 9px; line-height: 1.6; }
.editor-conflict-hint { color: var(--text-muted); font-size: 12px; }
.editor-conflict-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 18px;
}
.editor-conflict-actions [hidden] { display: none; }
@media (max-width: 1100px) {
    .editor-text-statusbar { gap: 9px; }
    #editorSelectionStatus, #editorTextSize { display: none; }
}

/* ============================================================
   THEME SYSTEM
   default = white/light (original)
   blue    = dark navy blue
   dark    = dark black cyber
   gray    = dark gray
   ============================================================ */

/* --- Default / White theme (base variables) --- */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e8eaed;
    --bg-input: #ffffff;
    --bg-inverse: #323232;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #5f697b;
    --text-inverse: #ffffff;
    --accent: #0066cc;
    --accent-hover: #0055aa;
    --accent-dim: rgba(0, 102, 204, 0.1);
    --accent-rgb: 0, 102, 204;
    --accent-soft-bg: rgba(0, 102, 204, 0.10);
    --accent-medium-bg: rgba(0, 102, 204, 0.20);
    --accent-soft-border: rgba(0, 102, 204, 0.30);
    --control-hover-bg: rgba(var(--accent-rgb), 0.08);
    --control-selected-bg: rgba(var(--accent-rgb), 0.16);
    --control-selected-hover-bg: rgba(var(--accent-rgb), 0.18);
    --control-selected-text: var(--text-primary);
    --control-selected-muted: var(--text-secondary);
    --action-bg: #0066cc;
    --action-hover: #0055aa;
    --action-fg: #ffffff;
    --border: #e0e0e0;
    --success: #168449;
    --success-action: #168449;
    --success-action-hover: #126f3d;
    --warning: #9a6700;
    --warning-soft-bg: rgba(217, 119, 6, 0.12);
    --warning-soft-border: rgba(217, 119, 6, 0.38);
    --error: #c5221f;
    --error-hover: #a50e0e;
    --error-soft-bg: rgba(197, 34, 31, 0.09);
    --error-soft-border: rgba(197, 34, 31, 0.32);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 38px rgba(0, 0, 0, 0.18);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius: var(--radius-sm);
    --font-mono: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Courier New', 'Noto Emoji', monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans CJK SC', Roboto, 'Noto Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    /* new layout vars */
    --panel-bg: rgba(255,255,255,0.98);
    --header-bg: rgba(255,255,255,0.98);
    --sidebar-bg: rgba(248,249,250,0.98);
    --cyber-primary: #0066cc;
    --cyber-muted: #4676a6;
    --cyber-border: rgba(0,102,204,0.25);
    --cyber-strong-border: rgba(0,102,204,0.60);
    --cyber-soft-bg: rgba(0,102,204,0.10);
    --cyber-medium-bg: rgba(0,102,204,0.20);
    --cyber-glow-soft: rgba(0,102,204,0.15);
    --cyber-glow-medium: rgba(0,102,204,0.20);
    --grid-color: rgba(0,102,204,0.05);
    --nav-active-bg: rgba(0,102,204,0.10);
    --floating-bg: rgba(255,255,255,0.97);
    --right-sidebar-bg: rgba(248,249,250,0.98);
    --highlight-bg: #ffe066;
    --highlight-color: #333;
    --scroll-to-top-btn-bottom: 170px;
    --scroll-to-bottom-btn-bottom: 130px;
    --star-active: var(--warning);
    --star-inactive: var(--text-muted);
    --success-soft-bg: rgba(34,197,94,0.15);
    --success-soft-border: rgba(34,197,94,0.35);
    --bg-code: #f3f4f6;
    --text-code: #202124;
    --border-code: #b8c9dc;
    --border-strong: #aeb7c2;
    --history-cyan: #087990;
    --history-purple: #7e22ce;
    --history-green: var(--success);
    --history-yellow: var(--warning);
    --history-blue: #1d4ed8;
    --syntax-keyword: #7c3aed;
    --syntax-type: #0f766e;
    --syntax-def: #1d4ed8;
    --syntax-variable: #0369a1;
    --syntax-number: #b45309;
    --syntax-string: #9f1239;
    --syntax-comment: #626b78;
    --syntax-meta: #be123c;
    --syntax-builtin: #92400e;
    --syntax-tag: #047857;
    --syntax-operator: #475569;
    /* Compatibility aliases for older component styles. */
    --border-color: var(--border);
    --bg-hover: var(--bg-tertiary);
    --text-tertiary: var(--text-muted);
    --card-bg: var(--bg-primary);
    --text: var(--text-primary);
    --hover-bg: var(--bg-tertiary);
    --tag-bg: var(--accent-dim);
    --tag-color: var(--accent);
    --primary: var(--accent);
    --primary-hover: var(--accent-hover);
}

.star-active-icon { color: var(--star-active); }
.star-inactive-icon { color: var(--star-inactive); opacity: 0.4; }

/* --- Blue theme --- */
[data-theme="blue"] {
    --bg-primary: #0d1b2e;
    --bg-secondary: #0a1628;
    --bg-tertiary: #0f2040;
    --bg-input: #0d1b2e;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #8496ad;
    --accent: #4da6ff;
    --accent-hover: #3d96ef;
    --accent-dim: rgba(77,166,255,0.15);
    --accent-rgb: 77, 166, 255;
    --accent-soft-bg: rgba(77,166,255,0.10);
    --accent-medium-bg: rgba(77,166,255,0.20);
    --accent-soft-border: rgba(77,166,255,0.30);
    --action-bg: #1b6fae;
    --action-hover: #155f98;
    --action-fg: #ffffff;
    --border: rgba(77,166,255,0.2);
    --success: #34d399;
    --success-action: #168449;
    --success-action-hover: #126f3d;
    --warning: #f6c453;
    --warning-soft-bg: rgba(246, 196, 83, 0.13);
    --warning-soft-border: rgba(246, 196, 83, 0.42);
    --error: #f87171;
    --error-hover: #ef5b5b;
    --error-soft-bg: rgba(248, 113, 113, 0.12);
    --error-soft-border: rgba(248, 113, 113, 0.38);
    --shadow: 0 1px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 38px rgba(0,0,0,0.58);
    --panel-bg: rgba(10,22,40,0.92);
    --header-bg: rgba(10,22,40,0.95);
    --sidebar-bg: rgba(8,18,36,0.95);
    --cyber-primary: #4da6ff;
    --cyber-muted: #7fb5e6;
    --cyber-border: rgba(77,166,255,0.3);
    --cyber-strong-border: rgba(77,166,255,0.60);
    --cyber-soft-bg: rgba(77,166,255,0.10);
    --cyber-medium-bg: rgba(77,166,255,0.20);
    --cyber-glow-soft: rgba(77,166,255,0.15);
    --cyber-glow-medium: rgba(77,166,255,0.20);
    --grid-color: rgba(77,166,255,0.07);
    --nav-active-bg: rgba(77,166,255,0.12);
    --floating-bg: rgba(10,22,40,0.97);
    --right-sidebar-bg: rgba(8,18,36,0.95);
    --highlight-bg: rgba(77,166,255,0.3);
    --highlight-color: #e2e8f0;
    --bg-code: #111f33;
    --text-code: #dbe7f3;
    --border-code: #315579;
    --border-strong: #46698d;
    --star-active: var(--warning);
}
[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: #0f0f18;
    --bg-tertiary: #15151f;
    --bg-input: #0a0a0f;
    --text-primary: #e0e0e8;
    --text-secondary: #9a9ab2;
    --text-muted: #85859f;
    --accent: #45c4cc;
    --accent-hover: #38aeb6;
    --accent-dim: rgba(69,196,204,0.12);
    --accent-rgb: 69, 196, 204;
    --accent-soft-bg: rgba(69,196,204,0.10);
    --accent-medium-bg: rgba(69,196,204,0.20);
    --accent-soft-border: rgba(69,196,204,0.30);
    --action-bg: #00747c;
    --action-hover: #00636a;
    --action-fg: #ffffff;
    --border: rgba(69,196,204,0.22);
    --success: #45d79a;
    --success-action: #168449;
    --success-action-hover: #126f3d;
    --warning: #f0b84b;
    --warning-soft-bg: rgba(240, 184, 75, 0.13);
    --warning-soft-border: rgba(240, 184, 75, 0.42);
    --error: #ff4466;
    --error-hover: #e73555;
    --error-soft-bg: rgba(255, 68, 102, 0.12);
    --error-soft-border: rgba(255, 68, 102, 0.4);
    --shadow: 0 1px 4px rgba(0,0,0,0.6);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.7);
    --shadow-lg: 0 12px 38px rgba(0,0,0,0.72);
    --panel-bg: rgba(15,15,25,0.9);
    --header-bg: rgba(10,10,15,0.95);
    --sidebar-bg: rgba(8,8,14,0.95);
    --cyber-primary: #45c4cc;
    --cyber-muted: #78b9bd;
    --cyber-border: rgba(69,196,204,0.28);
    --cyber-strong-border: rgba(69,196,204,0.60);
    --cyber-soft-bg: rgba(69,196,204,0.10);
    --cyber-medium-bg: rgba(69,196,204,0.20);
    --cyber-glow-soft: rgba(69,196,204,0.15);
    --cyber-glow-medium: rgba(69,196,204,0.20);
    --grid-color: rgba(69,196,204,0.045);
    --nav-active-bg: rgba(69,196,204,0.11);
    --floating-bg: rgba(10,10,15,0.97);
    --right-sidebar-bg: rgba(8,8,14,0.95);
    --highlight-bg: rgba(69,196,204,0.25);
    --highlight-color: #e0e0e8;
    --bg-code: #1a1a2e;
    --text-code: #cdd6f4;
    --border-code: #45475a;
    --border-strong: #595b70;
    --star-active: var(--warning);
}
[data-theme="gray"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #222222;
    --bg-tertiary: #2a2a2a;
    --bg-input: #1a1a1a;
    --text-primary: #dedede;
    --text-secondary: #a3a3a3;
    --text-muted: #929292;
    --accent: #71aaa4;
    --accent-hover: #86bbb6;
    --accent-dim: rgba(113,170,164,0.13);
    --accent-rgb: 113, 170, 164;
    --accent-soft-bg: rgba(113,170,164,0.10);
    --accent-medium-bg: rgba(113,170,164,0.20);
    --accent-soft-border: rgba(113,170,164,0.32);
    --action-bg: #356f6b;
    --action-hover: #2b5e5a;
    --action-fg: #ffffff;
    --border: rgba(170,170,170,0.28);
    --success: #60c060;
    --success-action: #287a45;
    --success-action-hover: #21663a;
    --warning: #dfb85b;
    --warning-soft-bg: rgba(223, 184, 91, 0.13);
    --warning-soft-border: rgba(223, 184, 91, 0.4);
    --error: #e06060;
    --error-hover: #c84f4f;
    --error-soft-bg: rgba(224, 96, 96, 0.12);
    --error-soft-border: rgba(224, 96, 96, 0.38);
    --shadow: 0 1px 4px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.6);
    --shadow-lg: 0 12px 38px rgba(0,0,0,0.66);
    --panel-bg: rgba(30,30,30,0.92);
    --header-bg: rgba(25,25,25,0.97);
    --sidebar-bg: rgba(20,20,20,0.97);
    --cyber-primary: #71aaa4;
    --cyber-muted: #9badab;
    --cyber-border: rgba(113,170,164,0.32);
    --cyber-strong-border: rgba(113,170,164,0.60);
    --cyber-soft-bg: rgba(113,170,164,0.10);
    --cyber-medium-bg: rgba(113,170,164,0.20);
    --cyber-glow-soft: rgba(113,170,164,0.14);
    --cyber-glow-medium: rgba(113,170,164,0.20);
    --grid-color: rgba(113,170,164,0.035);
    --nav-active-bg: rgba(113,170,164,0.12);
    --floating-bg: rgba(25,25,25,0.97);
    --right-sidebar-bg: rgba(20,20,20,0.97);
    --highlight-bg: rgba(113,170,164,0.24);
    --highlight-color: #dedede;
    --bg-code: #242424;
    --text-code: #dedede;
    --border-code: #555555;
    --border-strong: #686868;
    --star-active: var(--warning);
}

[data-theme="blue"],
[data-theme="dark"],
[data-theme="gray"] {
    /* Re-resolve aliases in the themed element instead of inheriting values
       computed against :root's default palette. */
    --control-hover-bg: rgba(var(--accent-rgb), 0.08);
    --control-selected-bg: rgba(var(--accent-rgb), 0.16);
    --control-selected-hover-bg: rgba(var(--accent-rgb), 0.18);
    --control-selected-text: var(--text-primary);
    --control-selected-muted: var(--text-secondary);
    --border-color: var(--border);
    --bg-hover: var(--bg-tertiary);
    --text-tertiary: var(--text-muted);
    --card-bg: var(--bg-primary);
    --text: var(--text-primary);
    --hover-bg: var(--bg-tertiary);
    --tag-bg: var(--accent-dim);
    --tag-color: var(--accent);
    --primary: var(--accent);
    --primary-hover: var(--accent-hover);
    --star-inactive: var(--text-muted);
    --history-cyan: #22d3ee;
    --history-purple: #c084fc;
    --history-green: #4ade80;
    --history-yellow: #facc15;
    --history-blue: #60a5fa;
    --syntax-keyword: #c792ea;
    --syntax-type: #89ddff;
    --syntax-def: #82aaff;
    --syntax-variable: #80cbc4;
    --syntax-number: #f78c6c;
    --syntax-string: #c3e88d;
    --syntax-comment: #95a1ad;
    --syntax-meta: #ffcb6b;
    --syntax-builtin: #f07178;
    --syntax-tag: #c3e88d;
    --syntax-operator: #89ddff;
}

/* Theme transition */
body, .header, .sidebar, .right-sidebar, .floating-input-bar,
.theme-dropdown-menu, .right-sidebar-inner, .fullscreen-modal-inner {
    transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

/* Theme changes use the component color transitions above. */
.theme-flash-overlay {
    display: none;
}

/* Cyber background grid */
.cyber-grid {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: none;
    pointer-events: none; z-index: 0;
}
@keyframes gridMove {
    0% { transform: translateY(0); }
    100% { transform: translateY(50px); }
}

body.performance-mode *,
body.performance-mode *::before,
body.performance-mode *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body.performance-mode .cyber-grid,
body.performance-mode .scanlines {
    display: none !important;
}

body.performance-mode .header,
body.performance-mode .sidebar,
body.performance-mode .right-sidebar,
body.performance-mode .right-sidebar-inner,
body.performance-mode .assistant-bubble,
body.performance-mode .floating-input-bar,
body.performance-mode .modal-content,
body.performance-mode .theme-dropdown-menu,
body.performance-mode .context-menu {
    box-shadow: none !important;
}

body.performance-mode .header,
body.performance-mode .floating-input-bar {
    background: var(--bg-primary) !important;
}
/* Scanlines */
.scanlines {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom,
        rgba(255,255,255,0), rgba(255,255,255,0) 50%,
        rgba(0,0,0,0.04) 50%, rgba(0,0,0,0.04));
    background-size: 100% 4px;
    pointer-events: none; z-index: 2; opacity: 0.2;
}
/* hide heavy effects in default/light theme */
:root .cyber-grid { opacity: 0.6; }
:root .scanlines { opacity: 0.05; }
[data-theme="dark"] .cyber-grid { opacity: 0.5; }
[data-theme="dark"] .scanlines { opacity: 0.10; }
[data-theme="blue"] .cyber-grid { opacity: 0.45; }
[data-theme="blue"] .scanlines { opacity: 0.07; }
[data-theme="gray"] .cyber-grid { opacity: 0.25; }
[data-theme="gray"] .scanlines { opacity: 0.05; }

/* Corner accents */
.corner-accent {
    position: absolute; width: 16px; height: 16px;
    border: 2px solid var(--cyber-border); pointer-events: none; z-index: 5;
}
.corner-tl { top: 4px; left: 4px; border-right: 0; border-bottom: 0; }
.corner-tr { top: 4px; right: 4px; border-left: 0; border-bottom: 0; }
.corner-bl { bottom: 4px; left: 4px; border-right: 0; border-top: 0; }
.corner-br { bottom: 4px; right: 4px; border-left: 0; border-top: 0; }

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 10;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--cyber-border);
    gap: 0;
    min-height: 56px;
    flex-shrink: 0;
    backdrop-filter: blur(12px);
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.header-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--cyber-primary);
    text-shadow: 0 0 10px var(--cyber-primary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* White theme removes data-theme from body. */
body:not([data-theme]) .header-title {
    text-shadow: none;
}

.header-version {
    font-size: 11px;
    font-family: monospace;
    color: var(--cyber-muted);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 6px;
    align-self: center;
    letter-spacing: 0.02em;
}

.session-workdir-chip {
    min-width: 0;
    max-width: 230px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font: 12px var(--font-ui);
    cursor: pointer;
    flex-shrink: 1;
}
.session-workdir-chip[hidden] { display: none; }
.session-workdir-chip i { color: var(--accent); flex: none; }
.session-workdir-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-workdir-chip:hover { color: var(--text-primary); border-color: var(--accent); background: var(--bg-hover); }

.header-nav-divider {
    width: 1px;
    height: 20px;
    background: var(--cyber-border);
    margin: 0 6px;
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.18s;
    border: 1px solid transparent;
}
.nav-link:hover {
    color: var(--cyber-primary);
    background: var(--nav-active-bg);
}
/* nav-action: opens a modal/action, no persistent active state */
.nav-link.nav-action:hover {
    color: var(--cyber-primary);
    background: var(--nav-active-bg);
}
.nav-link.active {
    color: var(--cyber-primary);
    background: var(--nav-active-bg);
    border-color: var(--cyber-border);
}
.nav-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-divider {
    width: 1px;
    height: 20px;
    background: var(--cyber-border);
    flex-shrink: 0;
}

/* Header skill button */
.skill-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--accent-soft-bg);
    border: 1px solid var(--cyber-primary);
    border-radius: 6px;
    color: var(--cyber-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}
.skill-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    transition: left 0.5s;
}
.skill-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 16px var(--accent-dim);
}
.skill-btn:hover::before { left: 100%; }

/* Header icon button (compact) */
.header-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.18s;
    display: flex;
    align-items: center;
}
.header-icon-btn:hover {
    color: var(--cyber-primary);
    background: var(--nav-active-bg);
    border-color: var(--cyber-border);
}

/* Theme dropdown */
.theme-dropdown { position: relative; z-index: 1000; }
.theme-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--accent-dim);
    border: 1px solid var(--cyber-border);
    border-radius: 6px;
    color: var(--cyber-primary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.18s;
}
.theme-btn:hover { background: var(--nav-active-bg); }
.theme-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--cyber-border);
    border-radius: 8px;
    padding: 6px;
    min-width: 150px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    z-index: 99999;
    display: none;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.theme-dropdown-menu.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: background 0.15s;
}
.theme-option:hover { background: var(--nav-active-bg); color: var(--cyber-primary); }
.theme-option.active { background: var(--nav-active-bg); color: var(--cyber-primary); font-weight: 600; }
.theme-color-preview {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(128,128,128,0.3);
    flex-shrink: 0;
}

/* conn dot / username */
.conn-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    transition: background 0.4s;
    flex-shrink: 0;
}
.conn-dot.offline { background: var(--error); }

/* User avatar in header */
.header-user-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    margin-right: 4px;
    position: relative;
}
.header-username {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-avatar {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg,#06b6d4,#3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.header-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.header-avatar span {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.header-avatar .notification-badge {
    position: absolute;
    right: -7px;
    bottom: -6px;
    display: flex;
    min-width: 19px;
    height: 19px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-primary);
    border-radius: 10px;
    background: var(--error);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    text-shadow: none;
    box-shadow: var(--shadow);
}
.header-avatar .notification-badge[hidden] { display: none; }
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    width: min(320px, calc(100vw - 24px));
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    z-index: 1000;
}
.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.user-dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 6px;
}
.user-dropdown-item[hidden] {
    display: none;
}
.user-dropdown-item:hover {
    background: var(--nav-active-bg);
}
.user-dropdown-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.user-notification-panel {
    margin: 8px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
}
.user-notification-panel[hidden] { display: none; }
.user-notification-heading {
    display: flex;
    min-height: 25px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 12px;
}
.user-notification-heading > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}
.user-notification-heading button,
.user-notification-all {
    border: 0;
    background: transparent;
    color: var(--accent);
    font: 600 12px var(--font-ui);
    cursor: pointer;
}
.user-notification-heading button:hover,
.user-notification-all:hover { color: var(--accent-hover); }
.user-notification-count {
    width: fit-content;
    margin: 3px 0 7px;
    padding: 2px 7px;
    border-radius: 8px;
    background: var(--error);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}
.user-notification-count[hidden] { display: none; }
.user-notification-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.user-notification-item {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: var(--bg-primary);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
}
.user-notification-item:hover {
    border-color: var(--accent-soft-border);
    background: var(--control-hover-bg);
}
.user-notification-item strong,
.user-notification-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-notification-item strong { font-size: 12px; font-weight: 600; }
.user-notification-item span { margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.user-notification-empty {
    padding: 10px 4px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.user-notification-all {
    width: 100%;
    margin-top: 7px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.user-notification-all:hover {
    border-color: var(--accent-soft-border);
    background: var(--control-hover-bg);
    color: var(--accent);
}

/* Keep old .icon-btn for hamburger */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 7px;
    border-radius: 6px;
    transition: background 0.18s;
    display: flex;
    align-items: center;
}
.icon-btn:hover { background: var(--nav-active-bg); color: var(--cyber-primary); }

/* ===== MAIN 3-COLUMN CONTAINER ===== */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

/* Sidebar */
.activity-bar {
    flex: 0 0 44px;
    width: 44px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 0;
    z-index: 210;
}

.activity-bar-btn {
    position: relative;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 19px;
}

.activity-bar-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 8px;
    background: var(--error);
    color: #fff;
    font: 10px/14px var(--font-ui);
    text-align: center;
    box-sizing: border-box;
}

.activity-bar-btn::before {
    content: '';
    position: absolute;
    top: 7px;
    bottom: 7px;
    left: 0;
    width: 2px;
    background: transparent;
}

.activity-bar-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.activity-bar-btn.active { color: var(--cyber-primary); }
.activity-bar-btn.active::before { background: var(--cyber-primary); }
.activity-bar-collapse {
    margin-top: auto;
    font-size: 14px;
    border-top: 1px solid var(--border);
}
.activity-bar-collapse.sidebar-is-collapsed { color: var(--cyber-primary); }

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.sidebar-view {
    display: none;
    min-width: 0;
    min-height: 0;
    height: 100%;
    flex-direction: column;
}

.sidebar-view.active { display: flex; }

.sidebar.collapsed {
    width: 0;
    opacity: 0;
    overflow: hidden;
}

.sidebar.collapsed + .sidebar-resizer {
    display: none;
}

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

.sidebar-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--cyber-primary);
    font-size: 13px;
    font-weight: 700;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-header-buttons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-header-buttons > button {
    width: 24px;
    height: 24px;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn,
.sidebar-refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.sidebar-collapse-btn:hover,
.sidebar-refresh-btn:hover {
    background: var(--bg-tertiary);
}

.sidebar-refresh-btn:active {
    animation: spin 0.5s ease-in-out;
}

/* File transfer sidebar */
.file-transfer-sidebar-header { min-height: 43px; box-sizing: border-box; }
.file-transfer-sidebar-header .sidebar-header-title { gap: 7px; }
.file-transfer-sections {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 18px;
}
.file-transfer-section { border-bottom: 1px solid var(--border); }
.file-transfer-section-title {
    min-height: 34px;
    padding: 7px 12px 6px 16px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    box-sizing: border-box;
}
.file-transfer-count {
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}
.file-transfer-list { padding: 0 8px 8px; }
.file-transfer-state { padding: 13px 8px; color: var(--text-muted); font-size: 11px; text-align: center; }
.file-transfer-card {
    margin: 3px 0;
    padding: 9px 8px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}
.file-transfer-card:hover { border-color: var(--accent); background: var(--bg-tertiary); }
.file-transfer-card-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; }
.file-transfer-card-title i { color: var(--accent); flex: 0 0 auto; }
.file-transfer-card-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-transfer-card-meta { margin-top: 4px; color: var(--text-secondary); font-size: 10px; line-height: 1.45; }
.file-transfer-card-status { margin-top: 4px; color: var(--text-muted); font-size: 10px; }
.file-transfer-progress { height: 4px; margin-top: 7px; overflow: hidden; border-radius: 3px; background: var(--bg-tertiary); }
.file-transfer-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.file-transfer-task-card.failed { border-left-color: var(--error); }
.file-transfer-task-card.failed .file-transfer-progress span { background: var(--error); }
.file-transfer-card-actions { display: flex; justify-content: flex-end; gap: 5px; margin-top: 7px; }
.file-transfer-card-actions button { min-height: 24px; padding: 2px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; font-size: 11px; }
.file-transfer-card-actions button:hover { border-color: var(--accent); color: var(--text-primary); }
.file-transfer-card-actions button[aria-label] { width: 26px; padding: 2px 0; }
.file-transfer-card-actions .accept { border-color: var(--success-soft-border); color: var(--success); }
.file-transfer-card-actions .reject { border-color: var(--error-soft-border); color: var(--error); }
.file-transfer-card-actions .choose-directory { border-color: var(--border); color: var(--text-secondary); }
.file-transfer-filter { margin-left: auto; display: flex; gap: 2px; }
.file-transfer-filter button { padding: 2px 4px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 10px; }
.file-transfer-filter button.active { color: var(--accent); font-weight: 700; }
.file-transfer-clear-btn { margin-left: 3px; padding: 2px 5px !important; }
.file-transfer-record-card { position: relative; cursor: default; }
.file-transfer-card[data-transfer-note]::after {
    content: '备注：' attr(data-transfer-note);
    position: absolute;
    left: 8px;
    right: 8px;
    top: calc(100% + 4px);
    z-index: 4;
    display: -webkit-box;
    max-width: 290px;
    max-height: 3.2em;
    padding: 6px 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--floating-bg);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-size: 11px;
    line-height: 1.6;
    opacity: 0;
    pointer-events: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    transition: opacity .12s ease;
}
.file-transfer-card[data-transfer-note]:hover::after { opacity: 1; }
.file-transfer-card-title .file-transfer-card-menu-btn {
    flex: 0 0 24px;
    width: 24px;
    height: 22px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
}
.file-transfer-card:hover .file-transfer-card-menu-btn,
.file-transfer-card-menu-btn:focus { opacity: 1; }
.file-transfer-card-menu-btn:hover { color: var(--text-primary); background: var(--control-hover-bg); }
.file-transfer-record-menu { position: fixed; z-index: 3001; min-width: 150px; display: block !important; padding: 4px 0; background: var(--floating-bg); }
.file-transfer-record-menu .context-menu-item { width: 100%; box-sizing: border-box; text-align: left; }
.file-transfer-record-menu button.context-menu-item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    padding: 10px 16px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    line-height: 1.35;
    appearance: none;
    -webkit-appearance: none;
}
.file-transfer-record-menu button.context-menu-item:hover,
.file-transfer-record-menu button.context-menu-item:focus,
.file-transfer-record-menu button.context-menu-item:focus-visible {
    outline: 0;
    background: var(--control-hover-bg);
    color: var(--accent);
}
.file-transfer-record-menu button.context-menu-item .context-menu-icon { flex: 0 0 16px; }

.file-transfer-share-modal-content { width: 560px; max-width: calc(100vw - 28px); }
.file-transfer-share-body { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 20px; }
.file-transfer-share-file { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.file-transfer-share-file > i { color: var(--accent); font-size: 18px; }
.file-transfer-share-file > div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-transfer-share-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); font-size: 13px; }
.file-transfer-share-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font: 10px var(--font-mono); }
.file-transfer-share-note { display: flex; flex-direction: column; gap: 5px; color: var(--text-secondary); font-size: 11px; }
.file-transfer-share-note textarea { width: 100%; box-sizing: border-box; min-height: 66px; resize: vertical; padding: 8px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: 0; background: var(--bg-primary); color: var(--text-primary); font: 12px/1.55 var(--font-ui); }
.file-transfer-share-note textarea:focus { border-color: var(--accent); }
.file-transfer-note-modal-content { width: 460px; max-width: calc(100vw - 28px); }
.file-transfer-note-body { padding: 18px 20px 20px; }
.file-transfer-note-body p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-primary); font: 13px/1.7 var(--font-ui); }
.file-transfer-user-search { display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-muted); }
.file-transfer-user-search:focus-within { border-color: var(--accent); }
.file-transfer-user-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text-primary); font: 12px var(--font-ui); }
.file-transfer-user-list { min-height: 92px; max-height: 230px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-primary); }
.file-transfer-user-row { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text-primary); cursor: pointer; text-align: left; }
.file-transfer-user-row:last-child { border-bottom: 0; }
.file-transfer-user-row:hover { background: var(--control-hover-bg); }
.file-transfer-user-row:focus { outline: 0; background: var(--control-hover-bg); }
.file-transfer-user-row.selected { background: var(--control-selected-bg); box-shadow: inset 3px 0 0 var(--accent); }
.file-transfer-user-row.selected:hover,
.file-transfer-user-row.selected:focus { background: var(--control-selected-hover-bg); }
.file-transfer-user-state { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
.file-transfer-user-state.online { background: var(--success); }
.file-transfer-user-name { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.file-transfer-user-name strong { font-size: 12px; font-weight: 600; }
.file-transfer-user-name span { color: var(--text-muted); font-size: 10px; }
.file-transfer-user-check { color: var(--accent); opacity: 0; }
.file-transfer-user-row.selected .file-transfer-user-check { opacity: 1; }
.file-transfer-user-pager { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 7px 0 1px; color: var(--text-muted); font-size: 10px; }
.file-transfer-user-pager button { width: 24px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; }
.file-transfer-user-pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--text-primary); }
.file-transfer-user-pager button:disabled { opacity: .45; cursor: default; }
.file-transfer-mode-switch { display: flex; gap: 6px; }
.file-transfer-mode-switch button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; font-size: 11px; }
.file-transfer-mode-switch button:hover { border-color: var(--accent); color: var(--text-primary); }
.file-transfer-mode-switch button.active { border-color: var(--accent); background: var(--accent-soft-bg); color: var(--accent); }
.file-transfer-mode-note { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border: 1px solid var(--accent-soft-border); border-radius: var(--radius-sm); background: var(--accent-soft-bg); color: var(--text-secondary); }
.file-transfer-mode-note > i { color: var(--accent); margin-top: 2px; }
.file-transfer-mode-note div { display: flex; flex-direction: column; gap: 3px; }
.file-transfer-mode-note strong { color: var(--text-primary); font-size: 12px; }
.file-transfer-mode-note span { font-size: 11px; }
.file-transfer-share-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 5px; }
.file-transfer-destination-modal-content { width: 520px; max-width: calc(100vw - 28px); }
.file-transfer-destination-body { display: flex; flex-direction: column; gap: 11px; padding: 18px 20px 20px; }
.file-transfer-destination-file { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--text-primary); font-size: 13px; }
.file-transfer-destination-file > i { color: var(--accent); font-size: 17px; }
.file-transfer-destination-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-transfer-destination-toolbar { display: flex; align-items: center; min-height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.file-transfer-destination-toolbar button { width: 38px; align-self: stretch; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--text-secondary); cursor: pointer; }
.file-transfer-destination-toolbar button:hover:not(:disabled) { background: var(--control-hover-bg); color: var(--text-primary); }
.file-transfer-destination-toolbar button:disabled { opacity: .35; cursor: default; }
.file-transfer-destination-toolbar span { min-width: 0; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); font: 11px var(--font-mono); }
.file-transfer-destination-list { min-height: 92px; max-height: 250px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-primary); }
.file-transfer-destination-item { width: 100%; display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text-primary); cursor: pointer; text-align: left; }
.file-transfer-destination-item:last-child { border-bottom: 0; }
.file-transfer-destination-item:hover { background: var(--control-hover-bg); }
.file-transfer-destination-item > i:first-child { color: var(--warning); }
.file-transfer-destination-item > span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.file-transfer-destination-item > i:last-child { color: var(--text-muted); font-size: 10px; }
.file-transfer-destination-hint { display: flex; align-items: flex-start; gap: 7px; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.file-transfer-destination-hint > i { margin-top: 2px; color: var(--accent); }

.file-sort-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
}

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

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

.sidebar-search-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-search-wrap input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
}

.sidebar-search-wrap input:focus {
    border-color: var(--accent);
}

.sidebar-search-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    display: none;
}

.sidebar-search-clear:hover {
    color: var(--text-primary);
}

/* SkillHub local skill sidebar */
.skillhub-sidebar-header { min-height: 43px; box-sizing: border-box; }
.skillhub-sidebar-header .sidebar-header-title { gap: 7px; }
.skillhub-sections {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.skillhub-section {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 104px;
    overflow: hidden;
}
.skillhub-section.collapsed {
    flex: 0 0 32px;
    min-height: 32px;
}
.skillhub-section-header {
    height: 32px;
    flex: 0 0 32px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 0;
    box-shadow: inset 0 -1px 0 var(--border);
}
.skillhub-section-toggle {
    min-width: 0;
    flex: 1;
    height: 100%;
    padding: 0 8px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font: 600 11px/1 var(--font-ui);
    text-transform: uppercase;
}
.skillhub-section-toggle .fa-chevron-down { width: 10px; font-size: 9px; transition: transform .15s ease; }
.skillhub-section.collapsed .skillhub-section-toggle .fa-chevron-down { transform: rotate(-90deg); }
.skillhub-count {
    min-width: 18px;
    height: 18px;
    margin-left: auto;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}
.skillhub-section-refresh {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.skillhub-section-refresh:hover { color: var(--text-primary); background: var(--nav-active-bg); }
.skillhub-section-refresh.refreshing i,
#skillHubRefreshAll.refreshing i { animation: skillhub-spin .8s linear infinite; }
@keyframes skillhub-spin { to { transform: rotate(360deg); } }
.skillhub-section-body {
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--bg-secondary);
}
.skillhub-section.collapsed .skillhub-section-body { display: none; }
.skillhub-market-section { min-height: 145px; }
.skillhub-market-section.collapsed { min-height: 32px; }
.skillhub-market-body {
    max-height: none;
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.skillhub-market-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 5px;
    padding: 7px 8px;
    border-bottom: 1px solid var(--border);
}
.skillhub-market-search {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-primary);
    color: var(--text-muted);
}
.skillhub-market-search:focus-within { border-color: var(--accent); }
.skillhub-market-search input,
.skillhub-market-controls select {
    min-width: 0;
    width: 100%;
    height: 26px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: 12px var(--font-ui);
}
.skillhub-market-controls select {
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0 4px;
    background: var(--bg-primary);
}
.skillhub-market-scroll { min-height: 0; flex: 1; overflow-y: auto; }
.skillhub-state {
    padding: 18px 12px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
    text-align: center;
}
.skillhub-state button { margin-top: 8px; }
.skillhub-list-refreshing { opacity: .72; }
.skillhub-row {
    position: relative;
    box-sizing: border-box;
    min-height: 72px;
    padding: 8px 7px 7px 42px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    background: var(--bg-secondary);
}
.skillhub-row.local-installed {
    background: var(--bg-primary);
    box-shadow: inset 3px 0 0 var(--success);
}
.skillhub-row.local-not-installed { background: var(--bg-primary); }
.skillhub-row.local-draft { background: var(--bg-primary); box-shadow: inset 3px 0 0 var(--accent); }
.skillhub-row:hover { background: var(--bg-tertiary); }
.skillhub-row.selected { box-shadow: inset 3px 0 0 var(--accent); background: var(--nav-active-bg); }
.skillhub-row.local-installed.selected { box-shadow: inset 3px 0 0 var(--success), inset 0 0 0 1px var(--success-soft-border); }
.skillhub-row-icon {
    position: absolute;
    left: 8px;
    top: 10px;
    width: 26px;
    height: 26px;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    color: var(--cyber-primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
.skillhub-row.local-installed .skillhub-row-icon { border-color: var(--success-soft-border); color: var(--success); }
.skillhub-row-titleline { display: flex; align-items: baseline; gap: 5px; min-width: 0; padding-right: 2px; }
.skillhub-row-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}
.skillhub-row-version { margin-left: auto; flex-shrink: 0; color: var(--text-secondary); font: 11px var(--font-ui); }
.skillhub-row-meta {
    min-width: 0;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font: 11px var(--font-ui);
}
.skillhub-row-slug {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
}
.skillhub-row-separator { flex: 0 0 auto; color: var(--border-code); }
.skillhub-row-author { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skillhub-row-footer { min-height: 22px; margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.skillhub-badge {
    display: inline-flex;
    align-items: center;
    max-width: 94px;
    height: 20px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-muted);
    font: 11px var(--font-ui);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.skillhub-badge.remote-published { color: var(--accent); border-color: var(--accent-soft-border); background: var(--accent-soft-bg); }
.skillhub-badge.local-installed { color: var(--success); border-color: var(--success-soft-border); background: var(--success-soft-bg); }
.skillhub-badge.local-draft { color: var(--accent); border-color: var(--accent-soft-border); background: var(--accent-soft-bg); }
.skillhub-badge.remote-private { color: var(--accent); }
.skillhub-badge.remote-pending { color: var(--star-active); }
.skillhub-badge.remote-rejected,
.skillhub-badge.local-error { color: var(--error); }
.skillhub-badge.local-update_available { color: var(--accent); border-color: var(--accent); }
.skillhub-badge.local-local_modified { color: var(--star-active); border-color: var(--star-active); }
.skillhub-row-actions { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.skillhub-action {
    min-width: 36px;
    height: 22px;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font: 11px var(--font-ui);
}
.skillhub-action:hover { border-color: var(--accent); color: var(--accent); }
.skillhub-action.primary { background: var(--action-bg); color: var(--action-fg); border-color: var(--accent); }
.skillhub-action.icon-only { min-width: 26px; width: 26px; padding: 0; }
.skillhub-action.icon-only i { font-size: 9px; transform: translateX(1px); }
.skillhub-action:disabled { cursor: default; opacity: .55; }
.skillhub-task-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--border); }
.skillhub-task-progress span { display: block; height: 100%; background: var(--accent); transition: width .2s linear; }
.skillhub-market-spacer { height: 0; pointer-events: none; }
.skillhub-market-sentinel { min-height: 26px; padding: 6px; text-align: center; color: var(--text-muted); font-size: 11px; }

/* SkillHub detail view */
.skillhub-detail-inner { max-width: 1100px; }
.skillhub-detail-toolbar { gap: 8px; }
.skillhub-detail-heading { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.skillhub-detail-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.skillhub-detail-heading span { color: var(--text-muted); font: 11px var(--font-mono); }
.skillhub-detail-content { flex: 1; min-height: 0; overflow-y: auto; background: var(--bg-primary); }
.skillhub-detail-meta {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.skillhub-detail-meta h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: 0; }
.skillhub-detail-meta-line { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--text-secondary); font-size: 12px; }
.skillhub-detail-readme { max-width: 900px; margin: 0 auto; padding: 24px 30px 60px; color: var(--text-primary); font-size: 14px; line-height: 1.7; }
.skillhub-detail-readme.message-content h1:first-child,
.skillhub-detail-readme.message-content h2:first-child,
.skillhub-detail-readme.message-content h3:first-child { margin-top: 0; }
.skillhub-detail-readme.message-content table { display: block; max-width: 100%; overflow-x: auto; }
.skillhub-detail-readme img { max-width: 100%; }
.skillhub-detail-readme pre { overflow-x: auto; }
.skillhub-detail-error { padding: 32px; text-align: center; color: var(--error); }

/* Local skill scoped workspace */
.skill-workspace-inner { max-width: 1100px; }
.skill-workspace-toolbar { gap: 10px; }
.skill-workspace-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.skill-workspace-heading > i { color: var(--accent); }
.skill-workspace-heading strong {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}
.skill-workspace-heading span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font: 11px var(--font-mono);
}
.skill-workspace-body {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
    background: var(--bg-primary);
}
.skill-workspace-publish-btn {
    height: 30px;
    padding: 0 11px;
    border: 1px solid var(--success-action);
    border-radius: 4px;
    background: var(--success-action);
    color: var(--action-fg);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font: 12px var(--font-ui);
}
.skill-workspace-publish-btn:hover { background: var(--success-action-hover); border-color: var(--success-action-hover); }
.skill-workspace-tree-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
}
.skill-workspace-tree-toolbar {
    min-height: 36px;
    padding: 3px 6px 3px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 3px;
}
.skill-workspace-tree-toolbar strong { color: var(--text-secondary); font-size: 11px; font-weight: 600; }
.skill-workspace-tree-toolbar > span { flex: 1; }
.skill-workspace-tree {
    min-width: 0;
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding: 6px 0 18px;
    background: var(--bg-secondary);
}
.skill-workspace-tree-state {
    padding: 20px 12px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.skill-workspace-node {
    --skill-tree-depth: 0;
    box-sizing: border-box;
    width: 100%;
    height: 29px;
    padding: 0 8px 0 calc(9px + var(--skill-tree-depth) * 15px);
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font: 12px var(--font-ui);
    text-align: left;
}
.skill-workspace-node:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.skill-workspace-node.selected { background: var(--nav-active-bg); color: var(--text-primary); }
.skill-workspace-node-caret {
    width: 10px;
    flex: 0 0 10px;
    color: var(--text-muted);
    font-size: 8px;
    text-align: center;
    transition: transform .12s ease;
}
.skill-workspace-node.open .skill-workspace-node-caret { transform: rotate(90deg); }
.skill-workspace-node-file .skill-workspace-node-caret { visibility: hidden; }
.skill-workspace-node-type { width: 14px; flex: 0 0 14px; color: var(--accent); text-align: center; }
.skill-workspace-node-file .skill-workspace-node-type { color: var(--text-muted); }
.skill-workspace-node-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-workspace-selection {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px;
    color: var(--text-muted);
}
.skill-workspace-selection > i { font-size: 34px; color: var(--border-code); }
.skill-workspace-selection strong { color: var(--text-primary); font-size: 16px; }
.skill-workspace-selection > span {
    max-width: 100%;
    overflow-wrap: anywhere;
    color: var(--text-muted);
    font: 12px var(--font-mono);
}
.skill-workspace-selection-actions { min-height: 32px; display: flex; align-items: center; gap: 7px; }
.skill-create-modal-content { width: min(520px, calc(100vw - 24px)); }
.skill-workspace-entry-modal-content { width: min(420px, calc(100vw - 24px)); }
.skill-create-form,
.skill-workspace-entry-form { display: flex; flex-direction: column; gap: 15px; padding: 20px; }
.skill-create-form label,
.skill-workspace-entry-form label { display: flex; flex-direction: column; gap: 6px; color: var(--text-secondary); font-size: 12px; }
.skill-create-form input,
.skill-create-form textarea,
.skill-workspace-entry-form input {
    box-sizing: border-box;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: 0;
    padding: 9px 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: 13px var(--font-ui);
    resize: vertical;
}
.skill-create-form input:focus,
.skill-create-form textarea:focus,
.skill-workspace-entry-form input:focus { border-color: var(--accent); }
.skill-identity-status { min-height: 15px; color: var(--text-muted); font-size: 11px; line-height: 15px; }
.skill-identity-status.available { color: var(--success); }
.skill-identity-status.conflict { color: var(--error); }
.skill-create-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.skill-generate-modal-content { width: min(620px, calc(100vw - 24px)); max-height: min(820px, calc(100vh - 28px)); }
.skill-generate-body { padding: 20px; overflow-y: auto; }
.skill-generate-source { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.skill-generate-source button {
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font: 13px var(--font-ui);
}
.skill-generate-source button:hover { background: var(--control-hover-bg); color: var(--text-primary); }
.skill-generate-source button.active { border-color: var(--accent); background: var(--control-selected-bg); color: var(--control-selected-text); }
.skill-generate-source button.active:hover { background: var(--control-selected-hover-bg); }
.skill-generate-source button i { margin-right: 6px; color: var(--accent); }
.skill-generate-requirement { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; color: var(--text-secondary); font-size: 12px; }
.skill-generate-requirement textarea { box-sizing: border-box; width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 4px; outline: 0; resize: vertical; background: var(--bg-primary); color: var(--text-primary); font: 13px var(--font-ui); }
.skill-generate-requirement textarea:focus { border-color: var(--accent); }
.skill-generate-attachments { margin-top: 10px; }
.skill-generate-attachment-drop {
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px dashed var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font: 12px var(--font-ui);
}
.skill-generate-attachment-drop:hover,
.skill-generate-attachment-drop.dragging { border-color: var(--accent); background: var(--nav-active-bg); color: var(--text-primary); }
.skill-generate-attachment-drop i { color: var(--accent); }
.skill-generate-attachment-list { display: flex; flex-direction: column; gap: 5px; margin-top: 7px; }
.skill-generate-attachment-list:empty { display: none; }
.skill-generate-attachment-item {
    min-height: 32px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto 24px;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 11px;
}
.skill-generate-attachment-item > i { color: var(--accent); text-align: center; }
.skill-generate-attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.skill-generate-attachment-size { color: var(--text-muted); white-space: nowrap; }
.skill-generate-attachment-remove { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--text-muted); cursor: pointer; }
.skill-generate-attachment-remove:hover { background: var(--bg-hover); color: var(--error); }
.skill-generate-attachment-item.uploading > i { animation: fa-spin 1s linear infinite; }
.skill-generate-attachment-item.failed { border-color: var(--error-soft-border); background: var(--error-soft-bg); }
.skill-generate-attachment-item.failed > i { color: var(--error); }
.skill-generate-source-note { margin: 14px 0 18px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg-secondary); color: var(--text-secondary); font-size: 12px; line-height: 1.6; }
.skill-generate-review { padding: 0; }
.skill-generate-review-summary { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; }
.skill-generate-review-summary i { color: var(--success); }
.skill-generate-files { color: var(--text-secondary); font-size: 12px; }
.skill-generate-files > span { display: block; margin-bottom: 6px; }
.skill-generate-files > div { display: flex; flex-wrap: wrap; gap: 5px; }
.skill-generate-files code { padding: 3px 6px; border: 1px solid var(--border); border-radius: 3px; background: var(--bg-secondary); color: var(--text-primary); font: 11px var(--font-mono); }
.skill-publish-modal-content { width: min(760px, calc(100vw - 24px)); max-height: min(860px, calc(100vh - 28px)); }
.skill-publish-form { display: flex; flex-direction: column; gap: 16px; padding: 20px; overflow-y: auto; }
.skill-publish-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.skill-publish-grid label { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: var(--text-secondary); font-size: 12px; }
.skill-publish-grid .skill-publish-wide { grid-column: 1 / -1; }
.skill-publish-grid input,
.skill-publish-grid textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: 13px var(--font-ui);
    resize: vertical;
}
.skill-publish-grid input:focus,
.skill-publish-grid textarea:focus { border-color: var(--accent); }
.skill-publish-grid input[readonly] { background: var(--bg-secondary); color: var(--text-muted); }
.skill-publish-form fieldset { min-width: 0; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--border); border-radius: 6px; }
.skill-publish-form legend { padding: 0 5px; color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.skill-publish-options { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.skill-publish-options label { display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.skill-publish-options input { accent-color: var(--accent); }
.skill-publish-compatibility { display: grid; gap: 12px; }
.skill-publish-compatibility > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: start; gap: 10px; }
.skill-publish-compatibility strong { color: var(--text-muted); font-size: 11px; line-height: 20px; }
.skill-publish-empty { color: var(--text-muted); font-size: 12px; }
.skill-publish-error { min-height: 18px; color: var(--error); font-size: 12px; line-height: 1.5; }
.skill-publish-result-content { width: min(480px, calc(100vw - 24px)); }
.skill-publish-result-content .modal-body { padding: 20px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.skill-global-install-content { width: min(520px, calc(100vw - 24px)); }
.skill-global-install-content .modal-header h2 { display: flex; align-items: center; gap: 8px; }
.skill-global-install-content .modal-header h2 i { color: var(--accent); font-size: 16px; }
.skill-global-install-body { padding: 20px; }
.skill-global-install-summary { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }
.skill-global-install-summary strong { color: var(--text-primary); font-size: 14px; font-weight: 600; }
.skill-global-install-summary span { overflow-wrap: anywhere; color: var(--text-muted); font: 11px/1.5 var(--font-mono); }
.skill-global-install-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--text-secondary); font-size: 12px; }
.skill-global-install-progress-head strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.skill-global-install-progress { height: 7px; overflow: hidden; border-radius: 4px; background: var(--bg-tertiary); }
.skill-global-install-progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s linear; }
.skill-global-install-content.completed .skill-global-install-progress > span { background: var(--success); }
.skill-global-install-content.failed .skill-global-install-progress > span { background: var(--error); }
.skill-global-install-error { margin: 12px 0 0; padding: 9px 10px; border-left: 3px solid var(--error); background: var(--bg-secondary); color: var(--error); font-size: 12px; line-height: 1.5; }
.skill-global-install-risk { margin: 16px 0 0; padding: 10px 12px; border-left: 3px solid var(--warning); background: var(--warning-soft-bg); color: var(--text-secondary); font-size: 12px; line-height: 1.6; }
.skill-global-install-risk i { margin-right: 6px; color: var(--warning); }

@media (max-width: 760px) {
    .skill-workspace-body { grid-template-columns: 1fr; }
    .skill-workspace-selection { display: none; }
    .skill-workspace-tree-pane { border-right: 0; }
    .skill-publish-grid { grid-template-columns: 1fr; }
    .skill-publish-grid .skill-publish-wide { grid-column: auto; }
    .skill-publish-compatibility > div { grid-template-columns: 1fr; gap: 5px; }
}

/* Batch toolbar */
.batch-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--accent-soft-bg);
    border-bottom: 1px solid var(--accent);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.batch-toolbar .batch-count {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    flex: 1 1 auto;
}
.batch-toolbar button {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--accent);
    background: var(--action-bg);
    color: var(--action-fg);
    cursor: pointer;
    white-space: nowrap;
}
.batch-toolbar button:hover {
    opacity: 0.85;
}
.batch-toolbar .batch-cancel-btn {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.batch-toolbar .batch-cancel-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Multi-selected tree item */
.tree-item.selected {
    background: rgba(var(--accent-rgb, 26,115,232), 0.18);
    outline: 1px solid rgba(var(--accent-rgb, 26,115,232), 0.35);
    outline-offset: -1px;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer !important;
    user-select: none;
    font-size: 13px;
    transition: background 0.15s;
}

.tree-more-btn {
    display: none;
    margin-left: auto;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 3px;
}

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

.tree-item:hover .tree-more-btn {
    display: block;
}

.tree-item:hover {
    background: var(--bg-tertiary);
}
.tree-item.directory {
    font-weight: 500;
}

.tree-item.directory.drag-over {
    background: var(--action-bg);
    color: var(--action-fg);
    border-radius: 4px;
}

.tree-item.drag-over {
    background: var(--accent-medium-bg);
    border-radius: 4px;
    outline: 1px dashed var(--accent);
}

.tree-children.drag-over {
    background: var(--accent-soft-bg);
    outline: 1px dashed var(--accent);
    border-radius: 4px;
    min-height: 8px;
}

.directory-tree.drag-over-root {
    outline: 2px dashed var(--accent);
    outline-offset: -4px;
}

.tree-item.cut-pending {
    opacity: 0.45;
}

.tree-item.copy-pending {
    outline: 1px dashed var(--accent);
    outline-offset: -1px;
}

.tree-item.compare-selected {
    box-shadow: inset 3px 0 var(--warning);
    background: var(--warning-soft-bg);
}

.tree-item.compare-selected .tree-name {
    color: var(--text-primary);
    font-weight: 600;
}

/* Font-independent expand chevron; fixed sizing keeps tree rows aligned. */
.tree-item.directory::before {
    content: '';
    width: 6px;
    height: 6px;
    margin: 0 5px 0 2px;
    border-right: 1.5px solid var(--text-secondary);
    border-bottom: 1.5px solid var(--text-secondary);
    box-sizing: border-box;
    flex-shrink: 0;
    align-self: center;
    transform: rotate(-45deg);
    transform-origin: center;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.tree-item.directory.open::before {
    transform: rotate(45deg);
}
.tree-item.directory:hover::before,
.tree-item.directory.selected::before {
    border-color: var(--accent);
}

/* Tree icons — SVG background images (Win7-safe, no emoji) */
.tree-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    display: inline-block;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    vertical-align: middle;
}

/* Folder closed */
.tree-item.directory .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Cpath d='M0 2.5C0 1.67.67 1 1.5 1H5l2 2h7.5c.83 0 1.5.67 1.5 1.5v6c0 .83-.67 1.5-1.5 1.5h-13C.67 12 0 11.33 0 10.5z' fill='%23C9956C'/%3E%3C/svg%3E");
}

/* Folder open */
.tree-item.directory.open .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 12'%3E%3Cpath d='M0 2.5C0 1.67.67 1 1.5 1H5l2 2h7.5c.83 0 1.5.67 1.5 1.5V7H0z' fill='%23C9956C'/%3E%3Cpath d='M0 7h16L14 12H2z' fill='%23DCB87A'/%3E%3C/svg%3E");
}

/* File */
.tree-item:not(.directory) .tree-icon {
    width: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23EEF0F2' stroke='%23C0C4CC' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23C0C4CC' stroke-width='1'/%3E%3C/svg%3E");
}

/* Code files — blue */
.tree-item[data-ext="js"] .tree-icon,
.tree-item[data-ext="ts"] .tree-icon,
.tree-item[data-ext="jsx"] .tree-icon,
.tree-item[data-ext="tsx"] .tree-icon,
.tree-item[data-ext="mjs"] .tree-icon,
.tree-item[data-ext="cjs"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23DBEAFE' stroke='%2393C5FD' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%2393C5FD' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="py"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23FEF9C3' stroke='%23FDE047' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23FDE047' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="rs"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23FFEDD5' stroke='%23FB923C' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23FB923C' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="sh"] .tree-icon,
.tree-item[data-ext="bash"] .tree-icon,
.tree-item[data-ext="zsh"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23DCFCE7' stroke='%2386EFAC' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%2386EFAC' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="html"] .tree-icon,
.tree-item[data-ext="htm"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23FCE7F3' stroke='%23F9A8D4' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23F9A8D4' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="css"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23EDE9FE' stroke='%23C4B5FD' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23C4B5FD' stroke-width='1'/%3E%3C/svg%3E");
}
.tree-item[data-ext="json"] .tree-icon,
.tree-item[data-ext="toml"] .tree-icon,
.tree-item[data-ext="yaml"] .tree-icon,
.tree-item[data-ext="yml"] .tree-icon,
.tree-item[data-ext="xml"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23F0F9FF' stroke='%2338BDF8' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%2338BDF8' stroke-width='1'/%3E%3C/svg%3E");
}
/* Markdown / text */
.tree-item[data-ext="md"] .tree-icon,
.tree-item[data-ext="markdown"] .tree-icon,
.tree-item[data-ext="txt"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23F1F5F9' stroke='%2394A3B8' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%2394A3B8' stroke-width='1'/%3E%3C/svg%3E");
}
/* Image files — teal */
.tree-item[data-ext="png"] .tree-icon,
.tree-item[data-ext="jpg"] .tree-icon,
.tree-item[data-ext="jpeg"] .tree-icon,
.tree-item[data-ext="gif"] .tree-icon,
.tree-item[data-ext="svg"] .tree-icon,
.tree-item[data-ext="webp"] .tree-icon,
.tree-item[data-ext="ico"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23CCFBF1' stroke='%232DD4BF' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%232DD4BF' stroke-width='1'/%3E%3C/svg%3E");
}
/* Compressed / archive — amber */
.tree-item[data-ext="zip"] .tree-icon,
.tree-item[data-ext="tar"] .tree-icon,
.tree-item[data-ext="gz"] .tree-icon,
.tree-item[data-ext="rar"] .tree-icon,
.tree-item[data-ext="7z"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23FEF3C7' stroke='%23FCD34D' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23FCD34D' stroke-width='1'/%3E%3C/svg%3E");
}
/* PDF / Office docs — red */
.tree-item[data-ext="pdf"] .tree-icon,
.tree-item[data-ext="doc"] .tree-icon,
.tree-item[data-ext="docx"] .tree-icon,
.tree-item[data-ext="xls"] .tree-icon,
.tree-item[data-ext="xlsx"] .tree-icon,
.tree-item[data-ext="ppt"] .tree-icon,
.tree-item[data-ext="pptx"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23FEE2E2' stroke='%23FCA5A5' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23FCA5A5' stroke-width='1'/%3E%3C/svg%3E");
}
/* SQL / DB */
.tree-item[data-ext="sql"] .tree-icon,
.tree-item[data-ext="db"] .tree-icon,
.tree-item[data-ext="sqlite"] .tree-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 15'%3E%3Cpath d='M1 0h8l4 4v11H1z' fill='%23E0E7FF' stroke='%23818CF8' stroke-width='1'/%3E%3Cpath d='M9 0v4h4' fill='none' stroke='%23818CF8' stroke-width='1'/%3E%3C/svg%3E");
}

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

.search-tree-name {
    white-space: normal;
    word-break: break-all;
    line-height: 1.4;
}

.search-dir-part {
    color: var(--text-muted);
    font-size: 11px;
}

.tree-children {
    padding-left: 20px;
}

/* Sidebar Overlay - hidden since sidebar is not absolute anymore */
.sidebar-overlay {
    display: none;
}

/* ===== CENTER CONTENT (chat area) ===== */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

/* messages scroll area — takes all space above floating input */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    padding-bottom: 180px; /* space for the default 130px composer */
    scroll-behavior: smooth;
}

/* Input Panel (Left Side) */
.input-panel {
    flex: 0 0 55%;
    min-width: 200px;
    max-width: calc(100% - 260px);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-right: 16px;
}

/* Panel Tabs */
.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.panel-tab {
    padding: 8px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

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

.panel-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

/* Tab content panels */
.panel-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    position: relative;
}

.panel-tab-content.active {
    display: flex;
}

/* Editor */
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: none;
    flex-shrink: 0;
}

.editor-filename {
    font-size: 13px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.editor-filename.has-file {
    color: var(--text-primary);
}

.editor-lang-badge {
    display: inline-block;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
    line-height: 18px;
}
.editor-lang-badge:empty {
    display: none;
}

.editor-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.toolbar-capture-wrap { position: relative; flex: 0 0 auto; }
.toolbar-icon-btn {
    width: 30px; height: 30px; padding: 0; display: inline-flex;
    align-items: center; justify-content: center; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg-tertiary); color: var(--text-secondary);
    cursor: pointer;
}
.toolbar-icon-btn:hover,
.toolbar-icon-btn:focus-visible,
.toolbar-capture-wrap.open .toolbar-icon-btn {
    color: var(--cyber-primary); border-color: var(--cyber-primary);
    background: var(--accent-soft-bg); outline: none;
}
.toolbar-capture-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 1700;
    width: 260px; padding: 6px; display: none; border: 1px solid var(--border);
    border-radius: 8px; background: var(--floating-bg, var(--panel-bg));
    box-shadow: var(--shadow-lg, 0 12px 38px rgba(0,0,0,.38));
}
.toolbar-capture-wrap.open .toolbar-capture-menu { display: block; }
.toolbar-capture-menu .capture-attachment-item { min-height: 38px; }
.toolbar-capture-menu .capture-attachment-item span { flex: 1; }

.editor-status {
    font-size: 12px;
    color: var(--accent);
}

.code-editor {
    flex: 1;
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.code-editor:focus {
    border-color: var(--accent);
}

/* CodeMirror overrides: shared by file and skill editors. */
#editorModal .CodeMirror {
    height: 100%;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* Text / Hex editor modes */
.editor-mode-switch {
    display: inline-flex;
    flex-shrink: 0;
    margin-left: 6px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-primary);
}

.editor-mode-switch[hidden] {
    display: none;
}

.editor-mode-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 58px;
    height: 25px;
    padding: 0 8px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font: 12px var(--font-ui);
    cursor: pointer;
}

.editor-mode-switch button:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.editor-mode-switch button.active {
    color: var(--action-fg);
    background: var(--action-bg);
}

.editor-mode-switch button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.editor-save-split {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.editor-save-split .editor-save-main {
    border-radius: 4px 0 0 4px;
    border-right: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.editor-save-split.single-action .editor-save-main {
    border-right: 1px solid var(--border);
    border-radius: 4px;
}

.editor-save-arrow {
    display: inline-flex;
    width: 25px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--cyber-border);
    border-radius: 0 4px 4px 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
}

.editor-save-arrow[hidden] {
    display: none;
}

.editor-save-arrow:hover,
.editor-save-arrow[aria-expanded="true"] {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

.editor-save-menu {
    position: absolute;
    z-index: 20;
    top: calc(100% + 5px);
    right: 0;
    display: none;
    min-width: 220px;
    overflow: hidden;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
}

.editor-save-menu.open {
    display: block;
}

.editor-save-menu-item {
    display: flex;
    width: 100%;
    min-height: 32px;
    align-items: center;
    gap: 9px;
    padding: 6px 9px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font: 12px var(--font-ui);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.editor-save-menu-item:hover:not(:disabled),
.editor-save-menu-item:focus-visible {
    outline: 0;
    background: var(--accent-dim);
    color: var(--accent);
}

.editor-save-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.editor-save-menu-item > i,
.editor-save-encoding-icon {
    width: 28px;
    flex-shrink: 0;
    color: var(--text-muted);
    text-align: center;
}

.editor-save-encoding-icon {
    font: 700 9px var(--font-mono);
}

.editor-hex-symbol,
.context-menu-hex-icon {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
}

.editor-hex-view {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.editor-hex-view[hidden] {
    display: none;
}

.hex-editor-controls {
    display: flex;
    min-height: 42px;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.hex-control-field {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}

.hex-control-field input {
    width: 122px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    outline: 0;
    background: var(--bg-input);
    color: var(--text-primary);
    font: 12px var(--font-mono);
}

.hex-control-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft-bg);
}

.hex-search-field input {
    width: 210px;
}

.hex-overwrite-badge {
    flex-shrink: 0;
    margin-left: auto;
    padding: 2px 7px;
    border: 1px solid var(--accent-soft-border);
    border-radius: 3px;
    background: var(--accent-soft-bg);
    color: var(--accent);
    font: 700 10px var(--font-mono);
}

#hexEditorHost,
.hex-editor-host {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.hex-editor-scroll {
    position: absolute;
    inset: 0;
    overflow: auto;
    outline: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 24px;
}

.hex-editor-scroll:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent-soft-border);
}

.hex-editor-content {
    position: relative;
    min-width: 856px;
}

.hex-editor-header,
.hex-editor-row {
    display: grid;
    grid-template-columns: 88px 508px 208px;
    column-gap: 16px;
    align-items: center;
    padding: 0 10px;
}

.hex-editor-header {
    position: sticky;
    z-index: 3;
    top: 0;
    height: 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    line-height: 32px;
}

.hex-byte-header,
.hex-byte-grid {
    display: grid;
    grid-template-columns: repeat(16, 28px);
    column-gap: 4px;
}

.hex-byte-header i {
    width: 28px;
    font-style: normal;
    text-align: center;
}

.hex-ascii-header,
.hex-ascii-grid {
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.hex-ascii-grid {
    display: grid;
    grid-template-columns: repeat(16, 12px);
}

.hex-editor-body {
    position: relative;
}

.hex-editor-rows {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
}

.hex-editor-row {
    height: 24px;
}

.hex-editor-row.alternate {
    background: rgba(127, 127, 127, 0.035);
}

.hex-offset {
    color: var(--text-muted);
    text-align: right;
    user-select: none;
}

.hex-byte-cell,
.hex-ascii-cell {
    display: inline-block;
    height: 22px;
    border-radius: 2px;
    cursor: default;
    line-height: 22px;
    text-align: center;
    user-select: none;
}

.hex-byte-cell {
    width: 28px;
}

.hex-ascii-cell {
    width: 12px;
}

.hex-byte-cell:hover:not(.empty),
.hex-ascii-cell:hover:not(.empty) {
    background: var(--accent-soft-bg);
}

.hex-byte-cell.changed,
.hex-ascii-cell.changed {
    background: var(--warning-soft-bg);
    color: var(--warning);
}

.hex-byte-cell.selected,
.hex-ascii-cell.selected {
    background: var(--accent-medium-bg);
    color: var(--text-primary);
}

.hex-byte-cell.active-area,
.hex-ascii-cell.active-area {
    box-shadow: inset 0 0 0 1px var(--accent);
    color: var(--accent);
    font-weight: 700;
}

.hex-byte-cell.empty,
.hex-ascii-cell.empty {
    cursor: default;
}

.hex-editor-statusbar {
    display: flex;
    min-height: 28px;
    align-items: center;
    gap: 18px;
    padding: 0 10px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font: 11px var(--font-mono);
    white-space: nowrap;
}

#hexChangedStatus {
    margin-left: auto;
    color: var(--accent);
}

/* Side-by-side text comparison */
.text-compare-inner {
    min-width: 760px;
}

.text-compare-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.text-compare-summary,
.text-compare-position {
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.compare-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.compare-icon-btn:hover:not(:disabled) {
    background: var(--accent-dim);
    color: var(--accent);
}

.compare-icon-btn:disabled {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.45;
}

.text-compare-loading {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.text-compare-loading.error {
    color: var(--error);
}

.text-compare-loading[hidden] {
    display: none;
}

.text-compare-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    background: var(--bg-primary);
}

.text-compare-grid[hidden] {
    display: none;
}

.text-compare-pane {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
}

.text-compare-divider {
    background: var(--border);
}

.text-compare-file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.text-compare-side-label {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 11px;
}

.text-compare-filename {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#textCompareModal .CodeMirror {
    flex: 1;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
}

#textCompareModal .CodeMirror-scroll {
    min-height: 0;
}

.compare-line-changed {
    background: var(--warning-soft-bg);
}

.compare-line-added {
    background: var(--success-soft-bg);
}

.compare-line-deleted {
    background: var(--error-soft-bg);
}

.compare-line-placeholder {
    background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(127, 127, 127, 0.08) 4px, rgba(127, 127, 127, 0.08) 8px);
}

.compare-current-change {
    box-shadow: inset 3px 0 var(--accent), inset 0 1px rgba(80, 120, 255, 0.45), inset 0 -1px rgba(80, 120, 255, 0.45);
}

.compare-inline-change {
    border-bottom: 2px solid var(--warning);
    background: var(--warning-soft-bg);
}

.text-compare-legend {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 32px;
    padding: 0 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 11px;
}

.text-compare-legend[hidden] {
    display: none;
}

.text-compare-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.compare-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid rgba(127, 127, 127, 0.25);
}

.compare-swatch-changed { background: var(--warning-soft-bg); border-color: var(--warning-soft-border); }
.compare-swatch-added { background: var(--success-soft-bg); border-color: var(--success-soft-border); }
.compare-swatch-deleted { background: var(--error-soft-bg); border-color: var(--error-soft-border); }

.text-compare-hint {
    margin-left: auto;
    color: var(--text-muted);
}

.editor-render-preview {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 20px;
    background: var(--bg-primary);
}

.editor-preview-content {
    width: min(100%, 1100px);
    min-height: 100%;
    margin: 0 auto;
    color: var(--text-primary);
    line-height: 1.7;
}

.editor-html-preview {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 420px;
    border: 0;
    background: #fff;
}

.editor-preview-loading,
.editor-preview-error {
    padding: 48px 20px;
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
}

.editor-preview-error {
    color: var(--error);
}

.CodeMirror {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.CodeMirror-gutters,
.CodeMirror-gutter-filler,
.CodeMirror-scrollbar-filler {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.CodeMirror-linenumber,
.CodeMirror-guttermarker-subtle {
    color: var(--text-muted);
}

.CodeMirror-guttermarker,
.CodeMirror-cursor {
    color: var(--text-primary);
    border-left-color: var(--accent);
}

.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected,
.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection {
    background: var(--accent-medium-bg);
}

.CodeMirror-activeline-background {
    background: var(--accent-soft-bg);
}

.CodeMirror .cm-keyword { color: var(--syntax-keyword); font-weight: 600; }
.CodeMirror .cm-type,
.CodeMirror .cm-variable-3 { color: var(--syntax-type); }
.CodeMirror .cm-def,
.CodeMirror .cm-header,
.CodeMirror .cm-link { color: var(--syntax-def); }
.CodeMirror .cm-variable-2,
.CodeMirror .cm-property,
.CodeMirror .cm-attribute { color: var(--syntax-variable); }
.CodeMirror .cm-number,
.CodeMirror .cm-atom { color: var(--syntax-number); }
.CodeMirror .cm-string,
.CodeMirror .cm-string-2 { color: var(--syntax-string); }
.CodeMirror .cm-comment { color: var(--syntax-comment); font-style: italic; }
.CodeMirror .cm-meta,
.CodeMirror .cm-negative { color: var(--syntax-meta); }
.CodeMirror .cm-builtin { color: var(--syntax-builtin); }
.CodeMirror .cm-tag,
.CodeMirror .cm-qualifier,
.CodeMirror .cm-positive { color: var(--syntax-tag); }
.CodeMirror .cm-operator { color: var(--syntax-operator); }
.CodeMirror .cm-quote { color: var(--syntax-type); }

.CodeMirror-scroll {
    height: 100%;
}

.ai-help-dialog { z-index: 2450; }
.ai-help-dialog-content { width: min(520px, calc(100vw - 28px)); }
.ai-help-dialog .modal-header h2 { display: flex; align-items: center; gap: 8px; }
.ai-help-dialog .modal-header h2 i { color: var(--accent); }
.ai-help-dialog-body { display: flex; flex-direction: column; gap: 10px; }
.ai-help-context {
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-help-dialog textarea {
    width: 100%;
    min-height: 108px;
    max-height: 260px;
    padding: 10px 11px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-input);
    color: var(--text-primary);
    font: 13px/1.5 var(--font-ui);
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}
.ai-help-dialog textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft-bg); }
.ai-help-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 20px 20px;
}
.ai-help-dialog-actions button { width: auto; min-width: 82px; flex: 0 0 auto; }

.browser-compatibility-dialog { z-index: 2480; }
.browser-compatibility-content { width: min(560px, calc(100vw - 28px)); max-height: min(86vh, 720px); }
.browser-compatibility-dialog .modal-header h2 { display: flex; align-items: center; gap: 8px; }
.browser-compatibility-dialog .modal-header h2 i { color: var(--accent); font-size: 16px; }
.browser-compatibility-body { display: flex; flex-direction: column; gap: 15px; }
.browser-compatibility-reason { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.65; }
.browser-compatibility-origins {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: 12px/1.65 var(--font-mono);
    overflow-wrap: anywhere;
}
.browser-compatibility-origins code { display: block; color: var(--text-primary); }
.browser-compatibility-loading { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); font-family: var(--font-ui); }
.browser-compatibility-steps { display: flex; flex-direction: column; gap: 13px; margin: 0; padding: 0; list-style: none; }
.browser-compatibility-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.browser-compatibility-step-number {
    display: inline-flex;
    width: 26px;
    height: 26px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent);
    color: var(--button-text, #fff);
    font-size: 12px;
    font-weight: 600;
}
.browser-compatibility-steps li > div { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.browser-compatibility-steps strong { color: var(--text-primary); font-size: 13px; }
.browser-compatibility-steps li span:not(.browser-compatibility-step-number) { color: var(--text-secondary); font-size: 12px; line-height: 1.55; }
.browser-compatibility-steps code { color: var(--text-primary); overflow-wrap: anywhere; }
.browser-compatibility-note { display: flex; gap: 8px; align-items: flex-start; color: var(--text-secondary); font-size: 12px; line-height: 1.55; }
.browser-compatibility-note i { margin-top: 2px; color: var(--warning); }
.browser-compatibility-status { padding: 9px 11px; border-radius: 5px; font-size: 12px; line-height: 1.55; }
.browser-compatibility-status.success { background: var(--success-soft-bg); color: var(--success); }
.browser-compatibility-status.error { background: var(--error-soft-bg); color: var(--error); }
.browser-compatibility-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }
.browser-compatibility-actions button { width: auto; min-width: 88px; flex: 0 0 auto; }

.input-area {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-area:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim), var(--shadow);
}

.input-area textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    padding: 16px;
    padding-bottom: 50px;
    line-height: 1.6;
    min-height: 200px;
}

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

.input-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.float-plus {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.float-plus:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.float-expand {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.float-expand:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.input-area.expanded {
    position: fixed;
    inset: 60px 16px 56px;
    z-index: 200;
    flex: unset;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.input-area.expanded textarea {
    min-height: unset;
    flex: 1;
}

/* Editor/Preview modal expanded = inner stretches to fill full viewport */
#editorModal .fullscreen-modal-inner.expanded,
#previewModal .fullscreen-modal-inner.expanded,
#textCompareModal .fullscreen-modal-inner.expanded {
    margin: 0;
    border-radius: 0;
}

.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
}

.file-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 12px;
    max-width: 220px;
}
.file-tag > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.file-tag .remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s;
}

.file-tag .remove:hover {
    color: var(--error);
}

.file-tag.skill-editing-tag {
    max-width: 320px;
    border-color: var(--accent-soft-border);
    background: var(--accent-soft-bg);
    color: var(--text-secondary);
}
.file-tag.skill-editing-tag > i { color: var(--accent); font-size: 11px; }

.file-tag.uploading {
    min-width: 160px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    border-radius: 10px;
    padding: 6px 12px;
}

.file-tag.uploading .upload-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-progress-bar-wrap {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.1s linear;
    width: 0%;
}

.upload-progress-pct {
    font-size: 11px;
    color: var(--text-muted);
    align-self: flex-end;
}

/* Tool execution card (f2) */
.tool-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 4px 0 8px 0;
    overflow: hidden;
    font-size: 13px;
    background: var(--bg-secondary);
}
.tool-card-running {
    border-color: var(--accent, #4a90e2);
    background: var(--accent-soft-bg);
}
.tool-card-done {
    border-color: var(--border);
}
.tool-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-weight: 600;
}
.tool-card-icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}
.tool-card-running .tool-card-icon { color: var(--accent, #4a90e2); }
.tool-card-done .tool-card-icon    { color: var(--success); }
.tool-card-name {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
    color: var(--text-primary);
}
.tool-card-status-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
}
.tool-card-input {
    border-top: 1px solid var(--border);
    padding: 4px 10px;
    max-height: 80px;
    overflow: auto;
}
.tool-card-input pre {
    margin: 0;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
}
.tool-card-result {
    border-top: 1px solid var(--border);
    padding: 4px 10px;
}
.tool-card-result details summary {
    cursor: pointer;
    font-size: 11px;
    color: var(--text-secondary);
    user-select: none;
    padding: 2px 0;
}
.tool-card-result details pre {
    margin: 4px 0 0 0;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow: auto;
    color: var(--text-primary);
}

/* Pasted image inline preview card */
.pasted-img-card {
    position: relative;
    display: inline-flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}
.pasted-img-thumb {
    max-width: 80px;
    max-height: 64px;
    object-fit: cover;
    display: block;
}
.pasted-img-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}
.pasted-img-remove:hover { background: var(--error); }

.send-btn {
    padding: 14px 28px;
    background: var(--action-bg);
    color: var(--action-fg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    align-self: center;
    display: block;
    margin: 0 auto;
    width: fit-content;
}

.send-btn:hover {
    background: var(--action-hover);
}

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
}

.send-btn.stop-mode {
    background: var(--error);
}

.send-btn.stop-mode:hover {
    background: var(--error-hover);
}

.send-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.send-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.send-hint {
    font-size: 11px;
    color: var(--text-muted);
    user-select: none;
}

.voice-btn {
    padding: 10px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover {
    background: var(--bg-tertiary);
}

.voice-btn.recording {
    background: var(--error-soft-bg);
    border-color: var(--error);
    animation: pulse-ring 1s ease-in-out infinite;
}

.voice-btn.processing {
    background: var(--bg-secondary);
    border-color: transparent;
    cursor: wait;
    /* spinning border via conic-gradient trick */
    position: relative;
    animation: none;
}

.voice-btn.processing::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(var(--accent) 80deg, transparent 80deg);
    z-index: -1;
    animation: voice-spin 0.8s linear infinite;
}

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

.voice-status {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    min-height: 18px;
    margin-bottom: 2px;
    transition: opacity 0.2s;
}

.voice-status:empty {
    display: none;
}

@keyframes pulse-ring {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234,67,53,0.4); }
    50%       { box-shadow: 0 0 0 6px rgba(234,67,53,0); }
}

/* Response Panel (Right Side) */
.response-panel {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

/* Panel Resizer */
.panel-resizer,
.sidebar-resizer {
    flex: 0 0 8px;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.panel-resizer::before,
.sidebar-resizer::before {
    content: '';
    width: 3px;
    height: 40px;
    border-radius: 2px;
    background: var(--border);
    transition: background 0.2s, height 0.2s;
}

.panel-resizer:hover::before,
.panel-resizer.dragging::before,
.sidebar-resizer:hover::before,
.sidebar-resizer.dragging::before {
    background: var(--accent);
    height: 60px;
}


.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 500;
    font-size: 14px;
}

.gen-skill-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 12px;
    background: var(--action-bg);
    border: 1px solid var(--action-bg);
    border-radius: 14px;
    color: var(--action-fg);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.gen-skill-header-btn:hover {
    background: var(--action-hover);
    border-color: var(--action-hover);
}

/* ── Message Navigation Bar ───────────────────────────────────────────── */
.msg-nav {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;        /* only the dot column; popup expands via absolute positioning */
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    z-index: 20;
    overflow: visible;
    pointer-events: none;
}
/* the popup card — shown when nav is hovered */
.msg-nav-popup {
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
    padding: 6px 0;
    pointer-events: none;   /* never block mouse when hidden */
    opacity: 0;
    transition: opacity 0.18s;
    overflow: hidden;
}
.msg-nav-popup.visible {
    opacity: 1;
    pointer-events: auto;
}
.msg-nav-popup-item {
    display: block;
    padding: 5px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: color 0.12s, background 0.12s;
    user-select: none;
}
.msg-nav-popup-item:hover {
    color: var(--accent);
    background: rgba(var(--accent-rgb, 26,115,232), 0.06);
}
.msg-nav-popup-item.active {
    color: var(--accent);
    font-weight: 500;
}
/* dot column */
.msg-nav-dots {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 20px;
    position: relative;
    pointer-events: auto;
}
/* track line behind dots */
.msg-nav-track {
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    background: var(--border);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
}
.msg-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 22px;
    cursor: pointer;
    flex-shrink: 0;
    z-index: 1;
}
.msg-nav-item::after {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0.45;
    transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.msg-nav-item.active::after {
    background: var(--accent);
    opacity: 1;
    transform: scale(1.4);
}
.msg-nav-dots:hover .msg-nav-item::after {
    opacity: 0.65;
}
.msg-nav-dots:hover .msg-nav-item:hover::after,
.msg-nav-dots:hover .msg-nav-item.active::after {
    background: var(--accent);
    opacity: 1;
    transform: scale(1.3);
}

/* ── Message Preview Tooltip (nav bar hover) ─────────────────────────── */
.msg-preview {
    position: absolute;
    z-index: 30;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.6;
    max-width: 260px;
    pointer-events: none;
    box-shadow: 0 4px 18px rgba(0,0,0,0.28);
    /* clamp to 5 lines */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-all;
    animation: previewFadeIn 0.15s ease;
}
@keyframes previewFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.clear-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 12px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.clear-header-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.text-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 16px;
    transition: all 0.2s;
}

.text-btn:hover {
    background: var(--accent-dim);
}

.btn-success-flash {
    color: var(--success) !important;
    background: var(--success-soft-bg) !important;
}

/* Messages Area */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 80px 180px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    color: var(--text-muted);
    text-align: center;
    margin-top: 60px;
    font-size: 14px;
}

/* Message row: avatar + body side by side */
.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 100%;
    animation: msgFadeIn 0.2s ease;
}
@keyframes msgFadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.message.user {
    flex-direction: row;
}

/* Avatar */
.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    flex-shrink: 0;
    align-self: flex-start;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}
.msg-avatar svg {
    width: 20px;
    height: 20px;
}
.msg-avatar-ai {
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.16);
    padding: 5px;
}
.msg-avatar-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.msg-avatar-api { padding: 3px; }
.msg-avatar-cli { background: #f8eee9; }
.msg-avatar-hermes { background: #f4f7fb; }
.msg-avatar-codex { background: #ffffff; }
.msg-avatar-hermes .msg-avatar-logo,
.msg-avatar-codex .msg-avatar-logo {
    width: 24px;
    height: 24px;
}
.msg-avatar-user {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    color: #fff;
    box-shadow: 0 2px 10px rgba(139,92,246,0.3);
}
.msg-avatar-user span {
    color: #fff;
    font-weight: 700;
}

/* Body */
.msg-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: calc(100% - 50px);  /* leave room for avatar */
}
.user-body {
    align-items: flex-end;
}

/* Name + time row */
.msg-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.user-header-row {
    flex-direction: row-reverse;
}
.msg-sender-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--cyber-primary, #06b6d4);
}

/* Bubbles */
.msg-bubble {
    border-radius: 14px;
    padding: 12px 16px;
    line-height: 1.65;
    font-size: 14px;
    word-break: break-word;
    position: relative;
    width: fit-content;
    max-width: 100%;
}
.assistant-bubble {
    background: var(--bg-primary);
    border: 1px solid var(--cyber-border);
    box-shadow: 0 0 12px var(--cyber-glow-soft), inset 0 0 20px var(--accent-soft-bg);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
    width: auto;
    max-width: 100%;
}
.user-bubble {
    background: linear-gradient(135deg, var(--action-bg), var(--action-hover));
    color: var(--action-fg);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 12px rgba(6,182,212,0.25);
}
.user-bubble .message-content {
    color: var(--action-fg);
}

.message-content {
    white-space: normal;
    word-break: break-word;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Markdown rendered content styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.1em; }

.message-content p {
    margin: 8px 0;
}
.message-content > :last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.message-content pre {
    background: var(--bg-code);
    color: var(--text-code);
    border-left: 3px solid var(--accent);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.markdown-diagram {
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-primary);
}

.diagram-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
}

.diagram-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.diagram-status {
    color: var(--text-muted);
    overflow-wrap: anywhere;
    text-align: right;
}

.diagram-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
}

.diagram-expand-btn:hover,
.diagram-expand-btn:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}

.diagram-expand-icon {
    width: 13px;
    height: 13px;
    background:
        linear-gradient(currentColor, currentColor) left top / 5px 1.5px no-repeat,
        linear-gradient(currentColor, currentColor) left top / 1.5px 5px no-repeat,
        linear-gradient(currentColor, currentColor) right top / 5px 1.5px no-repeat,
        linear-gradient(currentColor, currentColor) right top / 1.5px 5px no-repeat,
        linear-gradient(currentColor, currentColor) left bottom / 5px 1.5px no-repeat,
        linear-gradient(currentColor, currentColor) left bottom / 1.5px 5px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 5px 1.5px no-repeat,
        linear-gradient(currentColor, currentColor) right bottom / 1.5px 5px no-repeat;
}

.markdown-diagram[data-diagram-state="failed"] .diagram-status {
    color: var(--error);
}

.diagram-output {
    overflow-x: auto;
    max-width: 100%;
    background: #fff;
}

.markdown-diagram .diagram-image {
    display: block;
    width: auto;
    max-width: none;
    height: auto;
    margin: 12px auto;
}

.diagram-preview {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    flex-direction: column;
    background: rgba(16, 18, 22, 0.96);
    color: #f3f4f6;
}

.diagram-preview.active {
    display: flex;
}

.diagram-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 48px;
    min-height: 48px;
    padding: 6px 12px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    background: #202329;
}

.diagram-preview-title {
    overflow: hidden;
    color: #f3f4f6;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diagram-preview-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.diagram-preview-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    background: #2b2f36;
    color: #f3f4f6;
    font: 500 12px/1 var(--font-ui);
    cursor: pointer;
}

.diagram-preview-actions button:hover,
.diagram-preview-actions button:focus-visible {
    border-color: #75b7ff;
    background: #353a43;
    outline: none;
}

.diagram-preview-actions button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.diagram-save-icon {
    position: relative;
    width: 15px;
    height: 11px;
    margin-top: 3px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
}

.diagram-save-icon::before {
    content: '';
    position: absolute;
    left: 1px;
    top: -5px;
    width: 6px;
    height: 4px;
    border: 1.5px solid currentColor;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
}

.diagram-download-icon {
    position: relative;
    width: 15px;
    height: 15px;
    border-bottom: 1.5px solid currentColor;
}

.diagram-download-icon::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    width: 1.5px;
    height: 10px;
    background: currentColor;
}

.diagram-download-icon::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
}

.diagram-preview-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.diagram-preview-controls button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 4px;
    background: #2b2f36;
    color: #f3f4f6;
    font: 600 18px/1 var(--font-ui);
    cursor: pointer;
}

.diagram-preview-controls button:hover,
.diagram-preview-controls button:focus-visible {
    border-color: #75b7ff;
    background: #353a43;
    outline: none;
}

.diagram-preview-controls .diagram-preview-fit {
    min-width: auto;
    font-size: 12px;
    font-weight: 500;
}

.diagram-preview-zoom {
    width: 58px;
    color: #d7dbe2;
    font-size: 12px;
    text-align: center;
}

@media (max-width: 900px) {
    .diagram-preview-toolbar {
        flex: 0 0 auto;
        flex-wrap: wrap;
        height: auto;
    }

    .diagram-preview-title {
        flex: 1 1 auto;
    }

    .diagram-preview-actions {
        order: 3;
        flex: 1 0 100%;
    }
}

.diagram-preview-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    outline: none;
}

.diagram-preview-viewport.dragging {
    cursor: grabbing;
}

.diagram-preview-image {
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    max-width: none;
    max-height: none;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.38);
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
}

.diagram-preview[data-diagram-theme="dark"] .diagram-preview-image {
    background: #0a0a0f;
}

.markdown-diagram[data-diagram-state="rendering"] .diagram-source {
    display: none;
}

.markdown-diagram .diagram-source {
    margin: 0;
    border: 0;
    border-radius: 0;
}

/* Lightweight chat syntax highlighting (CodeMirror tokenizer, no editor instance). */
.message-content .chat-code-highlighted .cm-keyword { color: var(--syntax-keyword); font-weight: 600; }
.message-content .chat-code-highlighted .cm-type,
.message-content .chat-code-highlighted .cm-variable-3 { color: var(--syntax-type); }
.message-content .chat-code-highlighted .cm-def { color: var(--syntax-def); }
.message-content .chat-code-highlighted .cm-variable-2 { color: var(--syntax-variable); }
.message-content .chat-code-highlighted .cm-number,
.message-content .chat-code-highlighted .cm-atom { color: var(--syntax-number); }
.message-content .chat-code-highlighted .cm-string,
.message-content .chat-code-highlighted .cm-string-2 { color: var(--syntax-string); }
.message-content .chat-code-highlighted .cm-comment { color: var(--syntax-comment); font-style: italic; }
.message-content .chat-code-highlighted .cm-meta { color: var(--syntax-meta); }
.message-content .chat-code-highlighted .cm-builtin { color: var(--syntax-builtin); }
.message-content .chat-code-highlighted .cm-property,
.message-content .chat-code-highlighted .cm-attribute { color: var(--syntax-variable); }
.message-content .chat-code-highlighted .cm-tag,
.message-content .chat-code-highlighted .cm-qualifier { color: var(--syntax-tag); }
.message-content .chat-code-highlighted .cm-header,
.message-content .chat-code-highlighted .cm-link { color: var(--syntax-def); }
.message-content .chat-code-highlighted .cm-quote { color: var(--syntax-type); }
.message-content .chat-code-highlighted .cm-positive { color: var(--syntax-tag); }
.message-content .chat-code-highlighted .cm-negative { color: var(--syntax-meta); }
.message-content .chat-code-highlighted .cm-operator { color: var(--syntax-operator); }

[data-theme="blue"] .message-content pre,
[data-theme="blue"] .code-block-wrapper pre,
[data-theme="dark"] .message-content pre,
[data-theme="dark"] .code-block-wrapper pre,
[data-theme="gray"] .message-content pre,
[data-theme="gray"] .code-block-wrapper pre {
    background: var(--bg-code);
    color: var(--text-code);
    border-left: 3px solid var(--accent);
}

/* Code block wrapper with toolbar */
.code-block-wrapper {
    position: relative;
    margin: 8px 0;
    transition: background-color 0.2s, border-color 0.2s;
}
.code-block-wrapper pre {
    margin: 0;
    padding-top: 36px; /* room for toolbar */
}
.code-lang-label {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    text-transform: lowercase;
    user-select: none;
    pointer-events: none;
}
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    padding: 2px 10px;
    font-size: 11px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s, color 0.2s;
    z-index: 2;
}
.code-block-wrapper:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Code block collapse/expand */
.code-block-collapsed pre {
    max-height: 320px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}
.code-expand-btn {
    display: none;
    width: 100%;
    padding: 6px 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
}
.code-block-collapsed .code-expand-btn { display: block; }
.code-block-wrapper:not(.code-block-collapsed) .code-expand-btn { display: block; }

/* Structured Unified Diff blocks in assistant replies. */
.chat-diff-wrapper {
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid var(--border-code);
    border-radius: 6px;
    background: var(--bg-code);
    color: var(--text-code);
    font-family: var(--font-mono);
}
.chat-diff-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 5px 8px 5px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-family: var(--font-ui);
}
.chat-diff-title {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 9px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}
.chat-diff-title small {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 400;
}
.chat-diff-title .chat-diff-lite-label {
    padding-left: 9px;
    border-left: 1px solid var(--border);
}
.chat-diff-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
}
.chat-diff-actions button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 27px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font: 11px var(--font-ui);
    cursor: pointer;
}
.chat-diff-actions button:hover,
.chat-diff-actions button:focus-visible {
    border-color: var(--border);
    background: var(--bg-tertiary);
    color: var(--accent);
    outline: none;
}
.chat-diff-source { display: none !important; }
.chat-diff-file + .chat-diff-file { border-top: 1px solid var(--border); }
.chat-diff-file > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.chat-diff-file > summary::-webkit-details-marker { display: none; }
.chat-diff-file > summary::before {
    content: '›';
    flex: 0 0 12px;
    color: var(--text-muted);
    font: 17px/1 var(--font-ui);
    text-align: center;
    transform: rotate(0deg);
    transform-origin: center;
    transition: transform 0.12s ease;
}
.chat-diff-file[open] > summary::before { transform: rotate(90deg); }
.chat-diff-file > summary:hover { background: var(--bg-tertiary); }
.chat-diff-file-path {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.chat-diff-file-path { text-decoration: none; }
a.chat-diff-file-path:hover { color: var(--accent); text-decoration: underline; }
.chat-diff-file-stats {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 8px;
    margin-left: auto;
    font: 11px var(--font-mono);
}
.chat-diff-file-stats b { color: var(--success); font-weight: 600; }
.chat-diff-file-stats i { color: var(--error); font-style: normal; font-weight: 600; }
.chat-diff-lines {
    max-height: 620px;
    overflow: auto;
    overscroll-behavior: contain;
    font-size: 12px;
    line-height: 1.55;
    tab-size: 4;
}
.chat-diff-line {
    display: grid;
    grid-template-columns: 46px 46px 18px minmax(max-content, 1fr);
    min-height: 19px;
}
.chat-diff-line-number {
    padding: 0 6px;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    text-align: right;
    user-select: none;
}
.chat-diff-marker {
    color: var(--text-muted);
    text-align: center;
    user-select: none;
}
.chat-diff-text {
    padding-right: 12px;
    white-space: pre;
}
.chat-diff-add { background: var(--success-soft-bg); }
.chat-diff-add .chat-diff-marker { color: var(--success); }
.chat-diff-delete { background: var(--error-soft-bg); }
.chat-diff-delete .chat-diff-marker { color: var(--error); }
.chat-diff-hunk {
    background: var(--accent-soft-bg);
    color: var(--accent);
}
.chat-diff-hunk .chat-diff-text,
.chat-diff-meta .chat-diff-text,
.chat-diff-note .chat-diff-text {
    grid-column: 1 / -1;
    padding: 2px 10px;
    color: var(--text-muted);
}
.chat-diff-hunk .chat-diff-line-number,
.chat-diff-hunk .chat-diff-marker,
.chat-diff-meta .chat-diff-line-number,
.chat-diff-meta .chat-diff-marker,
.chat-diff-note .chat-diff-line-number,
.chat-diff-note .chat-diff-marker { display: none; }
.message-content .chat-diff-raw {
    max-height: 520px;
    margin: 0;
    overflow: auto;
    border: 0;
    border-radius: 0;
    background: var(--bg-code);
    color: var(--text-code);
    white-space: pre;
}
body.performance-mode .chat-diff-line {
    grid-template-columns: 18px minmax(max-content, 1fr);
}
body.performance-mode .chat-diff-line-number { display: none; }
body.performance-mode .chat-diff-lines { max-height: 480px; }

@media (max-width: 700px) {
    .chat-diff-toolbar { align-items: flex-start; }
    .chat-diff-title { flex-wrap: wrap; gap: 3px 8px; }
    .chat-diff-title span { flex-basis: 100%; }
    .chat-diff-actions button span { display: none; }
    .chat-diff-actions button { width: 29px; justify-content: center; padding: 0; }
    .chat-diff-line { grid-template-columns: 38px 38px 16px minmax(max-content, 1fr); }
}

/* Streaming plain-text pre — replaced by full markdown on completion */
.streaming-pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 0.88em;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.message-content blockquote {
    border-left: 3px solid var(--accent);
    margin: 8px 0;
    padding-left: 12px;
    color: var(--text-secondary);
}

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

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

.message-content table {
    border-collapse: collapse;
    margin: 8px 0;
    width: 100%;
}

.message-content th,
.message-content td {
    border: 1px solid var(--border);
    padding: 6px 12px;
    text-align: left;
}

.message-content th {
    background: var(--bg-secondary);
}

.message-content img {
    max-width: 100%;
    height: auto;
}

.message-actions {
    display: flex;
    gap: 8px;
}

/* Assistant message meta row: time on left, actions on right */
.msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
}
.msg-meta .msg-time {
    margin-top: 0;
}

/* Bubble-internal actions — right-bottom corner, fade in on hover */
.bubble-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.18s;
}
.assistant-bubble:hover .bubble-actions {
    opacity: 1;
}

.bubble-actions .copy-btn,
.bubble-actions .download-btn,
.bubble-actions .download-audio-btn,
.bubble-actions .gen-skill-btn,
.bubble-actions .regenerate-btn,
.message-actions .copy-btn,
.message-actions .download-btn,
.message-actions .download-audio-btn,
.message-actions .gen-skill-btn {
    padding: 3px 10px;
    font-size: 11px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.bubble-actions .copy-btn:hover,
.bubble-actions .download-btn:hover,
.bubble-actions .download-audio-btn:hover,
.bubble-actions .gen-skill-btn:hover,
.bubble-actions .regenerate-btn:hover,
.message-actions .copy-btn:hover,
.message-actions .download-btn:hover,
.message-actions .download-audio-btn:hover,
.message-actions .gen-skill-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.bubble-actions .download-audio-btn {
    /* visibility controlled by JS — button only in DOM when CosyVoice is available */
}

/* Split buttons for copy and Markdown delivery */
.copy-split-wrap,
.download-split-wrap {
    position: relative;
    display: inline-flex;
}
.copy-split-wrap .copy-btn {
    border-radius: 12px 0 0 12px;
    border-right: none;
}
.download-split-wrap .download-btn {
    border-radius: 12px 0 0 12px;
    border-right: none;
}
.copy-split-wrap .copy-split-arrow,
.download-split-wrap .download-split-arrow {
    padding: 3px 7px;
    font-size: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0 12px 12px 0;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.6;
}
.copy-split-wrap .copy-split-arrow:hover,
.download-split-wrap .download-split-arrow:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}
.copy-split-menu,
.download-split-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    z-index: 999;
    min-width: 120px;
    display: none;
    overflow: hidden;
}
.copy-split-menu.open,
.download-split-menu.open { display: block; }
.copy-split-menu-item,
.download-split-menu-item {
    padding: 7px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.copy-split-menu-item:hover,
.download-split-menu-item:hover {
    background: var(--accent-dim);
    color: var(--accent);
}

/* TTS speaker button */
.bubble-actions .tts-btn,
.message-actions .tts-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.bubble-actions .tts-btn:hover,
.message-actions .tts-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

.message-actions .tts-btn .tts-icon {
    font-size: 13px;
    line-height: 1;
}

/* Playing animation: bars pulse like equalizer */
.message-actions .tts-btn.tts-playing .tts-icon {
    display: inline-block;
    animation: tts-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes tts-pulse {
    from { transform: scale(0.85); opacity: 0.7; }
    to   { transform: scale(1.15); opacity: 1; }
}

/* Loading spinner */
.message-actions .tts-btn.tts-loading .tts-icon {
    display: inline-block;
    animation: tts-spin 1s linear infinite;
}

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

.msg-file-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 11px;
    margin-bottom: 6px;
    margin-right: 4px;
    color: var(--text-primary);
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
}

.footer-left {
    display: flex;
    gap: 8px;
}

.footer-right {
    display: flex;
    gap: 8px;
}

.footer .text-btn {
    color: var(--text-secondary);
}

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    animation: modalSlideUp 0.25s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal-large {
    max-width: 640px;
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

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

.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    position: relative;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.save-btn {
    width: 100%;
    padding: 12px;
    background: var(--action-bg);
    color: var(--action-fg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.2s;
}

.save-btn:hover {
    background: var(--action-hover);
}

.save-btn.danger-btn {
    background: var(--error);
    width: auto;
    padding: 10px 20px;
}

.save-btn.danger-btn:hover {
    background: var(--error-hover);
}

.about-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 0 16px;
    gap: 12px;
}

.about-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
}

.about-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.about-version {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.log-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.refresh-btn {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--bg-tertiary);
}

/* Permission Modal */
.permission-modal .modal-content {
    max-width: 380px;
    text-align: center;
}

.permission-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.permission-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.permission-desc {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

.permission-path {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-all;
    margin-bottom: 20px;
    text-align: left;
}

.permission-buttons {
    display: flex;
    gap: 12px;
}

.permission-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
}

.permission-buttons .deny-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.permission-buttons .deny-btn:hover {
    background: var(--bg-tertiary);
}

.permission-buttons .grant-btn {
    background: var(--action-bg);
    color: var(--action-fg);
}

.permission-buttons .grant-btn:hover {
    background: var(--action-hover);
}

/* History List */
.history-search-wrap {
    position: relative;
    padding-bottom: 8px;
}

.history-search-wrap input {
    width: 100%;
    padding: 7px 32px 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    outline: none;
    box-sizing: border-box;
}

.history-search-wrap input:focus {
    border-color: var(--accent);
}

.history-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-60%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}
.history-search-clear:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
}

.clear-all-btn {
    padding: 8px 16px;
    font-size: 13px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.clear-all-btn:hover:not(:disabled) {
    background: var(--error-soft-bg);
    border-color: var(--error);
    color: var(--error);
}

.clear-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.history-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 4px 4px;
}

.history-item {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item:hover {
    background: var(--bg-tertiary);
}

.history-item.active {
    border-left: 3px solid var(--accent);
    padding-left: 9px;
}

/* 顶行：标题 + 时间 */
.history-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.history-title {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.history-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-item .session-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.history-item .preview {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-item .history-snippet {
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: unset;
}

/* 底行：标签 + 操作按钮 */
.history-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
}

.history-tags {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.history-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-tag-model {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-soft-border);
}

.history-tag-count {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.history-tag-skills,
.rh-tag-skills {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--success-soft-bg);
    color: var(--success);
    border: 1px solid var(--success-soft-border);
}

.history-item.task-running {
    box-shadow: inset 3px 0 0 var(--success);
}

.history-tag-running,
.rh-tag-running {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--success);
    background: var(--success-soft-bg);
    border: 1px solid var(--success-soft-border);
}

.history-tag-running .fa-circle,
.rh-tag-running .fa-circle {
    font-size: 6px;
    animation: task-status-pulse 1.4s ease-in-out infinite;
}

@keyframes task-status-pulse {
    50% { opacity: 0.35; }
}

.history-action-btn.task-stop-btn,
.rh-action-btn.task-stop {
    color: var(--error);
}

.history-action-btn.task-stop-btn:hover,
.rh-action-btn.task-stop:hover {
    color: var(--action-fg);
    background: var(--error);
}


.history-load-more {
    display: block;
    width: 100%;
    padding: 8px 0;
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: color 0.15s, background 0.15s;
}
.history-load-more:hover {
    color: var(--accent);
    background: var(--bg-tertiary);
}

/* Keyword highlight in search results */
mark {
    background: var(--highlight-bg, #ffe066);
    color: var(--highlight-color, #333);
    border-radius: 2px;
    padding: 0 1px;
}

/* Editor tab dirty indicator dot */
.editor-dirty-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
    margin-left: 5px;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

.history-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* hover 显隐：默认隐藏，卡片 hover 时出现 */
.history-action-btn.hov-btn {
    display: none;
}

.history-item:hover .history-action-btn.hov-btn {
    display: inline-flex;
}

.history-item:hover .history-tag-model,
.history-item:hover .history-tag-count,
.history-item:hover .history-tag-skills {
    display: none;
}

.history-action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1;
}

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

.history-action-btn.star-btn.starred {
    color: var(--star-active);
    border-color: var(--star-active);
}

.history-action-btn.delete-btn:hover {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-soft-bg);
}

.history-action-btn.export-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-dim);
}

.modal-small .modal-content {
    max-width: 360px;
}

/* Folder archive download */
.folder-archive-modal-content {
    width: 420px;
    max-width: calc(100vw - 32px);
}

.folder-archive-target {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.folder-archive-target > i {
    flex: 0 0 auto;
    color: var(--warning);
    font-size: 24px;
}

.folder-archive-target > div {
    min-width: 0;
}

.folder-archive-target strong,
.folder-archive-target span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-archive-target strong {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.folder-archive-target span {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.folder-archive-formats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0;
    margin: 0 0 18px;
    border: 0;
}

.folder-archive-formats legend {
    grid-column: 1 / -1;
    width: 100%;
    padding: 0;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.folder-archive-formats label {
    position: relative;
    cursor: pointer;
}

.folder-archive-formats input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.folder-archive-formats label > span {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 58px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.folder-archive-formats label:hover > span {
    border-color: var(--accent);
    background: var(--control-hover-bg);
}

.folder-archive-formats input:checked + span {
    border-color: var(--accent);
    background: var(--control-selected-bg);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.folder-archive-formats label:hover input:checked + span {
    background: var(--control-selected-hover-bg);
}

.folder-archive-formats input:focus-visible + span {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.folder-archive-formats strong {
    color: var(--text-primary);
    font-size: 13px;
}

.folder-archive-formats small {
    color: var(--text-muted);
    font-size: 11px;
}

.folder-archive-formats.disabled {
    opacity: 0.65;
    pointer-events: none;
}

.folder-archive-progress {
    margin-bottom: 18px;
}

.folder-archive-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.folder-archive-progress-head strong {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.folder-archive-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--bg-tertiary);
}

.folder-archive-progress-track > div {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.25s ease;
}

.folder-archive-detail {
    min-height: 17px;
    margin-top: 7px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-archive-error {
    padding: 9px 10px;
    margin-bottom: 14px;
    border: 1px solid var(--error-soft-border);
    border-radius: var(--radius-sm);
    background: var(--error-soft-bg);
    color: var(--error);
    font-size: 12px;
    line-height: 1.5;
}

.folder-archive-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.folder-archive-actions .save-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: auto;
    min-width: 112px;
    padding: 9px 16px;
}

.folder-archive-actions button:disabled,
#closeFolderArchive:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .folder-archive-formats {
        grid-template-columns: 1fr;
    }
}

/* Move Confirm Dialog */
.move-confirm-box {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    min-width: 320px;
    max-width: 90vw;
    backdrop-filter: blur(12px);
    z-index: 3000;
}

.move-confirm-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-soft-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.move-confirm-body {
    flex: 1;
    min-width: 0;
}

.move-confirm-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.move-confirm-desc {
    font-size: 12px;
    color: var(--text-secondary);
    word-break: break-all;
}

.move-confirm-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Sticky save button in settings AI tab */
#ai-settings .save-btn {
    position: sticky;
    bottom: 0;
    width: 100%;
    margin-top: 8px;
    z-index: 1;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-inverse, #323232);
    color: var(--text-inverse, #ffffff);
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 2000;
    box-shadow: var(--shadow-md);
    animation: toast-in 0.15s ease;
    cursor: pointer;
    user-select: none;
}

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

/* Typing indicator */
.typing::after {
    content: '';
    animation: typing 1s infinite;
}

@keyframes typing {
    0%, 50% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Loading */
.loading {
    color: var(--text-muted);
    text-align: center;
    padding: 20px;
}
/* spinner dots for search/loading states */
.loading-searching::after {
    content: '';
    display: inline-block;
    animation: searchDots 1.2s steps(4, end) infinite;
}
@keyframes searchDots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* AI error message in chat */
.message.assistant.msg-error {
    border-left: 3px solid var(--error);
    background: var(--error-soft-bg);
}
.message.assistant.msg-error .message-content {
    color: var(--error);
}
.msg-error-icon {
    display: inline-block;
    margin-right: 6px;
    font-weight: bold;
}

/* Draggable */
[draggable="true"] {
    cursor: grab;
}

[draggable="true"]:active {
    cursor: grabbing;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 140px;
    z-index: 3000;
    display: none;
    padding: 4px 0;
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.context-menu-item-with-icon {
    display: flex;
    align-items: center;
}

.context-menu-label {
    min-width: 0;
    flex: 1;
    white-space: nowrap;
}

.context-menu-icon {
    width: 16px;
    margin-right: 8px;
    color: var(--text-secondary);
    text-align: center;
    flex-shrink: 0;
}

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

.context-menu-item:hover .context-menu-icon {
    color: currentColor;
}

.context-menu-item.disabled {
    color: var(--text-muted, #999);
    cursor: default;
    opacity: 0.5;
    font-style: italic;
    pointer-events: none;
}

.context-menu-separator {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 12px;
}

.context-menu-has-submenu {
    position: relative;
    padding-right: 10px;
    display: flex;
    align-items: center;
}

.context-menu-submenu-caret {
    margin-left: 14px;
    color: var(--text-muted);
    font-size: 9px;
}

.context-menu-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    z-index: 1;
    display: none;
}

.context-menu-has-submenu.submenu-open > .context-menu-submenu {
    display: block;
}

@media (hover: hover) {
    .context-menu-has-submenu:hover > .context-menu-submenu {
        display: block;
    }
}

.file-sort-check {
    visibility: hidden;
}

.context-menu-item.is-selected .file-sort-check {
    visibility: visible;
    color: var(--accent);
}

/* Editor context menu — two-column layout with shortcut hints */
.editor-context-menu {
    min-width: 180px;
}
.ecm-with-key {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.ecm-key {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Inline rename input inside tree items */
.tree-rename-input {
    flex: 1;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text-primary);
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-soft-border);
    min-width: 60px;
    max-width: calc(100% - 28px);
    height: 20px;
}

/* Permission Request in Chat */
.permission-request {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
}

.permission-content {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.permission-icon {
    font-size: 24px;
}

.permission-text {
    flex: 1;
}

.permission-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.permission-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.permission-path {
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-all;
    color: var(--text-secondary);
}

.permission-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.perm-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.perm-btn.deny {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.perm-btn.deny:hover {
    background: var(--error);
    color: #fff;
}

.perm-btn.grant {
    background: var(--action-bg);
    color: var(--action-fg);
}

.perm-btn.grant:hover {
    background: var(--action-hover);
}

/* Inline Permission in Message */
.permission-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.permission-inline .permission-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.permission-inline .permission-text {
    flex: 1;
    line-height: 1.5;
}

.message .permission-buttons {
    margin-top: 12px;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 320px;
    padding: 40px 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-logo {
    width: 56px;
    height: 56px;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.login-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.login-input:focus {
    border-color: var(--accent);
}

.login-remember {
    display: flex;
    align-items: center;
    align-self: flex-start;
    gap: 8px;
    min-height: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.login-remember input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.login-btn {
    width: 100%;
    padding: 10px;
    background: var(--action-bg);
    color: var(--action-fg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--action-hover);
}

.login-error {
    font-size: 13px;
    color: var(--error);
    text-align: center;
    min-height: 18px;
}

/* 密码框眼睛图标 */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper .login-input {
    padding-right: 40px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.toggle-password:hover {
    color: var(--accent);
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* 禁用 Edge/IE 内置密码眼睛图标 */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

/* 设置页密码框 wrapper */
.settings-password-wrapper {
    position: relative;
}

.settings-password-wrapper input {
    padding-right: 40px !important;
}

.settings-password-wrapper .toggle-password {
    right: 10px;
    top: 50%;
}

.service-restart-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.service-restart-copy {
    min-width: 0;
}

.service-restart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 104px;
}

.service-restart-btn:disabled {
    cursor: wait;
    opacity: 0.65;
}

.service-restart-btn.is-restarting i {
    animation: restart-service-spin 0.9s linear infinite;
}

.service-restart-status {
    min-height: 18px;
    color: var(--text-secondary);
    font-size: 12px;
}

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

@media (max-width: 560px) {
    .service-restart-setting {
        align-items: stretch;
        flex-direction: column;
    }

    .service-restart-btn {
        width: 100%;
    }
}

/* ===== Preview Tab ===== */
.preview-area {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.preview-iframe {
    width: 100%;
    flex: 1;
    border: none;
    min-height: 0;
}
.preview-area.document-viewer-active {
    min-height: 0;
    overflow: hidden;
    padding: 0;
}
.preview-document-stage {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 20px 24px 32px;
    background: var(--bg-primary);
}
.preview-document-content {
    width: min(100%, 1100px);
    min-height: 100%;
    margin: 0 auto;
    color: var(--text-primary);
    line-height: 1.7;
}
.preview-document-content > .markdown-diagram {
    margin-top: 0;
}
.preview-html-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    border: 0;
    background: #fff;
}
.preview-placeholder, .preview-loading, .preview-error {
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px;
    text-align: center;
}
.preview-error { color: var(--error); }
.preview-table-wrap {
    padding: 12px;
    overflow: auto;
}
.preview-table-wrap table {
    border-collapse: collapse;
    font-size: 12px;
}
.preview-table-wrap td, .preview-table-wrap th {
    border: 1px solid var(--border);
    padding: 4px 8px;
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.preview-table-wrap th {
    background: var(--bg-secondary);
    font-weight: 600;
    position: sticky;
    top: 0;
}
.preview-docx-wrap {
    padding: 24px 32px;
    max-width: 820px;
    margin: 0 auto;
    line-height: 1.7;
    font-size: 14px;
}
.preview-docx-wrap h1,.preview-docx-wrap h2,.preview-docx-wrap h3 {
    margin: 1em 0 0.4em;
}
.preview-docx-wrap p { margin: 0.5em 0; }
.preview-docx-wrap table {
    border-collapse: collapse;
    margin: 0.8em 0;
}
.preview-docx-wrap td, .preview-docx-wrap th {
    border: 1px solid var(--border);
    padding: 4px 8px;
}
.preview-area.image-viewer-active,
.preview-area.video-viewer-active,
.preview-area.audio-viewer-active,
.preview-area.office-viewer-active {
    overflow: hidden;
    padding: 0;
}

.office-preview-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    flex: 0 0 auto;
    font-size: 12px;
}

.office-preview-kind {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-weight: 500;
}

.office-preview-kind .fa-file-word { color: #2b66b1; }
.office-preview-kind .fa-file-excel { color: #217346; }
.office-preview-kind .fa-file-powerpoint { color: #b7472a; }
.office-preview-size { font-family: var(--font-mono); }

.office-preview-frame {
    background: #525659;
}

.preview-area.office-ai-locator-active { position: relative; }
.office-ai-locator {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    background: var(--bg-primary);
}
.office-ai-locator-toolbar {
    display: flex;
    min-height: 42px;
    padding: 5px 12px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex: 0 0 auto;
}
.office-ai-locator-toolbar-group {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}
.office-ai-locator-toolbar button {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    font: 500 12px/1 var(--font-ui);
    cursor: pointer;
}
.office-ai-locator-toolbar button:hover,
.office-ai-locator-toolbar button:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    outline: none;
}
.office-ai-locator-toolbar button:disabled { opacity: 0.42; cursor: default; }
.office-ai-page-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font: 12px/1 var(--font-mono);
}
.office-ai-page-control input {
    width: 52px;
    height: 30px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
    font: 12px/1 var(--font-mono);
    text-align: center;
    outline: none;
}
.office-ai-page-control input:focus { border-color: var(--accent); }
.office-ai-zoom {
    width: 48px;
    color: var(--text-primary);
    font: 500 12px/1 var(--font-mono);
    text-align: center;
}
.office-ai-locator-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: #525659;
    outline: none;
}
.office-ai-locator-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #f4f5f7;
    font-size: 13px;
}
.office-ai-locator-loading[hidden] { display: none; }
.office-ai-locator-loading.error { color: #fecaca; }
.office-ai-page {
    position: relative;
    margin: 24px auto;
    background: #fff;
    box-shadow: 0 5px 22px rgba(0, 0, 0, 0.38);
}
.office-ai-page[hidden] { display: none; }
.office-ai-page canvas { display: block; width: 100%; height: 100%; }
.office-ai-selection-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}
.office-ai-crosshair {
    position: absolute;
    z-index: 1;
    display: block;
    background: rgba(239, 68, 68, 0.92);
    pointer-events: none;
}
.office-ai-crosshair-x { right: 0; left: 0; height: 1px; }
.office-ai-crosshair-y { top: 0; bottom: 0; width: 1px; }
.office-ai-selection {
    position: absolute;
    z-index: 2;
    box-sizing: border-box;
    border: 2px solid #ef4444;
    background: rgba(239, 68, 68, 0.06);
    box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}
.office-ai-selection[hidden] { display: none; }
.office-ai-locator.busy .office-ai-selection-layer { cursor: wait; pointer-events: none; }
body.performance-mode .office-ai-page { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.32); }

@media (max-width: 900px) {
    .office-ai-locator-toolbar button span { display: none; }
    .office-ai-locator-toolbar { padding-right: 8px; padding-left: 8px; }
}

.office-prepare-panel .media-prepare-icon .fa-file-word { color: #2b66b1; }
.office-prepare-panel .media-prepare-icon .fa-file-excel { color: #217346; }
.office-prepare-panel .media-prepare-icon .fa-file-powerpoint { color: #b7472a; }

.media-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 5px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    flex: 0 0 auto;
}

.media-viewer-toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.media-viewer-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    font: 500 12px/1 var(--font-ui);
    cursor: pointer;
}

.media-viewer-toolbar button:hover,
.media-viewer-toolbar button:focus-visible {
    border-color: var(--cyber-primary);
    color: var(--cyber-primary);
    outline: none;
}

.media-viewer-divider {
    width: 1px;
    height: 20px;
    margin: 0 2px;
    background: var(--border);
}

.image-viewer-zoom {
    width: 50px;
    color: var(--text-primary);
    font: 500 12px/1 var(--font-mono);
    text-align: center;
}

.image-viewer-size,
.video-viewer-detail {
    overflow: hidden;
    color: var(--text-muted);
    font: 12px/1.3 var(--font-mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-viewer-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-primary);
    cursor: grab;
    touch-action: none;
    user-select: none;
    outline: none;
}

.image-viewer-viewport.dragging { cursor: grabbing; }

.image-ai-select-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    overflow: hidden;
    cursor: crosshair;
    touch-action: none;
    outline: none;
}
.image-ai-crosshair {
    position: absolute;
    z-index: 1;
    display: block;
    background: rgba(239, 68, 68, 0.9);
    pointer-events: none;
}
.image-ai-crosshair-x { left: 0; right: 0; height: 1px; }
.image-ai-crosshair-y { top: 0; bottom: 0; width: 1px; }
.image-ai-selection {
    position: absolute;
    z-index: 2;
    display: block;
    border: 2px solid #ef4444;
    background: rgba(239, 68, 68, 0.07);
    box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.28);
    box-sizing: border-box;
    pointer-events: none;
}
.image-ai-selection[hidden] { display: none; }
.image-ai-selection-cancel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    background: rgba(20, 24, 30, 0.82);
    color: #fff;
    cursor: pointer;
}
.image-ai-selection-cancel:hover,
.image-ai-selection-cancel:focus-visible { background: var(--error); border-color: var(--error); outline: none; }

.image-viewer-image {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    max-width: none;
    max-height: none;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.34);
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
}

body.performance-mode .image-viewer-image { will-change: auto; }

.preview-context-menu { min-width: 176px; }

.video-rate-control {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 12px;
    white-space: nowrap;
}

.video-rate-control select {
    height: 30px;
    padding: 0 26px 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-primary);
    font: 12px/1 var(--font-ui);
    outline: none;
}

.video-rate-control select:focus { border-color: var(--cyber-primary); }

.video-viewer-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #090a0c;
}

.video-viewer-player {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: #000;
    object-fit: contain;
}

.audio-viewer-stage {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 32px 24px;
    overflow: hidden;
    background: var(--bg-primary);
}

.audio-viewer-identity {
    display: flex;
    min-width: 0;
    max-width: min(720px, 90%);
    flex-direction: column;
    align-items: center;
    gap: 18px;
    margin-bottom: 36px;
    color: var(--text-secondary);
}

.audio-viewer-identity i {
    color: var(--cyber-primary);
    font-size: 58px;
}

.audio-viewer-identity span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-viewer-player {
    display: block;
    width: min(720px, calc(100% - 24px));
    height: 54px;
    flex: 0 0 54px;
}

.media-prepare-panel {
    width: min(420px, calc(100% - 48px));
    margin: auto;
    color: var(--text-secondary);
    text-align: center;
}

.media-prepare-icon {
    margin-bottom: 14px;
    color: var(--cyber-primary);
    font-size: 30px;
}

.media-prepare-title {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
}

.media-prepare-operation,
.media-prepare-meta {
    min-height: 18px;
    color: var(--text-muted);
    font-size: 12px;
}

.media-prepare-progress {
    height: 6px;
    margin: 16px 0 10px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--bg-secondary);
}

.media-prepare-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--cyber-primary);
    transition: width 0.2s ease;
}

body.performance-mode .media-prepare-progress span { transition: none; }

.media-prepare-cancel {
    height: 30px;
    margin-top: 14px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    cursor: pointer;
}

.media-prepare-cancel:hover { border-color: var(--cyber-primary); color: var(--cyber-primary); }
.media-prepare-cancel:disabled { cursor: wait; opacity: 0.55; }

@media (max-width: 700px) {
    .image-viewer-size { display: none; }
    .media-viewer-toolbar { overflow-x: auto; }
    .media-viewer-toolbar-group { min-width: max-content; }
}

/* ── 思考面板 ──────────────────────────────────────────── */
.thinking-panel {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
    background: var(--bg-secondary);
    font-size: 13px;
}
.thinking-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    font-weight: 500;
}
.thinking-header:hover { color: var(--text-primary); }
.thinking-icon { font-size: 12px; }
.thinking-chevron {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}
.thinking-panel.expanded .thinking-chevron { transform: rotate(180deg); }
.thinking-body {
    display: none;
    border-top: 1px solid var(--border);
    max-height: 360px;
    overflow-y: auto;
}
.thinking-panel.expanded .thinking-body { display: block; }
.thinking-text {
    margin: 0;
    padding: 10px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.thinking-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    font-size: 11px;
    color: var(--text-muted);
}
.thinking-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* Message timestamp */
.msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    display: block;
    opacity: 0.7;
}
.message.assistant .msg-time {
    text-align: left;
}

/* Streaming char count indicator */
.streaming-char-count {
    font-size: 11px;
    color: var(--accent);
    margin-left: 8px;
    opacity: 0.8;
    font-weight: 500;
}

.streaming-plain-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Drag-drop overlay on input area */
.input-drop-overlay {
    position: absolute;
    inset: 0;
    background: var(--accent-dim);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--accent);
    font-weight: 500;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.15s;
}
.input-area.drag-over .input-drop-overlay {
    opacity: 1;
}

/* Drop success flash */
@keyframes drop-success-kf {
    0%   { box-shadow: inset 0 0 0 2px var(--success); }
    60%  { box-shadow: inset 0 0 0 2px var(--success); }
    100% { box-shadow: inset 0 0 0 0px transparent; }
}
.input-area.drop-success {
    animation: drop-success-kf 0.8s ease-out forwards;
}

.mode-toggle { display: flex; flex-direction: row; gap: 16px; margin-top: 4px; flex-wrap: wrap; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.radio-label input[type="radio"] { width: 14px; height: 14px; margin: 0; cursor: pointer; flex-shrink: 0; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

.mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    letter-spacing: 0.02em;
    user-select: none;
}
.mode-badge-api {
    background: var(--accent-soft-bg);
    color: var(--accent);
    border: 1px solid var(--accent-soft-border);
}
.mode-badge-cli {
    background: var(--success-soft-bg);
    color: var(--success);
    border: 1px solid var(--success-soft-border);
}

/* ===== Responsive Layout ===== */

/* Tablet: hide sidebar, stack panels if needed */
@media (max-width: 1024px) {
    .sidebar {
        position: absolute;
        top: 0;
        left: 44px;
        height: 100%;
        z-index: 200;
        box-shadow: 2px 0 12px rgba(0,0,0,0.18);
        transition: transform 0.25s ease, opacity 0.25s ease;
    }
    .sidebar.collapsed {
        width: 280px;
        opacity: 1;
        transform: translateX(-100%);
        overflow: hidden;
    }
    .activity-bar { position: relative; z-index: 220; }
    .sidebar.collapsed + .sidebar-resizer { display: none; }
    .sidebar-resizer { display: none; }
    .input-panel {
        flex: 0 0 50%;
        min-width: 280px;
    }
}

/* Mobile: single-column — hide response panel, full-width input */
@media (max-width: 640px) {
    .header { padding: 8px 12px; gap: 8px; min-height: 50px; }
    .header-title { font-size: 14px; }
    .content { padding: 8px; flex-direction: column; }
    .input-panel {
        flex: 1 1 auto;
        width: 100%;
        max-width: 100%;
        padding-right: 0;
    }
    .panel-resizer { display: none; }
    .response-panel { display: none; }
    .input-panel.response-visible { flex: 0 0 45%; }
    .response-panel.visible { display: flex; flex: 1; }
}

/* Generic confirm modal always appears on top of other modals */
#genericConfirmModal { z-index: 2000; }

.browser-upgrade-dialog {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.34);
}

.browser-upgrade-dialog.active {
    display: flex;
}

.browser-upgrade-content {
    width: min(430px, calc(100vw - 40px));
    box-sizing: border-box;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
    color: var(--text-primary);
}

.browser-upgrade-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--warning-soft-bg);
    color: var(--warning);
    font-size: 18px;
}

.browser-upgrade-content h2 {
    margin: 0 0 10px;
    font-size: 18px;
    letter-spacing: 0;
}

.browser-upgrade-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.65;
}

.browser-upgrade-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 22px;
}

.browser-upgrade-actions .text-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 72px;
    white-space: nowrap;
}

.browser-upgrade-actions .save-btn {
    flex: 1 1 auto;
    width: auto;
    min-width: 160px;
    white-space: nowrap;
}

/* Scroll-to-top floating button */
.scroll-to-top-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 10;
    font-size: 12px;
}
.scroll-to-top-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* Scroll-to-bottom floating button */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s, transform 0.15s;
    z-index: 10;
    font-size: 12px;
}
.scroll-to-bottom-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* Edit button on user messages — icon style, sits left of timestamp */
.message.user .msg-time {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    text-align: unset;
}
.edit-msg-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.edit-msg-btn svg {
    width: 13px;
    height: 13px;
}
.message.user:hover .edit-msg-btn {
    opacity: 1;
}
.edit-msg-btn:hover {
    color: var(--text-primary);
}

/* Session title flash on auto-name */
@keyframes title-flash-kf {
    0%   { background: rgba(124, 77, 255, 0.25); }
    100% { background: transparent; }
}

/* ============================================================
   NEW COMPONENTS — appended for new 3-column layout
   ============================================================ */

/* ===== RIGHT SIDEBAR ===== */
.right-sidebar {
    width: 280px;
    background: var(--right-sidebar-bg);
    border-left: 1px solid var(--cyber-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    transition: width 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(10px);
}
.right-sidebar.collapsed {
    width: 0;
    opacity: 0;
    overflow: hidden;
}
/* Right sidebar toggle button — lives in header, no special positioning needed */
/* Active state: right panel open = icon fully opaque */
#toggleRightSidebar { opacity: 0.7; }
#toggleRightSidebar.panel-open { opacity: 1; color: var(--cyber-primary); }
#toggleRightSidebar svg rect:first-child { transition: opacity 0.2s; }
#toggleRightSidebar.panel-open svg rect:first-child { opacity: 0.8; }
.right-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Right panel (shared) */
.right-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}
.right-panel + .right-panel {
    border-top: 1px solid var(--cyber-border);
    flex: 0 0 auto;
    min-height: 160px;   /* 从 200px 减少到 160px */
    max-height: 200px;   /* 从 260px 减少到 200px */
}
.right-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--cyber-border);
}
.right-panel-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.right-panel-title .nav-icon { width: 12px; height: 12px; }
.right-panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.right-panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px 4px 8px;  /* 减少底部 padding */
}
.right-panel-footer {
    padding: 8px;
    border-top: 1px solid var(--cyber-border);
    flex-shrink: 0;
}
.right-panel-footer-btn {
    width: 100%;
    padding: 7px 10px;
    background: var(--accent-dim);
    border: 1px solid var(--cyber-border);
    border-radius: 6px;
    color: var(--cyber-primary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s;
}
.right-panel-footer-btn + .right-panel-footer-btn { margin-top: 5px; }
.right-panel-footer-btn:hover { background: var(--nav-active-bg); }

/* History panel list */
.right-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}
/* Inline search box in right history panel */
.right-history-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-bottom: 1px solid var(--cyber-border);
    flex-shrink: 0;
}
.right-history-search-wrap svg { color: var(--text-muted); flex-shrink: 0; }
.right-history-search-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 12px;
    color: var(--text-primary);
}
.right-history-search-wrap input::placeholder { color: var(--text-muted); }

/* Toolbar at bottom of history panel */
.rh-toolbar {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid var(--cyber-border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}
.rh-toolbar-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--cyber-border);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.rh-toolbar-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}
.rh-toolbar-btn:hover {
    color: var(--cyber-primary);
    border-color: var(--cyber-primary);
    background: var(--accent-dim);
}

.rh-toolbar-btn-danger:hover {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-soft-bg);
}

/* Search bar between history panel and status panel */
.rh-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    flex-shrink: 0;
    border-top: 1px solid var(--cyber-border);
    border-bottom: 1px solid var(--cyber-border);
    background: var(--bg-secondary);
}
.rh-search-bar svg {
    color: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.7;
}
.rh-search-bar input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--cyber-border);
    border-radius: 6px;
    outline: none;
    font-size: 12px;
    color: var(--text-primary);
    padding: 5px 10px;
    transition: border-color 0.2s;
}
.rh-search-bar input:focus {
    border-color: var(--cyber-primary);
}
.rh-search-bar input::placeholder { color: var(--text-muted); }

/* Section labels */
.right-history-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px 4px;
}

/* Card */
.rh-empty-state {
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.rh-card {
    padding: 10px 12px;
    border-radius: 8px;
    margin: 0 8px 8px;
    cursor: pointer;
    transition: transform 0.2s;
    user-select: none;
}
.rh-card:hover { transform: translateX(3px); }

.rh-card.task-running {
    box-shadow: inset 3px 0 0 var(--success);
}

.rh-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 6px;
}
.rh-card-title {
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.rh-card-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}
.rh-card-snippet {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    min-height: 1.5em;
}
.rh-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-width: 0;
}
.rh-card-tags {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    overflow: hidden;
}
.rh-tag {
    flex: none;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
}
.rh-tag-model {
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--accent-soft-border);
}
.rh-tag-count {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Action buttons (right-bottom) */
.rh-card-actions {
    display: flex;
    gap: 1px;
    flex-shrink: 0;
}
.rh-action-btn {
    background: none;
    border: none;
    padding: 3px 5px;
    font-size: 11px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 3px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.rh-action-btn:hover { color: var(--cyber-primary); background: var(--bg-tertiary); }
.rh-action-btn.starred { color: var(--star-active); }
.rh-action-btn.delete:hover { color: var(--error); background: var(--error-soft-bg); }
.rh-action-btn.hov-btn { display: none; }
.rh-card:hover .rh-action-btn.hov-btn { display: inline-flex; }
.rh-card:hover .rh-tag-model,
.rh-card:hover .rh-tag-count,
.rh-card:hover .rh-tag-skills { display: none; }

/* Status panel */
.status-panel { flex: 0 0 auto; min-height: 160px; }  /* 从 200px 减少到 160px */
.status-running-dot {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--success);
}
.status-pulse {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
    transition: background 0.4s;
}
.status-pulse::after {
    content: '';
    position: absolute;
    top: -3px; left: -3px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.5); opacity: 0; }
}
.status-block { padding: 6px 0; }  /* 减少上下 padding */
.status-block + .status-block { border-top: 1px solid var(--cyber-border); }
.status-block-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}
.status-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.status-value { font-size: 12px; color: var(--cyber-primary); font-family: var(--font-mono); font-weight: 600; }
.status-value.status-purple { color: #a78bfa; }
.status-value.status-green { color: var(--success); }
.status-bar-bg {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}
.status-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease;
}
.status-bar-cyan { background: linear-gradient(90deg, var(--cyber-primary), var(--accent-hover)); }
.status-bar-purple { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.status-bar-green { background: linear-gradient(90deg, #059669, #34d399); }
.status-no-device { font-size: 10px; color: var(--text-muted); opacity: 0.6; margin-top: 3px; display: block; }

/* ===== FLOATING INPUT BAR ===== */
.floating-input-container {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 860px;
    padding: 0 0 18px;
    pointer-events: none;
    z-index: 50;
}
.floating-input-bar {
    position: relative;
    background: var(--floating-bg, rgba(10,10,15,0.95));
    border: 1px solid var(--cyber-border);
    border-radius: 20px;
    box-shadow:
        0 0 30px var(--accent-dim),
        0 8px 32px rgba(0,0,0,0.35),
        inset 0 0 40px var(--accent-dim);
    backdrop-filter: blur(16px);
    pointer-events: all;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.floating-input-bar:hover {
    border-color: var(--cyber-strong-border);
    box-shadow:
        0 0 40px var(--cyber-glow-soft),
        0 8px 32px rgba(0,0,0,0.4),
        inset 0 0 40px var(--accent-dim);
}
.floating-input-bar:focus-within {
    border-color: var(--cyber-primary);
    box-shadow:
        0 0 40px var(--cyber-glow-medium),
        0 8px 32px rgba(0,0,0,0.4),
        0 0 0 2px var(--accent-dim),
        inset 0 0 40px var(--accent-dim);
}
/* streaming state: muted input visual */
.floating-input-bar.streaming-active {
    border-color: var(--cyber-border);
}
.floating-input-bar.streaming-active .floating-textarea {
    opacity: 0.5;
    cursor: not-allowed;
}
.floating-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
}
.floating-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    height: 74px;
    min-height: 74px;
    max-height: 300px;
    overflow-y: auto;
    padding: 2px 0;
    scrollbar-width: thin;
}
.floating-textarea.input-empty {
    padding-top: 26px;
    padding-bottom: 26px;
    overflow-y: hidden;
}
.floating-textarea::placeholder { color: var(--text-muted); }

/* Skill autocomplete dropdown */
.skill-autocomplete {
    position: absolute !important;
    bottom: 100% !important;
    left: 16px !important;
    right: 16px !important;
    margin-bottom: 8px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--floating-bg);
    border: 1px solid var(--cyber-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    backdrop-filter: blur(20px);
    pointer-events: all;
}
.skill-autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.skill-autocomplete-item:last-child {
    border-bottom: none;
}
.skill-autocomplete-item:hover { background: var(--control-hover-bg); }
.skill-autocomplete-item.active { background: var(--control-selected-bg); }
.skill-autocomplete-item.active:hover { background: var(--control-selected-hover-bg); }
.skill-autocomplete-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--cyber-primary);
}
.skill-autocomplete-real {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-left: 6px;
    font-family: 'Courier New', monospace;
}
.skill-autocomplete-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* On-demand skill recommendation */
.skill-recommend-btn {
    position: absolute;
    right: -16px;
    top: calc(50% - 9px);
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--warning-soft-border);
    border-radius: 50%;
    background: var(--floating-bg, #111118);
    color: var(--warning);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.38);
    cursor: pointer;
    pointer-events: all;
    z-index: 1002;
    font-size: 15px;
}
.skill-recommend-btn:hover,
.skill-recommend-btn:focus-visible,
.skill-recommend-btn.has-results {
    color: var(--warning);
    border-color: var(--warning);
    background: var(--warning-soft-bg);
    outline: none;
}
.skill-recommend-btn.loading i { animation: skill-recommend-pulse .9s ease-in-out infinite; }
.skill-recommend-btn:disabled { opacity: 0.55; cursor: wait; }

/* Screenshot and recording actions share the existing attachment button. */
.capture-attachment-wrap {
    position: relative;
    flex: 0 0 auto;
}
.capture-attachment-wrap.open .float-icon-btn,
.capture-attachment-wrap.recording .float-icon-btn {
    color: var(--cyber-primary);
    background: var(--accent-soft-bg);
}
.capture-attachment-wrap.busy .float-icon-btn { cursor: wait; opacity: 0.62; }
.capture-attachment-menu {
    position: fixed;
    z-index: 1500;
    width: 176px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--floating-bg, #111118);
    box-shadow: var(--shadow-lg, 0 12px 38px rgba(0, 0, 0, 0.38));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 0.14s, transform 0.14s, visibility 0.14s;
}
.capture-attachment-menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}
.capture-attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 11px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-primary);
    font: 13px var(--font-ui);
    text-align: left;
    cursor: pointer;
}
.capture-attachment-item i {
    width: 16px;
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
}
.capture-attachment-item:hover,
.capture-attachment-item:focus-visible {
    background: var(--control-hover-bg);
    color: var(--text-primary);
    outline: none;
}
.capture-attachment-item:hover i,
.capture-attachment-item:focus-visible i { color: var(--cyber-primary); }
.capture-record-item[aria-label="停止录屏"] { color: var(--error); }
.capture-record-item[aria-label="停止录屏"] i { color: var(--error); }
.capture-recording-status {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--error-soft-border);
    border-radius: 16px;
    background: var(--floating-bg, #111118);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    font: 11px var(--font-mono);
    pointer-events: all;
    z-index: 1501;
}
.capture-recording-status[hidden] { display: none; }
.capture-recording-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--error);
    animation: captureRecordingPulse 1s ease-in-out infinite;
}
.capture-recording-status button {
    height: 24px;
    padding: 0 8px;
    border: 0;
    border-radius: 12px;
    background: var(--error-soft-bg);
    color: var(--error);
    font: 11px var(--font-ui);
    cursor: pointer;
}
@keyframes captureRecordingPulse { 50% { opacity: 0.35; } }

/* Region selector keeps the captured bitmap static and redraws only its overlay. */
.capture-region-modal {
    z-index: 2300;
    padding: 12px;
    background: rgba(0, 0, 0, 0.82);
    box-sizing: border-box;
}
.capture-region-surface {
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    background: #111;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24), 0 14px 48px rgba(0, 0, 0, 0.5);
}
.capture-region-surface canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.capture-region-surface #captureRegionOverlay {
    position: absolute;
    inset: 0;
    cursor: none;
    touch-action: none;
}
.capture-region-actions {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2;
    display: flex;
    gap: 8px;
}
.capture-region-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 50%;
    background: rgba(18, 18, 22, 0.82);
    color: #fff;
    cursor: pointer;
}
.capture-region-close:hover,
.capture-region-close:focus-visible { background: var(--error); border-color: var(--error); outline: none; }

.capture-editor-modal { z-index: 2250; }
.capture-editor-modal-content {
    width: min(1180px, calc(100vw - 28px));
    height: min(850px, calc(100vh - 28px));
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.capture-editor-modal .modal-header h2,
.capture-playback-modal .modal-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.capture-editor-modal .modal-header h2 i { color: var(--accent); }
.capture-playback-modal .modal-header h2 i { color: var(--error); }
.capture-editor-size {
    margin-top: 3px;
    color: var(--text-muted);
    font: 11px var(--font-mono);
}
.capture-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-wrap: wrap;
}
.capture-tool-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-right: 10px;
    border-right: 1px solid var(--border);
}
.capture-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.capture-tool-btn i { font-size: 13px; }
.capture-shape-icon {
    display: block;
    width: 14px;
    height: 10px;
    border: 1.5px solid currentColor;
    box-sizing: border-box;
}
.capture-shape-ellipse { border-radius: 50%; }
.capture-tool-btn:hover,
.capture-tool-btn:focus-visible,
.capture-tool-btn.active {
    border-color: var(--accent);
    background: var(--accent-soft-bg);
    color: var(--accent);
    outline: none;
}
.capture-tool-btn:disabled { opacity: 0.35; cursor: default; }
.capture-colors { gap: 7px; }
.capture-color-swatch,
.capture-color-custom {
    position: relative;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: var(--swatch);
    cursor: pointer;
    box-sizing: border-box;
}
.capture-color-swatch.active { box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent); }
.capture-color-custom {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.capture-color-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.capture-color-custom i { font-size: 11px; pointer-events: none; }
.capture-stroke-control {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font: 11px var(--font-mono);
}
.capture-stroke-control i { font-size: 7px; color: var(--text-secondary); }
.capture-stroke-control input { width: 92px; accent-color: var(--accent); }
.capture-text-size-control i { font-size: 12px; }
.capture-text-size-control[hidden] { display: none; }
.capture-zoom-tools { padding-right: 8px; }
.capture-zoom-value {
    min-width: 48px;
    height: 30px;
    padding: 0 5px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font: 11px var(--font-mono);
    cursor: pointer;
}
.capture-zoom-value:hover,
.capture-zoom-value:focus-visible { background: var(--accent-soft-bg); color: var(--accent); outline: none; }
.capture-history-tools { margin-left: auto; padding-right: 0; border-right: 0; }
.capture-canvas-shell {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--bg-tertiary);
}
.capture-canvas-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: safe center;
    justify-content: safe center;
    overflow: auto;
    padding: 14px;
    background: var(--bg-tertiary);
    overscroll-behavior: contain;
    scrollbar-width: none;
}
.capture-canvas-stage::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}
.capture-custom-scrollbar {
    position: absolute;
    z-index: 4;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-secondary);
    box-shadow: none;
    box-sizing: border-box;
    pointer-events: auto;
}
.capture-custom-scrollbar[hidden] { display: none; }
.capture-custom-scrollbar-x {
    left: 8px;
    right: 22px;
    bottom: 4px;
    height: 10px;
}
.capture-custom-scrollbar-y {
    top: 8px;
    right: 4px;
    bottom: 22px;
    width: 10px;
}
.capture-custom-scrollbar-thumb {
    position: absolute;
    border-radius: 6px;
    background: var(--border-strong);
    cursor: grab;
}
.capture-custom-scrollbar-thumb:hover { background: var(--text-muted); }
.capture-custom-scrollbar-thumb:active { cursor: grabbing; background: var(--text-secondary); }
.capture-custom-scrollbar-x .capture-custom-scrollbar-thumb { top: 0; bottom: 0; left: 0; }
.capture-custom-scrollbar-y .capture-custom-scrollbar-thumb { left: 0; right: 0; top: 0; }
.capture-canvas-workspace {
    position: relative;
    flex: 0 0 auto;
    min-width: 1px;
    min-height: 1px;
}
.capture-canvas-workspace canvas {
    display: block;
    background: #111;
    box-shadow: 0 0 0 1px var(--border-strong), 0 8px 28px rgba(0, 0, 0, 0.32);
    cursor: crosshair;
    touch-action: none;
}
.capture-crop-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;
}
.capture-crop-overlay[hidden] { display: none; }
.capture-crop-selection {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.48);
    pointer-events: none;
}
.capture-crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1px solid var(--accent);
    border-radius: 2px;
    background: var(--bg-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    pointer-events: auto;
    touch-action: none;
}
.capture-crop-handle-nw { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.capture-crop-handle-n { left: 50%; top: 0; transform: translate(-50%, -50%); cursor: ns-resize; }
.capture-crop-handle-ne { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.capture-crop-handle-e { right: 0; top: 50%; transform: translate(50%, -50%); cursor: ew-resize; }
.capture-crop-handle-se { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.capture-crop-handle-s { left: 50%; bottom: 0; transform: translate(-50%, 50%); cursor: ns-resize; }
.capture-crop-handle-sw { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.capture-crop-handle-w { left: 0; top: 50%; transform: translate(-50%, -50%); cursor: ew-resize; }
.capture-crop-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 5px;
    pointer-events: auto;
}
.capture-crop-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 4px;
    background: rgba(20, 24, 30, 0.78);
    color: #fff;
    cursor: pointer;
}
.capture-crop-actions button:hover,
.capture-crop-actions button:focus-visible { border-color: #fff; background: rgba(20, 24, 30, 0.94); outline: none; }
.capture-editor-modal.crop-adjusting [data-capture-tool],
.capture-editor-modal.crop-adjusting .capture-colors,
.capture-editor-modal.crop-adjusting .capture-stroke-control,
.capture-editor-modal.crop-adjusting .capture-history-tools {
    opacity: 0.45;
    pointer-events: none;
}
.capture-editor-modal.crop-adjusting #captureAdjustRangeBtn {
    opacity: 1;
    pointer-events: auto;
}
.capture-text-input {
    position: absolute;
    z-index: 2;
    min-width: 100px;
    min-height: 42px;
    max-height: 220px;
    padding: 5px 7px;
    border: 1px dashed currentColor;
    border-radius: 3px;
    background: rgba(10, 10, 14, 0.76);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.38);
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    line-height: 1.25;
    resize: both;
    outline: none;
    box-sizing: border-box;
}
.capture-text-input[hidden] { display: none; }
.capture-editor-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 58px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}
.capture-editor-actions button,
.capture-playback-prompt button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: auto;
    min-width: 116px;
    min-height: 36px;
    padding: 7px 14px;
    gap: 7px;
    border-radius: 6px;
    white-space: nowrap;
}
.capture-editor-actions .save-btn { min-width: 128px; }

.capture-playback-modal { z-index: 2250; }
.capture-playback-modal-content { width: min(900px, calc(100vw - 28px)); max-width: none; overflow: hidden; }
.capture-playback-body {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: var(--bg-tertiary);
}
.capture-playback-prompt,
.capture-playback-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--text-primary);
    text-align: center;
}
.capture-playback-prompt > i { color: var(--accent); font-size: 50px; }
.capture-playback-prompt > div { display: flex; gap: 8px; }
.capture-playback-idle i { color: var(--success); font-size: 34px; }
.capture-playback-prompt[hidden],
.capture-playback-idle[hidden],
.capture-playback-body video[hidden] { display: none; }
.capture-playback-body video {
    display: block;
    width: 100%;
    max-height: min(620px, calc(100vh - 230px));
    background: #000;
}

body.performance-mode .capture-attachment-menu { transition: none; }
body.performance-mode .capture-recording-dot { animation: none; }
body.performance-mode .capture-region-modal.active { animation: none; }

@media (max-width: 700px) {
    .capture-attachment-menu { width: min(176px, calc(100vw - 16px)); }
    .capture-editor-modal-content { width: 100vw; height: 100vh; border-radius: 0; }
    .capture-editor-toolbar { gap: 7px; }
    .capture-stroke-control input { width: 64px; }
    .capture-history-tools { margin-left: 0; }
    .capture-editor-actions { flex-wrap: wrap; }
}
.skill-recommend-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: min(440px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 190px));
    overflow-y: auto;
    padding: 0;
    border: 1px solid var(--cyber-border);
    border-radius: 8px;
    background: var(--floating-bg, #111118);
    box-shadow: var(--shadow-lg, 0 12px 38px rgba(0, 0, 0, 0.48));
    pointer-events: all;
    z-index: 1001;
}
.skill-recommend-panel[hidden] { display: none; }
.skill-recommend-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 0 12px 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--floating-bg, #111118);
}
.skill-recommend-head strong { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.skill-recommend-head span { margin-left: 7px; font-size: 11px; color: var(--text-muted); font-weight: 400; }
.skill-recommend-close {
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.skill-recommend-close:hover { color: var(--text-primary); }
.skill-recommend-section { padding: 9px 10px 5px; }
.skill-recommend-section + .skill-recommend-section { border-top: 1px solid var(--border); }
.skill-recommend-section-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 3px 7px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
}
.skill-recommend-item {
    padding: 9px 10px;
    border-left: 3px solid var(--border-strong);
    background: var(--bg-secondary);
}
.skill-recommend-item + .skill-recommend-item { margin-top: 6px; }
.skill-recommend-item.is-installed { border-left-color: var(--success); }
.skill-recommend-item-top { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.skill-recommend-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}
.skill-recommend-level {
    flex: none;
    font-size: 10px;
    color: var(--success);
}
.skill-recommend-level.medium { color: var(--warning); }
.skill-recommend-reason {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.45;
}
.skill-recommend-meta {
    margin-top: 3px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}
.skill-recommend-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.skill-recommend-action {
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 11px;
    cursor: pointer;
}
.skill-recommend-action:hover { border-color: var(--cyber-primary); color: var(--text-primary); }
.skill-recommend-action.primary { border-color: var(--success); color: var(--success); }
.skill-recommend-action:disabled { opacity: 0.55; cursor: wait; }
.skill-recommend-state { padding: 25px 18px; color: var(--text-muted); font-size: 12px; text-align: center; }
.skill-recommend-state i { margin-right: 6px; }
.skill-recommend-market-link { margin-top: 10px; }

@keyframes skill-recommend-pulse {
    0%, 100% { opacity: 0.45; transform: scale(0.92); }
    50% { opacity: 1; transform: scale(1.08); }
}

@media (max-width: 700px) {
    .skill-recommend-btn { right: -6px; }
    .skill-recommend-panel { right: -4%; width: min(440px, 100vw - 20px); }
}

/* Icon buttons (upload) */
.float-icon-btn {
    background: transparent;
    border: none;
    color: var(--cyber-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.float-icon-btn:hover {
    color: var(--cyber-primary);
    background: var(--accent-soft-bg);
}

/* Voice button: bordered pill like prototype */
.float-voice-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--cyber-soft-bg);
    border: 1px solid var(--cyber-border);
    color: var(--cyber-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.float-voice-btn:hover {
    background: var(--cyber-medium-bg);
    border-color: var(--cyber-strong-border);
}
.float-voice-btn.recording {
    color: var(--error);
    border-color: var(--error);
    background: var(--error-soft-bg);
    animation: recordPulse 1s ease-in-out infinite;
}
.float-voice-btn.processing {
    opacity: 0.6;
    cursor: not-allowed;
}
@keyframes recordPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Voice equalizer bars */
.voice-equalizer {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}
.voice-equalizer span {
    width: 3px;
    border-radius: 2px;
    background: currentColor;
    animation: eq-bar 0.8s ease-in-out infinite;
}
.voice-equalizer span:nth-child(1) { animation-delay: 0s;    height: 6px; }
.voice-equalizer span:nth-child(2) { animation-delay: 0.15s; height: 10px; }
.voice-equalizer span:nth-child(3) { animation-delay: 0.3s;  height: 14px; }
.voice-equalizer span:nth-child(4) { animation-delay: 0.45s; height: 8px; }
@keyframes eq-bar {
    0%,100% { transform: scaleY(0.3); }
    50%      { transform: scaleY(1); }
}

/* Send button: rounded, with icon */
.float-send-btn {
    background: var(--action-bg);
    color: var(--action-fg);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.float-send-btn svg { flex-shrink: 0; }
.float-send-btn:hover { background: var(--action-hover); box-shadow: 0 0 12px var(--accent-dim); }
.float-send-btn:active { transform: scale(0.97); }
.float-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Bottom bar */
.floating-bottom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.floating-bottom-bar::-webkit-scrollbar { display: none; }

/* Chip buttons in bottom bar (快速 / skill shortcuts) */
.fbb-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    border: 1px solid var(--cyber-border);
    color: var(--cyber-muted);
    background: transparent;
    transition: all 0.15s;
}
.fbb-chip:hover {
    color: var(--cyber-primary);
    border-color: var(--cyber-primary);
    background: var(--accent-soft-bg);
}
/* active = 快速/no-think selected */
.fbb-chip.fbb-chip-active {
    color: var(--cyber-primary);
    border-color: var(--cyber-primary);
    background: var(--accent-soft-bg);
}
/* deselected = thinking mode on */
.fbb-chip.fbb-chip-thinking {
    color: var(--warning);
    border-color: var(--warning);
    background: var(--warning-soft-bg);
}

/* Agent switcher dropdown */
.agent-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    min-width: 100px;
    z-index: 200;
    overflow: hidden;
}
.agent-menu-item {
    padding: 8px 14px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.agent-menu-item:hover { background: var(--control-hover-bg); }
.agent-menu-item.active {
    color: var(--cyber-primary);
    font-weight: 600;
    background: var(--control-selected-bg);
}
.agent-menu-item.active:hover { background: var(--control-selected-hover-bg); }
.agent-brand-icon {
    display: block;
    width: 16px;
    height: 16px;
    padding: 2px;
    border-radius: 4px;
    background: #ffffff;
    object-fit: contain;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
    flex-shrink: 0;
}

/* Attached files */
.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 0;
}
.attached-files:empty { display: none; }

/* Drop overlay */
.input-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--accent-dim);
    border: 2px dashed var(--cyber-primary);
    border-radius: 16px;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--cyber-primary);
    z-index: 10;
    pointer-events: none;
}
.input-drop-overlay.active { display: flex; }

/* Voice status - inline in bottom bar */
.voice-status-inline {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Input char count indicator */
.input-char-count {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
    opacity: 0.7;
    transition: color 0.2s;
}
.input-char-count.warn  { color: var(--warning); opacity: 1; }
.input-char-count.error { color: var(--error); opacity: 1; }

/* Quick skill actions */
.floating-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 12px 8px;
}
.floating-quick-actions:empty { display: none; }
.quick-skill-chip {
    padding: 3px 10px;
    border: 1px solid var(--cyber-border);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    background: transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.quick-skill-chip:hover { background: var(--nav-active-bg); color: var(--cyber-primary); border-color: var(--cyber-primary); }

/* ===== FULLSCREEN MODAL (editor / preview) ===== */
.fullscreen-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}
.fullscreen-modal-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    margin: 40px;
    border-radius: 12px;
    border: 1px solid var(--cyber-border);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--cyber-border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.editor-filename {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}
.editor-lang-badge {
    font-size: 11px;
    padding: 2px 7px;
    background: var(--accent-dim);
    border: 1px solid var(--cyber-border);
    border-radius: 4px;
    color: var(--cyber-primary);
    font-family: var(--font-mono);
    white-space: nowrap;
}
.editor-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.editor-status { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.float-expand, .modal-close-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.float-expand:hover, .modal-close-btn:hover { color: var(--cyber-primary); background: var(--nav-active-bg); }
.modal-close-btn { font-size: 18px; }

.code-editor {
    flex: 1;
    width: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    tab-size: 4;
}

.preview-area {
    flex: 1;
    overflow: auto;
    background: var(--bg-primary);
    padding: 20px;
}
.preview-placeholder {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    margin-top: 80px;
}

/* ===== SIDEBAR STORAGE BAR ===== */
.sidebar-storage {
    border-top: 1px solid var(--cyber-border);
    padding: 10px 14px;
    flex-shrink: 0;
}
.storage-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}
.storage-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.storage-pct { font-size: 11px; font-family: var(--font-mono); color: var(--cyber-primary); font-weight: 600; }
.storage-bar-bg { height: 4px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.storage-bar-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--cyber-primary), var(--accent-hover)); transition: width 0.5s ease; }
.storage-detail { font-size: 11px; color: var(--text-muted); }

/* ===== MODE BADGE (in right panel header) ===== */
.mode-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-mono);
}
.mode-badge-api { background: var(--accent-dim); color: var(--cyber-primary); border: 1px solid var(--cyber-border); }
.mode-badge-cli { background: var(--success-soft-bg); color: var(--success); border: 1px solid var(--success-soft-border); }
.mode-badge-hermes { background: rgba(167,139,250,0.12); color: #a78bfa; border: 1px solid rgba(167,139,250,0.25); }

/* ===== SCROLL BUTTONS — repositioned for new layout ===== */
.scroll-to-top-btn {
    position: absolute;
    bottom: var(--scroll-to-top-btn-bottom);
    right: 14px;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--cyber-border);
    background: var(--panel-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s, transform 0.15s, color 0.15s;
    z-index: 50; font-size: 11px;
    backdrop-filter: blur(8px);
}
.scroll-to-top-btn:hover { color: var(--cyber-primary); border-color: var(--cyber-primary); transform: translateY(-1px); }
.scroll-to-bottom-btn {
    position: absolute;
    bottom: var(--scroll-to-bottom-btn-bottom);
    right: 14px;
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1px solid var(--cyber-border);
    background: var(--panel-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s, transform 0.15s, color 0.15s;
    z-index: 50; font-size: 11px;
    backdrop-filter: blur(8px);
}
.scroll-to-bottom-btn:hover { color: var(--cyber-primary); border-color: var(--cyber-primary); transform: translateY(-1px); }

/* ===== RESPONSIVE: hide right sidebar on narrow screens ===== */
@media (max-width: 1200px) {
    .right-sidebar { display: none; }
}
@media (max-width: 900px) {
    .header-nav span { display: none; }
    .header-skill-btn span { display: none; }
    .theme-btn span { display: none; }
}
@media (max-width: 640px) {
    .header-nav { display: none; }
    .fullscreen-modal-inner { margin: 0; border-radius: 0; }
}

/* ===== WELCOME MESSAGE ===== */
.welcome-message {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 60px;
    user-select: none;
}

/* Enhanced welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 32px;
    user-select: none;
    animation: msgFadeIn 0.3s ease;
}
.welcome-logo-wrap {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent-dim, rgba(0,240,255,0.08));
    border: 1px solid var(--cyber-border, rgba(0,240,255,0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.welcome-logo-svg {
    width: 28px;
    height: 28px;
    color: var(--cyber-primary, #00f0ff);
    opacity: 0.8;
}
.welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.welcome-mode-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 28px;
}
.welcome-prompts {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 600px;
    margin-bottom: 20px;
}
.welcome-prompt-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s;
    max-width: 220px;
    font-size: 13px;
    color: var(--text-secondary);
}
.welcome-prompt-card:hover {
    border-color: var(--cyber-primary, #00f0ff);
    color: var(--text-primary);
    background: var(--accent-dim, rgba(0,240,255,0.06));
    transform: translateY(-2px);
}
.welcome-prompt-icon { font-size: 16px; flex-shrink: 0; }
.welcome-prompt-text { font-size: 12px; line-height: 1.4; }
.welcome-tip {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Recent sessions on welcome screen */
.welcome-recent {
    margin-top: 20px;
    width: 100%;
    max-width: 480px;
}
.welcome-recent-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    padding-left: 2px;
}
.welcome-recent-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.welcome-recent-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-width: 0;
}
.welcome-recent-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.welcome-recent-icon {
    font-size: 13px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.welcome-recent-title {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.welcome-recent-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ===== NAV PAGE VIEWS (history full, skills full, settings full) ===== */
.nav-page {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    z-index: 200;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.nav-page.active { display: flex; }

/* ===== ABOUT PANEL ===== */
.about-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0 20px;
    gap: 8px;
}
.about-logo { width: 60px; height: 60px; border-radius: 14px; }
.about-name { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.about-version { font-size: 13px; color: var(--text-muted); font-family: var(--font-mono); }
.about-build-time { font-size: 11px; color: var(--text-muted); opacity: 0.6; margin-top: -2px; }
.move-confirm-actions { display: flex; gap: 6px; flex-shrink: 0; }


.text-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.text-btn:hover { border-color: var(--cyber-primary); color: var(--cyber-primary); background: var(--nav-active-bg); }
.send-btn {
    background: var(--action-bg);
    border: none;
    border-radius: 7px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--action-fg);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}
.send-btn:hover { background: var(--action-hover); box-shadow: 0 0 10px var(--accent-dim); }
.danger-btn { background: var(--error) !important; }
.danger-btn:hover { background: var(--error-hover) !important; }

/* ===== MODAL WIDE/LARGE/SMALL SIZES ===== */
.modal-wide .modal-content { width: 680px; max-width: 95vw; }
.modal-large .modal-content { width: 760px; max-width: 95vw; max-height: 85vh; }
.modal-small .modal-content { width: 380px; max-width: 95vw; }
.new-session-modal-content { width: 500px; max-width: 95vw; }
.new-session-directory-field { margin-top: 2px; }
.new-session-directory-selection {
    display: flex;
    align-items: stretch;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}
.new-session-directory-selection.selected {
    border-color: var(--success);
    background: var(--control-selected-bg);
}
.new-session-directory-selection.selected .new-session-directory-open { color: var(--control-selected-text); }
.new-session-directory-selection.selected .new-session-directory-open i { color: var(--success); }
.new-session-directory-open {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}
.new-session-directory-open span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.new-session-directory-open i { color: var(--accent); flex: none; }
.new-session-directory-clear {
    width: 38px;
    border: 0;
    border-left: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.new-session-directory-open:hover,
.new-session-directory-clear:hover { color: var(--text-primary); background: var(--control-hover-bg); }
.new-session-directory-selection.selected .new-session-directory-open:hover,
.new-session-directory-selection.selected .new-session-directory-clear:hover {
    color: var(--control-selected-text);
    background: var(--control-selected-hover-bg);
}
.new-session-directory-picker {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-secondary);
}
.new-session-directory-picker[hidden] { display: none; }
.new-session-directory-toolbar {
    display: flex;
    align-items: center;
    min-height: 38px;
    border-bottom: 1px solid var(--border);
}
.new-session-directory-toolbar button {
    width: 38px;
    align-self: stretch;
    border: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.new-session-directory-toolbar button:disabled { opacity: 0.35; cursor: default; }
.new-session-directory-toolbar span {
    min-width: 0;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font: 12px var(--font-mono);
}
.new-session-directory-list { height: 190px; overflow-y: auto; padding: 4px; }
.new-session-directory-item {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 9px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
}
.new-session-directory-item:hover { background: var(--control-hover-bg); color: var(--text-primary); }
.new-session-directory-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-session-directory-item i:first-child { color: var(--accent); }
.new-session-directory-item i:last-child { color: var(--text-muted); font-size: 10px; }
.new-session-directory-empty { padding: 54px 12px; text-align: center; color: var(--text-muted); font-size: 12px; }
.new-session-directory-hint {
    padding: 7px 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
}
.new-session-directory-hint i { margin-right: 5px; color: var(--accent); }
.new-session-directory-actions { display: flex; border-top: 1px solid var(--border); }
.new-session-directory-choose,
.new-session-directory-none {
    flex: 1;
    min-height: 38px;
    border: 0;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.new-session-directory-none { background: var(--bg-primary); color: var(--text-secondary); }
.new-session-directory-choose { background: var(--action-bg); color: var(--action-fg); font-weight: 600; }
.new-session-directory-choose:hover { background: var(--action-hover); }
.new-session-directory-none:hover { background: var(--control-hover-bg); color: var(--text-primary); }
.new-session-directory-actions button + button { border-left: 1px solid var(--border); }

.session-skill-field { margin-top: 2px; }
label.session-skill-filter {
    min-height: 34px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-muted);
    font-weight: 400;
}
.session-skill-filter:focus-within { border-color: var(--accent); }
.session-skill-filter i { flex: none; font-size: 12px; }
label.session-skill-filter input {
    width: auto;
    height: 32px;
    min-width: 0;
    flex: 1;
    padding: 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    box-shadow: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    line-height: normal;
    transition: none;
}
label.session-skill-filter input:focus {
    border: 0;
    box-shadow: none;
}
.session-skill-filter input::placeholder { color: var(--text-muted); }
.session-skill-choice-list {
    max-height: 168px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    padding: 4px;
}
label.session-skill-choice {
    min-height: 46px;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 5px 8px;
    border-radius: 4px;
    font-weight: 400;
    cursor: pointer;
}
.session-skill-choice:hover { background: var(--control-hover-bg); }
.session-skill-choice.selected {
    background: var(--control-selected-bg);
    color: var(--control-selected-text);
}
.session-skill-choice.selected:hover { background: var(--control-selected-hover-bg); }
.session-skill-choice.selected .session-skill-choice-name { color: var(--control-selected-text); }
.session-skill-choice.selected .session-skill-choice-meta { color: var(--control-selected-muted); }
.session-skill-choice[hidden] { display: none; }
.session-skill-choice input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    padding: 0;
    box-shadow: none;
    accent-color: var(--accent);
}
.session-skill-choice-text { min-width: 0; }
.session-skill-choice-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}
.session-skill-choice-meta {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 11px;
}
.session-skill-choice-state {
    padding: 24px 10px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}
.session-skill-config-content { width: min(500px, calc(100vw - 24px)); }
.session-skill-config-session {
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 12px;
}
.session-skill-config-list { max-height: min(360px, calc(100vh - 250px)); }
.session-skill-config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.session-install-menu {
    width: 220px;
    max-height: min(360px, calc(100vh - 8px));
    overflow-y: auto;
    overflow-x: hidden;
}
.session-install-menu .context-menu-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== SESSION TITLE IN HEADER ===== */
.header-session-title {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ===== HISTORY SEARCH ===== */
.history-search-wrap {
    padding: 12px 16px 8px;
    flex-shrink: 0;
}
.history-search-wrap input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}
.history-search-wrap input:focus { border-color: var(--cyber-primary); }


/* ===== NAV APPS MODAL ===== */
.nav-tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 16px 0 0;
    margin-bottom: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav-tab-bar::-webkit-scrollbar { display: none; }
.nav-tab-btn {
    flex-shrink: 0;
    padding: 7px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 4px 4px 0 0;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.nav-tab-btn:hover { color: var(--text-primary); }
.nav-tab-btn.active {
    color: var(--accent, #3b82f6);
    border-bottom-color: var(--accent, #3b82f6);
    font-weight: 500;
}
.nav-apps-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 4px 0;
}
.nav-app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 88px;
    cursor: pointer;
    padding: 12px 6px 10px;
    border-radius: 12px;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, transform 0.12s;
    text-decoration: none;
    color: inherit;
}
.nav-app-item:hover {
    background: var(--bg-secondary);
    border-color: var(--border);
    transform: translateY(-2px);
}
.nav-app-item:active { transform: translateY(0); }
.nav-app-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: contain;
    flex-shrink: 0;
    background: var(--bg-secondary);
}
/* fallback gradient icon (canvas/div) */
.nav-app-icon-fallback {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    user-select: none;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.nav-app-name {
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    color: var(--text-secondary);
    word-break: break-all;
    max-width: 80px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}


/* ============================================================
   应用商店子系统样式
   ============================================================ */

.appstore-list {
    margin: 12px 0;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.appstore-list .list-header {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.app-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.app-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.app-card:last-child {
    margin-bottom: 0;
}

.app-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.app-stats {
    font-size: 12px;
    color: var(--text-muted);
}

.app-download-btn {
    padding: 8px 16px;
    background: var(--action-bg);
    color: var(--action-fg);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.app-download-btn:hover {
    background: var(--action-hover);
    transform: translateY(-1px);
}

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

.subsystem-error {
    margin: 8px 0;
    padding: 12px;
    background: var(--error-soft-bg);
    color: var(--error);
    border-radius: 6px;
    font-size: 14px;
    border: 1px solid var(--error-soft-border);
}

/* ============================================================
   子系统卡片样式（应用商店 + 网站列表）
   ============================================================ */

.subsystem-card {
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

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

.subsystem-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.subsystem-body {
    max-height: 400px;
    overflow-y: auto;
}

.subsystem-empty {
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 网站列表项 */
.website-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.website-item:last-child {
    border-bottom: none;
}

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

.website-info {
    flex: 1;
    min-width: 0;
}

.website-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.website-url {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.website-tags {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.website-tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--tag-bg);
    color: var(--tag-color);
    border-radius: 12px;
    font-size: 11px;
}

.website-action {
    margin-left: 12px;
}

.website-open-btn {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

/* AI 联动：当前用户 Token 用量 */
.subsystem-usage-card {
    --subsystem-usage-input: #1769c2;
    --subsystem-usage-output: #14806b;
    max-width: 760px;
}

[data-theme="blue"] .subsystem-usage-card,
[data-theme="dark"] .subsystem-usage-card,
[data-theme="gray"] .subsystem-usage-card {
    --subsystem-usage-input: #59a9ff;
    --subsystem-usage-output: #52c7a5;
}

.subsystem-usage-header > div {
    min-width: 0;
}

.subsystem-usage-identity {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subsystem-usage-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid var(--border);
}

.subsystem-usage-summary span {
    padding: 10px 12px;
    color: var(--text-secondary);
    font-size: 11px;
    border-right: 1px solid var(--border);
}

.subsystem-usage-summary span:last-child {
    border-right: 0;
}

.subsystem-usage-summary strong {
    display: block;
    margin-top: 2px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.subsystem-usage-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px 2px;
    color: var(--text-secondary);
    font-size: 11px;
}

.subsystem-usage-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.subsystem-usage-legend i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.subsystem-usage-key-input { background: var(--subsystem-usage-input); }
.subsystem-usage-key-output { background: var(--subsystem-usage-output); }

.subsystem-usage-legend b {
    margin-left: auto;
    color: var(--text-muted);
    font-weight: 400;
}

.subsystem-usage-chart-scroll {
    overflow-x: auto;
    padding: 8px 12px 5px;
}

.subsystem-usage-chart {
    display: flex;
    align-items: stretch;
    min-width: 100%;
    height: 128px;
    border-bottom: 1px solid var(--border);
}

.subsystem-usage-day {
    display: flex;
    flex: 1 0 24px;
    min-width: 24px;
    flex-direction: column;
    align-items: center;
    min-height: 0;
}

.subsystem-usage-bar-pair {
    display: flex;
    flex: 1;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-height: 0;
}

.subsystem-usage-bar {
    display: block;
    width: 6px;
    min-height: 0;
    border-radius: 2px 2px 0 0;
}

.subsystem-usage-bar-input { background: var(--subsystem-usage-input); }
.subsystem-usage-bar-output { background: var(--subsystem-usage-output); }

.subsystem-usage-day > span {
    height: 20px;
    padding-top: 5px;
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
}

.subsystem-usage-table-wrap {
    max-height: 210px;
    overflow: auto;
    border-top: 1px solid var(--border);
}

.subsystem-usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.subsystem-usage-table th,
.subsystem-usage-table td {
    padding: 7px 12px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.subsystem-usage-table th:first-child,
.subsystem-usage-table td:first-child {
    text-align: left;
}

.subsystem-usage-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    font-weight: 600;
}

.subsystem-usage-table td {
    color: var(--text-primary);
}

.subsystem-usage-table tr:last-child td {
    border-bottom: 0;
}

@media (max-width: 720px) {
    .subsystem-usage-header {
        align-items: flex-start;
        gap: 8px;
        flex-direction: column;
    }

    .subsystem-usage-summary strong { font-size: 14px; }
    .subsystem-usage-table th,
    .subsystem-usage-table td { padding-left: 8px; padding-right: 8px; }
}

/* File path clickable links in AI responses */
.file-path-link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dashed var(--primary);
    cursor: pointer;
    font-weight: 500;
    padding: 0 2px;
    border-radius: 2px;
    transition: all 0.2s;
}

.file-path-link:hover {
    color: var(--primary-hover, #1565c0);
    border-bottom-style: solid;
    background-color: rgba(25, 118, 210, 0.08);
}

/* Flash highlight animation for located files */
.tree-item.highlight-flash {
    animation: file-flash 2s ease-out;
}

@keyframes file-flash {
    0%, 100% { 
        background-color: transparent; 
    }
    15%, 45% { 
        background-color: rgba(255, 235, 59, 0.4);
    }
    30%, 60% {
        background-color: rgba(255, 235, 59, 0.2);
    }
}


/* ============================================================
   PERFORMANCE: Load More Messages Button
   ============================================================ */
.load-more-messages {
    text-align: center;
    padding: 15px 0;
    margin: 10px 0;
}

.load-more-messages button {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.load-more-messages button:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--accent);
}

.load-more-messages button i {
    font-size: 12px;
}

/* ============================================================
   PERSONAL TOKEN USAGE
   ============================================================ */
.usage-modal-content {
    --usage-input: #1769c2;
    --usage-output: #14806b;
    width: min(980px, 94vw);
    max-width: 980px;
    max-height: 90vh;
    border-radius: 8px;
}

[data-theme="blue"] .usage-modal-content,
[data-theme="dark"] .usage-modal-content,
[data-theme="gray"] .usage-modal-content {
    --usage-input: #59a9ff;
    --usage-output: #52c7a5;
}

.usage-modal-header {
    min-height: 68px;
    padding: 14px 20px;
}

.usage-modal-header h2 {
    font-size: 17px;
    font-weight: 650;
}

.usage-identity {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.usage-modal-body {
    padding: 0;
    min-height: 500px;
}

.usage-loading,
.usage-error {
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.usage-loading[hidden],
.usage-error[hidden],
#usageContent[hidden] {
    display: none;
}

.usage-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid var(--border);
    border-top-color: var(--action-bg);
    border-radius: 50%;
    animation: usage-spin 0.8s linear infinite;
}

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

.usage-error svg {
    color: var(--error);
}

.usage-error button {
    border: 0;
    border-radius: 6px;
    padding: 7px 16px;
    background: var(--action-bg);
    color: var(--action-fg);
    cursor: pointer;
    font: inherit;
}

.usage-error button:hover {
    background: var(--action-hover);
}

.usage-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.usage-summary-item {
    min-width: 0;
    padding: 17px 20px;
    border-right: 1px solid var(--border);
}

.usage-summary-item:last-child {
    border-right: 0;
}

.usage-summary-label {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.usage-summary-item strong {
    display: block;
    color: var(--text-primary);
    font-size: 21px;
    font-weight: 650;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.usage-summary-total strong {
    color: var(--action-bg);
}

.usage-section {
    padding: 18px 20px 20px;
}

.usage-day-section {
    border-top: 1px solid var(--border);
}

.usage-section-header {
    min-height: 30px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.usage-section-header h3 {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 650;
}

.usage-section-header > div > span,
.usage-selected-date {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

.usage-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 12px;
}

.usage-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.usage-legend i {
    display: inline-block;
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 2px;
}

.usage-legend-input { background: var(--usage-input); }
.usage-legend-output { background: var(--usage-output); }

.usage-chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.usage-chart {
    position: relative;
    min-width: 800px;
    height: 260px;
}

.usage-chart-grid {
    position: absolute;
    inset: 10px 8px 30px 52px;
}

.usage-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
}

.usage-grid-line span {
    position: absolute;
    right: calc(100% + 8px);
    top: -7px;
    min-width: 40px;
    text-align: right;
    color: var(--text-muted);
    font-size: 10px;
}

.usage-bars {
    position: absolute;
    inset: 10px 8px 0 52px;
    display: grid;
    grid-template-columns: repeat(30, minmax(18px, 1fr));
    gap: 2px;
}

.usage-day-group {
    position: relative;
    min-width: 0;
    height: 100%;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
}

.usage-day-group:hover {
    background: var(--nav-active-bg);
}

.usage-day-group:focus-visible {
    outline: 1px solid var(--accent-soft-border);
    outline-offset: -1px;
}

.usage-day-group.selected {
    background: var(--nav-active-bg);
    outline: none;
    box-shadow: inset 0 0 0 1px var(--accent-soft-border);
}

.usage-day-group.selected::after {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 1px;
    height: 2px;
    border-radius: 2px;
    background: var(--action-bg);
}

.usage-bar-pair {
    position: absolute;
    inset: 0 2px 30px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.usage-bar {
    display: block;
    width: calc(50% - 1px);
    max-width: 10px;
    border-radius: 2px 2px 0 0;
    transition: height 0.2s ease, filter 0.15s ease;
}

.usage-day-group:hover .usage-bar {
    filter: brightness(1.12);
}

.usage-bar-input { background: var(--usage-input); }
.usage-bar-output { background: var(--usage-output); }

.usage-day-axis-label {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 10px;
    white-space: nowrap;
}

.usage-day-group.selected .usage-day-axis-label {
    color: var(--accent);
    font-weight: 700;
}

.usage-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.usage-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.usage-table th,
.usage-table td {
    padding: 10px 12px;
    text-align: right;
    border-right: 1px solid var(--border);
}

.usage-table th:last-child,
.usage-table td:last-child {
    border-right: 0;
}

.usage-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.usage-table td {
    border-top: 1px solid var(--border);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.usage-table th:first-child,
.usage-table td:first-child {
    text-align: left;
}

@media (max-width: 700px) {
    .usage-modal-content {
        width: 96vw;
        max-height: 94vh;
    }
    .usage-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .usage-summary-item:nth-child(2) { border-right: 0; }
    .usage-summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
    .usage-summary-item strong { font-size: 18px; }
    .usage-section { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .usage-spinner { animation-duration: 1.6s; }
    .usage-bar { transition: none; }
}

/* ZEE workflow notifications. */
.notification-modal-content {
    width: min(820px, 94vw);
    max-width: calc(100vw - 32px);
    height: min(760px, 90vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.notification-modal-header { flex-shrink: 0; }
.notification-modal-summary {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12px;
}
.notification-toolbar {
    display: flex;
    min-height: 54px;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.notification-toolbar[hidden] { display: none; }
.notification-status-tabs,
.notification-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.notification-status-tabs {
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
}
.notification-status-tabs button,
.notification-toolbar-actions button,
.notification-pagination button,
.notification-state button,
.notification-card-read,
.notification-card-detail,
.notification-detail-back {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font: 600 12px var(--font-ui);
    cursor: pointer;
}
.notification-status-tabs button { border-color: transparent; }
.notification-status-tabs button.active {
    border-color: var(--accent-soft-border);
    background: var(--control-selected-bg);
    color: var(--control-selected-text);
}
.notification-status-tabs button:hover,
.notification-toolbar-actions button:hover,
.notification-pagination button:hover,
.notification-state button:hover,
.notification-card-read:hover,
.notification-card-detail:hover,
.notification-detail-back:hover {
    border-color: var(--accent-soft-border);
    background: var(--control-hover-bg);
    color: var(--accent);
}
.notification-toolbar-actions #notificationMarkAllBtn {
    border-color: var(--accent);
    background: var(--action-bg);
    color: var(--action-fg);
}
.notification-toolbar-actions #notificationMarkAllBtn:hover {
    border-color: var(--accent-hover);
    background: var(--action-hover);
    color: var(--action-fg);
}
.notification-toolbar button:disabled,
.notification-pagination button:disabled,
.notification-card-read:disabled,
.notification-card-detail:disabled {
    opacity: 0.48;
    cursor: default;
}
.notification-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px;
    background: var(--bg-primary);
}
.notification-state {
    display: flex;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
}
.notification-state[hidden] { display: none; }
.notification-error { color: var(--error); }
.notification-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: notification-spin 0.8s linear infinite;
}
@keyframes notification-spin { to { transform: rotate(360deg); } }
.notification-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.notification-list[hidden] { display: none; }
.notification-card {
    display: grid;
    grid-template-columns: 5px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 13px 14px 13px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
}
.notification-card.unread {
    border-color: var(--accent-soft-border);
    background: var(--accent-soft-bg);
}
.notification-card-indicator { background: transparent; }
.notification-card.unread .notification-card-indicator { background: var(--accent); }
.notification-card-main { min-width: 0; }
.notification-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0;
}
.notification-card-status,
.notification-card-type {
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
}
.notification-card.unread .notification-card-status {
    border-color: var(--accent-soft-border);
    background: var(--control-selected-bg);
    color: var(--accent);
}
.notification-card-title {
    margin-top: 7px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.notification-card-content {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.notification-card-actions {
    display: flex;
    align-self: start;
    flex-direction: column;
    gap: 6px;
}
.notification-card-read,
.notification-card-detail {
    white-space: nowrap;
}
.notification-card-detail {
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--accent-soft-border);
    border-radius: 5px;
    background: var(--accent-soft-bg);
    color: var(--accent);
    font: 600 12px var(--font-ui);
    cursor: pointer;
}
.notification-detail { min-height: 100%; }
.notification-detail[hidden] { display: none; }
.notification-detail-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.notification-detail-heading {
    padding: 15px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
}
.notification-detail-heading h3 {
    margin-top: 9px;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.45;
    letter-spacing: 0;
}
.notification-detail-loading,
.notification-detail-error {
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}
.notification-detail-loading[hidden],
.notification-detail-error[hidden],
.notification-business-content[hidden] { display: none; }
.notification-detail-error { color: var(--error); }
.notification-business-content {
    margin-top: 12px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}
.notification-content-plain { white-space: pre-wrap; }
.notification-content-markdown > :first-child { margin-top: 0; }
.notification-content-markdown > :last-child { margin-bottom: 0; }
.notification-pagination {
    display: flex;
    min-height: 49px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 12px;
}
.notification-pagination[hidden] { display: none; }
.notification-pagination button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 620px) {
    .notification-modal-content { width: 96vw; height: 94vh; }
    .notification-toolbar { align-items: stretch; flex-direction: column; }
    .notification-status-tabs button { flex: 1; }
    .notification-toolbar-actions { justify-content: flex-end; }
    .notification-card { grid-template-columns: 4px minmax(0, 1fr); }
    .notification-card-actions { grid-column: 2; flex-direction: row; justify-self: start; }
}

/* Local KaTeX output in assistant messages. */
.message-content .math-inline-wrap {
    display: inline;
    color: inherit;
}

.message-content .math-display-wrap {
    max-width: 100%;
    margin: 12px 0;
    overflow-x: auto;
    overflow-y: hidden;
    color: inherit;
    scrollbar-width: thin;
}

.message-content .math-display-wrap .katex-display {
    margin: 0;
    padding: 4px 2px;
    text-align: center;
}

.message-content .math-render-error {
    overflow-wrap: anywhere;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
