:root {
  --chat-offset: 28px;
  --chat-width: 360px;
  --chat-bg: rgba(7, 17, 30, 0.92);
  --chat-border: rgba(76, 243, 199, 0.22);
  --chat-highlight: rgba(76, 243, 199, 0.12);
}

body.chat-left .hg-chat,
body.chat-left .hg-chat-launcher { left: var(--chat-offset); right: auto; }

.hg-chat {
  position: fixed;
  right: var(--chat-offset);
  bottom: var(--chat-offset);
  z-index: 120;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(var(--chat-width), calc(100vw - 36px));
  max-height: min(640px, calc(100dvh - 80px));
  border-radius: 22px;
  border: 1px solid var(--chat-border);
  background: var(--chat-bg);
  backdrop-filter: blur(22px);
  box-shadow: 0 18px 60px rgba(5, 15, 35, 0.6);
  overflow: hidden;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .32s var(--timing), opacity .32s var(--timing);
}

.hg-chat.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }

.hg-chat__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(120deg, rgba(19, 44, 60, 0.95), rgba(5, 14, 26, 0.95));
  border-bottom: 1px solid rgba(76, 243, 199, 0.18);
}
.hg-chat__title { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.hg-chat__spacer { flex: 1; }
.hg-chat__close {
  appearance: none;
  border: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text);
  font-size: 20px;
  line-height: 1;
}
.hg-chat__close:hover { background: rgba(255, 255, 255, 0.1); }

.hg-chat__msgs {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: radial-gradient(900px 500px at 20% 10%, rgba(76, 243, 199, 0.12), transparent);
}

.hg-bubble {
  padding: 13px 16px;
  border-radius: 18px;
  max-width: 80%;
  line-height: 1.5;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(76, 243, 199, 0.12);
  box-shadow: 0 8px 24px rgba(5, 15, 35, 0.4);
  backdrop-filter: blur(8px);
}
.hg-bubble.user { align-self: flex-end; border-color: rgba(76, 243, 199, 0.4); background: rgba(76, 243, 199, 0.16); color: var(--color-accent); }
.hg-bubble.bot { align-self: flex-start; color: var(--color-text); }

.hg-typing { display: inline-flex; gap: 6px; align-items: center; padding: 10px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); }
.hg-typing .dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(166, 184, 204, 0.7); animation: chat-blink 1s infinite ease-in-out; }
.hg-typing .dot:nth-child(2) { animation-delay: .16s; }
.hg-typing .dot:nth-child(3) { animation-delay: .32s; }

.hg-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 18px 18px;
  border-top: 1px solid rgba(76, 243, 199, 0.16);
  background: linear-gradient(180deg, rgba(8, 22, 36, 0.94), rgba(4, 10, 18, 0.94));
}
.hg-chat__input {
  flex: 1;
  min-height: 46px;
  max-height: 160px;
  resize: none;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(76, 243, 199, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.4;
  overflow-y: hidden;
}
.hg-chat__input::placeholder { color: rgba(166, 184, 204, 0.7); }
.hg-chat__btn {
  padding: 12px 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(120deg, var(--color-accent-strong), var(--color-accent));
  color: #032f24;
  box-shadow: 0 8px 24px rgba(76, 243, 199, 0.3);
  transition: transform .3s var(--timing), box-shadow .3s var(--timing);
}
.hg-chat__btn:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(76, 243, 199, 0.35); }

.hg-chat-launcher {
  position: fixed;
  right: var(--chat-offset);
  bottom: var(--chat-offset);
  z-index: 110;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(76, 243, 199, 0.22);
  background: linear-gradient(135deg, var(--color-accent-strong), var(--color-accent));
  color: #032f24;
  font-weight: 700;
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(5, 15, 35, 0.45);
  transition: transform .28s var(--timing), box-shadow .28s var(--timing);
}
.hg-chat-launcher:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 24px 52px rgba(5, 15, 35, 0.55); }

.hg-hidden { display: none !important; }

@keyframes chat-blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 560px) {
  :root { --chat-offset: 18px; }
  .hg-chat {
    width: calc(100vw - 24px);
    left: 12px;
    right: 12px;
    max-height: calc(100dvh - 60px);
    border-radius: 20px;
  }
  .hg-chat-launcher { right: 18px; left: unset; }
  body.chat-left .hg-chat-launcher { left: 18px; right: unset; }
}
