/* AI客服悬浮组件 */
.ai-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 1000;
  width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--wood) 0%, var(--wood-deep) 100%);
  color: #fff; box-shadow: 0 6px 20px rgba(111,82,54,.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(111,82,54,.5); }
.ai-fab svg { width: 28px; height: 28px; }

.ai-panel {
  position: fixed; right: 24px; bottom: 94px; z-index: 1000;
  width: 360px; height: 520px; max-height: calc(100vh - 120px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 48px rgba(20,18,15,.18);
  display: none; flex-direction: column; overflow: hidden;
}
.ai-panel.open { display: flex; }

.ai-head {
  background: var(--dark); color: var(--paper);
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  flex: none;
}
.ai-head-title { font-size: 15px; letter-spacing: 2px; }
.ai-head-sub { font-size: 12px; opacity: .7; letter-spacing: 1px; margin-top: 2px; }
.ai-close {
  background: none; border: none; color: var(--paper); cursor: pointer;
  font-size: 22px; line-height: 1; padding: 4px 6px; opacity: .8;
}
.ai-close:hover { opacity: 1; }

.ai-msgs {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--cream);
}
.ai-msg { max-width: 86%; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.ai-msg.ai-user {
  align-self: flex-end;
  background: var(--wood); color: #fff;
  padding: 9px 14px; border-radius: 12px 12px 2px 12px;
}
.ai-msg.ai-bot {
  align-self: flex-start;
  background: var(--paper); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 12px 12px 12px 2px;
}
.ai-msg.ai-err { background: #fbeeec; border-color: #e3b8b0; color: #8c4a3d; }
.ai-src {
  align-self: flex-start; max-width: 86%;
  font-size: 12px; color: var(--grey); line-height: 1.8;
}
.ai-src a { color: var(--wood-deep); border-bottom: 1px dashed var(--champagne); }
.ai-src a:hover { color: var(--gold); }

.ai-typing { align-self: flex-start; color: var(--grey); font-size: 13px; padding: 4px 2px; }
.ai-typing::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 6px;
  border-radius: 50%; background: var(--champagne); vertical-align: middle;
  animation: ai-blink 1s infinite;
}
@keyframes ai-blink { 0%,100% { opacity: .2; } 50% { opacity: 1; } }

.ai-form {
  flex: none; display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid var(--line); background: var(--paper);
}
.ai-input {
  flex: 1; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  background: var(--cream); color: var(--ink); outline: none;
}
.ai-input:focus { border-color: var(--champagne); }
.ai-send {
  border: none; border-radius: 8px; padding: 0 18px; cursor: pointer;
  background: var(--ink); color: var(--paper); font-size: 14px; letter-spacing: 2px;
  font-family: inherit;
}
.ai-send:disabled { opacity: .5; cursor: default; }
.ai-send:not(:disabled):hover { background: var(--wood-deep); }

@media (max-width: 520px) {
  .ai-fab { right: 16px; bottom: 16px; }
  .ai-panel { right: 12px; left: 12px; width: auto; bottom: 84px; height: min(560px, calc(100vh - 140px)); }
}
