.lazy-chat-widget {
  --lazy-chat-edge-inline: max(1.25rem, env(safe-area-inset-right));
  --lazy-chat-edge-block: max(1.25rem, env(safe-area-inset-bottom));
  --lazy-chat-launcher-size: 4rem;
  position: relative;
  z-index: 1085;
}

.lazy-chat-widget [hidden] {
  display: none !important;
}

.lazy-chat-launcher {
  position: fixed;
  right: var(--lazy-chat-edge-inline);
  bottom: var(--lazy-chat-edge-block);
  display: grid;
  width: var(--lazy-chat-launcher-size);
  height: var(--lazy-chat-launcher-size);
  padding: 0;
  place-items: center;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #7779ff, #5558e8);
  box-shadow: 0 14px 34px rgba(78, 81, 210, 0.36);
  color: #fff;
  cursor: pointer;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.lazy-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(78, 81, 210, 0.42);
}

.lazy-chat-launcher-unread {
  position: absolute;
  z-index: 2;
  top: -0.3rem;
  right: -0.3rem;
  display: grid;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.35rem;
  place-items: center;
  border: 2px solid var(--bs-body-bg);
  box-shadow: 0 5px 12px rgba(255, 62, 29, 0.3);
  font-size: 0.68rem;
  line-height: 1;
}

.lazy-chat-launcher.is-open {
  pointer-events: none;
  opacity: 0;
  transform: scale(0.78);
  visibility: hidden;
}

.lazy-chat-launcher:focus-visible,
.lazy-chat-invitation-content:focus-visible,
.lazy-chat-invitation-close:focus-visible {
  outline: 3px solid rgba(105, 108, 255, 0.28);
  outline-offset: 3px;
}

.lazy-chat-launcher-avatar {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  transition:
    opacity 160ms ease,
    transform 180ms ease;
}

.lazy-chat-launcher-avatar img {
  display: block;
  width: 2.875rem;
  height: 2.875rem;
  object-fit: contain;
}

.lazy-chat-launcher-close {
  position: absolute;
  font-size: 1.8rem;
  opacity: 0;
  transform: scale(0.65) rotate(-20deg);
  transition:
    opacity 160ms ease,
    transform 180ms ease;
}

.lazy-chat-launcher.is-open .lazy-chat-launcher-avatar {
  opacity: 0;
  transform: scale(0.72) rotate(12deg);
}

.lazy-chat-launcher.is-open .lazy-chat-launcher-close {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.lazy-chat-launcher-status,
.lazy-chat-agent-status {
  position: absolute;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #28c76f;
  box-shadow: 0 0 0 2px rgba(40, 199, 111, 0.16);
}

.lazy-chat-launcher-status {
  right: 0.12rem;
  bottom: 0.18rem;
  transition: opacity 160ms ease;
}

.lazy-chat-launcher.is-open .lazy-chat-launcher-status {
  opacity: 0;
}

.lazy-chat-invitation {
  position: fixed;
  right: var(--lazy-chat-edge-inline);
  bottom: calc(var(--lazy-chat-edge-block) + var(--lazy-chat-launcher-size) + 0.9rem);
  width: min(19.5rem, calc(100vw - 2.5rem));
  overflow: visible;
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem 1rem 0.35rem 1rem;
  background: var(--bs-body-bg);
  box-shadow: 0 16px 44px rgba(34, 48, 74, 0.2);
  color: var(--bs-body-color);
  opacity: 0;
  transform: translateY(0.65rem) scale(0.97);
  visibility: hidden;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    visibility 180ms ease;
}

.lazy-chat-invitation::after {
  position: absolute;
  right: 1.55rem;
  bottom: -0.48rem;
  width: 0.95rem;
  height: 0.95rem;
  border-right: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  content: '';
  transform: rotate(45deg);
}

.lazy-chat-invitation.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.lazy-chat-invitation-content {
  display: flex;
  width: 100%;
  padding: 1.15rem 2.6rem 1.15rem 1.15rem;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
}

.lazy-chat-invitation-content strong {
  color: var(--bs-heading-color);
  font-size: 1rem;
}

.lazy-chat-invitation-content > span:last-child {
  color: var(--bs-secondary-color);
  font-size: 0.85rem;
  line-height: 1.45;
}

.lazy-chat-invitation-kicker {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.15rem;
  color: var(--bs-primary);
  font-size: 0.72rem;
  font-weight: 600;
  gap: 0.4rem;
}

.lazy-chat-status-dot {
  display: inline-block;
  width: 0.48rem;
  height: 0.48rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #28c76f;
  box-shadow: 0 0 0 0.18rem rgba(40, 199, 111, 0.12);
}

.lazy-chat-invitation-close {
  position: absolute;
  z-index: 1;
  top: 0.55rem;
  right: 0.55rem;
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bs-secondary-color);
  cursor: pointer;
}

