:root {
    --chat-green: #00a652;
    --chat-light-gray: #f4f5f7;
    --chat-border-gray: #dde1e6;
    --chat-text-gray: #6b6b6b;
  }
  
  body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }
  
  /* Контейнер виджета в правом нижнем углу */
  .chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
  }
  
  /* Кнопка открытия / закрытия */
  .chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--chat-green);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  
  .chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  }
  
/* Окно чата */
   .chat-window {
    position: absolute;
    bottom: 72px;
    right: -15px;
    width: 300px;
    max-height: 520px;         /* ограничиваем высоту всего окна */
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;          /* чтобы содержимое не вылезало наружу */
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  
  .chat-window.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  
  /* Хедер */
  .chat-header {
    background: var(--chat-green);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
  }
  
  .chat-header-title {
    font-size: 16px;
    font-weight: 600;
  }
  
  .chat-header-minimize {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
  }
  
/* Основная область */
  .chat-body {                      /* важно: не забудьте добавить flex: 1; */
    background: var(--chat-light-gray);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  
/* Список сообщений */
  .chat-messages {
    padding: 12px 12px 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }
  
  .chat-message-row {
    display: flex;
    margin-bottom: 8px;
  }
  
  .chat-message-row.bot {
    justify-content: flex-start;
  }
  
  .chat-message-row.user {
    justify-content: flex-end;
  }
  
  .chat-bubble {
    border-radius: 16px;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
  }
  
  .chat-bubble.bot {
    background: #ffffff;
    color: #000;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  
  .chat-bubble.user {
    background: #e1f5e9;
    color: #000;
    border-radius: 16px 16px 4px 16px;
  }

  /* Индикатор «печатает» — три точки */
  .chat-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
  }

  .chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--chat-text-gray);
    animation: chat-typing-bounce 0.6s ease-in-out infinite both;
  }

  .chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
  .chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

  @keyframes chat-typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-4px); opacity: 1; }
  }
  
  .chat-timestamp {
    font-size: 11px;
    color: var(--chat-text-gray);
    margin-top: 2px;
    padding: 0 6px;
  }
  
  .chat-message-row.bot .chat-timestamp {
    text-align: left;
  }
  
  .chat-message-row.user .chat-timestamp {
    text-align: right;
  }
  
  /* Футер с инпутом */
  .chat-input-area {
    padding: 8px;
    border-top: 1px solid var(--chat-border-gray);
    background: #fff;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
  }
  
  .chat-input {
    flex: 1;
    border-radius: 20px;
    border: 1px solid var(--chat-border-gray);
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
  }
  
  .chat-input:focus {
    border-color: var(--chat-green);
    box-shadow: 0 0 0 1px rgba(0, 166, 82, 0.1);
  }
  
  .chat-send-btn {
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    background: var(--chat-green);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
  }


.chat-source-block {
  margin-top: 8px;
}

.chat-source-block + .chat-source-block {
  margin-top: 16px; /* пробел между категориями */
}

.chat-source-label {
  font-weight: 600;
  margin-bottom: 4px;
}
