.cwc-fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: #249AF3; border: none; cursor: pointer; z-index: 9997;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.cwc-fab:hover { transform: scale(1.05); box-shadow: 0 6px 16px rgba(0,0,0,0.2); }
.cwc-fab svg { width: 24px; height: 24px; fill: white; }

.cwc-panel {
  position: fixed; bottom: 92px; right: 20px;
  width: 380px; height: 540px;
  background: #ffffff; border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 9998; transform: scale(0.8); opacity: 0; pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.cwc-panel.open { transform: scale(1); opacity: 1; pointer-events: auto; }

/* ---------- Подсказка (Tooltip) ---------- */
.cwc-tooltip {
  position: fixed;
  bottom: 90px; /* Располагаем над кнопкой FAB */
  right: 20px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 12px 16px;
  z-index: 9996;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 260px;
  border: 1px solid #f3f4f6;
}

/* Класс для отображения */
.cwc-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Делаем треугольный хвостик, указывающий на FAB */
.cwc-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px; /* Центрируем относительно FAB */
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
  border-right: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
  z-index: -1;
}

.cwc-tooltip-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.cwc-tooltip-text {
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937;
  cursor: pointer; /* Показываем, что текст кликабелен */
}

.cwc-tooltip-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

.cwc-tooltip-close:hover {
  color: #4b5563;
}

.cwc-header {
  background: linear-gradient(135deg, #249AF3 0%, #1a73e8 100%);
  color: white; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.cwc-header-info { display: flex; align-items: center; gap: 10px; }
.cwc-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cwc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cwc-title-area { display: flex; flex-direction: column; }
.cwc-title { font-weight: 600; font-size: 15px; line-height: 1.2; }
.cwc-status {
  display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: 0.9; margin-top: 2px;
}
.cwc-status-dot {
  width: 7px; height: 7px; background: #34d399; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.3);
}
.cwc-header-close {
  background: none; border: none; color: white; font-size: 18px; cursor: pointer; opacity: 0.8; transition: opacity 0.2s;
}
.cwc-header-close:hover { opacity: 1; }

.cwc-messages-wrapper {
  position: relative; flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.cwc-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; background: #f9fafb;
}

.cwc-scroll-bottom {
  position: absolute; bottom: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: #ffffff; color: #249AF3; border: 1px solid #e5e7eb;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: all 0.2s; z-index: 10;
}
.cwc-scroll-bottom:hover { background: #f3f4f6; }
.cwc-scroll-bottom svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }

.cwc-message {
  max-width: 85%; padding: 10px 14px; border-radius: 14px;
  font-size: 15px; line-height: 1.4; word-break: break-word;
}
.cwc-message.user {
  align-self: flex-end; background: #249AF3; color: white; border-bottom-right-radius: 4px;
}
.cwc-message.bot {
  align-self: flex-start; background: #ffffff; border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px; color: #111827;
}
.cwc-message.bot p { margin: 0 0 8px; }
.cwc-message.bot p:last-child { margin-bottom: 0; }
.cwc-message.bot pre { background: #f3f4f6; padding: 8px; border-radius: 6px; overflow-x: auto; }
.cwc-message.bot code { font-size: 13px; }

.cwc-input-area {
  border-top: 1px solid #e5e7eb; padding: 12px; display: flex; gap: 8px; background: white;
}
.cwc-input-area textarea {
  flex: 1; resize: none; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 10px; font-size: 15px; font-family: inherit; outline: none; max-height: 80px;
}
.cwc-input-area button {
  background: #249AF3; color: white; border: none; border-radius: 12px;
  padding: 0 16px; cursor: pointer; font-weight: 500; font-size: 15px; transition: background 0.2s;
}
.cwc-input-area button.stop-btn { background: #ef4444; }
.cwc-input-area button.stop-btn:hover { background: #dc2626; }

.cwc-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.cwc-suggestion-btn {
  background: #e5e7eb; border: none; border-radius: 12px; padding: 6px 12px;
  font-size: 13px; color: #111827; cursor: pointer; transition: background 0.2s;
}
.cwc-suggestion-btn:hover { background: #d1d5db; }

.cwc-typing-indicator { display: flex; gap: 4px; padding: 10px 14px; }
.cwc-typing-indicator span {
  width: 6px; height: 6px; background: #9ca3af; border-radius: 50%;
  animation: cwc-bounce 1.4s infinite ease-in-out both;
}
.cwc-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.cwc-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes cwc-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.cwc-disclaimer {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
  padding: 8px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .cwc-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .cwc-fab svg {
    width: 20px;
    height: 20px;
  }

  .cwc-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 85vh;
    border-radius: 20px 20px 0 0;
    max-width: 100%;
  }

  .cwc-tooltip {
    bottom: 80px;
    right: 16px;
    max-width: 240px;
    font-size: 13px;
  }

  .cwc-header {
    padding: 10px 14px;
  }

  .cwc-title {
    font-size: 14px;
  }

  .cwc-message {
    font-size: 14px;
    padding: 8px 12px;
  }

  .cwc-input-area textarea {
    font-size: 14px;
    padding: 8px;
  }

  .cwc-suggestion-btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}

@media (max-width: 480px) {
  .cwc-panel {
    height: 90vh;
  }

  .cwc-tooltip {
    max-width: 200px;
    font-size: 12px;
  }
}