/* AI 助手（站内业务问答）· 悬浮入口 + 抽屉式聊天面板
 * 仅登录用户可见；与站点既有视觉（--primary / --card / --border）保持一致。 */

.ai-fab {
  position: fixed;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.38);
  transition: transform .15s, background .15s;
}
.ai-fab:hover { background: var(--primary-dark); transform: translateY(-2px); }

.ai-panel {
  position: fixed;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  z-index: 71;
  width: 384px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 150px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}
.ai-head-txt { flex: 1; min-width: 0; }
.ai-title { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.ai-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.ai-icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.ai-icon-btn:hover { background: #f3f4f6; }

.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.ai-msg.err {
  align-self: flex-start;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.ai-cursor::after {
  content: '▍';
  color: var(--primary);
  animation: aiBlink 1s steps(1) infinite;
}
@keyframes aiBlink { 50% { opacity: 0; } }
.ai-retry { align-self: flex-start; }

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.ai-chips:empty { display: none; }
.ai-chip {
  border: 1px solid #cfe0ff;
  background: #fff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.ai-chip:hover { background: var(--primary-light); }

.ai-foot { border-top: 1px solid var(--border); padding: 9px 12px 10px; background: var(--card); }
.ai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ai-input-row textarea {
  flex: 1;
  min-height: 40px;
  max-height: 96px;
  resize: none;
  padding: 9px 10px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 10px;
}
.ai-input-row .btn { flex: 0 0 auto; }
.ai-tip { font-size: 11px; color: var(--muted); margin-top: 7px; text-align: center; line-height: 1.4; }

@media (max-width: 640px) {
  .ai-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    height: 80vh;
    max-height: 80vh;
    border-radius: 16px 16px 0 0;
  }
  .ai-fab { right: 14px; }
}
