/* ========== 右侧抽屉 ========== */
.drawer-mask { position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:90; display:none;}
.drawer-mask.open { display:block;}
.drawer {
  position:fixed; top:0; right:0; width:420px; height:100vh;
  background:#fff; z-index:100; transform:translateX(100%); transition:transform .25s;
  display:flex; flex-direction:column; box-shadow:-4px 0 20px rgba(0,0,0,0.15);
}
.drawer.open { transform:translateX(0);}
.drawer-head { padding:16px 20px; border-bottom:1px solid #f3f4f6; display:flex; align-items:center; gap:10px;}
.drawer-head .t { flex:1; min-width:0;}
.drawer-head .title { font-weight:700; font-size:16px;}
.drawer-head .subtitle { font-size:12px; color:#9ca3af; margin-top:2px;}
.drawer-close { width:32px; height:32px; border-radius:8px; border:none; background:#f3f4f6; cursor:pointer; font-size:18px; line-height:1;}
.drawer-tabs { display:flex; border-bottom:1px solid #f3f4f6;}
.drawer-tab { flex:1; padding:10px; text-align:center; cursor:pointer; font-size:14px; color:#6b7280; border:none; background:transparent;}
.drawer-tab.active { color:#7c3aed; border-bottom:2px solid #7c3aed; font-weight:600;}
.drawer-body { flex:1; overflow-y:auto; padding:16px; background:#f9fafb;}
.chat-msg { margin-bottom:14px; display:flex; }
.chat-msg.user { justify-content:flex-end;}
.bubble { max-width:80%; padding:10px 14px; border-radius:12px; font-size:14px; line-height:1.5; word-break:break-word;}
.chat-msg.user .bubble { background:#7c3aed; color:#fff; border-bottom-right-radius:4px;}
.chat-msg.ai .bubble { background:#fff; color:#1f2937; border-bottom-left-radius:4px; box-shadow:0 1px 3px rgba(0,0,0,0.08);}
/* ========== 统一聊天弹框 ChatOverlay（单例，三态：展开/最小化/关闭） ========== */
.chat-mask {
  position:fixed; inset:0; background:rgba(15,23,42,0.35); z-index:150;
  opacity:0; pointer-events:none; transition:opacity .2s;
}
.chat-mask.open { opacity:1; pointer-events:auto; }
.chat-overlay {
  position:fixed; left:50%; bottom:0; transform:translate(-50%, 105%);
  width:80%; max-width:900px; height:70vh;
  background:#fff; border-radius:14px 14px 0 0;
  box-shadow:0 -10px 40px rgba(0,0,0,0.2);
  z-index:160; display:flex; flex-direction:column; overflow:hidden;
  transition:transform .25s ease;
}
.chat-overlay.open { transform:translate(-50%, 0); }
.chat-overlay.min {
  width:64px; height:64px; left:auto; right:24px; bottom:24px;
  border-radius:50%; transform:translateY(150%); cursor:pointer;
  box-shadow:0 6px 20px rgba(124,58,237,0.45);
  background:linear-gradient(135deg,#7c3aed,#a855f7);
}
.chat-overlay.min.open { transform:translateY(0); }
.chat-overlay.min .co-head, .chat-overlay.min .co-toolbar,
.chat-overlay.min .co-body, .chat-overlay.min .co-input { display:none; }
.chat-overlay.min .co-mini-icon { display:flex; }
.co-mini-icon {
  display:none; position:absolute; inset:0; align-items:center; justify-content:center;
  color:#fff;
}
.co-head { padding:12px 16px; border-bottom:1px solid #f3f4f6; display:flex; align-items:center; gap:10px; background:#fff;}
.co-head .t { flex:1; min-width:0; }
.co-head .title { font-weight:700; font-size:15px; color:#1f2937; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.co-head .subtitle { font-size:12px; color:#9ca3af; margin-top:1px;}
.co-head-btn {
  width:30px; height:30px; border-radius:8px; border:none; background:#f3f4f6;
  cursor:pointer; font-size:16px; color:#4b5563; display:flex; align-items:center; justify-content:center;
}
.co-head-btn:hover { background:#e5e7eb; }
.co-toolbar {
  padding:8px 16px; border-bottom:1px solid #f3f4f6; background:#fafafa;
  display:flex; align-items:center; justify-content:flex-end; gap:8px;
  position:relative;
}
.co-history-btn {
  margin-right:auto; background:transparent; border:1px solid #e5e7eb; color:#6b7280;
  padding:6px 12px; border-radius:8px; cursor:pointer; font-size:13px;
}
.co-history-btn:hover { background:#f3f4f6; }
.co-history-menu {
  position:absolute; top:100%; left:12px; margin-top:4px; background:#fff;
  border:1px solid #e5e7eb; border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,0.12);
  width:300px; max-height:320px; overflow-y:auto; z-index:170; display:none; padding:6px;
}
.co-history-menu.open { display:block; }
.co-history-item { padding:10px; border-radius:8px; cursor:pointer; border-bottom:1px solid #f3f4f6; }
.co-history-item:last-child { border-bottom:none; }
.co-history-item:hover { background:#f9fafb; }
.co-history-item .hi-msg { font-size:13px; color:#1f2937; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.co-history-item .hi-meta { font-size:11px; color:#9ca3af; margin-top:3px; display:flex; gap:8px; align-items:center; }
.co-history-empty { padding:14px; text-align:center; color:#9ca3af; font-size:13px; }
.co-compile-btn {
  background:linear-gradient(135deg,#7c3aed,#a855f7); color:#fff; border:none;
  padding:6px 14px; border-radius:8px; cursor:pointer; font-size:13px; font-weight:600;
  display:none; align-items:center; gap:6px;
}
.co-compile-btn.show { display:inline-flex; }
.co-compile-btn:disabled { opacity:0.6; cursor:not-allowed; }
.co-body { flex:1; overflow-y:auto; padding:16px; background:#f9fafb; }
.co-body .chat-msg { margin-bottom:14px; }
.co-body .chat-msg.ai .bubble { max-width:88%; }
.co-input { padding:12px 16px; border-top:1px solid #f3f4f6; display:flex; gap:8px; background:#fff;}
.co-input input { flex:1; padding:10px 12px; border:1px solid #e5e7eb; border-radius:8px; font-size:14px; outline:none;}
.co-input input:focus { border-color:#7c3aed; }
.co-input button {
  background:#7c3aed; color:#fff; border:none; border-radius:8px; padding:0 16px;
  cursor:pointer; display:flex; align-items:center;
}
.co-unread-dot {
  position:absolute; top:-4px; right:-4px; min-width:18px; height:18px; padding:0 5px;
  background:#ef4444; color:#fff; border-radius:9px; font-size:11px; font-weight:700;
  display:none; align-items:center; justify-content:center; z-index:165;
}
.chat-overlay.min.open .co-unread-dot { display:flex; }
@media (max-width: 700px){
  .chat-overlay { width:100%; height:75vh; }
}


/* ==================== 对话工具化（F-1）+ token 角标（F-2）+ 快捷指令（F-15） ==================== */

/* 工具卡：跟随 AI 气泡的消息内元素 */
.tool-card {
  max-width: 88%;
  margin-top: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 3px solid #7c3aed;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tc-head { display: flex; align-items: center; gap: 6px; }
.tc-icon { font-size: 14px; }
.tc-name { font-weight: 600; color: #1f2937; }
.tc-status { margin-left: auto; font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.tc-status.st-proposed { background: #fef3c7; color: #b45309; }
.tc-status.st-done { background: #dcfce7; color: #15803d; }
.tc-status.st-error { background: #fee2e2; color: #b91c1c; }
.tc-status.st-cancelled { background: #f3f4f6; color: #6b7280; }
.tc-args { margin-top: 6px; color: #6b7280; }
.tc-args summary { cursor: pointer; font-size: 12px; user-select: none; }
.tc-args pre {
  margin: 6px 0 0; padding: 8px; background: #f9fafb; border-radius: 6px;
  font-size: 12px; max-height: 180px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.tc-summary { margin-top: 6px; color: #374151; }
.tc-btns { margin-top: 8px; display: flex; gap: 8px; }
.tc-btns button {
  border: none; border-radius: 7px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.tc-btns .tc-ok { background: #7c3aed; color: #fff; }
.tc-btns .tc-ok:disabled { opacity: .5; cursor: default; }
.tc-btns .tc-no { background: #f3f4f6; color: #374151; }
.tc-btns .tc-no:disabled { opacity: .5; cursor: default; }

/* token 角标（F-2）：气泡右下灰色小字 */
.msg-tokens { font-size: 11px; color: #9ca3af; margin-top: 4px; text-align: right; }

/* 输入区「+」快捷指令（F-15；v24.15 拍板 E：hover 展开 + 防误关 + 分组样式） */
.input-wrap { position: relative; flex: 1; display: flex; align-items: center; gap: 6px; }
.input-wrap input { flex: 1; }
.input-plus {
  flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid #e5e7eb;
  background: #fff; color: #7c3aed; font-size: 17px; line-height: 1; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.input-plus:hover { border-color: #7c3aed; background: #f5f3ff; }
.quick-panel {
  display: none;
  position: absolute;
  bottom: 40px;
  left: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 60;
  animation: quickIn .12s ease-out;
}
@keyframes quickIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.quick-panel.open { display: block; }
.quick-g { padding: 6px 10px 2px; font-size: 11px; color: #9ca3af; letter-spacing: .08em; }
.quick-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; font-size: 13px; color: #1f2937; cursor: pointer;
}
.qi { font-size: 14px; width: 18px; text-align: center; flex: none; }
.quick-item:hover { background: #f5f3ff; color: #6d28d9; }
.quick-foot {
  margin-top: 4px; padding: 6px 10px 3px; font-size: 11px; color: #c0c4cc;
  border-top: 1px solid #f3f4f6;
}