.lazy-chat-invitation-close:hover {
  background: var(--bs-secondary-bg);
  color: var(--bs-heading-color);
}

.lazy-chat-panel {
  position: fixed;
  right: var(--lazy-chat-edge-inline);
  bottom: calc(var(--lazy-chat-edge-block) + var(--lazy-chat-launcher-size) + 0.9rem);
  display: flex;
  width: min(23.5rem, calc(100vw - 2.5rem));
  height: min(50rem, calc(100dvh - 7rem));
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  border-radius: 1.1rem;
  background: var(--bs-body-bg);
  box-shadow: 0 24px 70px rgba(34, 48, 74, 0.26);
  color: var(--bs-body-color);
  flex-direction: column;
  opacity: 0;
  transform: translateY(0.8rem) scale(0.98);
  transform-origin: bottom right;
  visibility: hidden;
  transition:
    opacity 190ms ease,
    transform 190ms ease,
    visibility 190ms ease;
}

.lazy-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.lazy-chat-header {
  display: flex;
  min-height: 5rem;
  padding: 0.9rem 0.95rem 0.9rem 1.05rem;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #696cff, #575ae6);
  color: #fff;
}

.lazy-chat-agent {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.8rem;
}

.lazy-chat-agent-avatar {
  position: relative;
  display: grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(26, 28, 84, 0.2);
}

.lazy-chat-agent-avatar img {
  display: block;
  width: 2.625rem;
  height: 2.625rem;
  object-fit: contain;
}

.lazy-chat-agent-status {
  right: -0.04rem;
  bottom: 0.02rem;
  width: 0.7rem;
  height: 0.7rem;
}

.lazy-chat-agent-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.2;
}

.lazy-chat-agent-copy strong {
  color: #fff;
  font-size: 1rem;
}

.lazy-chat-agent-copy small {
  display: inline-flex;
  margin-top: 0.3rem;
  align-items: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  gap: 0.45rem;
}

.lazy-chat-agent-copy .lazy-chat-status-dot {
  width: 0.4rem;
  height: 0.4rem;
  background: #8be4ad;
  box-shadow: none;
}

.lazy-chat-panel-close {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.9) !important;
}

.lazy-chat-panel-close:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
}

.lazy-chat-body {
  display: flex;
  min-height: 0;
  padding: 1rem;
  background:
    radial-gradient(circle at 14% 10%, rgba(105, 108, 255, 0.1), transparent 38%),
    var(--bs-body-bg);
  flex: 1 1 auto;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.lazy-chat-privacy-note {
  display: inline-flex;
  margin: 0 auto 1rem;
  padding: 0.38rem 0.65rem;
  align-items: center;
  border: 1px solid rgba(105, 108, 255, 0.14);
  border-radius: 999px;
  background: rgba(105, 108, 255, 0.08);
  color: var(--bs-secondary-color);
  font-size: 0.7rem;
  gap: 0.35rem;
}

.lazy-chat-message {
  display: flex;
  width: fit-content;
  max-width: 94%;
  align-items: flex-start;
  gap: 0.65rem;
}

.lazy-chat-messages {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 1rem;
}

.lazy-chat-message-content {
  min-width: 0;
}

.lazy-chat-message-avatar {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--bs-border-color);
  border-radius: 50%;
  background: #fff;
}

