:root {
    --bg-base: #09090b;
    --bg-panel: #18181b;
    --bg-hover: #27272a;
    --bg-active: #3f3f46;
    --border-color: #27272a;
    --border-light: #3f3f46;
    --text-primary: #f8fafc;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

.light-mode {
    --bg-base: #f8fafc;
    --bg-panel: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #3b82f6;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08);
}

.light-mode .editor { background: rgba(0,0,0,0.02); }
.light-mode .pt { background: rgba(0, 0, 0, 0.03); }
.light-mode .input-user { color: var(--text-primary); }
.light-mode button.danger { color: #b91c1c; background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.2); }
.light-mode button.danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.light-mode button.warning { color: #fff; background: var(--warning); }
.light-mode .b0 { background: rgba(71, 85, 105, 0.08); color: #334155; border: 1px solid rgba(71, 85, 105, 0.15); }
.light-mode .b1 { background: rgba(37, 99, 235, 0.08); color: #1d4ed8; border: 1px solid rgba(37, 99, 235, 0.15); }
.light-mode .b2 { background: rgba(147, 51, 234, 0.08); color: #7e22ce; border: 1px solid rgba(147, 51, 234, 0.15); }
.light-mode .b3 { background: rgba(220, 38, 38, 0.08); color: #b91c1c; border: 1px solid rgba(220, 38, 38, 0.15); box-shadow: 0 0 8px rgba(220, 38, 38, 0.05); }
.light-mode .b4 { background: rgba(22, 163, 74, 0.08); color: #15803d; border: 1px solid rgba(22, 163, 74, 0.15); }
.light-mode .b6 { background: rgba(71, 85, 105, 0.15); color: #475569; border: 1px solid rgba(71, 85, 105, 0.3); }
.light-mode .b6 { background: rgba(71, 85, 105, 0.15); color: #475569; border: 1px solid rgba(71, 85, 105, 0.3); }
.light-mode .hl { background: rgba(245, 158, 11, 0.12); border-bottom: 2px solid var(--warning); }
.light-mode .hl:hover { background: rgba(245, 158, 11, 0.22); }

.light-mode .anno-panel { background: var(--bg-panel); border-color: var(--border-light); }
.light-mode .a-item { background: var(--bg-hover); border-color: var(--border-light); }
.light-mode .a-item h4 { color: var(--primary); }
.light-mode .tooltip { background: var(--bg-panel); border-color: var(--border-light); color: var(--text-primary); box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.light-mode .tooltip-title { color: var(--primary); border-bottom-color: var(--border-light); }

.light-mode .auth-overlay { background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(12px); }
.light-mode .auth-box { background: var(--bg-panel); border-color: var(--border-light); box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.light-mode .auth-box input, 
.light-mode .auth-box textarea,
.light-mode .modal-box textarea { background: var(--bg-base); color: var(--text-primary); border-color: var(--border-light); }
.light-mode .kbd { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }

button.primary.outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}
button.primary.outline:hover {
    background: var(--primary);
    color: #fff;
}

* { box-sizing: border-box; }

body, html {
    height: 100%; margin: 0; padding: 0; overflow: hidden;
    background: var(--bg-base); color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(59, 130, 246, 0.4); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

button, input, textarea, select { font: inherit; outline: none; }
button {
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 8px 14px; background: var(--bg-panel); color: var(--text-primary);
    cursor: pointer; transition: all 0.2s ease;
    font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-light); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); }

button.primary { background: var(--primary); border-color: transparent; color: #fff; }
button.primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 0 12px rgba(59, 130, 246, 0.4); }
button.success { background: var(--success); border-color: transparent; }
button.danger { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
button.danger:hover:not(:disabled) { background: var(--danger); color: #fff; box-shadow: 0 0 12px rgba(239, 68, 68, 0.4); }
button.warning { background: var(--warning); border-color: transparent; color: #111; }
button.outline { background: transparent; }

input, select {
    background: var(--bg-base); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 8px 12px; transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.w-full { width: 100%; }
.w-half { width: calc(50% - 4px); }

.app { height: 100%; display: grid; grid-template-rows: 56px minmax(0, 1fr); }

.topbar {
    display: flex; gap: 16px; align-items: center; padding: 0 20px;
    background: var(--bg-panel); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color); z-index: 10;
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: -0.5px; background: linear-gradient(to right, #60a5fa, #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sp { flex: 1; }

/* Topbar Actions Area */
.actions-top { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 2px;
}
.actions-top::-webkit-scrollbar {
    height: 4px;
}
.actions-top::-webkit-scrollbar-track {
    background: transparent;
}
.actions-top::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
}
.actions-top::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary);
}
.actions-top > * {
    flex-shrink: 0;
}
.select-css { padding: 6px 10px; font-weight: 500; min-width: 130px; background: var(--bg-base); }
.select-css option { background: var(--bg-panel); color: var(--text-primary); }
.divider { width: 1px; height: 24px; background: var(--border-color); margin: 0 8px; }
.account-badge { 
    display: flex; align-items: center; gap: 6px; 
    background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2px 4px 2px 10px; border-radius: var(--radius-sm);
}
.account-badge span { font-size: 12px; font-weight: 600; color: #60a5fa; }
.input-user { background: transparent; border: none; padding: 4px; width: 100px; color: #fff; font-weight: 600; font-size: 13px; }
.input-user:focus { box-shadow: none; border-bottom: 1px solid var(--primary); border-radius: 0; }

.btn-icon { padding: 6px; border-radius: var(--radius-sm); border: none; background: transparent; }
.btn-icon:hover { background: var(--bg-hover); }

.main { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.main.imm { grid-template-columns: 40px minmax(0, 1fr); }

.sidebar { border-right: 1px solid var(--border-color); background: var(--bg-base); display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.rail { display: none; height: 100%; writing-mode: vertical-rl; text-align: center; color: var(--text-secondary); cursor: pointer; padding: 20px 0; font-weight: 600; letter-spacing: 2px; }
.rail:hover { background: var(--bg-panel); color: var(--text-primary); }
.main.imm .rail { display: flex; align-items: center; justify-content: center; }
.main.imm .content { display: none; }

.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.sec { padding: 16px; border-bottom: 1px solid var(--border-color); }
.sec h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); font-weight: 700; }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.mt-2 { margin-top: 12px; }

.meta { font-size: 12px; color: var(--text-secondary); }
.meta-light { color: var(--text-primary); font-weight: 500; }

.progress { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px; margin-top: 12px; }
.progbar { height: 6px; background: var(--bg-base); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progbar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.3s ease; box-shadow: 0 0 8px var(--primary); }
.log { max-height: 100px; overflow-y: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); white-space: pre-wrap; line-height: 1.4; }

.btn-action { padding: 6px 12px; font-size: 13px; }

/* 重点修复：Tasks列表自适应高度，并确保内部可滚动 */
.tasks { flex: 1; overflow-y: auto; padding: 12px; background: rgba(24, 24, 27, 0.3); height: 0; }

.task {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 12px; cursor: pointer;
    transition: all 0.2s ease; margin-bottom: 8px;
}
.task:hover { border-color: var(--border-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.task.on { border-color: var(--primary); background: rgba(59, 130, 246, 0.05); box-shadow: 0 0 0 1px var(--primary); }
.task.disabled { opacity: 0.5; pointer-events: none; }
.task b { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; font-weight: 600; word-break: break-all; line-height: 1.4; }
.task input[type="checkbox"] { margin-top: 3px; }
.task-details { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.task-path { font-size: 11px; color: var(--text-muted); word-break: break-all; margin-top: 4px; }

.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; display: inline-block; }
.b0 { background: rgba(161, 161, 170, 0.15); color: #e4e4e7; border: 1px solid rgba(161,161,170,0.3); }
.b1 { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.b2 { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168,85,247,0.3); }
.b3 { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); box-shadow: 0 0 8px rgba(239,68,68,0.2); }
.b4 { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.b6 { background: rgba(71, 85, 105, 0.25); color: #94a3b8; border: 1px solid rgba(71, 85, 105, 0.4); }
.archived-task { opacity: 0.6; filter: grayscale(80%); }
.b6 { background: rgba(71, 85, 105, 0.25); color: #94a3b8; border: 1px solid rgba(71, 85, 105, 0.4); }
.archived-task { opacity: 0.6; filter: grayscale(80%); }

.workspace { position: relative; display: flex; flex-direction: column; background: var(--bg-base); min-height: 0; }
.work { flex: 1; display: grid; grid-template-rows: 56px minmax(0, 1fr) 64px; min-width: 0; }

.work-container { display: flex; height: 100%; width: 100%; min-width: 0; min-height: 0; }
.resizer-h { width: 6px; cursor: col-resize; background: var(--bg-base); transition: background 0.2s; z-index: 10; border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color); flex-shrink: 0; }
.resizer-h:hover, .resizer-h.active { background: var(--primary); }
.right-sidebar { display: flex; flex-direction: column; background: var(--bg-panel); overflow: hidden; height: 100%; flex-shrink: 0; border-left: 1px solid var(--border-color); }
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.sidebar-tab { flex: 1; padding: 12px 0; text-align: center; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-secondary); background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; transition: all 0.2s; }
.sidebar-tab:hover { color: var(--text-primary); }
.sidebar-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sidebar-content { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg-base); }


.head, .bar { display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--bg-panel); border-bottom: 1px solid var(--border-color); }
.bar { border-top: 1px solid var(--border-color); border-bottom: none; }
.title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.split { height: 100%; display: grid; grid-template-rows: minmax(0, 40%) 12px minmax(0, 1fr); padding: 16px; gap: 0; min-height: 0; }
.pane { min-height: 0; border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-panel); display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.pt { padding: 8px 16px; background: rgba(39, 39, 42, 0.5); border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: 12px; letter-spacing: 1px; color: var(--text-secondary); text-transform: uppercase; }
.pb { flex: 1; overflow: auto; position: relative; min-height: 0; }

.viewer, .editor { width: 100%; height: 100%; margin: 0; padding: 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--text-primary); border: none; background: transparent; resize: none; white-space: pre-wrap; word-break: break-word; }
.editor { background: rgba(0,0,0,0.2); }
.editor:focus { outline: none; }

.div { cursor: row-resize; display: flex; justify-content: center; align-items: center; transition: background 0.2s; }
.div::before { content: ""; width: 60px; height: 4px; background: var(--border-light); border-radius: 99px; transition: background 0.2s; }
.div:hover::before { background: var(--primary); }

.hide { display: none !important; }

.hl { background: rgba(245, 158, 11, 0.25); border-bottom: 2px solid var(--warning); padding: 0 2px; border-radius: 2px; cursor: help; transition: background 0.2s; }
.hl:hover { background: rgba(245, 158, 11, 0.4); }

.anno-panel { position: absolute; left: calc(100% - 380px); top: 72px; width: 340px; min-width: 240px; min-height: 200px; height: calc(80vh - 120px); background: rgba(24, 24, 27, 0.85); backdrop-filter: blur(16px); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px; z-index: 20; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; resize: both; overflow: hidden; }
.a-item { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; background: rgba(0,0,0,0.3); }
.a-item h4 { margin: 0 0 6px; font-size: 13px; color: var(--warning); }
.a-item p { margin: 6px 0; font-size: 13px; }
.a-item .quote { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); padding-left: 8px; border-left: 2px solid var(--border-color); margin-bottom: 8px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; animation: fadeIn 0.2s; }
.modal-box { width: min(500px, 90vw); background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-lg); animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-box h3 { margin: 0 0 16px; font-size: 18px; }
.modal-box textarea { width: 100%; height: 120px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 12px; margin: 16px 0; background: var(--bg-base); color: var(--text-primary); font-family: var(--font-sans); }
.modal-box .actions { justify-content: flex-end; gap: 12px; }

.toasts-container { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: 600px; width: 90vw; }
.toast-item { pointer-events: auto; background: var(--bg-panel); border: 1px solid var(--border-color); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 12px 20px; box-shadow: var(--shadow-lg); font-weight: 500; font-size: 13px; animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1); display: flex; align-items: center; gap: 10px; backdrop-filter: blur(12px); }
.toast-item.err { border-left-color: var(--danger); }
.toast-item.warn { border-left-color: var(--warning); }
.toast-item.ok { border-left-color: var(--success); }
.toast-item.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-16px); } }

.empty-state { height: 100%; display: grid; place-items: center; color: var(--text-secondary); }
.empty-card { max-width: 600px; text-align: center; }
.empty-card h2 { color: var(--text-primary); margin-bottom: 16px; font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.empty-card p { line-height: 1.6; margin-bottom: 16px; font-size: 15px; }
.kbd { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 4px; padding: 2px 6px; font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); }

.tooltip { position: absolute; pointer-events: none; background: rgba(24, 24, 27, 0.95); border: 1px solid var(--border-color); box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); padding: 12px; color: var(--text-primary); z-index: 100; max-width: 300px; font-size: 13px; font-family: var(--font-sans); opacity: 0; transition: opacity 0.2s; white-space: pre-wrap; line-height: 1.5; word-break: break-all; }
.tooltip.show { opacity: 1; }
.tooltip-title { font-weight: 700; color: var(--warning); margin-bottom: 6px; font-size: 12px; border-bottom: 1px solid var(--border-light); padding-bottom: 6px;}

.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(12px); z-index: 1000; display: grid; place-items: center; }
.auth-box { width: min(340px, 90vw); background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); }
.auth-box h2 { margin: 0 0 24px; text-align: center; color: var(--text-primary); font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.auth-box input { margin-bottom: 16px; padding: 12px; font-size: 14px; background: rgba(9, 9, 11, 0.5); }
.auth-box button { padding: 12px; font-size: 15px; font-weight: 600; margin-top: 8px; }

.env-item { padding: 12px 16px; border-bottom: 1px solid var(--border-color); cursor: pointer; font-size: 13px; font-family: var(--font-mono); word-break: break-all; transition: background 0.2s; color: var(--text-secondary); }
.env-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.env-item.on { background: rgba(59, 130, 246, 0.1); border-left: 3px solid var(--primary); color: var(--primary); font-weight: 600; padding-left: 13px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }


/* MD Code Block JSON Workspace */
.md-code-block { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: #e2e8f0; background: #0f172a; padding: 16px; overflow: auto; height: 100%; }
.light-mode .md-code-block { background: #f8fafc; color: #334155; border: 1px solid var(--border-light); }
.json-line { display: block; white-space: pre-wrap; overflow-wrap: break-word; word-break: break-all; position: relative; }
.json-fold-btn { display: inline-block; width: 16px; text-align: center; cursor: pointer; color: #64748b; user-select: none; font-size: 10px; margin-right: 8px; vertical-align: top; padding-top: 4px; }

.json-fold-placeholder { display: inline-block; width: 16px; text-align: center; cursor: pointer; color: #64748b; user-select: none; font-size: 10px; margin-right: 8px; vertical-align: top; padding-top: 4px; }

.json-fold-btn:hover { color: var(--primary); }
.json-str { color: #4ade80; }
.json-num { color: #fca5a5; }
.json-bool { color: #fde047; }
.json-punct { color: #94a3b8; }
.json-brace-open, .json-brace-close { color: #cbd5e1; }
.light-mode .json-str { color: #16a34a; }
.light-mode .json-num { color: #b91c1c; }
.light-mode .json-bool { color: #ca8a04; }
.light-mode .json-punct { color: #64748b; }
.light-mode .json-brace-open, .light-mode .json-brace-close { color: #475569; }
.json-line.folded::after { content: ' ...'; color: var(--text-secondary); background: rgba(128,128,128,0.2); padding: 0 4px; border-radius: 4px; margin-left: 8px; cursor: pointer; font-size: 12px; }

.json-key { color: #f472b6; }
.light-mode .json-key { color: #db2777; }
.pane-query .md-code-block, .pane-query .viewer, .pane-query .editor, .pane-query .cm-s-custom { font-size: var(--query-font-size, 13px) !important; }
.pane-rubrics .md-code-block, .pane-rubrics .viewer, .pane-rubrics .editor, .pane-rubrics .cm-s-custom { font-size: var(--rubrics-font-size, 13px) !important; }

/* CodeMirror Custom Theme */
.cm-s-custom.CodeMirror { background: #0f172a; color: #e2e8f0; font-family: var(--font-mono); height: 100%; border-radius: 4px; padding: 10px; }
.light-mode .cm-s-custom.CodeMirror { background: #f8fafc; color: #334155; border: 1px solid var(--border-light); }
.cm-s-custom .cm-string { color: #4ade80 !important; }
.light-mode .cm-s-custom .cm-string { color: #16a34a !important; }
.cm-s-custom .cm-property { color: #f472b6 !important; }
.light-mode .cm-s-custom .cm-property { color: #db2777 !important; }

/* Selection Bubble */
#selBubble {
    position: fixed;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1e293b;
    border: 1px solid rgba(251,191,36,0.5);
    border-radius: 20px;
    padding: 5px 12px 5px 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #fbbf24;
    white-space: nowrap;
    animation: bubblePop 0.15s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: all;
    transform-origin: center bottom;
}
.light-mode #selBubble {
    background: #fff;
    border-color: rgba(251,191,36,0.6);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
#selBubble:hover { background: rgba(251,191,36,0.15); border-color: #fbbf24; }
@keyframes bubblePop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Common Error Floating Dialog (no overlay) */
#commonErrDialog {
    position: fixed;
    z-index: 9998;
    width: 340px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    overflow: hidden;
    animation: slideUp 0.2s ease;
}
#commonErrDialog .ced-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(251,191,36,0.08);
    border-bottom: 1px solid var(--border-color);
    cursor: move;
    user-select: none;
    font-weight: 700;
    font-size: 13px;
    color: #fbbf24;
}
#commonErrDialog .ced-body { padding: 14px; }
#commonErrDialog .ced-quote {
    font-size: 12px;
    background: var(--bg-base);
    border-left: 3px solid #fbbf24;
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    color: var(--text-secondary);
    margin-bottom: 10px;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
#commonErrDialog textarea {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    font-size: 13px;
    margin-bottom: 10px;
}
#commonErrDialog .ced-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Search Highlight */
.search-highlight { background-color: #fde047; color: #000; border-radius: 2px; }
.search-highlight.current { background-color: #fb923c; box-shadow: 0 0 0 2px #fb923c; }
.light-mode .search-highlight { background-color: #fef08a; }
.light-mode .search-highlight.current { background-color: #fdba74; }

.search-bar-mini { 
    display: flex; gap: 4px; align-items: center; margin-left: 12px; 
    border: 1px solid var(--border-color); border-radius: 4px; padding: 2px 4px; 
    background: var(--bg-base); flex: 1; max-width: 200px;
}
.search-bar-mini input { border: none; outline: none; background: transparent; font-size: 11px; width: 100%; padding: 0 4px; color: var(--text-primary); }
.search-bar-mini .info { font-size: 10px; color: var(--text-secondary); min-width: 30px; text-align: center; white-space: nowrap; }


.cm-s-custom .cm-number { color: #fca5a5 !important; }
.light-mode .cm-s-custom .cm-number { color: #b91c1c !important; }
.cm-s-custom .cm-atom { color: #fde047 !important; }
.light-mode .cm-s-custom .cm-atom { color: #ca8a04 !important; }
.cm-s-custom .CodeMirror-gutters { background: transparent; border-right: 1px solid rgba(255,255,255,0.1); }
.light-mode .cm-s-custom .CodeMirror-gutters { border-right: 1px solid var(--border-light); }
.cm-s-custom .CodeMirror-cursor { border-left: 2px solid #fff !important; }
.light-mode .cm-s-custom .CodeMirror-cursor { border-left: 2px solid #000 !important; }

/* AI Floating Ball */
.ai-ball {
    position: fixed; right: 24px; bottom: 80px; z-index: 1000;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-ball:hover { transform: scale(1.1) translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.ai-ball-text { font-size: 9px; font-weight: 700; text-align: center; line-height: 1.1; }

.ai-ball.thinking { background: var(--warning); animation: pulse-thinking 1.5s infinite; }
@keyframes pulse-thinking {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(245, 158, 11, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.ai-ball.done { background: var(--success); }
.ai-ball.hide { transform: scale(0) rotate(-180deg); opacity: 0; pointer-events: none; }

/* AI Enhanced Modal */
.ai-modal-resizable {
    position: fixed !important; 
    margin: 0 !important;
    resize: both; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
}
.ai-modal-resizable .modal-box { width: 100% !important; height: 100% !important; max-height: none !important; border: none !important; margin: 0 !important; }

.project-list-locked { pointer-events: none; opacity: 0.6; filter: grayscale(0.5); cursor: not-allowed; }
.project-list-locked::after { content: 'AI 质检中...'; position: absolute; top: 10px; right: 10px; font-size: 10px; background: var(--warning); color: #fff; padding: 2px 6px; border-radius: 4px; z-index: 100; }
/* Selection Bubble */
.sel-bubble {
    position: fixed; z-index: 1000;
    background: var(--primary); color: #fff;
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 500;
    cursor: pointer; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 6px;
    animation: pop 0.2s ease-out;
    border: 1px solid rgba(255,255,255,0.1);
}
.sel-bubble:hover { background: var(--primary-hover); transform: translateY(-1px); }
@keyframes pop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Non-blocking Annotation Modal */
.anno-dialog {
    position: fixed; z-index: 1001;
    width: 380px; background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.anno-dialog-header {
    padding: 12px 16px; background: var(--bg-hover);
    border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
    cursor: move;
}
.anno-dialog-body { padding: 16px; }
.anno-dialog-body textarea {
    width: 100%; height: 120px; padding: 10px;
    background: var(--bg-base); color: var(--text-primary);
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    resize: vertical; font-family: var(--font-sans); margin-top: 10px;
}
.anno-dialog-footer { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-hover); }

.light-mode .anno-dialog { box-shadow: 0 10px 40px rgba(0,0,0,0.1); }

/* Highlight for selected annotation */
.hl-active {
    background: rgba(245, 158, 11, 0.4) !important;
    border-bottom: 2px solid #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
    border-radius: 2px;
    animation: pulse-hl 1.5s infinite;
}
@keyframes pulse-hl {
    0% { background: rgba(245, 158, 11, 0.4); }
    50% { background: rgba(245, 158, 11, 0.6); }
    100% { background: rgba(245, 158, 11, 0.4); }
}

.a-item.active {
    border-left: 4px solid var(--warning) !important;
    background: var(--bg-active) !important;
}

/* Temporary highlight during annotation creation */
.temp-hl {
    background: rgba(59, 130, 246, 0.25) !important;
    border-bottom: 2px dashed var(--primary);
    border-radius: 2px;
}

.cm-hl-pending { border-bottom: 2px dashed var(--warning); background: rgba(245, 158, 11, 0.1); }
.cm-hl-fixed { border-bottom: 2px solid var(--success); background: rgba(16, 185, 129, 0.1); }
.fixed-done { border-left: 4px solid var(--success) !important; opacity: 0.7; }
.a-item.fixed-done .quote { text-decoration: line-through; color: var(--text-muted); }
.btn-fixed { padding: 2px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-base); color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.btn-fixed:hover { border-color: var(--primary); color: var(--primary); }
.btn-fixed.active { background: var(--success); border-color: var(--success); color: white; }
.meta-info { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.note-box { background: rgba(0,0,0,0.1); padding: 8px; border-radius: 4px; font-size: 12px; margin-top: 4px; border-left: 3px solid var(--border-color); }
.btn-sm { padding: 2px 6px; font-size: 11px; border-radius: 4px; }
.b5 { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.cm-hl-pending { background: rgba(245, 158, 11, 0.25) !important; border-bottom: 2px dashed #f59e0b !important; }
.cm-hl-fixed { background: rgba(16, 185, 129, 0.2) !important; border-bottom: 2px solid #10b981 !important; }
.hl.cm-hl-pending, .hl.cm-hl-fixed { position: static; z-index: 1; }
