/* ============ ЧАТ С ИИ ============ */
.chat-launcher {
  position: fixed;
  bottom: 28px; right: 28px;
  z-index: 1100;
}

.chat-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; cursor: pointer;
  color: #fff; font-size: 1.6rem;
  box-shadow: 0 12px 28px -8px rgba(255,107,53,.6);
  transition: .3s;
  position: relative;
}
.chat-btn:hover { transform: scale(1.08); }

.chat-btn .badge {
  position: absolute; top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: #22c55e;
  border: 3px solid #fff;
  border-radius: 50%;
}

.chat-panel {
  position: absolute;
  bottom: 82px; right: 0;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 32px 64px -16px rgba(0,0,0,.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
}

.chat-panel.open {
  display: flex;
  animation: chatSlideUp .3s ease;
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-head {
  padding: 20px;
  background: var(--dark);
  color: #fff;
  display: flex; align-items: center; gap: 12px;
}

.chat-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  position: relative;
}
.chat-avatar::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  background: #22c55e;
  border: 2px solid var(--dark);
  border-radius: 50%;
}

.chat-head b { display: block; font-size: .95rem; }
.chat-head small { opacity: .6; font-size: .8rem; }

.chat-close {
  margin-left: auto;
  background: none; border: none;
  color: #fff; font-size: 1.2rem;
  cursor: pointer; opacity: .6;
}
.chat-close:hover { opacity: 1; }

.chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #f6f4f1;
  display: flex; flex-direction: column; gap: 12px;
}

.msg {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .92rem;
  line-height: 1.5;
  animation: msgIn .3s ease;
  word-wrap: break-word;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.bot {
  background: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.msg.user {
  background: var(--dark);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Индикатор набора текста */
.typing { display: flex; gap: 4px; padding: 14px 18px; }
.typing span {
  width: 7px; height: 7px;
  background: var(--gray);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%         { transform: translateY(-6px); opacity: 1; }
}

.chat-foot {
  padding: 14px;
  display: flex; gap: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-foot input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 100px;
  outline: none;
  font-family: inherit;
  font-size: .92rem;
  transition: .2s;
}
.chat-foot input:focus { border-color: var(--accent); }

.chat-foot button {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--dark);
  color: #fff; border: none;
  cursor: pointer; font-size: 1rem;
  transition: .2s;
}
.chat-foot button:hover { background: var(--accent); }
.chat-foot button:disabled { opacity: .4; cursor: not-allowed; }

@media (max-width: 640px) {
  .chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 140px);
    right: -12px;
  }
}
/* Форматирование Markdown в сообщениях бота */
.msg.bot strong {
  font-weight: 700;
  color: #12141d;
}

.msg.bot em {
  font-style: italic;
  opacity: 0.9;
}

.msg.bot code {
  background: #f0ede9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.88em;
}

.msg.bot a {
  color: var(--accent);
  text-decoration: underline;
}

.msg.bot a:hover {
  opacity: 0.8;
}

.msg.bot ul {
  margin: 8px 0 4px;
  padding-left: 20px;
  list-style: disc;
}

.msg.bot li {
  margin: 4px 0;
  line-height: 1.5;
}

.msg.bot li::marker {
  color: var(--accent);
}

/* Перенос длинных слов, чтобы не ломали верстку */
.msg {
  overflow-wrap: break-word;
  word-break: break-word;
}