.lazy-chat-message-avatar img {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

.lazy-chat-message-bubble {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.3rem 0.9rem 0.9rem;
  background: var(--bs-body-bg);
  box-shadow: 0 5px 16px rgba(34, 48, 74, 0.07);
  color: var(--bs-body-color);
  font-size: 0.875rem;
  line-height: 1.5;
}

.lazy-chat-message-bubble p {
  margin: 0;
}

.lazy-chat-message-bubble p + p {
  margin-top: 0.35rem;
}

.lazy-chat-message-bubble p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lazy-chat-message-bubble > :last-child {
  margin-bottom: 0;
}

.lazy-chat-markdown-list {
  margin: 0 0 0.45rem;
  padding-left: 1.15rem;
  overflow-wrap: anywhere;
}

.lazy-chat-markdown-quote {
  margin: 0 0 0.45rem;
  padding-left: 0.65rem;
  border-left: 3px solid rgba(105, 108, 255, 0.65);
  color: inherit;
}

.lazy-chat-markdown-code,
.lazy-chat-markdown-pre {
  border-radius: 0.3rem;
  background: rgba(var(--bs-secondary-rgb), 0.14);
  color: inherit;
  font-family: var(--bs-font-monospace);
  font-size: 0.84em;
}

.lazy-chat-markdown-code {
  padding: 0.1rem 0.3rem;
  overflow-wrap: anywhere;
}

.lazy-chat-markdown-pre {
  max-width: 100%;
  margin: 0 0 0.45rem;
  padding: 0.65rem;
  overflow-x: auto;
  white-space: pre-wrap;
}

.lazy-chat-markdown-link {
  color: inherit;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.lazy-chat-message-author {
  display: block;
  margin-top: 0.35rem;
  color: var(--bs-secondary-color);
  font-size: 0.68rem;
}

.lazy-chat-message-user {
  margin-left: auto;
}

.lazy-chat-message-user .lazy-chat-message-content {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
}

.lazy-chat-message-user .lazy-chat-message-bubble {
  border-color: rgba(105, 108, 255, 0.35);
  border-radius: 0.9rem 0.3rem 0.9rem 0.9rem;
  background: linear-gradient(145deg, rgba(105, 108, 255, 0.16), rgba(105, 108, 255, 0.1));
  box-shadow: none;
}

.lazy-chat-message-system {
  width: min(100%, 19rem);
  margin-inline: auto;
  align-items: center;
  color: var(--bs-secondary-color);
}

.lazy-chat-message-system-icon {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 159, 67, 0.14);
  color: #ff9f43;
}

.lazy-chat-message-system .lazy-chat-message-bubble {
  padding: 0.65rem 0.75rem;
  border-color: rgba(255, 159, 67, 0.2);
  background: rgba(255, 159, 67, 0.07);
  box-shadow: none;
  font-size: 0.78rem;
}

.lazy-chat-sitelinks {
  display: flex;
  width: min(100%, 18.5rem);
  margin-top: 0.55rem;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.35rem;
}

.lazy-chat-sitelink {
  display: inline-flex;
  max-width: 100%;
  min-height: 2rem;
  padding: 0.32rem 0.55rem;
  align-items: center;
  border: 1px solid rgba(105, 108, 255, 0.18);
  border-radius: 0.55rem;
  background: rgba(105, 108, 255, 0.06);
  color: var(--bs-body-color);
  gap: 0.4rem;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease;
}

.lazy-chat-sitelink:hover {
  border-color: rgba(105, 108, 255, 0.38);
  background: rgba(105, 108, 255, 0.1);
  color: var(--bs-primary);
  transform: translateY(-1px);
}

.lazy-chat-sitelink-icon {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
  place-items: center;
  color: var(--bs-primary);
  font-size: 0.9rem;
}

.lazy-chat-sitelink-copy {
  display: block;
  min-width: 0;
  overflow: hidden;
  line-height: 1.2;
}

.lazy-chat-sitelink-copy strong {
  display: block;
  color: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lazy-chat-loading .lazy-chat-message-bubble {
  display: flex;
  min-width: 3.4rem;
  padding-block: 0.95rem;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.lazy-chat-loading .lazy-chat-message-bubble span {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 50%;
  background: var(--bs-primary);
  animation: lazy-chat-loading-bounce 1s infinite ease-in-out;
}

.lazy-chat-loading .lazy-chat-message-bubble span:nth-child(2) {
  animation-delay: 120ms;
}

.lazy-chat-loading .lazy-chat-message-bubble span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes lazy-chat-loading-bounce {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-0.2rem);
  }
}

.lazy-chat-shortcuts {
  display: flex;
  margin: 1rem 0 0 2.65rem;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.45rem;
}

.lazy-chat-shortcuts .btn {
  display: inline-flex;
  align-items: center;
  border-radius: 0.65rem;
  gap: 0.4rem;
  text-align: left;
}

.lazy-chat-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}

