:root {
  --chat-panel: #08090b;
  --chat-panel-soft: #111317;
  --chat-white: #ffffff;
  --chat-muted: rgba(255, 255, 255, 0.62);
  --chat-line: rgba(255, 255, 255, 0.12);
  --chat-green: #dff3e8;
  --chat-blue: #2dd9ff;
  --chat-purple: #a855ff;
}

.market-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1500;
  font-family: "Montserrat", sans-serif;
}

.market-chat * {
  box-sizing: border-box;
}

.chat-toggle {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  color: var(--chat-white);
  background:
    radial-gradient(circle at 30% 20%, rgba(45, 217, 255, 0.3), transparent 44%),
    linear-gradient(135deg, #050505, #17191d);
  cursor: pointer;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.36), 0 0 28px rgba(45, 217, 255, 0.16);
}

.chat-toggle span {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 2px;
}

.chat-window {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(420px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 24px;
  color: var(--chat-white);
  background:
    radial-gradient(circle at top left, rgba(45, 217, 255, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(168, 85, 255, 0.16), transparent 34%),
    var(--chat-panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.chat-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--chat-line);
}

.chat-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #090909;
  background: var(--chat-green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
}

.chat-title strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

.chat-title span {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: var(--chat-muted);
  font-size: 12px;
  line-height: 1.4;
}

.chat-title i {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: #7eff37;
  box-shadow: 0 0 12px rgba(126, 255, 55, 0.72);
}

.chat-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  color: var(--chat-white);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 20px;
}

.chat-context {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px 0;
}

.chat-context span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.04);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.chat-messages {
  height: 340px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 16px;
}

.chat-message {
  max-width: 90%;
  border-radius: 18px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.58;
}

.chat-message span {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.chat-message p {
  margin: 0;
}

.chat-message.bot {
  justify-self: start;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.08);
}

.chat-message.bot span {
  color: var(--chat-blue);
}

.chat-message.user {
  justify-self: end;
  color: #111111;
  background: var(--chat-green);
}

.chat-message.user span {
  color: rgba(0, 0, 0, 0.56);
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-actions a {
  border: 1px solid rgba(45, 217, 255, 0.4);
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--chat-white);
  background: rgba(45, 217, 255, 0.1);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  text-decoration: none;
  text-transform: uppercase;
}

.chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
}

.chat-chip {
  border: 1px solid rgba(45, 217, 255, 0.34);
  border-radius: 999px;
  padding: 9px 11px;
  color: var(--chat-white);
  background: rgba(45, 217, 255, 0.08);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}

.chat-typing {
  width: fit-content;
  display: flex;
  gap: 5px;
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.08);
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-blue);
  animation: chatPulse 0.8s ease-in-out infinite alternate;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.12s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.24s;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 14px;
  border-top: 1px solid var(--chat-line);
  background: rgba(0, 0, 0, 0.24);
}

.chat-form input {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0 13px;
  color: var(--chat-white);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  font: inherit;
  font-size: 13px;
}

.chat-form input:focus {
  border-color: rgba(45, 217, 255, 0.5);
}

.chat-form input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.chat-form button {
  min-width: 78px;
  border: 0;
  border-radius: 14px;
  color: #111111;
  background: var(--chat-blue);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}

@keyframes chatPulse {
  from {
    opacity: 0.35;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 640px) {
  .market-chat {
    right: 16px;
    bottom: 16px;
  }

  .chat-window {
    bottom: 74px;
  }

  .chat-messages {
    height: 310px;
  }
}
