:root {
  --chat-w: 420px;
  --chat-h: 600px;
  --chat-bg: #0e0e0e;
  --chat-bg-2: #161616;
  --chat-bg-3: #1e1e1e;
  --chat-border: rgba(201,168,76,.12);
  --chat-gold: #c9a84c;
  --chat-gold-dim: rgba(201,168,76,.15);
  --chat-gold-glow: rgba(201,168,76,.08);
  --chat-white: #f5f0e8;
  --chat-muted: #8a8578;
  --chat-text: #e8e2d6;
  --chat-red: #c0392b;
  --chat-radius: 20px;
}

/* ═══════════ FAB КНОПКА ═══════════ */
.oracle-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--chat-white);
  background: linear-gradient(135deg, #1a1a1a 0%, #2a2420 100%);
  box-shadow:
    0 8px 32px rgba(0,0,0,.5),
    0 0 0 1px var(--chat-border),
    inset 0 1px 0 rgba(201,168,76,.1);
  transition:
    transform .35s cubic-bezier(.4,0,.2,1),
    box-shadow .35s cubic-bezier(.4,0,.2,1);
  animation: fabGlow 4s ease-in-out infinite;
  isolation: isolate;
}

.oracle-fab:hover {
  transform: scale(1.08);
  box-shadow:
    0 12px 48px rgba(0,0,0,.6),
    0 0 0 1px rgba(201,168,76,.25),
    0 0 30px rgba(201,168,76,.12),
    inset 0 1px 0 rgba(201,168,76,.15);
}

.oracle-fab:active {
  transform: scale(.96);
}

.oracle-fab.active {
  z-index: 10002;
}

@keyframes fabGlow {
  0%, 100% {
    box-shadow:
      0 8px 32px rgba(0,0,0,.5),
      0 0 0 1px var(--chat-border),
      inset 0 1px 0 rgba(201,168,76,.1);
  }
  50% {
    box-shadow:
      0 8px 32px rgba(0,0,0,.5),
      0 0 0 1px rgba(201,168,76,.2),
      0 0 24px rgba(201,168,76,.1),
      inset 0 1px 0 rgba(201,168,76,.15);
  }
}

/* ═══════════ ТУЛТИП — СКРЫТ (используем title) ═══════════ */
.oracle-tooltip {
  display: none;
}

/* ═══════════ ИКОНКИ ВНУТРИ FAB ═══════════ */
.oracle-fab-icon {
  position: relative;
  z-index: 1;
  transition: transform .3s ease, opacity .3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e74c3c;
  pointer-events: none;
}

.oracle-fab.active .oracle-fab-icon {
  transform: rotate(90deg) scale(0);
  opacity: 0;
}

.oracle-fab-close {
  position: absolute;
  font-size: 1.3rem;
  opacity: 0;
  transform: rotate(-90deg) scale(0);
  transition: transform .3s ease, opacity .3s ease;
  color: var(--chat-gold);
  pointer-events: none;
}

.oracle-fab.active .oracle-fab-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* ═══════════ ОВЕРЛЕЙ ═══════════ */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}

.chat-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ═══════════ ОКНО ЧАТА ═══════════ */
.chat-window {
  position: fixed;
  bottom: calc(2rem + 64px + 1rem);
  right: 2rem;
  z-index: 10001;
  width: var(--chat-w);
  height: var(--chat-h);
  max-height: calc(100vh - 120px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  border: 1px solid var(--chat-border);
  box-shadow:
    0 24px 80px rgba(0,0,0,.6),
    0 0 0 1px rgba(201,168,76,.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition:
    opacity .35s cubic-bezier(.4,0,.2,1),
    transform .35s cubic-bezier(.4,0,.2,1);
}

.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.chat-window::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--chat-gold), transparent);
  opacity: .3;
  z-index: 5;
}

