/* ============ 桌面助手样式（浅色） ============ */
:root {
  --teal: #0f766e; --teal-2: #14b8a6; --teal-bg: #e6f7f5;
  --orange: #ea580c; --amber: #f59e0b; --red: #e11d48;
  --blue: #2563eb; --slate: #64748b;
  --green: #15803d;
  /* 来源色 */
  --src-voice: #22a06b; --src-voice-bg: #e8f7f0;
  --src-doc: #2563eb; --src-doc-bg: #eaf1fe;
  --src-ai: #ea580c; --src-ai-bg: #fef0e6;
  --bg: #f3f5f9; --card: #ffffff; --line: #e3e8ef;
  --text: #1f2430; --text-2: #6b7280;
  --done: #94a3b8;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --r: 12px;
  /* 可调布局变量（运行时由 splitter 改写，localStorage 持久化） */
  --rail-w: 372px;       /* 右栏聊天栏宽度 */
  --gantt-h: 56vh;       /* 甘特图卡片高度 */
  --chat-input-h: 96px;  /* 聊天栏输入区高度（splitH3 拖动） */
  --top-gap: 12px;       /* 主区内卡片间距（不变，供参考） */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.app { display: flex; height: 100vh; width: 100vw; }

/* ============ 可拖动分割条 ============ */
.split { position: relative; flex: 0 0 auto; background: transparent; z-index: 30; user-select: none; touch-action: none; }
.split::before { content: ''; position: absolute; background: var(--line); transition: background .15s; }
.split:hover::before, .split.dragging::before { background: var(--teal-2); }
.split-v { width: 8px; cursor: col-resize; }
.split-v::before { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }
.split-v:hover::before, .split-v.dragging::before { width: 4px; }
.split-h { height: 8px; cursor: row-resize; width: 100%; }
.split-h::before { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); }
.split-h:hover::before, .split-h.dragging::before { height: 4px; }
.split:active { cursor: grabbing; }
body.sizing, body.sizing * { cursor: inherit !important; user-select: none !important; }
body.sizing-v { cursor: col-resize !important; }
body.sizing-v * { cursor: col-resize !important; }
body.sizing-h { cursor: row-resize !important; }
body.sizing-h * { cursor: row-resize !important; }

