/*
 * Support chat widget — global styles.
 * Used by: supportchat/templates/supportchat/chat.html (embedded from base)
 */

@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500&display=swap');

/* --- 75/166, развёрнуто: правый край = центр круга (right: 37.5px) */

.floating-chat {
  position: fixed;
  right: 2.4rem;
  bottom: 2.4rem;
  z-index: 120;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: end;
  -ms-flex-pack: end;
  justify-content: flex-end;
  width: 75px;
  height: 75px;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
  -webkit-transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), -webkit-transform 0.28s ease;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1), transform 0.28s ease;
}

.floating-chat:hover,
.floating-chat:focus-within {
  /* 0..166 + 37.5; левый край = 0 */
  width: 203.5px;
  -webkit-transform: translateY(-2px);
  -ms-transform: translateY(-2px);
  transform: translateY(-2px);
}

.floating-chat__btn {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 100%;
  flex: 0 0 100%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: relative;
  z-index: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: end;
  -ms-flex-pack: end;
  justify-content: flex-end;
  width: 100%;
  height: 75px;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  line-height: 0;
  text-align: left;
  border-radius: 0;
  isolation: isolate;
  -webkit-transition: none;
  -o-transition: none;
  transition: none;
}

.floating-chat__btn:focus {
  outline: none;
}

.floating-chat__btn:focus-visible {
  outline: 2px solid #4f5a81;
  outline-offset: 2px;
}

