:root {
  --sq-chat-red: #b51007;
  --sq-chat-red-dark: #851008;
  --sq-chat-ink: #15191d;
  --sq-chat-muted: #66707a;
  --sq-chat-line: #e4e8eb;
  --sq-chat-surface: #f6f7f8;
}

.sq-chatbot,
.sq-chatbot * {
  box-sizing: border-box;
}

.sq-chatbot {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10020;
  color: var(--sq-chat-ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

body.sq-chatbot-ready .scroll-top {
  right: auto;
  left: 30px;
}

.sq-chatbot__launcher {
  position: relative;
  display: flex;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #c8170d, var(--sq-chat-red-dark));
  box-shadow: 0 12px 34px rgba(90, 10, 5, 0.3);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.sq-chatbot__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 38px rgba(90, 10, 5, 0.38);
}

.sq-chatbot__launcher:focus-visible,
.sq-chatbot button:focus-visible,
.sq-chatbot input:focus-visible {
  outline: 3px solid rgba(181, 16, 7, 0.25);
  outline-offset: 2px;
}

.sq-chatbot__launcher svg {
  width: 29px;
  height: 29px;
}

.sq-chatbot__label {
  position: absolute;
  right: 75px;
  padding: 9px 13px;
  border-radius: 9px;
  color: #fff;
  background: var(--sq-chat-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

.sq-chatbot.is-open .sq-chatbot__label {
  display: none;
}

.sq-chatbot__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: none;
  width: min(410px, calc(100vw - 28px));
  height: min(650px, calc(100vh - 115px));
  min-height: min(480px, calc(100dvh - 100px));
  overflow: hidden;
  border: 1px solid rgba(21, 25, 29, 0.1);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 20, 25, 0.24);
  transform-origin: bottom right;
}

.sq-chatbot.is-open .sq-chatbot__panel {
  display: flex;
  flex-direction: column;
  animation: sq-chat-in 180ms ease-out;
}

.sq-chatbot__header {
  display: flex;
  min-height: 78px;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  color: #fff;
  background:
    radial-gradient(
      circle at 100% 0,
      rgba(255, 255, 255, 0.18),
      transparent 40%
    ),
    linear-gradient(135deg, #c8170d, #841108);
}

.sq-chatbot__avatar {
  display: flex;
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: #fff;
  color: var(--sq-chat-red);
  font-size: 19px;
  font-weight: 800;
}

.sq-chatbot__heading {
  min-width: 0;
  flex: 1;
}

.sq-chatbot__heading strong,
.sq-chatbot__heading span {
  display: block;
}

.sq-chatbot__heading strong {
  color: inherit;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.sq-chatbot__heading span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
}

.sq-chatbot__status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: #68df88;
  box-shadow: 0 0 0 3px rgba(104, 223, 136, 0.16);
}

.sq-chatbot__icon-button {
  display: flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
}

.sq-chatbot__icon-button:hover {
  background: rgba(255, 255, 255, 0.23);
}

.sq-chatbot__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 15px 10px;
  background: var(--sq-chat-surface);
  scrollbar-color: #c7ccd0 transparent;
  scrollbar-width: thin;
}

.sq-chatbot__message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.sq-chatbot__message-row--user {
  justify-content: flex-end;
}

.sq-chatbot__mini-avatar {
  display: flex;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--sq-chat-red);
  font-size: 10px;
  font-weight: 800;
}

.sq-chatbot__bubble {
  max-width: 82%;
  padding: 10px 12px;
  border: 1px solid var(--sq-chat-line);
  border-radius: 14px 14px 14px 4px;
  color: #30363b;
  background: #fff;
  box-shadow: 0 3px 12px rgba(20, 28, 34, 0.05);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sq-chatbot__bubble--formatted {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sq-chatbot__message-title {
  display: block;
  margin: 2px 0 1px;
  color: var(--sq-chat-red);
  font-size: 13px;
  font-weight: 800;
}

.sq-chatbot__message-space {
  height: 3px;
}

.sq-chatbot__message-list-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 3px;
}

.sq-chatbot__message-bullet {
  color: var(--sq-chat-red);
  font-weight: 800;
}

.sq-chatbot__message-line {
  display: block;
}

.sq-chatbot__message-row--user .sq-chatbot__bubble {
  border-color: var(--sq-chat-red);
  border-radius: 14px 14px 4px 14px;
  color: #fff;
  background: var(--sq-chat-red);
  box-shadow: 0 5px 16px rgba(181, 16, 7, 0.16);
}

.sq-chatbot__typing {
  display: flex;
  min-width: 52px;
  align-items: center;
  gap: 4px;
}

.sq-chatbot__typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8a9299;
  animation: sq-chat-dot 1s infinite ease-in-out;
}

.sq-chatbot__typing i:nth-child(2) {
  animation-delay: 120ms;
}

.sq-chatbot__typing i:nth-child(3) {
  animation-delay: 240ms;
}

.sq-chatbot__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px 36px;
}

.sq-chatbot__choice {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #ccd2d7;
  border-radius: 999px;
  color: #333a40;
  background: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease,
    background-color 150ms ease;
}

.sq-chatbot__choice:hover {
  border-color: var(--sq-chat-red);
  color: var(--sq-chat-red);
  background: #fff9f8;
}

.sq-chatbot button:disabled,
.sq-chatbot input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.sq-chatbot__composer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 12px 13px;
  border-top: 1px solid var(--sq-chat-line);
  background: #fff;
}

.sq-chatbot__input {
  width: 100%;
  height: 43px;
  min-width: 0;
  padding: 0 13px;
  border: 1px solid #d5dade;
  border-radius: 12px;
  color: var(--sq-chat-ink);
  background: #fff;
  font: inherit;
  font-size: 13px;
}

.sq-chatbot__input::placeholder {
  color: #91999f;
}

.sq-chatbot__send {
  display: flex;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--sq-chat-red);
  cursor: pointer;
}

.sq-chatbot__send:hover {
  background: var(--sq-chat-red-dark);
}

.sq-chatbot__send svg {
  width: 18px;
  height: 18px;
}

.sq-chatbot__notice {
  padding: 0 13px 10px;
  color: var(--sq-chat-muted);
  background: #fff;
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
}

@keyframes sq-chat-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sq-chat-dot {
  0%,
  60%,
  100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (max-width: 520px) {
  .sq-chatbot {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  body.sq-chatbot-ready .scroll-top {
    right: auto;
    left: 12px;
  }

  .sq-chatbot__panel {
    right: 0;
    bottom: 72px;
    width: calc(100vw - 24px);
    height: min(680px, calc(100dvh - 100px));
    min-height: min(430px, calc(100dvh - 100px));
    border-radius: 17px;
  }

  .sq-chatbot__launcher {
    width: 58px;
    height: 58px;
  }

  .sq-chatbot__label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sq-chatbot *,
  .sq-chatbot *::before,
  .sq-chatbot *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
