/* ============ AI 问办 · 右侧滑出面板 ============ */
.ai-mask {
  position: fixed; inset: 0; z-index: 260;
  background: rgba(16, 24, 40, .28); opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease-out); backdrop-filter: blur(1px);
}
.ai-mask.show { opacity: 1; pointer-events: auto; }

.ai-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
  z-index: 265; background: #fff; display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .35s var(--ease-drawer);
  box-shadow: -30px 0 70px rgba(16, 24, 40, .2); will-change: transform;
}
.ai-panel.is-open { transform: none; }

/* ---------- 头部 ---------- */
.ai-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #F7FAFF 0%, #FFFFFF 70%);
}
.ai-head-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--brand-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-brand);
}
.ai-head-main { flex: 1; min-width: 0; }
.ai-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 650; letter-spacing: -.2px; color: var(--ink);
}
.ai-online {
  display: inline-flex; align-items: center; gap: 4px; height: 17px; padding: 0 5px;
  border-radius: 3px; background: var(--green-bg); border: 1px solid var(--green-line);
  color: var(--green-600); font-size: 10px; font-weight: 500;
}
.ai-online .dot-live { width: 5px; height: 5px; }
.ai-online .dot-live::after { inset: -2px; }
.ai-sub { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-head-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.ai-head-actions .btn-icon { width: 28px; height: 28px; }

/* ---------- 上下文任务 ---------- */
.ai-context {
  flex: none; display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; background: var(--brand-50); border-bottom: 1px solid var(--brand-100);
  font-size: 11.5px; color: var(--brand-700);
}
.ai-context .icon { flex: none; }
.ai-ctx-no {
  font-size: 10.5px; color: var(--brand); background: #fff; border: 1px solid var(--brand-100);
  border-radius: 3px; padding: 0 4px; line-height: 16px;
}
.ai-ctx-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ai-ctx-close {
  margin-left: auto; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: 0; border-radius: 4px; background: transparent;
  color: var(--brand); cursor: pointer; padding: 0;
}
.ai-ctx-close:hover { background: #DCE8FF; }

/* ---------- 消息区 ---------- */
.ai-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 14px 10px; background: #FBFCFE;
  display: flex; flex-direction: column; gap: 14px;
}
.ai-msg { display: flex; gap: 8px; align-items: flex-start; animation: aiMsgIn .22s var(--ease-out); }
@keyframes aiMsgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-main { flex: 1; min-width: 0; }
.ai-msg-user .ai-msg-main { flex: none; max-width: 86%; display: flex; flex-direction: column; align-items: flex-end; }
.ai-bot-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none; margin-top: 1px;
  background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.ai-msg-who { font-size: 10.5px; color: var(--ink-4); margin-bottom: 3px; }
.ai-bubble {
  border-radius: 10px; padding: 9px 11px; font-size: 12.5px; line-height: 1.65;
  color: var(--ink-2); word-break: break-word;
}
.ai-msg-user .ai-bubble {
  background: var(--brand-gradient); color: #fff; border-bottom-right-radius: 3px;
  box-shadow: 0 4px 12px -6px rgba(31, 107, 255, .5);
}
.ai-msg-bot .ai-bubble {
  background: #fff; border: 1px solid var(--line); border-top-left-radius: 3px;
  box-shadow: var(--shadow-xs);
}
.ai-msg-bot .ai-msg-main { min-width: 0; }
.ai-time { font-size: 10px; color: var(--ink-4); margin-top: 4px; }
.ai-msg-user .ai-time { text-align: right; }

/* 打字中 */
.ai-msg-typing .ai-msg-main { display: flex; }
.ai-typing {
  display: inline-flex; align-items: center; gap: 4px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; border-top-left-radius: 3px;
  box-shadow: var(--shadow-xs);
}
.ai-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  opacity: .3; animation: aiDot 1.1s infinite ease-in-out;
}
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- 富文本回答 ---------- */
.ai-conclusion {
  display: flex; gap: 7px; padding: 9px 10px; border-radius: 7px;
  background: #F7F9FC; border: 1px solid var(--line-2);
  font-size: 12.5px; color: var(--ink-2); line-height: 1.65;
}
.ai-conclusion .icon { flex: none; margin-top: 2px; }
.ai-conclusion b { font-weight: 650; color: var(--ink); }
.ai-tone-red { background: var(--red-bg); border-color: var(--red-line); color: #912018; }
.ai-tone-red .icon { color: var(--red); }
.ai-tone-red b { color: #912018; }
.ai-tone-orange { background: var(--orange-bg); border-color: var(--orange-line); color: #8A4B00; }
.ai-tone-orange .icon { color: var(--orange); }
.ai-tone-orange b { color: #8A4B00; }
.ai-tone-green { background: var(--green-bg); border-color: var(--green-line); color: var(--green-600); }
.ai-tone-green .icon { color: var(--green); }
.ai-tone-green b { color: var(--green-600); }
.ai-tone-blue { background: var(--brand-50); border-color: var(--brand-100); color: #1D4F9C; }
.ai-tone-blue .icon { color: var(--brand); }
.ai-tone-blue b { color: #1D4F9C; }
.ai-tone-gray { background: #F7F9FC; border-color: var(--line-2); color: var(--ink-2); }
.ai-tone-gray .icon { color: var(--ink-3); }
.ai-tone-purple { background: var(--purple-bg); border-color: #D9D6FE; color: #5B44C4; }
.ai-tone-purple .icon { color: var(--purple); }
.ai-tone-purple b { color: #5B44C4; }

.ai-section-title {
  display: flex; align-items: center; gap: 5px; margin: 11px 0 6px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .03em;
}
.ai-section-title::before {
  content: ""; width: 3px; height: 10px; border-radius: 2px; background: var(--brand);
}
.ai-more { margin: 3px 0 2px; font-size: 10.5px; color: var(--ink-4); }
.ai-tip {
  display: flex; gap: 5px; margin-top: 9px; font-size: 10.5px; color: var(--ink-3); line-height: 1.65;
}
.ai-tip .icon { flex: none; margin-top: 2px; color: var(--ink-4); }
.ai-follow { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 9px; }
.ai-chip-btn {
  display: inline-flex; align-items: center; height: 22px; padding: 0 7px;
  border: 1px solid var(--brand-100); background: var(--brand-50); color: var(--brand);
  border-radius: 4px; font-size: 10.5px; cursor: pointer; transition: .15s;
}
.ai-chip-btn:hover { background: #E3EDFF; border-color: #C9DAFF; }
.ai-context-note {
  display: flex; align-items: center; gap: 5px; padding: 7px 9px; border-radius: 6px;
  background: #F7F9FC; border: 1px dashed var(--line); font-size: 11px; color: var(--ink-3);
}
.ai-context-note .icon { color: var(--brand); flex: none; }
.ai-context-note b { color: var(--ink-2); }

/* 任务卡 */
.ai-task {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: #FCFDFF; border-radius: 8px;
  padding: 8px 9px; margin-bottom: 6px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.ai-task:hover { border-color: var(--brand-100); background: #fff; box-shadow: var(--shadow-sm); }
.ai-task-top { display: flex; align-items: center; gap: 5px; }
.ai-task-no { font-size: 10.5px; color: var(--ink-4); }
.ai-task-top .tag { height: 17px; padding: 0 4px; font-size: 10px; border-radius: 3px; margin-left: auto; }
.ai-task-top .tag + .tag { margin-left: 0; }
.ai-task-name {
  font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.45; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ai-task-meta { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.ai-task .progress { height: 4px; margin-top: 6px; }

/* 统计格子 */
.ai-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0 2px; }
.ai-stat {
  background: #F7F9FC; border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 8px;
}
.ai-stat span { display: block; font-size: 10px; color: var(--ink-3); }
.ai-stat b { display: block; font-size: 16px; line-height: 1.25; color: var(--ink); }
.ai-stat em { display: block; font-style: normal; font-size: 9.5px; color: var(--ink-4); margin-top: 1px; }

/* 人员行 */
.ai-person {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 9px; margin-bottom: 6px; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.ai-person:hover { border-color: var(--brand-100); background: var(--hover-blue); }
.ai-person-avatar { flex: none; }
.ai-person-main { flex: 1; min-width: 0; }
.ai-person-name { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink); }
.ai-person-dept { display: block; font-size: 10px; color: var(--ink-4); margin-top: 1px; }
.ai-person-tags { display: flex; gap: 3px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.ai-person-tags .tag { height: 17px; padding: 0 4px; font-size: 9.5px; border-radius: 3px; }

/* 动态 / 流水 */
.ai-logs { margin-top: 4px; }
.ai-log { display: flex; gap: 8px; padding: 7px 4px; border-radius: 6px; transition: background var(--t-fast); }
.ai-log + .ai-log { border-top: 1px dashed var(--line-2); }
.ai-log[data-task-id] { cursor: pointer; }
.ai-log[data-task-id]:hover { background: var(--hover-blue); }
.ai-log-time { flex: none; width: 74px; font-size: 10px; color: var(--ink-4); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ai-log-main { flex: 1; min-width: 0; }
.ai-log-top { font-size: 10.5px; color: var(--ink-3); }
.ai-log-text { font-size: 11px; color: var(--ink-2); line-height: 1.55; margin-top: 1px; }
.ai-log-task { font-size: 10px; color: var(--ink-4); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 键值 */
.ai-kv {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 5px 8px;
  margin-top: 8px; padding: 8px 9px; background: #F7F9FC; border: 1px solid var(--line-2);
  border-radius: 7px; font-size: 11px;
}
.ai-kv-k { color: var(--ink-4); }
.ai-kv-v { color: var(--ink-2); overflow-wrap: anywhere; }

/* 催办文案 */
.ai-draft {
  margin: 8px 0 0; padding: 9px 10px; max-height: 250px; overflow: auto;
  background: #F7F9FC; border: 1px dashed var(--line); border-radius: 7px;
  font-family: var(--font-ui); font-size: 11px; line-height: 1.7; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
}
.ai-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }


/* 自然语言派单确认卡 */
.ai-dispatch {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 4px 12px;
  margin-top: 9px;
}
.ai-dispatch-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12px;
}
.ai-dispatch-row:last-child { border-bottom: 0; }
.ai-dispatch-row span { color: var(--ink-4); width: 44px; flex: none; }
.ai-dispatch-row b { color: var(--ink); font-weight: 600; }
.ai-dispatch-row em { color: var(--ink-4); font-style: normal; font-size: 11px; margin-left: auto; text-align: right; }



.ai-knowledge {
  border: 1px solid var(--line-2);
  border-radius: 8px;
  margin: -3px 0 8px;
  background: #FBFCFE;
  padding: 4px 9px;
}
.ai-knowledge-src { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.ai-knowledge-src:last-child { border-bottom: 0; }
.ai-knowledge-src span { display: block; font-size: 10px; color: var(--ink-4); margin-bottom: 2px; }
.ai-knowledge-src p { margin: 0; font-size: 11px; line-height: 1.55; color: var(--ink-3); }

.ai-org-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  margin-top: 6px;
  background: #fff;
  font-size: 11.5px;
}
.ai-org-rank { width: 18px; flex: none; text-align: center; color: var(--ink-4); font-size: 10.5px; }
.ai-org-row .grow { min-width: 0; }
.ai-org-row b { display: block; color: var(--ink); font-weight: 600; }
.ai-org-row em { display: block; margin-top: 1px; color: var(--ink-4); font-style: normal; font-size: 10.5px; }
.ai-org-metrics { flex: none; color: var(--ink-3); font-size: 10.5px; text-align: right; }

.ai-reminder-text {
  margin-top: 8px;
  padding: 9px 11px;
  background: #F8FAFC;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--ink-3);
  white-space: pre-wrap;
  max-height: 150px;
  overflow: auto;
}

.ai-dispatch .ai-actions { margin-top: 2px; }

.ai-actions .btn { height: 28px; font-size: 12px; }

/* 能力入口 */
.ai-cap-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.ai-cap {
  display: flex; align-items: center; gap: 6px; padding: 8px 9px; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 11px; color: var(--ink-2); cursor: pointer; transition: .15s;
}
.ai-cap .icon { color: var(--brand); flex: none; }
.ai-cap:hover { border-color: var(--brand-100); background: var(--brand-50); color: var(--brand); }

/* ---------- 建议问题 / 输入区 ---------- */
.ai-input-area { flex: none; border-top: 1px solid var(--line-2); background: #fff; }
.ai-suggest {
  display: flex; gap: 5px; flex-wrap: wrap;
  padding: 9px 14px 0; max-height: 76px; overflow: hidden;
}
.ai-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 12px;
  color: var(--ink-2); font-size: 10.5px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.ai-chip:hover { border-color: var(--brand-100); background: var(--brand-50); color: var(--brand); }
.ai-compose { display: flex; align-items: center; gap: 7px; padding: 8px 14px; }
.ai-compose .input { flex: 1; min-width: 0; height: 36px; font-size: 12.5px; }
.ai-compose .btn { height: 36px; flex: none; padding: 0 12px; font-size: 12.5px; }
.ai-compose .btn[disabled] { opacity: .55; pointer-events: none; }
.ai-compose .btn.is-busy .icon { animation: spin 1s linear infinite; }
.ai-foot {
  padding: 0 14px 9px; font-size: 10px; color: var(--ink-4); text-align: center; line-height: 1.5;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .ai-panel { width: 100vw; }
  .ai-head { padding: 11px 12px; }
  .ai-body { padding: 12px 12px 8px; }
  .ai-suggest { padding: 8px 12px 0; }
  .ai-compose { padding: 8px 12px; }
  .ai-foot { padding: 0 12px 8px; }
  .ai-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