/* ============ 左主区 ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 8px 14px 16px; overflow: hidden; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-logo { font-size: 26px; }
.brand-text h1 { font-size: 17px; font-weight: 700; line-height: 1.2; }
.brand-text { display: flex; flex-direction: column; }
.ai-badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; width: fit-content; }
.ai-badge.on { background: #dcfce7; color: #15803d; }
.ai-badge.off { background: #fee2e2; color: #b91c1c; }
.ai-badge.wait { background: #fef9c3; color: #a16207; }

.clock { text-align: center; flex: 0 0 auto; margin: 0 auto; }
.clock-time { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.clock-date { font-size: 12px; color: var(--text-2); }

.now-box { flex: 0 1 520px; min-width: 280px; display: flex; align-items: center; gap: 8px; background: var(--teal-bg); border: 1px solid #b7e5df; border-radius: 10px; padding: 6px 10px; position: relative; transition: background .3s, border-color .3s; }
.now-box.flash { background: #fff4e5; border-color: #fcd08a; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(245, 158, 11, .15); } }
.now-box.urgent { background: #fef2f2; border-color: #fecaca; }
.now-label { font-size: 12px; font-weight: 700; color: var(--teal); white-space: nowrap; }
.now-box.urgent .now-label { color: var(--red); }
.now-text { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#notifyBtn, #speakBtn { flex: 0 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; width: 30px; height: 30px; }
#notifyBtn.on { border-color: var(--teal); background: var(--teal-bg); }
#speakBtn.on { border-color: var(--orange); background: #fef0e6; }

/* ---------- 卡片通用 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-weight: 400; font-size: 12px; color: var(--text-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-teal { background: var(--teal-2); } .dot-orange { background: var(--orange); }

.gantt-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 12px; font-size: 13px; color: var(--text); transition: all .15s; }
.mini-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-bg); }
.mini-btn.strong { font-weight: 600; }
.mini-btn.accent { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.mini-btn.accent:hover { background: #0d6a63; color: #fff; }
.mini-btn.danger { color: var(--red); border-color: #fecaca; }
.mini-btn.danger:hover { background: #fef2f2; }
.mini-select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 13px; background: #fff; color: var(--text); }
.mini-date { border: 1px solid var(--line); border-radius: 8px; padding: 3px 5px; font-size: 12px; background: #fff; color: var(--text); font-family: inherit; width: 118px; }
.gantt-range-label { font-size: 12px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 15px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--teal); }

/* ---------- 甘特图 ---------- */
.gantt-card { flex: 0 0 auto; height: var(--gantt-h, 56vh); min-height: 180px; max-height: 78vh; overflow: hidden; }
.gantt-wrap { overflow: auto; padding: 10px 6px 6px 0; flex: 1; min-height: 0; }
.gantt { position: relative; min-width: 680px; }
.gantt-head { display: grid; border-bottom: 1px solid var(--line); }
.gantt-day { text-align: center; font-size: 12px; padding: 2px 0; color: var(--text-2); border-left: 1px dashed transparent; }
.gantt-day .wd { display: block; font-weight: 600; font-size: 12px; }
.gantt-day.weekend .wd { color: var(--red); opacity: .75; }
.gantt-day.today { background: var(--teal-bg); border-radius: 6px 6px 0 0; }
.gantt-day.today .wd, .gantt-day.today .md { color: var(--teal); font-weight: 800; }
.gantt-day .md { font-size: 11px; }
.gantt-head.rows-mode .gantt-day { border-left-color: transparent; }

