.chat-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: #1d4ed8;
  border: 2px solid rgba(255,255,255,0.85);
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.45), 0 6px 14px rgba(0,0,0,0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 160px;
  width: min(420px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 190px));
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
}

.chat-panel.expanded {
  width: min(760px, calc(100vw - 24px));
  height: min(840px, calc(100vh - 24px));
  bottom: 12px;
  right: 12px;
}

.chat-bubble-wrap {
  padding: 10px 10px 0 10px;
}

.chatbot-container {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
  font-family: Arial, sans-serif;
}

.chatbot-image {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  animation: botTalk 5.2s ease-in-out infinite;
}

.chatbot-talk-image {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  display: block;
}

.chat-bubble {
  background-color: #e6f2ff;
  color: #003366;
  padding: 8px 10px;
  border-radius: 14px;
  position: relative;
  max-width: 140px;
  font-size: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.chat-bubble-dots {
  display: block;
  width: 32px;
  height: 6px;
  margin-top: 6px;
  position: relative;
}

.chat-bubble-dots::before,
.chat-bubble-dots::after,
.chat-bubble-dots span {
  content: "";
  position: absolute;
  top: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0b3a60;
  opacity: 0.4;
  animation: dotPulse 1s infinite ease-in-out;
}

.chat-bubble-dots::before {
  left: 0;
  animation-delay: 0s;
}

.chat-bubble-dots span {
  left: 12px;
  animation-delay: 0.2s;
}

.chat-bubble-dots::after {
  left: 24px;
  animation-delay: 0.4s;
}

.chat-bubble::before {
  content: "";
  position: absolute;
  top: 12px;
  left: -8px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-right-color: #e6f2ff;
}

.chat-header {
  padding: 12px 14px;
  background: #111827;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-header-actions {
  display: inline-flex;
  gap: 6px;
}

.chat-head-btn {
  background: #334155;
  color: #e2e8f0;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.chat-head-btn.danger {
  background: #b91c1c;
  color: #fff;
}

.chat-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #111827;
}

.chat-input input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #e2e8f0;
}

.chat-input button {
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

@media (max-width: 680px) {
  .chat-panel {
    right: 10px;
    bottom: 116px;
    width: calc(100vw - 20px);
    height: min(76vh, 680px);
  }
  .chat-panel.expanded {
    right: 6px;
    bottom: 6px;
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
  }
}

.chat-msg {
  line-height: 1.35;
  max-width: 80%;
  padding: 9px 11px;
  border-radius: 14px;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: #1e8e59;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chat-msg.bot {
  align-self: flex-start;
  background: #2563eb;
  color: #ffffff;
  border-bottom-left-radius: 4px;
}

.chat-msg.typing {
  min-width: 54px;
  padding: 8px 10px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  opacity: 0.35;
  animation: dotPulse 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

.chat-cites {
  margin-top: 6px;
  font-size: 11px;
  color: #cbd5e1;
}
.chat-cite a {
  color: #93c5fd;
  text-decoration: none;
}
.chat-cite a:hover {
  text-decoration: underline;
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

@keyframes botTalk {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
