/* AI 客服挂件（kb-chat.js 运行时接管）。固定右下角，不依赖任何框架。
   配色跟随站点主题：--brand 主色、--kbc-head 深色顶栏、--bg 浅背景；未读红角标保持红色。 */
#kb-chat-bubble {
  position: fixed; right: 20px; bottom: 20px; z-index: 99990;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--brand, #2563eb); color: var(--brand-ink, #fff); border: none; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.22); display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
#kb-chat-bubble:hover { transform: scale(1.06); }
#kb-chat-bubble svg { width: 26px; height: 26px; }
.kbc-bubble-badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px;
  background: #e53935; color: #fff; border: 2px solid #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1; display: none;
  align-items: center; justify-content: center; box-sizing: border-box; z-index: 1;
}

#kb-chat-panel {
  position: fixed; right: 20px; bottom: 88px; z-index: 99991;
  width: 360px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 120px);
  background: #fff; border: 1px solid var(--line, #e5e7eb); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.20); display: none; flex-direction: column; overflow: hidden;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#kb-chat-panel.open { display: flex; }

.kbc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; background: var(--kbc-head, var(--navy, #2563eb)); color: var(--hero-ink, #fff);
}
.kbc-head b { font-size: 14px; }
.kbc-head button { background: transparent; border: none; color: var(--hero-ink, #fff); cursor: pointer; font-size: 20px; line-height: 1; }
/* 顶栏按钮描边/悬停跟随文字色，深色偏亮时自动变深，避免白底白边看不见 */
.kbc-head-btn { font-size: 12px !important; padding: 3px 8px; border: 1px solid rgba(255,255,255,.55) !important; border: 1px solid color-mix(in srgb, currentColor 55%, transparent) !important; border-radius: 999px; line-height: 1.2 !important; }
.kbc-head-btn:hover { background: rgba(255,255,255,.15); background: color-mix(in srgb, currentColor 15%, transparent); }

.kbc-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 14px; background: var(--bg, #f7f8fa); }
.kbc-body::-webkit-scrollbar, .kbc-foot::-webkit-scrollbar { width: 8px; }
.kbc-body::-webkit-scrollbar-thumb, .kbc-foot::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 8px; }
.kbc-body, .kbc-foot { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.18) transparent; }
.kbc-msg { margin-bottom: 10px; max-width: 85%; }
.kbc-msg .kbc-bubble {
  padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.kbc-msg.me { margin-left: auto; }
.kbc-msg.me .kbc-bubble { background: var(--brand, #2563eb); color: var(--brand-ink, #fff); border-bottom-right-radius: 4px; }
.kbc-msg.bot .kbc-bubble { background: #fff; border: 1px solid var(--line, #e5e7eb); border-bottom-left-radius: 4px; }
.kbc-msg.agent .kbc-bubble { background: #fff; border: 1px solid var(--brand, #2563eb); border-bottom-left-radius: 4px; }
.kbc-agent-name { font-size: 11px; font-weight: 600; color: var(--brand, #2563eb); margin: 0 0 3px 2px; }
.kbc-hint { font-size: 12px; color: #888; text-align: center; margin: 6px 0; }

.kbc-foot { border-top: 1px solid var(--line, #e5e7eb); padding: 10px; background: #fff; flex: 0 0 auto; }
.kbc-input-row { display: flex; gap: 8px; align-items: flex-end; }
/* 高优先级覆盖站点主题对 textarea 的全局 min-height 设置，强制与发送按钮等高 */
#kb-chat-panel .kbc-input-row textarea#kbc-input {
  flex: 1 1 auto; box-sizing: border-box; resize: none;
  height: 42px; min-height: 42px; max-height: 42px; line-height: 1.35;
  padding: 10px 12px; border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px; font-size: 13.5px; font-family: inherit; outline: none;
}
#kb-chat-panel .kbc-input-row textarea#kbc-input:focus {
  border-color: #9ca3af; outline: none;
}
.kbc-send {
  box-sizing: border-box;
  border: none; background: var(--brand, #2563eb); color: var(--brand-ink, #fff); border-radius: 10px; padding: 0 16px; cursor: pointer; font-size: 13px; height: 42px; line-height: 42px; flex: 0 0 auto;
}
.kbc-send:disabled { opacity: .55; cursor: default; }

.kbc-lead-toggle { display: block; margin: 8px 0 0; font-size: 12.5px; color: var(--brand-deep, var(--brand, #2563eb)); background: none; border: none; cursor: pointer; text-align: left; padding: 0; }

.kbc-lead { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line, #e5e7eb); }
.kbc-lead.open { display: block; max-height: 240px; overflow-y: auto; }
.kbc-lead label { display: block; font-size: 12px; color: #555; margin: 6px 0 3px; }
.kbc-lead select, .kbc-lead input, .kbc-lead textarea {
  width: 100%; box-sizing: border-box; padding: 8px 9px; border: 1px solid var(--line, #e5e7eb); border-radius: 9px; font-size: 13px; font-family: inherit; outline: none;
}
.kbc-lead select:focus, .kbc-lead input:focus, .kbc-lead textarea:focus { border-color: #9ca3af; outline: none; }
.kbc-lead textarea { resize: vertical; min-height: 46px; }
.kbc-lead .kbc-lead-send { margin-top: 8px; width: 100%; border: none; background: var(--brand, #2563eb); color: var(--brand-ink, #fff); padding: 9px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.kbc-lead .kbc-msg-ok { font-size: 12.5px; color: #137333; margin-top: 8px; }
.kbc-loading { font-size: 12px; color: #999; padding: 4px 2px; }

.kbc-cards { display: flex; flex-direction: column; gap: 8px; }
.kbc-card {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--line, #e5e7eb); border-radius: 10px; overflow: hidden; padding: 8px;
}
.kbc-card:hover { border-color: var(--brand-deep, var(--brand, #2563eb)); }
.kbc-card-img { width: 56px; height: 56px; border-radius: 8px; background-size: cover; background-position: center; background-color: #eef; flex: 0 0 auto; }
.kbc-card-meta { min-width: 0; }
.kbc-card-title { font-size: 13.5px; font-weight: 600; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbc-card-desc { font-size: 12px; color: #6b7280; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