/* ═══════════ ШАПКА ЧАТА ═══════════ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.3rem;
  background: var(--chat-bg-2);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-bg-3) 0%, #2a2420 100%);
  border: 1.5px solid var(--chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  color: #e74c3c;
}

.chat-header-info h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--chat-white);
  line-height: 1.2;
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .72rem;
  color: var(--chat-muted);
  margin-top: .15rem;
  letter-spacing: .03em;
}

.chat-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74,222,128,.4);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.chat-btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  color: var(--chat-muted);
  font-size: .85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s ease;
}

.chat-btn-icon:hover {
  background: rgba(201,168,76,.1);
  border-color: var(--chat-border);
  color: var(--chat-gold);
}

.chat-btn-icon.danger:hover {
  background: rgba(192,57,43,.12);
  border-color: rgba(192,57,43,.2);
  color: var(--chat-red);
}

/* ═══════════ СООБЩЕНИЯ ═══════════ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(201,168,76,.03) 0%, transparent 50%),
    var(--chat-bg);
}

.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,.15);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(201,168,76,.25);
}

.chat-welcome {
  text-align: center;
  padding: 1.5rem 1rem;
}

.chat-welcome-icon {
  font-size: 2.2rem;
  margin-bottom: .8rem;
  display: block;
  color: #e74c3c;
}

.chat-welcome h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--chat-white);
  margin-bottom: .5rem;
}

.chat-welcome p {
  font-size: .82rem;
  color: var(--chat-muted);
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* ═══════════ БАБЛЫ СООБЩЕНИЙ ═══════════ */
.chat-msg {
  display: flex;
  gap: .65rem;
  max-width: 88%;
  animation: msgSlideIn .3s ease both;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg--user      { align-self: flex-end;   flex-direction: row-reverse; }
.chat-msg--assistant { align-self: flex-start; }

.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  margin-top: .15rem;
}

.chat-msg--assistant .chat-msg-avatar {
  background: linear-gradient(135deg, var(--chat-bg-3), #2a2420);
  border: 1px solid var(--chat-border);
  color: #e74c3c;
}

.chat-msg--user .chat-msg-avatar {
  background: rgba(192,57,43,.15);
  border: 1px solid rgba(192,57,43,.2);
  font-size: .7rem;
  color: #e74c3c;
}

.chat-msg-bubble {
  padding: .85rem 1.1rem;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.65;
  position: relative;
}

.chat-msg--assistant .chat-msg-bubble {
  background: var(--chat-bg-2);
  color: var(--chat-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,.04);
}

.chat-msg--user .chat-msg-bubble {
  background: linear-gradient(135deg, rgba(192,57,43,.9), rgba(146,43,33,.9));
  color: var(--chat-white);
  border-bottom-right-radius: 4px;
}

.chat-msg-bubble strong { color: var(--chat-gold); font-weight: 700; }
.chat-msg--user .chat-msg-bubble strong { color: #ffd6d2; }
.chat-msg-bubble em { font-style: italic; color: rgba(232,226,214,.85); }
.chat-msg-bubble ul,
.chat-msg-bubble ol { padding-left: 1.2rem; margin: .4rem 0; }
.chat-msg-bubble li { margin-bottom: .25rem; list-style: disc; }
.chat-msg-bubble li::marker { color: var(--chat-gold); }
.chat-msg-bubble p { margin-bottom: .4rem; }
.chat-msg-bubble p:last-child { margin-bottom: 0; }

.chat-msg-time {
  font-size: .65rem;
  color: var(--chat-muted);
  margin-top: .3rem;
  opacity: .6;
}

.chat-msg--user .chat-msg-time { text-align: right; }

/* ═══════════ TYPING ИНДИКАТОР ═══════════ */
.chat-typing {
  display: none;
  align-self: flex-start;
  padding: .7rem 1.1rem;
  background: var(--chat-bg-2);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,.04);
  gap: .4rem;
  align-items: center;
}

.chat-typing.visible { display: flex; }

.chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-gold);
  opacity: .4;
  animation: typingPulse 1.2s ease-in-out infinite;
}

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

@keyframes typingPulse {
  0%, 100% { opacity: .25; transform: scale(.85); }
  50%      { opacity: .9;  transform: scale(1.1); }
}

/* ═══════════ ПОЛЕ ВВОДА ═══════════ */
.chat-input-area {
  padding: 1rem 1.2rem;
  background: var(--chat-bg-2);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  background: var(--chat-bg);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: .5rem .6rem .5rem 1rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.chat-input-wrap:focus-within {
  border-color: rgba(201,168,76,.3);
  box-shadow: 0 0 0 3px rgba(201,168,76,.06);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: 'Raleway', sans-serif;
  font-size: .88rem;
  color: var(--chat-white);
  resize: none;
  max-height: 100px;
  min-height: 22px;
  line-height: 1.5;
  padding: .25rem 0;
}

.chat-input::placeholder {
  color: var(--chat-muted);
  opacity: .6;
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--chat-red), var(--clr-red-deep));
  color: var(--chat-white);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  box-shadow: 0 4px 16px rgba(192,57,43,.3);
}

.chat-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 24px rgba(192,57,43,.4);
}

.chat-send-btn:active { transform: scale(.95); }

.chat-send-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.chat-send-btn svg { width: 18px; height: 18px; }

/* ═══════════ КНОПКА ЗАКАЗА В ЧАТЕ ═══════════ */
.chat-order-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .6rem;
  padding: .55rem 1rem;
  background: linear-gradient(135deg, var(--chat-red), var(--clr-red-deep));
  color: var(--chat-white);
  border: none;
  border-radius: 10px;
  font-family: 'Raleway', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  box-shadow: 0 4px 16px rgba(192,57,43,.25);
}