.g-row { display: grid; grid-template-columns: 232px 1fr; min-height: 38px; border-bottom: 1px solid #eef1f6; }
.g-row:last-child { border-bottom: none; }
.g-name { padding: 4px 8px 4px 12px; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; }
.g-name .t { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-name .t .src-tag { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.src-tag.voice { background: var(--src-voice-bg); color: var(--src-voice); }
.src-tag.doc { background: var(--src-doc-bg); color: var(--src-doc); }
.src-tag.ai { background: var(--src-ai-bg); color: var(--src-ai); }
.g-name .meta { font-size: 11px; color: var(--text-2); display: flex; gap: 6px; align-items: center; overflow: hidden; white-space: nowrap; }
.tag-pri { font-size: 10px; padding: 0 5px; border-radius: 4px; font-weight: 700; }
.tag-pri.high { background: #fee2e2; color: var(--red); }
.tag-pri.medium { background: #fef3c7; color: #b45309; }
.tag-pri.low { background: #e0e7ff; color: #4338ca; }
.g-name.done .t { color: var(--done); text-decoration: line-through; }
.g-cells { position: relative; }
.g-cells .cellgrid { position: absolute; inset: 0; display: grid; }
.cellgrid .c { border-left: 1px solid #f1f4f9; }
.cellgrid .c.weekend { background: #fafbfd; }
.cellgrid .c.today-col { background: rgba(20, 184, 166, .10); }
.g-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--teal-2); opacity: .5; pointer-events: none; z-index: 1; }
.g-bar { position: absolute; top: 6px; height: 26px; border-radius: 7px; z-index: 2; display: flex; align-items: center; padding: 0 8px; font-size: 12px; font-weight: 600; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; box-shadow: 0 1px 2px rgba(16,24,40,.12); transition: transform .1s, box-shadow .1s; }
.g-bar:hover { transform: translateY(-1px); box-shadow: 0 4px 8px rgba(16,24,40,.18); z-index: 3; }
/* 状态 × 来源：优先级状态视觉，来源用左侧色条 + 文字标签 */
.g-bar.st-todo.src-voice { background: #fff; border: 1.5px solid var(--src-voice); color: var(--src-voice); }
.g-bar.st-todo.src-doc { background: #fff; border: 1.5px solid var(--src-doc); color: var(--src-doc); }
.g-bar.st-todo.src-ai { background: #fff; border: 1.5px solid var(--src-ai); color: var(--src-ai); }
.g-bar.st-doing.src-voice { background: var(--src-voice); color: #fff; }
.g-bar.st-doing.src-doc { background: var(--src-doc); color: #fff; }
.g-bar.st-doing.src-ai { background: var(--src-ai); color: #fff; }
.g-bar.st-done { background: #e2e8f0; color: var(--done); border: 1px dashed #cbd5e1; }
.g-bar.st-done::after { content: "✓"; position: absolute; right: 4px; font-weight: 800; }
.g-bar.st-ignored { background: #f1f5f9; color: #94a3b8; border: 1px dotted #cbd5e1; opacity: .85; }
.g-bar.st-ignored::after { content: "✕"; position: absolute; right: 4px; font-weight: 800; }
.g-bar.st-overdue.src-voice { background: var(--red); color: #fff; }
.g-bar.st-overdue.src-doc { background: var(--red); color: #fff; }
.g-bar.st-overdue.src-ai { background: var(--red); color: #fff; }
.g-bar.drag { opacity: .6; }
.g-rowhead { position: sticky; top: 0; z-index: 5; background: var(--card); }
.loading, .empty-hint { color: var(--text-2); padding: 26px; text-align: center; font-size: 13px; }
.legend { display: flex; gap: 12px; padding: 6px 14px 10px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; border-top: 1px dashed var(--line); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.lg-sep { color: var(--line); font-weight: 700; }
.lg-dot { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-dot.src-voice { background: var(--src-voice); }
.lg-dot.src-doc { background: var(--src-doc); }
.lg-dot.src-ai { background: var(--src-ai); }
.lg-dot.st-doing { background: var(--teal); }
.lg-dot.st-todo { border: 1.5px solid var(--teal-2); background: #fff; }
.lg-dot.st-overdue { background: var(--red); }
.lg-dot.st-done { background: #e2e8f0; border: 1px dashed #cbd5e1; }
.lg-dot.st-ignored { background: #f1f5f9; border: 1px dotted #cbd5e1; }

/* ---------- 待确认建议区 ---------- */
.pending-area { border-bottom: 1px dashed var(--line); max-height: 0; overflow: hidden; transition: max-height .3s; background: #fffdf8; flex: 0 0 auto; }
.pending-area.has { max-height: 240px; overflow-y: auto; }
.pending-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 2px; font-size: 12px; font-weight: 700; color: var(--src-ai); gap: 8px; }
.pending-head small { font-weight: 400; color: var(--text-2); }
.pending-head-btns { display: flex; gap: 6px; flex-shrink: 0; }
.pending-list { padding: 6px 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.pend-item { display: flex; gap: 8px; align-items: flex-start; border: 1px solid #fbd9c2; border-left: 4px solid var(--src-ai); background: #fff; border-radius: 9px; padding: 7px 10px; }
.pend-item .p-what { font-weight: 600; font-size: 13px; }
.pend-item .p-why { color: var(--text-2); font-size: 12px; margin-top: 1px; }
.pend-item .p-when { font-size: 11px; color: var(--src-ai); margin-top: 1px; }
.pend-btns { display: flex; gap: 5px; margin-left: auto; flex: 0 0 auto; align-items: center; }
.pend-ok { border: none; background: var(--src-ai); color: #fff; border-radius: 7px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.pend-ok:hover { background: #c2410c; }
.pend-no { border: 1px solid var(--line); background: #fff; color: var(--text-2); border-radius: 7px; padding: 4px 8px; font-size: 12px; }
.pend-no:hover { color: var(--red); border-color: #fecaca; }

/* ---------- 建议面板 ---------- */
.suggest-card { flex: 1 1 auto; min-height: 80px; overflow: hidden; transition: min-height .2s; }
.suggest-card.is-empty { flex: 0 0 auto; min-height: 0; }
.suggest-card.is-empty .suggest-body { display: none; }
.suggest-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; min-height: 0; }
.sug-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-left: 4px solid var(--teal-2); background: #fafdfc; border-radius: 10px; padding: 8px 12px; }
.sug-item .idx { font-weight: 800; color: var(--teal); font-size: 15px; flex: 0 0 auto; }
.sug-item .what { font-weight: 600; font-size: 13px; }
.sug-item .why { color: var(--text-2); font-size: 12px; }
.sug-item .when { margin-top: 2px; font-size: 11px; }
.sug-item .when b { color: var(--orange); }
.sug-loading { color: var(--text-2); padding: 8px 4px; font-size: 13px; }

/* ---------- 周报结果区 ---------- */
.report-box { margin: 8px 14px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.report-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.report-head b { font-size: 13px; }
.report-body { padding: 8px 12px; font-size: 12.5px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; font-family: "Cascadia Mono", Consolas, monospace; line-height: 1.6; color: #334155; }

/* ============ 聊天栏 ============ */
.chat-rail { width: var(--rail-w, 372px); flex: 0 0 var(--rail-w, 372px); min-width: 240px; max-width: 640px; display: flex; flex-direction: column; background: var(--card); border-left: 1px solid var(--line); height: 100vh; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 700; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.chat-title small { font-weight: 400; color: var(--text-2); font-size: 12px; }
.chat-msgs { flex: 1 1 0; min-height: 100px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: #fafbfd; }
.msg { max-width: 86%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.msg.ai b { color: var(--teal); }
.msg.sys { align-self: center; background: #fef9c3; color: #854d0e; font-size: 12px; border-radius: 8px; padding: 5px 12px; }
.msg.ai.err { border-color: #fecaca; color: var(--red); background: #fff5f5; }
.msg .op-tag { display: inline-block; background: var(--teal-bg); color: var(--teal); font-size: 11px; border-radius: 6px; padding: 1px 7px; margin: 2px 4px 0 0; }
.typing { display: inline-flex; align-items: center; gap: 4px; padding: 4px 2px; }
.typing .t-think {
  font-style: normal; font-size: 12.5px; color: var(--text-2);
  margin-right: 4px; animation: thinkPulse 1.2s infinite;
}
.typing i { width: 7px; height: 7px; background: var(--text-2); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing i:nth-of-type(2) { animation-delay: .15s; } .typing i:nth-of-type(3) { animation-delay: .3s; }
@keyframes bounce { 30% { transform: translateY(-5px); background: var(--teal); } }
@keyframes thinkPulse { 0%, 60%, 100% { opacity: 0.45; } 30% { opacity: 1; } }

.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 2px; }
.chip { border: 1px solid #c9e8e3; background: var(--teal-bg); color: var(--teal); font-size: 12px; border-radius: 999px; padding: 3px 10px; }
.chip:hover { background: var(--teal); color: #fff; }
.chat-input { display: flex; gap: 8px; padding: 8px 12px 12px; border-top: 1px solid var(--line); align-items: stretch; flex: 0 0 var(--chat-input-h, 96px); min-height: var(--chat-input-h, 96px); max-height: 60vh; }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; font-family: inherit; height: 100%; max-height: 100%; min-height: 0; outline: none; background: #fff; color: var(--text); overflow-y: auto; }
.chat-input textarea:focus { border-color: var(--teal-2); }
#chatSend { width: 38px; height: 38px; border-radius: 10px; border: none; background: var(--teal); color: #fff; font-size: 17px; }
#chatSend:hover { background: #0d6a63; }
#chatSend:disabled { opacity: .5; cursor: not-allowed; }

.chat-float { position: fixed; right: 22px; bottom: 22px; z-index: 60; background: var(--teal); color: #fff; border: none; border-radius: 999px; padding: 12px 18px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(15,118,110,.4); }

/* ============ 弹窗 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 80; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; width: 520px; max-width: 94vw; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.modal-body input, .modal-body select, .modal-body textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px; font-family: inherit; outline: none; background: #fff; color: var(--text); }
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus { border-color: var(--teal-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 100; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 70vw; }
#toast.show { opacity: .95; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #aeb8c6; }

/* ===== Agent 操作确认卡（聊天区里，AI 写文件/删文件/跑命令需你授权） ===== */
.act-card {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 4px 0; padding: 10px 12px;
  background: #fff8ec;
  border: 1px solid #f2d9a4;
  border-radius: 12px;
  max-width: 92%;
  align-self: flex-start;
  box-shadow: var(--shadow);
  animation: fadein 0.2s ease-out;
}
.act-card .act-ic {
  font-size: 18px; line-height: 1.4; flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fdeed3;
}
.act-card.cmd .act-ic { background: #e8f1fd; }
.act-card.del .act-ic { background: #fde8e8; }
.act-card .act-body { flex: 1; min-width: 0; }
.act-card .act-title { font-size: 13px; font-weight: 700; color: var(--text); }
.act-card .act-path {
  font-size: 12px; color: var(--teal);
  background: #fff; border: 1px dashed var(--line);
  border-radius: 6px; padding: 4px 7px; margin: 5px 0;
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all; white-space: pre-wrap;
  user-select: text;
}
.act-card .act-hint { font-size: 11px; color: var(--text-2); }
.act-card .act-btns { display: flex; gap: 6px; flex-shrink: 0; }
.act-card .act-btns button {
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 5px 12px;
  transition: all .12s; color: #fff; white-space: nowrap;
}
.act-card .act-btns .ok { background: var(--teal); }
.act-card .act-btns .ok:hover:not(:disabled) { background: #0d6a63; }
.act-card .act-btns .all { background: #f0a020; }
.act-card .act-btns .all:hover:not(:disabled) { background: #d68e16; }
.act-card .act-btns .no { background: #cbd5e1; }
.act-card .act-btns .no:hover:not(:disabled) { background: #dc2626; }
.act-card .act-btns button:disabled { opacity: .55; cursor: not-allowed; }
.act-card.busy { opacity: .7; }

/* ===== 🧠 大脑页 ===== */
.modal.modal-lg { width: 900px; max-width: 96vw; height: 86vh; }
.brain-body { display: flex; flex: 1; min-height: 0; }
.brain-side {
  width: 220px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brain-tabs { display: flex; flex-direction: column; gap: 6px; }
.brain-tabs .tab {
  text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 9px; padding: 8px 12px; font-size: 13px; cursor: pointer;
  color: var(--text); transition: all .12s;
}
.brain-tabs .tab:hover { border-color: var(--teal-2); }
.brain-tabs .tab.on { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.brain-meta {
  background: var(--teal-bg); border: 1px solid var(--teal-bg-2);
  border-radius: 10px; padding: 9px 11px; font-size: 12px;
  color: var(--text); line-height: 1.7; word-break: break-all;
}
.brain-meta b { color: var(--teal); }
.brain-meta code { background: #fff; border-radius: 4px; padding: 1px 4px; font-size: 11px; }
.brain-tip { font-size: 11.5px; color: var(--text-2); line-height: 1.6; }
.brain-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding: 12px 14px 14px; gap: 8px;
}
#brainText {
  flex: 1; resize: none;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; line-height: 1.65;
  font-family: Consolas, "SF Mono", "Courier New", monospace;
  background: #fcfdfe; color: var(--text);
  outline: none; min-height: 160px;
  white-space: pre-wrap;
}
#brainText:focus { border-color: var(--teal-2); box-shadow: 0 0 0 2px rgba(20, 184, 166, .12); }
.brain-bar { display: flex; align-items: center; gap: 8px; }
.brain-bar .hint { font-size: 12px; color: var(--text-2); }
.brain-log-head {
  font-size: 12px; font-weight: 700; color: var(--teal);
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.brain-log {
  height: 120px; overflow-y: auto;
  background: #fafbfd; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 11.5px; color: var(--text-2);
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.75;
  user-select: text;
}
.brain-log .hint { color: var(--text-2); }

/* ===== L5 文档知识库管理界面 ===== */
.brain-docs { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.brain-docs-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.brain-docs-search {
  flex: 1; min-width: 200px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: var(--bg-2); color: var(--text);
  outline: none; transition: border-color .15s;
}
.brain-docs-search:focus { border-color: var(--accent); }
.brain-docs-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.brain-doc-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: var(--bg-2); transition: border-color .15s, box-shadow .15s;
}
.brain-doc-card:hover { border-color: var(--accent-soft); box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.brain-doc-head { display: flex; gap: 10px; align-items: flex-start; }
.brain-doc-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.brain-doc-info { flex: 1; min-width: 0; }
.brain-doc-name { font-weight: 600; font-size: 13.5px; color: var(--text); word-break: break-all; }
.brain-doc-meta { font-size: 11.5px; color: var(--text-2); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.brain-doc-meta .tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: #eff6ff; color: #1d4ed8; border-radius: 4px; padding: 1px 6px; font-size: 11px;
}
.brain-doc-meta .tag.archived { background: #f3f4f6; color: #6b7280; }
.brain-doc-meta .tag.superseded { background: #fef3c7; color: #92400e; }
.brain-doc-summary { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.6; }
.brain-doc-keywords { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.brain-doc-kw {
  font-size: 10.5px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; color: var(--text-2);
}
.brain-doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.brain-doc-chunks { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; display: none; flex-direction: column; gap: 6px; }
.brain-doc-chunks.open { display: flex; }
.brain-chunk-item {
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  background: var(--bg); font-size: 11.5px;
}
.brain-chunk-title { font-weight: 600; color: var(--text); margin-bottom: 3px; }
.brain-chunk-meta { font-size: 10.5px; color: var(--text-2); margin-bottom: 4px; }
.brain-chunk-content { color: var(--text-2); line-height: 1.6; max-height: 80px; overflow: hidden; position: relative; }
.brain-chunk-content::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 20px;
  background: linear-gradient(transparent, var(--bg));
}
.brain-docs-empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.brain-docs-empty .icon { font-size: 40px; margin-bottom: 10px; }

/* ===== 信息出处（编辑弹窗 + 摘录原文浮层） ===== */
.ref-line { display: flex; gap: 6px; width: 100%; }
.ref-line input { flex: 1; min-width: 0; }
.doc-src { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.doc-src .ds-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; max-width: 260px;
}
.doc-src .ds-tag b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-src-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.doc-src-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-src-pre {
  flex: 1; min-height: 200px; max-height: 56vh; overflow: auto;
  background: #fafbfd; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 12px; line-height: 1.7; color: var(--text);
  font-family: Consolas, "Courier New", monospace; white-space: pre-wrap; word-break: break-word;
  user-select: text;
}

/* ============ 🧬 v2.49 L4 自我命题库面板 ============ */
.brain-l4 { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.brain-l4-stats { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
.l4-chip { font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.l4-chip b { color: var(--text); font-weight: 500; }
.l4-chip.warn { color: #8a5a00; border-color: #e8c98a; background: #fdf6e6; }
.l4-chip.warn b { color: #8a5a00; }
.brain-l4-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 4px; }
.l4-sec { display: flex; flex-direction: column; gap: 8px; }
.l4-sec-h { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.l4-tip { font-size: 11px; font-weight: 400; color: var(--text-2); }
.l4-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; background: var(--card); }
.l4-item.dim { opacity: .72; }
.l4-txt { font-size: 13px; line-height: 1.6; color: var(--text); word-break: break-word; }
.l4-txt.sm { font-size: 12px; color: var(--text-2); }
.l4-meta { font-size: 12px; color: var(--text-2); line-height: 1.5; word-break: break-word; }
.l4-tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); color: var(--text-2); margin-right: 4px; }
.l4-act { display: flex; gap: 8px; margin-top: 2px; }
