/* 悬浮球 · AI 资料库助手（贴合本地知识库极简风格，复用 styles.css 的 CSS 变量） */
#ai-fab-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
}

.ai-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent, #0B5FFF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(11, 95, 255, .32);
  transition: transform .15s ease, box-shadow .15s ease;
}
.ai-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 30px rgba(11, 95, 255, .40); }
.ai-fab:active { transform: scale(.96); }

.ai-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  z-index: 60;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: var(--panel, #fff);
  border: 1px solid var(--line, #E6E6EA);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(16, 16, 26, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--sans);
}
.ai-panel.hidden { display: none; }

.ai-head {
  position: relative;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft, #F0F0F3);
  background: linear-gradient(180deg, #fff, #fcfcff);
}
.ai-title { font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.ai-sub { font-size: 11px; color: var(--fg-3, #9A9AA4); margin-top: 2px; }
.ai-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--fg-3, #9A9AA4);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}
.ai-close:hover { background: var(--line-soft, #F0F0F3); color: var(--fg, #16161A); }

.ai-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg, #FAFAFA);
}
.ai-msg { display: flex; flex-direction: column; max-width: 86%; }
.ai-user { align-self: flex-end; align-items: flex-end; }
.ai-bot { align-self: flex-start; align-items: flex-start; }
.ai-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.ai-user .ai-bubble { background: var(--accent, #0B5FFF); color: #fff; border-bottom-right-radius: 4px; }
.ai-bot .ai-bubble {
  background: var(--panel, #fff);
  color: var(--fg, #16161A);
  border: 1px solid var(--line, #E6E6EA);
  border-bottom-left-radius: 4px;
}

.ai-sources { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-src {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-2, #5A5A63);
  background: var(--line-soft, #F0F0F3);
  border: 1px solid var(--line, #E6E6EA);
  border-radius: 6px;
  padding: 2px 7px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-banner {
  padding: 8px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--warn, #B4530A);
  background: #FFF7ED;
  border-bottom: 1px solid #FED7AA;
}
.ai-banner.hidden { display: none; }

.ai-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft, #F0F0F3);
  background: var(--panel, #fff);
  align-items: flex-end;
}
.ai-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--line, #E6E6EA);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--fg, #16161A);
  outline: none;
  max-height: 140px;
}
.ai-input:focus { border-color: var(--accent, #0B5FFF); }
.ai-send {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent, #0B5FFF);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.ai-send:hover { filter: brightness(1.05); }
.ai-send:disabled { opacity: .5; cursor: default; }

.ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--fg-3, #9A9AA4);
  animation: ai-blink 1.2s infinite both;
}
.ai-dot:nth-child(2) { animation-delay: .2s; }
.ai-dot:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

@media (max-width: 520px) {
  .ai-panel { right: 12px; left: 12px; width: auto; bottom: 84px; }
  #ai-fab-root { right: 14px; bottom: 14px; }
}
