:root {
  --chatbot-width: 120px;
  --chatbot-panel-width: 260px;
}

.chatbot-widget {
  position: fixed;
  left: 12px;
  bottom: 24px;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.chatbot-toggle {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  width: var(--chatbot-width);
  position: relative;
}

.chatbot-toggle img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.chatbot-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff5a5f;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  white-space: nowrap;
}

.chatbot-bubble {
  position: absolute;
  left: 100%;
  bottom: 70%;
  margin-left: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  transform: translateY(50%);
  opacity: 0.95;
  animation: chatbot-bob 2.4s ease-in-out infinite;
}

.chatbot-bubble::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid rgba(255, 255, 255, 0.95);
}

.chatbot-widget.is-open .chatbot-bubble {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

@keyframes chatbot-bob {
  0%, 100% {
    transform: translateY(50%);
  }
  50% {
    transform: translateY(40%);
  }
}

.chatbot-panel {
  width: var(--chatbot-panel-width);
  max-height: 360px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chatbot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  background: #f6f7fb;
  border-bottom: 1px solid #eee;
}

.chatbot-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.chatbot-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chatbot-message {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.chatbot-message.bot {
  align-self: flex-start;
  background: #f2f3f7;
  color: #333;
}

.chatbot-message.user {
  align-self: flex-end;
  background: #0056b3;
  color: #fff;
}

.chatbot-input {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid #eee;
}

.chatbot-input input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
}

.chatbot-input button {
  border: none;
  background: #0056b3;
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

@media (max-width: 768px) {
  .chatbot-widget {
    left: 8px;
    bottom: 16px;
  }

  .chatbot-toggle {
    width: 90px;
  }

  .chatbot-panel {
    width: 220px;
  }

  .chatbot-bubble {
    font-size: 11px;
  }
}
/* Markdown 渲染样式 */
.chatbot-message.bot code {
  background: #e8e9ed;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

.chatbot-message.bot pre {
  background: #e8e9ed;
  padding: 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 4px 0;
}

.chatbot-message.bot pre code {
  background: none;
  padding: 0;
}

.chatbot-message.bot ul {
  margin: 4px 0;
  padding-left: 16px;
}

.chatbot-message.bot li {
  margin: 2px 0;
}

.chatbot-message.bot strong {
  font-weight: 600;
}

.chatbot-message.bot h1,
.chatbot-message.bot h2,
.chatbot-message.bot h3 {
  margin: 8px 0 6px;
  line-height: 1.3;
}

.chatbot-message.bot p {
  margin: 6px 0;
}

.chatbot-message.bot blockquote {
  border-left: 3px solid #ccc;
  margin: 6px 0;
  padding-left: 10px;
  color: #666;
}

.chatbot-message.bot a {
  color: #0056b3;
  text-decoration: underline;
}

.chatbot-message.bot table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
}

.chatbot-message.bot th,
.chatbot-message.bot td {
  border: 1px solid #ddd;
  padding: 4px 6px;
}