/* Клип: правый край = вертикаль по центру круга (75/2=37.5), растяжение только влево */
.floating-chat__hint {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  z-index: 0;
  top: 0;
  right: 37.5px; /* линия схлопывания = центр кнопки-круга 75px */
  left: auto;
  width: 0;
  max-width: 166px;
  height: 75px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
  -webkit-transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.floating-chat:hover .floating-chat__hint,
.floating-chat:focus-within .floating-chat__hint {
  width: 166px;
}

.floating-chat__hint-surface {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  width: 166px;
  min-width: 166px;
  height: 75px;
  margin: 0;
  padding: 0 0 0 17px;
  border: 1px solid #4f5a81;
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: #fff;
  -webkit-box-shadow: 0 9px 24px -3px rgba(0, 0, 0, 0.12);
  box-shadow: 0 9px 24px -3px rgba(0, 0, 0, 0.12);
  -webkit-transform-origin: 100% 50%;
  -ms-transform-origin: 100% 50%;
  transform-origin: 100% 50%;
  -webkit-transition: box-shadow 0.3s ease;
  transition: box-shadow 0.3s ease;
}

.floating-chat__hint-text {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: block;
  max-width: 106px;
  font-family: "Onest", sans-serif;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 16px;
  color: #667085;
  text-align: left;
  white-space: normal;
  opacity: 0;
  -webkit-transform: translate3d(6px, 0, 0);
  transform: translate3d(6px, 0, 0);
  -webkit-transition: opacity 0.32s ease 0.1s, -webkit-transform 0.32s ease 0.1s;
  transition: opacity 0.32s ease 0.1s, transform 0.32s ease 0.1s;
  transition: opacity 0.32s ease 0.1s, transform 0.32s ease 0.1s, -webkit-transform 0.32s ease 0.1s;
}

.floating-chat:hover .floating-chat__hint-text,
.floating-chat:focus-within .floating-chat__hint-text {
  opacity: 1;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

.floating-chat__fab {
  position: relative;
  z-index: 2;
  -webkit-box-flex: 0;
  -ms-flex: 0 0 75px;
  flex: 0 0 75px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: block;
  width: 75px;
  min-width: 75px;
  height: 75px;
  margin: 0 0 0 0;
  border-radius: 50%;
  overflow: hidden;
  -webkit-box-shadow: 0 9px 24px 0 rgba(0, 0, 0, 0.12);
  box-shadow: 0 9px 24px 0 rgba(0, 0, 0, 0.12);
  background: #4f5a81;
}

.floating-chat__base {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -o-object-fit: cover;
  object-fit: cover;
  -o-object-position: center;
  object-position: center;
  pointer-events: none;
}

.floating-chat__swirl {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: block;
  width: 86%;
  height: 86%;
  -o-object-fit: contain;
  object-fit: contain;
  -o-object-position: center;
  object-position: center;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  -webkit-transition: opacity 0.2s ease, visibility 0.2s;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.floating-chat__swirl--wobble-anim {
  -webkit-animation: floating-chat-swirl-wobble 1.35s ease-in-out 1;
  animation: floating-chat-swirl-wobble 1.35s ease-in-out 1;
  -webkit-transform-origin: 50% 50%;
  -ms-transform-origin: 50% 50%;
  transform-origin: 50% 50%;
}

@-webkit-keyframes floating-chat-swirl-wobble {
  0%,
  100% {
    -webkit-transform: translate(-50%, -50%) rotate(0deg);
    transform: translate(-50%, -50%) rotate(0deg);
  }
  25% {
    -webkit-transform: translate(-50%, -50%) rotate(-4.5deg);
    transform: translate(-50%, -50%) rotate(-4.5deg);
  }
  50% {
    -webkit-transform: translate(-50%, -50%) rotate(4.2deg);
    transform: translate(-50%, -50%) rotate(4.2deg);
  }
  75% {
    -webkit-transform: translate(-50%, -50%) rotate(-2.2deg);
    transform: translate(-50%, -50%) rotate(-2.2deg);
  }
}

@keyframes floating-chat-swirl-wobble {
  0%,
  100% {
    -webkit-transform: translate(-50%, -50%) rotate(0deg);
    transform: translate(-50%, -50%) rotate(0deg);
  }
  25% {
    -webkit-transform: translate(-50%, -50%) rotate(-4.5deg);
    transform: translate(-50%, -50%) rotate(-4.5deg);
  }
  50% {
    -webkit-transform: translate(-50%, -50%) rotate(4.2deg);
    transform: translate(-50%, -50%) rotate(4.2deg);
  }
  75% {
    -webkit-transform: translate(-50%, -50%) rotate(-2.2deg);
    transform: translate(-50%, -50%) rotate(-2.2deg);
  }
}

.floating-chat__eyes {
  position: absolute;
  z-index: 2;
  inset: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 0 6px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity 0.2s ease, visibility 0.2s;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.floating-chat--eyes .floating-chat__eyes {
  opacity: 1;
  visibility: visible;
}

.floating-chat--eyes .floating-chat__swirl {
  opacity: 0;
  visibility: hidden;
}

/* Во время открытия чата: мгновенно убрать глазки; при закрытии — плавно (см. --eyes-post-modal). */
[data-floating-chat].floating-chat--eyes-modal-suppress .floating-chat__eyes,
.floating-chat.floating-chat--eyes-modal-suppress.floating-chat--eyes .floating-chat__eyes {
  opacity: 0 !important;
  visibility: hidden !important;
  -webkit-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
}

[data-floating-chat].floating-chat--eyes-post-modal .floating-chat__eyes,
.floating-chat.floating-chat--eyes-post-modal.floating-chat--eyes .floating-chat__eyes {
  -webkit-transition: opacity 0.45s ease, visibility 0.45s !important;
  -o-transition: opacity 0.45s ease, visibility 0.45s !important;
  transition: opacity 0.45s ease, visibility 0.45s !important;
}

.floating-chat__eye {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: relative;
  width: 24px;
  height: 24px;
  background: #ffffff;
  border: 1.5px solid #333333;
  border-radius: 50%;
  overflow: hidden;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  -webkit-transform-origin: center;
  -ms-transform-origin: center;
  transform-origin: center;
}

.floating-chat__pupil {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  margin: 0;
  background: #222222;
  border-radius: 50%;
  -webkit-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  -webkit-transition: -webkit-transform 0.08s ease-out;
  transition: -webkit-transform 0.08s ease-out;
  transition: transform 0.08s ease-out;
  transition: transform 0.08s ease-out, -webkit-transform 0.08s ease-out;
  will-change: transform;
}

.floating-chat__pupil::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 3px;
  height: 3px;
  background: #ffffff;
  border-radius: 50%;
  pointer-events: none;
}

.floating-chat__eye--blink-anim {
  -webkit-animation: floating-chat-eyes-blink 0.12s ease-in-out;
  animation: floating-chat-eyes-blink 0.12s ease-in-out;
}

/* Same timing as: 0% / 50% / 100% vertical squint; scoped name to avoid clashes */
@-webkit-keyframes floating-chat-eyes-blink {
  0%,
  100% {
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
  50% {
    -webkit-transform: scaleY(0.05);
    transform: scaleY(0.05);
  }
}
@keyframes floating-chat-eyes-blink {
  0%,
  100% {
    -webkit-transform: scaleY(1);
    transform: scaleY(1);
  }
  50% {
    -webkit-transform: scaleY(0.05);
    transform: scaleY(0.05);
  }
}

/* Touch viewports: влево — вправо — влево (3 фазы на EYES_FOR_MS); плавный сдвиг зрачка */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .floating-chat--eyes .floating-chat__pupil {
    -webkit-transition: -webkit-transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    -o-transition: -o-transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    transition: -webkit-transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
      -webkit-transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .floating-chat,
  .floating-chat__hint,
  .floating-chat__fab,
  .floating-chat__hint-text,
  .floating-chat__swirl,
  .floating-chat__eyes {
    -webkit-transition: none;
    transition: none;
  }

  .floating-chat__swirl--wobble-anim {
    -webkit-animation: none !important;
    animation: none !important;
  }

  [data-floating-chat].floating-chat--eyes-post-modal .floating-chat__eyes,
  .floating-chat.floating-chat--eyes-post-modal.floating-chat--eyes .floating-chat__eyes {
    -webkit-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }

  .floating-chat__pupil {
    -webkit-transition: none;
    transition: none;
  }
}

/* Плавающий виджет: скрываем, пока открыт чат (клон переноса кнопки) */
body:has(.popup.chat-widget-modal.active) [data-floating-chat] {
  visibility: hidden;
  pointer-events: none;
}

/*
 * FLIP (морф): снимаем transition только с панели — корень .popup тогда плавно анимирует
 * opacity при открытии. Раньше отключались и корень, и !important — CSS-вход 0→1 визуально не был.
 */
body.chat-morph--panel-instant .popup.chat-widget-modal .popup-container {
  -webkit-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
}

/*
 * Mobile FLIP needs the final send-button coordinates before the sheet is shown.
 * Keep the dialog in layout for measurement, but invisible to the user.
 */
.popup.chat-widget-modal.chat-widget-modal--measure {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  -webkit-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
}

.popup.chat-widget-modal.chat-widget-modal--measure .popup-container {
  -webkit-transform: translate(0, 0) translateZ(0) !important;
  -ms-transform: translate(0, 0) translateZ(0) !important;
  transform: translate(0, 0) translateZ(0) !important;
  -webkit-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
}

/*
 * Без мгновенного скрытия при закрытии: у .popup transition ~300ms (base.css) на opacity.
 * Если снять .active, родитель ещё 1+ кадр полупрозрачный, а chat-morph--closing уже снят —
 * у .chat-widget__panel пропадает opacity:0 !important, белая панель «вспыхивает».
 */
body.chat-morph--close-instant .popup.chat-widget-modal,
body.chat-morph--close-instant .popup.chat-widget-modal .popup-container {
  -webkit-transition: none !important;
  -o-transition: none !important;
  transition: none !important;
}

/* Во время закрытия: призрак сверху; слой + панель плавно (перекрывает .active). */
.popup.chat-widget-modal.active.chat-morph--closing {
  pointer-events: none;
  background: transparent;
  -webkit-transform: none;
  -ms-transform: none;
  transform: none;
  opacity: 0;
  -webkit-transition: opacity 0.52s cubic-bezier(0.4, 0, 0.2, 1);
  -o-transition: opacity 0.52s cubic-bezier(0.4, 0, 0.2, 1);
  transition: opacity 0.52s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup.chat-widget-modal.active.chat-morph--closing .popup-container {
  -webkit-transform: translate(0, 28px) translateZ(0);
  -ms-transform: translate(0, 28px) translateZ(0);
  transform: translate(0, 28px) translateZ(0);
  -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.48s cubic-bezier(0.4, 0, 0.2, 1);
  -o-transition: -o-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.48s cubic-bezier(0.4, 0, 0.2, 1);
  transition: -webkit-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.48s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Реальная панель не дублируем !important-скрытием — визуал задаёт opacity корня. */
.chat-morph--closing .chat-widget__panel,
.chat-morph--closing .chat-widget__error,
.chat-morph--closing .chat-widget__bar {
  pointer-events: none;
}

/* Настоящая кнопка send скрыта, пока ведёт клон (FLIP) */
.chat-widget__send--morph-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.chat-morph-ghost {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20000;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.chat-morph-ghost__surface {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: fixed;
  left: 0;
  top: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  background: #4f5a81;
  -webkit-box-shadow: 0 9px 24px 0 rgba(0, 0, 0, 0.12);
  box-shadow: 0 9px 24px 0 rgba(0, 0, 0, 0.12);
  overflow: hidden;
  will-change: left, top, width, height, border-radius, transform;
  -ms-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.chat-morph-ghost__from,
.chat-morph-ghost__to {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  position: absolute;
  inset: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  pointer-events: none;
  border-radius: inherit;
}

.chat-morph-ghost__to img {
  display: block;
  max-width: 20px;
  max-height: 20px;
  width: auto;
  height: auto;
  -o-object-fit: contain;
  object-fit: contain;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .chat-morph-ghost,
  .chat-morph-ghost__surface {
    -webkit-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }
}

/*
 * Модалка чата: плавное появление/исчезновение (opacity у слоя, transform у панели).
 * base.css .popup { transition: var(--quad) } слишком краток — переопределяем здесь.
 * Морфинг: chat-morph--panel-instant только на .popup-container; close-instant — краткое
 * снятие анимации на кадр закрытия (см. комментарий у close-instant).
 */
.popup.chat-widget-modal {
  /* base .popup: только opacity; visibility смена не анимируется, без задержки show */
  -webkit-transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1);
  -o-transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1);
  transition: opacity 0.48s cubic-bezier(0.22, 1, 0.36, 1);
  top: auto;
  bottom: 24px;
  left: auto;
  right: 24px;
  width: auto;
  max-width: 100%;
  height: auto;
  background-color: transparent;
  overflow-y: visible;
  overflow-x: hidden;
  z-index: 121;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  box-sizing: border-box;
  /* Блокирует «прокрутку-цепочку» на body при достижении края панели */
  overscroll-behavior: contain;
}

/* Немного быстрее/острее исчезновение (при :not(.active) специфичнее) */
.popup.chat-widget-modal:not(.active) {
  -webkit-transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  -o-transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup.chat-widget-modal .popup-container {
  -webkit-transform: translate(0, 20px) translateZ(0);
  -ms-transform: translate(0, 20px) translateZ(0);
  transform: translate(0, 20px) translateZ(0);
  -webkit-transition: -webkit-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  -o-transition: -o-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  transition: -webkit-transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0.96;
}

.popup.chat-widget-modal.active .popup-container {
  -webkit-transform: translate(0, 0) translateZ(0);
  -ms-transform: translate(0, 0) translateZ(0);
  transform: translate(0, 0) translateZ(0);
  opacity: 1;
}

/*
 * base.css: body:has(.popup.active) { overflow: hidden } — панель чата не на весь экран,
 * нужна прокрутка фона, когда курсор/колёсико вне .chat-widget__panel.
 * Переопределяет только сценарий supportchat.
 * «Прыжок» скролла с ленты на страницу гасим: overscroll-behavior на зоне сообщений.
 */
body:has(.popup.chat-widget-modal.active) {
  overflow: auto;
}

.chat-widget__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 48px;
  width: 500px;
  min-width: 0;
  max-width: 100%;
  height: min(640px, calc(100vh - 96px));
  min-height: 520px;
  max-height: calc(100vh - 96px);
  background: #ffffff;
  border: 1px solid #4f5a81;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
  font-family: "Onest", sans-serif;
  overflow: hidden;
  box-sizing: border-box;
}

.chat-widget__handle {
  display: none;
}

/* Оболочка: flex-якорь в панели, подсказки-градиенты — поверх списка */
.chat-widget__messages-outer {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  -ms-overscroll-behavior: contain;
  overscroll-behavior: contain;
}

/* Нативная полоса прокрутки не показываем; прокрутка колёсом/касанием/клавишами сохраняется */
.chat-widget__messages {
  display: flex;
  flex-direction: column;
  gap: 32px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 260px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Не уводит скролл на страницу после дна/потолка ленты */
  overscroll-behavior: contain;
  padding-inline-end: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chat-widget__messages::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Лёгкий градиент: «есть ещё сообщения выше / ниже» */
.chat-widget__edge-hint {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity 0.22s ease, visibility 0.22s ease;
  -o-transition: opacity 0.22s ease, visibility 0.22s ease;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.chat-widget__edge-hint--show {
  opacity: 1;
  visibility: visible;
}

.chat-widget__edge-hint--top {
  top: 0;
  background: -webkit-linear-gradient(top, rgba(79, 90, 129, 0.09) 0%, rgba(255, 255, 255, 0) 100%);
  background: linear-gradient(180deg, rgba(79, 90, 129, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
}

.chat-widget__edge-hint--bottom {
  bottom: 0;
  background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(79, 90, 129, 0.08) 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(79, 90, 129, 0.1) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget__edge-hint {
    -webkit-transition: none;
    -o-transition: none;
    transition: none;
  }
}

.chat-widget__scroll-anchor {
  flex-shrink: 0;
  height: 0;
}

.chat-sep {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  box-sizing: border-box;
}

.chat-sep__label {
  display: block;
  max-width: 100%;
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 18px;
  letter-spacing: 0.13px;
  color: #9ca3af;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.chat-sep__line {
  display: block;
  width: 100%;
  height: 0.5px;
  background: #9ca3af;
  border-radius: 2px;
}

.chat-entry {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: visible;
}

.chat-entry--agent {
  align-items: flex-start;
  gap: 8px;
}

.chat-entry--user {
  align-items: flex-start;
}

.chat-entry__sender {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

.chat-entry__dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6e8b6b;
  flex-shrink: 0;
}

.chat-entry__name {
  font-family: "Onest", sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.28px;
  color: rgba(20, 22, 21, 0.4);
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-entry__row {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.chat-entry--agent .chat-entry__row,
.chat-entry--user .chat-entry__row {
  flex-direction: row;
}

.chat-time {
  /* HH:MM не должен обрезаться: без фикс. max-width/overflow, только запас по ширине */
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 18px;
  letter-spacing: 0.13px;
  color: #9ca3af;
  white-space: nowrap;
  flex: 0 0 auto;
  width: auto;
  min-width: 5.5ch;
  text-align: right;
  margin: 0;
  box-sizing: border-box;
  overflow: visible;
}

.chat-entry--user .chat-time {
  text-align: left;
}

.chat-bubble {
  flex: 1;
  min-width: 0;
  padding: 16px;
  border: 1px solid #9ca3af;
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: #1f2937;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble--agent {
  background: #ffffff;
  border-radius: 16px 16px 16px 0;
}

.chat-bubble--user {
  background: transparent;
  border-radius: 16px 16px 0 16px;
}

.chat-bubble__text {
  width: 100%;
  font-family: inherit;
  font-weight: 400;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
  align-self: flex-start;
}

/* Оценка качества обслуживания (оператор + AI), Figma node 82:2731 */
.chat-entry--service-rating {
  gap: 0;
}

.chat-entry__row--service-rating {
  width: 100%;
  min-width: 0;
}

.chat-service-rating {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 385px;
  min-height: 124px;
  padding: 16px 15px 17px;
  background: #ffffff;
  border: 1px solid #9ca3af;
  border-radius: 16px 16px 16px 0;
}

.chat-service-rating__text {
  margin: 0;
  width: 100%;
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 14px;
  line-height: 20px;
  color: #1f2937;
}

.chat-service-rating--done {
  gap: 32px;
  justify-content: center;
}

.chat-service-rating--done .chat-service-rating__text {
  text-align: left;
}

.chat-service-rating__row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 32px;
  min-height: 40px;
  width: 100%;
}

.chat-service-rating__opt {
  box-sizing: border-box;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.chat-service-rating__opt:focus {
  outline: none;
}

.chat-service-rating__opt:focus-visible {
  outline: 2px solid #4f5a81;
  outline-offset: 2px;
}

.chat-service-rating__face {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  pointer-events: none;
  transition: width 0.2s ease, height 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  .chat-service-rating__opt,
  .chat-service-rating__face {
    transition: none;
  }
}

.chat-service-rating__opt:hover:not(:disabled) .chat-service-rating__face {
  width: 40px;
  height: 40px;
}

.chat-service-rating--done .chat-service-rating__row {
  justify-content: center;
  align-items: center;
  min-height: 40px;
}

.chat-service-rating--done .chat-service-rating__opt:not(.chat-service-rating__opt--selected) {
  display: none;
}

.chat-service-rating--done .chat-service-rating__opt--selected {
  cursor: default;
  transform: none;
}

.chat-service-rating--done .chat-service-rating__opt--selected .chat-service-rating__face {
  width: 40px;
  height: 40px;
}

.chat-service-rating--done .chat-service-rating__opt--selected:hover .chat-service-rating__face {
  width: 40px;
  height: 40px;
}

.chat-files {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  flex-shrink: 0;
}

.chat-file {
  width: 64px;
  height: 64px;
  background: #f7f8fa;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-file__img {
  width: 32px;
  height: 32px;
  display: block;
  flex-shrink: 0;
}

.chat-widget__bar {
  display: flex;
  align-items: center;
  height: 56px;
  background: #ffffff;
  border: 1px solid #4f5a81;
  border-radius: 30px;
  padding: 4px 4px 4px 24px;
  flex-shrink: 0;
  gap: 0;
}

.chat-widget__input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 18px;
  letter-spacing: 0.13px;
  color: #1f2937;
  outline: none;
  padding: 0;
  border-radius: 0;
  cursor: text;
}

.chat-widget__input::placeholder {
  color: #9ca3af;
  opacity: 1;
}

.chat-widget__send {
  flex-shrink: 0;
  width: auto;
  height: 100%;
  aspect-ratio: 1;
  background: #4f5a81;
  border: none;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-widget__send:hover {
  background-color: #65719c;
}

.chat-widget__send:active {
  background-color: #263361;
}

.chat-widget__send:focus-visible {
  outline: 2px solid #4f5a81;
  outline-offset: 2px;
}

.chat-widget__send:disabled {
  cursor: not-allowed;
  background-color: #9ca3af;
}

.chat-widget__send-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  pointer-events: none;
}

.chat-widget__error {
  margin: 8px 0 0;
  min-height: 18px;
  font-family: "Onest", sans-serif;
  font-size: 12px;
  line-height: 18px;
  color: #b4234a;
}

@media (min-width: 769px) and (max-width: 1023px) {
  .popup.chat-widget-modal {
    bottom: 16px;
    right: 16px;
  }

  .chat-widget__panel {
    width: 450px;
    height: min(600px, calc(100vh - 80px));
    min-height: 500px;
    gap: 48px;
    padding: 32px;
  }

  .chat-sep__label,
  .chat-time {
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.12px;
  }

  .chat-entry__name {
    font-size: 13px;
    line-height: 18px;
    letter-spacing: 0.26px;
  }

  .chat-entry__dot {
    width: 9px;
    height: 9px;
  }

  .chat-bubble {
    font-size: 13px;
    line-height: 18px;
  }

  .chat-bubble__text {
    font-size: 13px;
    line-height: 18px;
  }

  .chat-file {
    width: 60px;
    height: 60px;
  }

  .chat-file__img {
    width: 28px;
    height: 28px;
  }

  .chat-service-rating {
    max-width: 100%;
    min-height: 118px;
    padding: 14px 14px 15px;
    gap: 20px;
  }

  .chat-service-rating__text {
    font-size: 13px;
    line-height: 18px;
  }

  .chat-service-rating__row {
    gap: 28px;
  }

  .chat-service-rating__opt {
    width: 36px;
    height: 36px;
  }

  .chat-service-rating__face {
    width: 28px;
    height: 28px;
  }

  .chat-service-rating__opt:hover:not(:disabled) .chat-service-rating__face {
    width: 35px;
    height: 35px;
  }

  .chat-service-rating--done .chat-service-rating__opt--selected .chat-service-rating__face,
  .chat-service-rating--done .chat-service-rating__opt--selected:hover .chat-service-rating__face {
    width: 35px;
    height: 35px;
  }

  .chat-widget__bar {
    height: 52px;
  }

  .chat-widget__input {
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.12px;
  }

  .chat-widget__send {
    padding: 14px;
  }
}

@media (max-width: 768px) {
  .floating-chat {
    right: 1.6rem;
    bottom: 1.6rem;
    width: 70px;
    height: 70px;
  }

  .floating-chat:hover,
  .floating-chat:focus-within {
    width: 70px;
    -webkit-transform: none;
    -ms-transform: none;
    transform: none;
  }

  .floating-chat__btn {
    height: 70px;
  }

  .floating-chat__fab {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 70px;
    flex: 0 0 70px;
    width: 70px;
    min-width: 70px;
    height: 70px;
  }

  .floating-chat__swirl {
    width: 86%;
    height: 86%;
  }

  .floating-chat__hint {
    display: none;
  }

  .popup.chat-widget-modal {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(101, 113, 156, 0.6);
    overflow: hidden;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    -webkit-transition: opacity 0.68s cubic-bezier(0.22, 1, 0.36, 1);
    -o-transition: opacity 0.68s cubic-bezier(0.22, 1, 0.36, 1);
    transition: opacity 0.68s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .popup.chat-widget-modal:not(.active) {
    -webkit-transition: opacity 0.58s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: opacity 0.58s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.58s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .popup.chat-widget-modal .popup-container {
    -webkit-transform: translate3d(0, 104%, 0);
    transform: translate3d(0, 104%, 0);
    -webkit-transition: -webkit-transform 0.74s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.48s ease-out;
    -o-transition: -o-transform 0.74s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.48s ease-out;
    transition: -webkit-transform 0.74s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.74s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.48s ease-out;
    opacity: 1;
    will-change: transform;
  }

  .popup.chat-widget-modal.active .popup-container {
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }

  .popup.chat-widget-modal.active.chat-widget-modal--mobile-preenter {
    opacity: 0;
    -webkit-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }

  .popup.chat-widget-modal.active.chat-widget-modal--mobile-leave {
    pointer-events: none;
    opacity: 0;
    -webkit-transition: opacity 0.68s cubic-bezier(0.4, 0, 0.2, 1);
    -o-transition: opacity 0.68s cubic-bezier(0.4, 0, 0.2, 1);
    transition: opacity 0.68s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .popup.chat-widget-modal.active.chat-widget-modal--mobile-preenter .popup-container,
  .popup.chat-widget-modal.active.chat-widget-modal--mobile-leave .popup-container {
    -webkit-transform: translate3d(0, 104%, 0);
    transform: translate3d(0, 104%, 0);
  }

  .popup.chat-widget-modal.chat-widget-modal--dragging {
    -webkit-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }

  .popup.chat-widget-modal.chat-widget-modal--dragging .popup-container {
    -webkit-transform: translate3d(0, var(--chat-sheet-drag-y, 0px), 0) !important;
    transform: translate3d(0, var(--chat-sheet-drag-y, 0px), 0) !important;
    -webkit-transition: none !important;
    -o-transition: none !important;
    transition: none !important;
  }

  .chat-widget__panel {
    width: 100%;
    max-width: 100%;
    height: 92vh;
    min-height: 420px;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    border: none;
    gap: 32px;
    padding: 20px 24px 24px;
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12);
  }

  .chat-widget__messages {
    min-height: 180px;
  }

  .chat-widget__handle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: -6px 0 4px;
    padding: 10px 0 8px;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  .popup.chat-widget-modal.chat-widget-modal--dragging .chat-widget__handle {
    cursor: grabbing;
  }

  .chat-widget__handle::before {
    content: "";
    display: block;
    width: 75px;
    height: 2px;
    background: #9ca3af;
    border-radius: 2px;
  }

  .chat-sep__label,
  .chat-time {
    font-size: 11px;
    line-height: 14px;
    letter-spacing: 0.11px;
  }

  .chat-entry__name {
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.24px;
  }

  .chat-entry__dot {
    width: 9px;
    height: 9px;
  }

  .chat-bubble {
    font-size: 12px;
    line-height: 16px;
  }

  .chat-bubble__text {
    font-size: 12px;
    line-height: 16px;
  }

  .chat-file {
    width: 56px;
    height: 56px;
  }

  .chat-file__img {
    width: 28px;
    height: 28px;
  }

  .chat-service-rating {
    max-width: 100%;
    min-height: 112px;
    padding: 12px 12px 14px;
    gap: 18px;
  }

  .chat-service-rating--done {
    gap: 24px;
  }

  .chat-service-rating__text {
    font-size: 12px;
    line-height: 16px;
  }

  .chat-service-rating__row {
    gap: 24px;
    min-height: 36px;
  }

  .chat-service-rating__opt {
    width: 32px;
    height: 32px;
  }

  .chat-service-rating__face {
    width: 24px;
    height: 24px;
  }

  .chat-service-rating__opt:hover:not(:disabled) .chat-service-rating__face {
    width: 30px;
    height: 30px;
  }

  .chat-service-rating--done .chat-service-rating__opt--selected .chat-service-rating__face,
  .chat-service-rating--done .chat-service-rating__opt--selected:hover .chat-service-rating__face {
    width: 30px;
    height: 30px;
  }

  .chat-widget__bar {
    height: 48px;
    padding-left: 20px;
  }

  .chat-widget__input {
    font-size: 11px;
    line-height: 14px;
    letter-spacing: 0.11px;
  }

  .chat-widget__send {
    padding: 12px;
  }
}

/* Плавающая кнопка на телефонах (внутри max-width: 768px) */
@media (max-width: 600px) {
  .floating-chat {
    width: 65px;
    height: 65px;
  }

  .floating-chat:hover,
  .floating-chat:focus-within {
    width: 65px;
  }

  .floating-chat__btn {
    height: 65px;
  }

  .floating-chat__fab {
    -webkit-box-flex: 0;
    -ms-flex: 0 0 65px;
    flex: 0 0 65px;
    width: 65px;
    min-width: 65px;
    height: 65px;
  }
}

/* ===== Chat loading spinner ===== */
.chat-widget__loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.chat-widget__messages-outer[data-chat-loading] .chat-widget__loading {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.chat-widget__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(79, 90, 129, 0.2);
  border-top-color: #4F5A81;
  border-radius: 50%;
  -webkit-animation: chat-spin 0.75s linear infinite;
          animation: chat-spin 0.75s linear infinite;
}

@-webkit-keyframes chat-spin {
  to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
@keyframes chat-spin {
  to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}
