.rg-site-chat,
.rg-site-chat * {
  box-sizing: border-box;
}

.rg-site-chat {
  bottom: 24px;
  font-family: Arial, sans-serif;
  position: fixed;
  right: 24px;
  z-index: 700;
}

.rg-site-chat__toggle {
  align-items: center;
  background: #ec482f;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(236, 72, 47, .32);
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 0;
  font-weight: 700;
  height: 46px;
  justify-content: center;
  min-width: 46px;
  padding: 0;
  position: relative;
  width: 46px;
}

.rg-site-chat__toggle::before {
  background-color: #fff;
  background-image:
    radial-gradient(circle at 7px 8px, #ec482f 0 1.5px, transparent 1.7px),
    radial-gradient(circle at 12px 8px, #ec482f 0 1.5px, transparent 1.7px),
    radial-gradient(circle at 17px 8px, #ec482f 0 1.5px, transparent 1.7px);
  border: 0;
  border-radius: 7px;
  content: '';
  height: 16px;
  position: absolute;
  width: 24px;
}

.rg-site-chat__toggle::after {
  border-right: 7px solid transparent;
  border-top: 7px solid #fff;
  bottom: 10px;
  content: '';
  height: 0;
  left: 12px;
  position: absolute;
  transform: rotate(8deg);
  width: 0;
}

.rg-site-chat__toggle:focus,
.rg-site-chat__close:focus,
.rg-site-chat__send:focus,
.rg-site-chat__attach:focus,
.rg-site-chat__document:focus,
.rg-site-chat__document-remove:focus {
  outline: 3px solid rgba(236, 72, 47, .28);
  outline-offset: 2px;
}

.rg-site-chat__panel {
  background: #fff;
  border: 2px solid #ec482f;
  border-radius: 18px;
  bottom: 58px;
  box-shadow: 0 20px 56px rgba(236, 72, 47, .2);
  display: none;
  height: min(560px, calc(100vh - 120px));
  overflow: hidden;
  position: absolute;
  right: 0;
  width: 360px;
}

.rg-site-chat--open .rg-site-chat__panel {
  display: flex;
  flex-direction: column;
}

.rg-site-chat__header {
  align-items: center;
  background: #ec482f;
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 12px 14px 12px 18px;
}

.rg-site-chat__header strong,
.rg-site-chat__header span {
  display: block;
}

.rg-site-chat__header strong {
  font-size: 17px;
}

.rg-site-chat__header span {
  font-size: 12px;
  margin-top: 3px;
  opacity: .88;
}

.rg-site-chat__close {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font-size: 28px;
  height: 40px;
  line-height: 36px;
  width: 40px;
}

.rg-site-chat__messages {
  background: #fff5f5;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 14px 18px;
}

.rg-site-chat__welcome,
.rg-site-chat__message {
  background: #fff;
  border-radius: 13px 13px 13px 3px;
  box-shadow: 0 1px 3px rgba(18, 23, 31, .08);
  color: #282c32;
  font-size: 14px;
  line-height: 1.42;
  margin: 0 0 10px;
  max-width: 86%;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.rg-site-chat__message-row {
  align-items: flex-start;
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  width: 100%;
}

.rg-site-chat__message-row--visitor {
  justify-content: flex-start;
}

.rg-site-chat__message-stack {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  max-width: 86%;
  min-width: 0;
}

.rg-site-chat__message-row--visitor .rg-site-chat__message-stack {
  align-items: flex-start;
}

.rg-site-chat__message-row .rg-site-chat__message {
  margin-bottom: 0;
  max-width: 100%;
}

.rg-site-chat__avatar {
  align-items: center;
  background: #ec482f;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(18, 23, 31, .14);
  color: #fff;
  display: flex;
  flex: 0 0 32px;
  font-size: 12px;
  font-weight: 700;
  height: 32px;
  justify-content: center;
  overflow: hidden;
  position: relative;
  width: 32px;
}

.rg-site-chat__avatar img {
  height: 100%;
  left: 0;
  object-fit: cover;
  position: absolute;
  top: 0;
  width: 100%;
}

.rg-site-chat__message--visitor {
  background: #ffe5e6;
  border-radius: 13px 13px 13px 3px;
  margin-left: 0;
}

.rg-site-chat__time {
  align-self: flex-end;
  color: #858b94;
  display: block;
  font-size: 10px;
  margin-top: 2px;
  padding: 0 4px;
  text-align: right;
}

.rg-site-chat__status {
  color: #6f7680;
  font-size: 12px;
  min-height: 18px;
  padding: 4px 14px 0;
}

.rg-site-chat__status--error {
  color: #ad1016;
}

.rg-site-chat__form {
  background: #fff;
  border-top: 1px solid rgba(236, 72, 47, .24);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
}

.rg-site-chat__controls {
  align-items: flex-end;
  display: flex;
  gap: 6px;
  width: 100%;
}

.rg-site-chat__file-input {
  height: 1px;
  left: -10000px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.rg-site-chat__attach {
  align-items: center;
  background: #f1f3f5;
  border: 0;
  border-radius: 50%;
  color: #697386;
  cursor: pointer;
  display: flex;
  flex: 0 0 42px;
  font-size: 20px;
  height: 42px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.rg-site-chat__document-preview {
  align-items: center;
  background: #fff5f5;
  border: 1px solid rgba(236, 72, 47, .24);
  border-radius: 10px;
  color: #3f454d;
  display: flex;
  font-size: 12px;
  gap: 8px;
  justify-content: space-between;
  padding: 7px 9px;
  width: 100%;
}

.rg-site-chat__document-preview[hidden] {
  display: none;
}

.rg-site-chat__document-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rg-site-chat__document-remove {
  background: transparent;
  border: 0;
  color: #ad1016;
  cursor: pointer;
  flex: 0 0 24px;
  font-size: 20px;
  height: 24px;
  padding: 0;
}

.rg-site-chat__input {
  border: 1px solid #d7dbe0;
  border-radius: 21px;
  flex: 1;
  font: inherit;
  height: 42px;
  max-height: 42px;
  min-height: 42px;
  overflow-y: auto;
  padding: 9px 13px 7px;
  resize: none;
}

.rg-site-chat__input:focus {
  border-color: #ec482f;
  outline: none;
}

.rg-site-chat__send {
  align-items: center;
  background: #ec482f;
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 42px;
  font-size: 0;
  font-weight: 700;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  padding: 0;
  width: 42px;
}

.rg-site-chat__send-icon {
  fill: currentColor;
  height: 20px;
  transform: translateX(1px);
  width: 20px;
}

.rg-site-chat__send:disabled,
.rg-site-chat__attach:disabled,
.rg-site-chat__document:disabled,
.rg-site-chat__document-remove:disabled,
.rg-site-chat__input:disabled {
  opacity: .58;
}

.rg-site-chat__document {
  align-items: flex-start;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(236, 72, 47, .3);
  border-radius: 10px;
  color: #282c32;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
  padding: 8px 10px;
  text-align: left;
}

.rg-site-chat__document::before {
  color: #ec482f;
  content: 'Документ';
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.rg-site-chat__document strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rg-site-chat__document span {
  color: #858b94;
  font-size: 11px;
}

@media (max-width: 700px) {
  .rg-site-chat {
    bottom: 84px;
    right: 12px;
  }

  .rg-site-chat__toggle {
    height: 44px;
    min-width: 44px;
    width: 44px;
  }

  .rg-site-chat__panel {
    bottom: 54px;
    height: min(520px, calc(100vh - 166px));
    max-width: calc(100vw - 24px);
    width: 350px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rg-site-chat * {
    scroll-behavior: auto !important;
  }
}

/* Overlay the indicator while keeping the native scrollbar's layout footprint. */
.rg-site-chat__message-viewport {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.rg-site-chat__messages--scroll-ready {
  scrollbar-color: transparent transparent;
}

.rg-site-chat__messages--scroll-ready::-webkit-scrollbar,
.rg-site-chat__messages--scroll-ready::-webkit-scrollbar-track,
.rg-site-chat__messages--scroll-ready::-webkit-scrollbar-thumb,
.rg-site-chat__messages--scroll-ready::-webkit-scrollbar-button,
.rg-site-chat__messages--scroll-ready::-webkit-scrollbar-corner {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.rg-site-chat__scroll {
  bottom: 6px;
  cursor: pointer;
  outline: none;
  position: absolute;
  right: 0;
  top: 6px;
  touch-action: none;
  user-select: none;
  width: 14px;
  z-index: 2;
}

.rg-site-chat__scroll[hidden],
.rg-site-chat__scroll-preview[hidden] {
  display: none !important;
}

.rg-site-chat__scroll::before,
.rg-site-chat__scroll-active {
  background: repeating-linear-gradient(to bottom, rgba(66, 65, 60, .23) 0 2px, transparent 2px 9px);
  bottom: 0;
  pointer-events: none;
  position: absolute;
  right: 4px;
  top: 0;
  width: 6px;
}

.rg-site-chat__scroll::before { content: ''; }

.rg-site-chat__scroll-active {
  background: repeating-linear-gradient(to bottom, #ec482f 0 2px, transparent 2px 9px);
  -webkit-mask-image: linear-gradient(to bottom, transparent calc(var(--rg-chat-scroll-center) - 56px), #000 calc(var(--rg-chat-scroll-center) - 12px), #000 calc(var(--rg-chat-scroll-center) + 12px), transparent calc(var(--rg-chat-scroll-center) + 56px));
  mask-image: linear-gradient(to bottom, transparent calc(var(--rg-chat-scroll-center) - 56px), #000 calc(var(--rg-chat-scroll-center) - 12px), #000 calc(var(--rg-chat-scroll-center) + 12px), transparent calc(var(--rg-chat-scroll-center) + 56px));
}

.rg-site-chat__scroll:focus-visible {
  border-radius: 3px;
  outline: 1px solid #ec482f;
}

.rg-site-chat__scroll-preview {
  background: #fff;
  border: 1px solid rgba(236, 72, 47, .22);
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(18, 23, 31, .14);
  color: #282c32;
  font-size: 12px;
  line-height: 1.4;
  max-height: calc(100% - 8px);
  max-width: calc(100% - 36px);
  overflow: hidden;
  overflow-wrap: anywhere;
  padding: 9px 11px;
  pointer-events: none;
  position: absolute;
  right: 22px;
  width: 280px;
  z-index: 3;
}

.rg-site-chat__scroll-preview-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.rg-site-chat__scroll-preview-author .rg-site-chat__avatar {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
}
.rg-site-chat__scroll-preview-author strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rg-site-chat__scroll-preview-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