.chat-order-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(192,57,43,.35);
}

/* ═══════════ ОШИБКА ═══════════ */
.chat-error {
  text-align: center;
  padding: .6rem 1rem;
  background: rgba(192,57,43,.08);
  border: 1px solid rgba(192,57,43,.15);
  border-radius: 10px;
  font-size: .78rem;
  color: #e74c3c;
  margin: .4rem 0;
  animation: msgSlideIn .3s ease both;
}

/* ═══════════ ФУТЕР ЧАТА ═══════════ */
.chat-footer-note {
  text-align: center;
  padding: .45rem;
  font-size: .65rem;
  color: var(--chat-muted);
  opacity: .5;
  background: var(--chat-bg-2);
  letter-spacing: .03em;
}

/* ═══════════ МОДАЛКА ПОДТВЕРЖДЕНИЯ ОЧИСТКИ ═══════════ */
.chat-confirm-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  border-radius: var(--chat-radius);
}

.chat-confirm-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.chat-confirm-box {
  background: var(--chat-bg-2);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  padding: 1.8rem 1.5rem;
  text-align: center;
  max-width: 280px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  transform: scale(.92);
  transition: transform .25s ease;
}

.chat-confirm-overlay.visible .chat-confirm-box {
  transform: scale(1);
}

.chat-confirm-box p {
  font-size: .88rem;
  color: var(--chat-text);
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

.chat-confirm-actions {
  display: flex;
  gap: .6rem;
  justify-content: center;
}

.chat-confirm-btn {
  padding: .55rem 1.3rem;
  border-radius: 10px;
  border: none;
  font-family: 'Raleway', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

.chat-confirm-btn--cancel {
  background: rgba(255,255,255,.06);
  color: var(--chat-muted);
  border: 1px solid rgba(255,255,255,.08);
}

.chat-confirm-btn--cancel:hover {
  background: rgba(255,255,255,.1);
  color: var(--chat-white);
}

.chat-confirm-btn--clear {
  background: linear-gradient(135deg, var(--chat-red), var(--clr-red-deep));
  color: var(--chat-white);
  box-shadow: 0 4px 16px rgba(192,57,43,.3);
}

.chat-confirm-btn--clear:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(192,57,43,.4);
}

/* ═══════════ СООБЩЕНИЕ ОТ НАДЕЖДЫ ═══════════ */
.chat-msg--human { flex-direction: row; }

.chat-msg--human .chat-msg-avatar {
  background: linear-gradient(135deg, #e8a87c, #d4786c);
  color: #fff;
  font-size: 14px;
}

.chat-msg--human .chat-msg-bubble {
  background: linear-gradient(135deg, #2a1f1f 0%, #1f1a1a 100%);
  border: 1px solid rgba(232,168,124,.2);
  border-radius: 18px 18px 18px 4px;
  color: var(--chat-white);
}

.chat-msg--human .chat-msg-name {
  color: #e8a87c;
  font-weight: 600;
  font-size: .75rem;
  margin-bottom: 2px;
}

.chat-msg--human .chat-msg-time {
  color: rgba(232,168,124,.5);
}

/* ═══════════ ОЖИДАНИЕ ОТВЕТА НАДЕЖДЫ ═══════════ */
.chat-waiting-human {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 8px 0;
  color: #e8a87c;
  font-size: .82rem;
  font-style: italic;
  animation: fadeInUp .3s ease;
}

.waiting-dots { display: inline-flex; gap: 4px; }

.waiting-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e8a87c;
  animation: waitingPulse 1.4s infinite ease-in-out both;
}

.waiting-dot:nth-child(1) { animation-delay: 0s; }
.waiting-dot:nth-child(2) { animation-delay: .2s; }
.waiting-dot:nth-child(3) { animation-delay: .4s; }

@keyframes waitingPulse {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ═══════════ МОБИЛЬНАЯ ВЕРСИЯ ═══════════ */
@media (max-width: 480px) {
  .chat-window {
    right: .5rem;
    bottom: calc(56px + 1.5rem);
    left: .5rem;
    width: auto;
    height: 50vh;
    max-height: 50vh;
    border-radius: var(--chat-radius);
  }

  .oracle-fab {
    bottom: 1.2rem;
    right: 1.2rem;
    width: 56px;
    height: 56px;
  }

  .chat-overlay {
    background: transparent;
    backdrop-filter: none;
  }

  .oracle-fab-close { display: none; }

  .oracle-fab.active .oracle-fab-icon {
    transform: none;
    opacity: 1;
  }
}




