.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99999;
  touch-action: none;
  isolation: isolate;
}

.chat-orb {
  position: relative;
  width: 84px;
  height: 84px;
  border: 1px solid rgba(167, 255, 47, 0.38);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 28%, #efffd8 0%, #c7ff83 48%, #86dc45 100%);
  box-shadow: 0 0 34px rgba(167, 255, 47, 0.34), inset 0 0 20px rgba(255, 255, 255, 0.3);
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  display: grid;
  place-items: center;
  animation: chatPlay 5.2s ease-in-out infinite;
}

.chat-widget.dragging .chat-orb {
  cursor: grabbing;
}

.chat-widget.open .chat-orb {
  animation: none;
  transform: scale(0.88);
}

.chat-pulse {
  position: absolute;
  inset: 8px;
  border-radius: inherit;
  border: 1px solid rgba(167, 255, 47, 0.24);
  animation: chatPulse 2.4s ease-out infinite;
}

.chat-orb-video,
.chat-orb-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.chat-orb-video {
  transform: scale(1.16);
  transform-origin: center;
}

.chat-orb-fallback {
  display: none;
  object-fit: contain;
  padding: 6px;
  transform: scale(1.12);
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 102px;
  width: min(420px, calc(100vw - 28px));
  padding: 16px;
  border: 1px solid rgba(167, 255, 47, 0.34);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(10, 14, 12, 0.98), rgba(5, 8, 6, 0.98));
  box-shadow: 0 0 34px rgba(167, 255, 47, 0.1), 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.24s ease, transform 0.24s ease;
  touch-action: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  max-height: min(680px, calc(100dvh - 132px));
}

.chat-widget.open .chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(167, 255, 47, 0.34);
  background: rgba(167, 255, 47, 0.06);
  flex: 0 0 48px;
}

.chat-avatar video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  padding: 2px;
  filter: drop-shadow(0 0 10px rgba(167,255,47,.2));
}

.chat-header strong {
  display: block;
  color: #fff;
  font-size: 15px;
}

.chat-header span {
  color: #a7ff2f;
  font-size: 13px;
}

.chat-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  cursor: pointer;
}

.chat-header-actions [data-chat-restart] {
  width: auto;
  min-width: 0;
  padding: 0 10px;
  color: #a7ff2f;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  border-color: rgba(167,255,47,.22);
  background: rgba(167,255,47,.07);
}

.chat-header-actions button:hover {
  border-color: rgba(167,255,47,.38);
  background: rgba(167,255,47,.12);
}

.chat-messages {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 310px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(167,255,47,.22);
}

.chat-messages article {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 14px;
  white-space: pre-line;
  animation: chatMessageIn .22s ease both;
}

.chat-messages .bot-message {
  background: rgba(167, 255, 47, 0.08);
  border: 1px solid rgba(167, 255, 47, 0.18);
  color: #eef4ea;
}

.chat-messages .user-message {
  margin-left: auto;
  background: #a7ff2f;
  color: #071004;
  font-weight: 600;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.chat-options button {
  min-height: 34px;
  border: 1px solid rgba(167,255,47,.28);
  border-radius: 999px;
  background: rgba(167,255,47,.075);
  color: #dfffca;
  padding: 0 12px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.chat-options button:hover {
  transform: translateY(-1px);
  border-color: rgba(167,255,47,.58);
  background: rgba(167,255,47,.15);
  color: #fff;
}

.support-feedback-form { width: 100%; display: grid; gap: 10px; }
.support-feedback-form > strong { color: #fff; font-size: 14px; }
.support-feedback-stars { display: flex; gap: 6px; }
.support-feedback-stars button { min-width: 38px; width: 38px; padding: 0; border-radius: 9px; color: #6f776c; font-size: 24px; }
.support-feedback-stars button.active { color: #ffd84d; border-color: rgba(255,216,77,.7); background: rgba(255,216,77,.12); }
.support-feedback-form textarea { width: 100%; resize: vertical; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(255,255,255,.035); color: #fff; padding: 10px 12px; font: inherit; box-sizing: border-box; }
.support-feedback-form > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
.support-feedback-form > div:last-child button:first-child { color: #071004; background: #a7ff2f; }

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
}

.chat-form input {
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  color: #fff;
  padding: 0 14px;
  outline: 0;
}

.chat-form button {
  height: 46px;
  min-width: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #a7ff2f, #8fec20);
  color: #071004;
  font-weight: 900;
  cursor: pointer;
}

@keyframes chatPlay {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-4px) rotate(-2deg); }
  55% { transform: translateY(2px) rotate(2deg); }
  75% { transform: translateY(-2px); }
}

@keyframes chatPulse {
  0% { opacity: 0.85; transform: scale(0.92); }
  100% { opacity: 0; transform: scale(1.18); }
}

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

@media (max-width: 760px) {
  .chat-widget {
    right: 14px;
    bottom: 14px;
  }

  .chat-orb {
    width: 76px;
    height: 76px;
  }

  .chat-panel {
    bottom: 92px;
    max-height: calc(100dvh - 112px);
  }

  .chat-options button {
    flex: 1 1 calc(50% - 8px);
  }
}

@media (max-width: 560px) {
  body.register-pro .chat-widget {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .chat-widget {
    right: 10px;
    bottom: 58px;
  }

  .chat-orb {
    width: 64px;
    height: 64px;
  }

  .chat-panel {
    bottom: 74px;
    width: min(320px, calc(100vw - 24px));
    max-height: calc(100dvh - 96px);
    overflow: auto;
  }
}
