/* AI 助手浮窗样式 */
#aiFab {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #4f8cff, #7c5cff);
  color: #fff; font-size: 24px; box-shadow: 0 6px 24px rgba(79,140,255,.4);
  display: grid; place-items: center; transition: transform .2s, box-shadow .2s;
}
#aiFab:hover { transform: scale(1.08); box-shadow: 0 8px 32px rgba(79,140,255,.55); }
#aiFab .ai-dot {
  position: absolute; top: 4px; right: 4px; width: 11px; height: 11px;
  background: #34d399; border: 2px solid #fff; border-radius: 50%;
}

#aiPanel {
  position: fixed; right: 24px; bottom: 92px; z-index: 9999;
  width: 380px; height: 560px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 16px; box-shadow: 0 12px 48px rgba(0,0,0,.22);
  display: none; flex-direction: column; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#aiPanel.open { display: flex; }
#aiPanel * { box-sizing: border-box; }

#aiHeader {
  padding: 14px 16px; color: #fff; display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #4f8cff, #7c5cff);
}
#aiHeader .ai-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
#aiHeader .ai-title .ai-ico { font-size: 18px; }
#aiHeader .ai-sub { font-size: 11px; opacity: .85; margin-top: 2px; }
#aiClose { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
#aiClose:hover { background: rgba(255,255,255,.2); }

#aiMessages {
  flex: 1; overflow-y: auto; padding: 14px; background: #f5f7fb;
  display: flex; flex-direction: column; gap: 10px;
}
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.ai-msg.user { align-self: flex-end; background: #4f8cff; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }

/* ===== 算法备案合规：AI 生成标识 ===== */
.ai-gen-badge {
  display: inline-block; font-size: 10.5px; color: #7c6b1e;
  background: #fdf6d8; border: 1px solid #ece3b3;
  border-radius: 4px; padding: 1px 7px; margin-bottom: 6px;
  font-weight: 500; letter-spacing: 0.5px;
}

.ai-msg.bot strong { color: #2563eb; }
.ai-msg.bot .ai-tbl { display: block; overflow-x: auto; margin-top: 6px; font-size: 12px; }
.ai-msg.bot .ai-tbl table { border-collapse: collapse; width: 100%; }
.ai-msg.bot .ai-tbl td, .ai-msg.bot .ai-tbl th { border: 1px solid #e2e8f0; padding: 4px 8px; text-align: left; white-space: nowrap; }
.ai-msg.bot .ai-tbl th { background: #f1f5f9; }
.ai-msg.bot .ai-err { color: #dc2626; }
.ai-msg.bot ul, .ai-msg.bot ol { margin: 4px 0; padding-left: 20px; }
.ai-msg.bot h1, .ai-msg.bot h2, .ai-msg.bot h3 { font-size: 14px; margin: 6px 0 4px; }
.ai-msg.bot code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

#aiInputBar {
  display: flex; gap: 8px; padding: 12px; background: #fff; border-top: 1px solid #e2e8f0;
}
#aiInput {
  flex: 1; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px 12px;
  font-size: 13.5px; outline: none; resize: none; max-height: 90px; font-family: inherit;
}
#aiInput:focus { border-color: #4f8cff; box-shadow: 0 0 0 3px rgba(79,140,255,.15); }
#aiSend {
  border: none; border-radius: 10px; padding: 0 18px; background: #4f8cff; color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s;
}
#aiSend:hover { background: #3b78e8; }
#aiSend:disabled { background: #94a3b8; cursor: not-allowed; }

.ai-hint { font-size: 11px; color: #94a3b8; text-align: center; padding: 6px 0 0; }

/* 小屏适配 */
@media (max-width: 520px) {
  #aiPanel { right: 12px; left: 12px; width: auto; bottom: 88px; }
}
