.live-chat {
  bottom: max(24px, env(safe-area-inset-bottom));
  position: fixed;
  right: 24px;
  z-index: 9999;
}

.live-chat__toggle {
  align-items: center;
  background: #c09b6c;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  color: #fff;
  display: flex;
  font-size: 24px;
  height: 60px;
  justify-content: center;
  position: relative;
  width: 60px;
}

.live-chat__badge {
  background: #e32636;
  border: 2px solid #fff;
  border-radius: 50%;
  height: 14px;
  position: absolute;
  right: 1px;
  top: 1px;
  width: 14px;
}

.live-chat__panel {
  background: #fff;
  border-radius: 15px;
  bottom: 76px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  height: min(560px, calc(100vh - 120px));
  height: min(560px, calc(100dvh - 120px));
  max-height: min(560px, calc(100vh - 120px));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: min(380px, calc(100vw - 32px));
}

.live-chat__panel[hidden] {
  display: none;
}

.live-chat__header {
  align-items: center;
  background: #c09b6c;
  color: #fff;
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  padding: 14px 16px;
}

.live-chat__header h2 {
  color: inherit;
  font-size: 18px;
  margin: 0;
}

.live-chat__close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 28px;
  line-height: 1;
}

.live-chat__messages {
  background: #f8f9fa;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  overflow-y: auto;
  padding: 16px;
}

.live-chat__message {
  display: flex;
  margin-bottom: 12px;
}

.live-chat__message--user {
  justify-content: flex-end;
}

.live-chat__bubble {
  background: #edcb9e;
  border-radius: 14px;
  max-width: 78%;
  overflow-wrap: anywhere;
  padding: 10px 12px;
}

.live-chat__message--user .live-chat__bubble {
  background: #fff;
  border: 1px solid #dee2e6;
}

.live-chat__bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.live-chat__time {
  color: #6c757d;
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.live-chat__form {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 12px;
}

.live-chat__form input {
  font-size: 16px;
  min-width: 0;
}

.live-chat__send {
  background: #c09b6c;
  border: 0;
  border-radius: 8px;
  color: #fff;
  flex: 0 0 44px;
}

.live-chat__error {
  color: #b42318;
  font-size: 13px;
  margin: 8px 12px 0;
}

.live-chat ~ .scrollToTop {
  right: 100px;
}

@media (max-width: 575.98px) {
  .live-chat {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
  }

  .live-chat__panel {
    bottom: calc(88px + env(safe-area-inset-bottom));
    height: calc(100vh - 112px - env(safe-area-inset-bottom));
    height: calc(100dvh - 112px - env(safe-area-inset-bottom));
    left: 16px;
    max-height: 520px;
    position: fixed;
    right: 16px;
    width: auto;
  }

  .live-chat--input-focused .live-chat__panel {
    bottom: auto;
    height: calc(var(--live-chat-viewport-height, 100dvh) - 16px);
    left: 8px;
    max-height: none;
    right: 8px;
    top: calc(var(--live-chat-viewport-top, 0px) + 8px);
  }

  .live-chat--input-focused .live-chat__toggle {
    pointer-events: none;
    visibility: hidden;
  }

  .live-chat ~ .scrollToTop {
    right: 88px;
  }
}

@media (max-width: 575.98px) and (max-height: 480px) {
  .live-chat:not(.live-chat--input-focused) .live-chat__panel {
    bottom: calc(76px + env(safe-area-inset-bottom));
    height: calc(100dvh - 92px - env(safe-area-inset-bottom));
  }

  .live-chat__header {
    padding-block: 10px;
  }

  .live-chat__messages {
    padding: 10px;
  }

  .live-chat__form {
    padding: 8px;
  }
}