.lazy-chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
}

.lazy-chat-compose .form-control {
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 8.5rem;
  padding-block: 0.7rem;
  border-color: rgba(105, 108, 255, 0.24);
  border-radius: 0.75rem;
  background: rgba(105, 108, 255, 0.06);
  line-height: 1.35;
  overflow-y: hidden;
  resize: none;
}

.lazy-chat-compose .form-control:focus {
  border-color: rgba(105, 108, 255, 0.5);
  background: rgba(105, 108, 255, 0.08);
  box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.12);
}

.lazy-chat-compose .btn {
  flex: 0 0 auto;
}

.lazy-chat-compose .btn.is-loading {
  pointer-events: none;
}

.lazy-chat-compose .form-control:disabled {
  border-color: rgba(105, 108, 255, 0.2);
  background: rgba(105, 108, 255, 0.05);
  opacity: 1;
}

.lazy-chat-footer small {
  display: block;
  margin-top: 0.45rem;
  color: var(--bs-secondary-color);
  font-size: 0.68rem;
  text-align: center;
}

[data-bs-theme='dark'] .lazy-chat-launcher-avatar,
[data-bs-theme='dark'] .lazy-chat-agent-avatar,
[data-bs-theme='dark'] .lazy-chat-message-avatar {
  background: #fff;
}

@media (min-width: 576px) {
  .lazy-chat-panel {
    inset: 0 0 0 auto;
    width: min(27rem, calc(100vw - 2.5rem));
    height: 100vh;
    height: 100dvh;
    border-block: 0;
    border-inline-end: 0;
    border-radius: 0;
    transform-origin: center right;
  }

  .lazy-chat-header {
    padding-top: calc(0.9rem + env(safe-area-inset-top));
  }

  .lazy-chat-footer {
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 575.98px) {
  .lazy-chat-widget {
    --lazy-chat-edge-inline: max(0.75rem, env(safe-area-inset-right));
    --lazy-chat-edge-block: max(0.75rem, env(safe-area-inset-bottom));
    --lazy-chat-launcher-size: 3.75rem;
  }

  .lazy-chat-panel {
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    transform-origin: center;
  }

  .lazy-chat-header {
    padding-top: calc(0.9rem + env(safe-area-inset-top));
  }

  .lazy-chat-footer {
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
  }

  .lazy-chat-invitation {
    width: min(19rem, calc(100vw - 1.5rem));
  }

  .lazy-chat-launcher-avatar {
    width: 3rem;
    height: 3rem;
  }

  .lazy-chat-launcher-avatar img {
    width: 2.625rem;
    height: 2.625rem;
  }

  .lazy-chat-body {
    padding: 0.85rem;
  }

  .lazy-chat-message {
    max-width: 96%;
  }

  .lazy-chat-sitelinks {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lazy-chat-launcher,
  .lazy-chat-launcher-avatar,
  .lazy-chat-launcher-close,
  .lazy-chat-invitation,
  .lazy-chat-panel {
    transition: none;
  }

  .lazy-chat-loading .lazy-chat-message-bubble span {
    animation: none;
  }
}
