:root {
  --chat-primary: #efefe9;
  --chat-primary-2: #d9d9d2;
  --chat-bg: #dfdfd8;
  --chat-surface: #d2d2cb;
  --chat-border: rgba(0, 0, 0, 0.16);
  --chat-text: #111110;
  --chat-muted: #5f5f59;
  --chat-user-msg: #2b2b28;
  --chat-ai-msg: #ecece6;
  --chat-ai-text: #121210;
  --chat-user-text: #f2f2ef;
}

.chat-toggle-btn {
  position: fixed;
  right: 1.3rem;
  bottom: 1.3rem;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  background: linear-gradient(140deg, var(--chat-primary), var(--chat-primary-2));
  color: #111110;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 140;
}

.chat-toggle-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.42);
}

.chat-bubble {
  position: fixed;
  right: 1.35rem;
  bottom: 6rem;
  max-width: 280px;
  background: linear-gradient(145deg, rgba(246, 246, 241, 0.98), rgba(224, 224, 217, 0.98));
  color: #111110;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 0.85rem;
  border-bottom-right-radius: 0;
  padding: 0.68rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  z-index: 139;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: bubbleFloat 3.2s ease-in-out infinite;
}

.chat-bubble-title {
  color: #111110;
  font-weight: 400;
  line-height: 1.28;
}

.chat-bubble-subtitle {
  color: #5f5f59;
  font-size: 0.75rem;
  line-height: 1.3;
}

.chat-bubble::after {
  content: '';
  position: absolute;
  right: 16px;
  bottom: -9px;
  border-left: 9px solid transparent;
  border-top: 9px solid rgba(224, 224, 217, 0.98);
}

.chat-bubble::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 0.9rem;
  border-bottom-right-radius: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.chat-window {
  position: fixed;
  right: 1.3rem;
  bottom: 5.7rem;
  width: 360px;
  max-width: calc(100vw - 1.6rem);
  height: 500px;
  max-height: calc(100vh - 7.8rem);
  border: 1px solid var(--chat-border);
  border-radius: 1rem;
  overflow: hidden;
  background: var(--chat-bg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.46);
  display: flex;
  flex-direction: column;
  transform: translateY(16px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
  z-index: 140;
}

.chat-window.open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.chat-window.open+.chat-bubble,
body:has(.chat-window.open) .chat-bubble {
  display: none;
}

.chat-header {
  background: linear-gradient(140deg, var(--chat-primary), var(--chat-primary-2));
  color: #111110;
  padding: 0.8rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.chat-header-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #cacac3;
  border: 1px solid rgba(0, 0, 0, 0.14);
  color: #1a1a18;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 26px;
}

.chat-header-avatar i {
  font-size: 0.74rem;
  line-height: 1;
}

.chat-header h3 {
  margin: 0;
  font-size: 0.97rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-close-btn {
  border: 0;
  background: transparent;
  color: #111110;
  font-size: 1rem;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  background: var(--chat-surface);
  padding: 0.85rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.message {
  max-width: 86%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.9rem;
  line-height: 1.4;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message strong {
  font-weight: 700;
}

.message.user {
  align-self: flex-end;
  background: var(--chat-user-msg);
  color: var(--chat-user-text);
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-bottom-right-radius: 0.25rem;
}

.message.ai {
  align-self: flex-start;
  background: var(--chat-ai-msg);
  color: var(--chat-ai-text);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom-left-radius: 0.25rem;
}

.message .chat-inline-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

.message.ai .chat-inline-link:hover,
.message.user .chat-inline-link:hover {
  opacity: 0.88;
}

.typing-indicator {
  display: none;
  align-self: flex-start;
  gap: 0.3rem;
  padding: 0.55rem 0.72rem;
  border-radius: 0.8rem;
  background: var(--chat-ai-msg);
}

.typing-dot {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #9f9f98;
  animation: chatBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.32s;
}

.chat-input-area {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  border-top: 1px solid var(--chat-border);
  background: #cecec8;
}

.chat-input-area input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  padding: 0.6rem 0.82rem;
  outline: none;
  font: inherit;
  color: var(--chat-text);
  background: #f9f9f6;
}

.chat-input-area input:focus {
  border-color: rgba(0, 0, 0, 0.42);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.chat-input-area input::placeholder {
  color: #76766f;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #111110;
  background: linear-gradient(140deg, var(--chat-primary), var(--chat-primary-2));
}

.chat-send-btn:hover {
  filter: brightness(1.07);
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  padding: 0;
  margin: -0.12rem 0 0.16rem;
  align-self: flex-start;
  max-width: 100%;
  border: 0;
  background: transparent;
}

.chat-suggestion-chip {
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  background: #e6e6df;
  color: #1a1a18;
  font-size: 0.76rem;
  line-height: 1.2;
  padding: 0.38rem 0.62rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chat-suggestion-chip:hover,
.chat-suggestion-chip:focus-visible {
  color: #10100f;
  border-color: rgba(0, 0, 0, 0.34);
  background: #eeeee8;
}

.chat-selection-ask-btn {
  position: fixed;
  left: 0;
  top: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.44rem 0.78rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  background: linear-gradient(140deg, var(--chat-primary), var(--chat-primary-2));
  color: #111110;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.34);
  z-index: 190;
}

.chat-selection-ask-btn:hover {
  filter: brightness(1.05);
}

@keyframes bubbleFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes chatBounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
  }

  40% {
    transform: scale(1);
  }
}

@media (max-width: 580px) {
  .chat-window {
    right: 1rem;
    bottom: 5.2rem;
    width: calc(100vw - 2.8rem);
    max-width: 330px;
    height: 62vh;
  }

  .chat-toggle-btn {
    right: 0.85rem;
    bottom: 0.9rem;
  }

  .chat-bubble {
    display: none;
  }

  .chat-selection-ask-btn {
    font-size: 0.74rem;
    padding: 0.4rem 0.7rem;
  }

  .chat-suggestions {
    margin-top: -0.08rem;
  }
}
