/* Live-чат витрины. Самодостаточный блок: свой префикс .rtc, ничего общего с
   остальной вёрсткой, чтобы виджет не конфликтовал ни с чем на странице. */
.rtc { position: fixed; right: 20px; bottom: 20px; z-index: 900; font: 15px/1.5 var(--font, -apple-system, Segoe UI, Roboto, Arial, sans-serif); }
.rtc *, .rtc *::before, .rtc *::after { box-sizing: border-box; }

.rtc__launcher {
  position: relative;
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, #19bde8 0%, #0a93b8 100%);
  box-shadow: 0 8px 24px rgba(10, 62, 78, .35); display: grid; place-items: center;
  transition: transform .15s, box-shadow .15s;
}
/* Ненавязчивый пульс раз в ~2.6 c — привлекает внимание, но не мельтешит как Jivo. */
.rtc__launcher::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(25, 189, 232, .45);
  animation: rtc-pulse 2.6s ease-out infinite;
}
/* Когда чат открыт — прячем кнопку целиком (появится снова при сворачивании). */
.rtc:has(.rtc__panel:not(.rtc__hidden)) .rtc__launcher { display: none; }
@keyframes rtc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(25, 189, 232, .45); }
  70%  { box-shadow: 0 0 0 14px rgba(25, 189, 232, 0); }
  100% { box-shadow: 0 0 0 0 rgba(25, 189, 232, 0); }
}
@media (prefers-reduced-motion: reduce) { .rtc__launcher::after { animation: none; } }
.rtc__launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 30px rgba(10, 62, 78, .45); }
.rtc__launcher svg { width: 27px; height: 27px; }
.rtc__badge {
  position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 6px;
  background: #ff7a2f; color: #fff; border-radius: 11px; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff;
}
.rtc__hint {
  position: absolute; right: 74px; bottom: 8px; background: #fff; color: #0f172a; padding: 10px 14px;
  border-radius: 14px 14px 2px 14px; box-shadow: 0 8px 24px rgba(15, 23, 42, .16); width: 230px;
  font-size: 14px; animation: rtc-pop .25s ease;
}
.rtc__hint-close { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: #0f172a; color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }

.rtc__panel {
  position: absolute; right: 0; bottom: 0; width: 370px; max-width: calc(100vw - 32px);
  height: 540px; max-height: calc(100vh - 40px); background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3); display: flex; flex-direction: column;
  animation: rtc-up .2s ease;
}
/* dvh учитывает адресную строку браузера, которая появляется и исчезает при
   прокрутке. С обычным vh окно чата на телефоне оказывалось выше экрана,
   и поле ввода уезжало под нижний край. */
@supports (height: 100dvh) {
  .rtc__panel { max-height: calc(100dvh - 40px); }
}
.rtc__head {
  background: linear-gradient(135deg, #0f5f74 0%, #0a93b8 60%, #19bde8 100%); color: #fff;
  padding: 16px 18px; display: flex; align-items: center; gap: 12px;
}
.rtc__avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; flex: none; }
.rtc__head-t { flex: 1; min-width: 0; }
.rtc__title { font-weight: 700; font-size: 16px; }
.rtc__status { font-size: 12px; opacity: .85; }
.rtc__x { background: transparent; border: 0; color: #fff; cursor: pointer; font-size: 24px; line-height: 1; opacity: .85; }
.rtc__x:hover { opacity: 1; }

.rtc__body { flex: 1; overflow-y: auto; padding: 16px; background: #f6f8fa; display: flex; flex-direction: column; gap: 10px; }
.rtc__intro { background: #fff; border-radius: 12px; padding: 12px 14px; color: #33445c; font-size: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.rtc__msg { max-width: 82%; padding: 9px 13px; border-radius: 14px; font-size: 14px; word-wrap: break-word; white-space: pre-wrap; }
.rtc__msg--in { align-self: flex-start; background: #fff; color: #0f172a; border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.rtc__msg--out { align-self: flex-end; background: #19bde8; color: #04222b; border-bottom-right-radius: 4px; }
.rtc__time { font-size: 11px; opacity: .6; margin-top: 3px; }

.rtc__contacts { display: grid; gap: 8px; padding: 0 16px 12px; background: #f6f8fa; }
.rtc__contacts input { width: 100%; padding: 9px 12px; border: 1px solid #e2e8ef; border-radius: 8px; font: inherit; }

.rtc__foot { padding: 12px; border-top: 1px solid #e2e8ef; display: flex; gap: 8px; align-items: flex-end; background: #fff; }
.rtc__input { flex: 1; resize: none; border: 1px solid #e2e8ef; border-radius: 10px; padding: 10px 12px;
  font: inherit; max-height: 110px; min-height: 42px; }
.rtc__input:focus { outline: 2px solid #19bde8; outline-offset: -1px; }
.rtc__send { flex: none; width: 42px; height: 42px; border: 0; border-radius: 10px; cursor: pointer;
  background: #19bde8; color: #04222b; display: grid; place-items: center; }
.rtc__send:hover { background: #0a93b8; color: #fff; }
.rtc__send:disabled { opacity: .5; cursor: default; }
.rtc__hidden { display: none !important; }
.rtc__powered { text-align: center; font-size: 11px; color: #9aa7b5; padding: 6px; background: #fff; }

@keyframes rtc-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rtc-pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 700px) {
  /* Кнопку и панель держим над «домашней полоской» айфонов. */
  .rtc { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .rtc__hint { display: none; }

  /* На телефоне чат раскрывается во весь экран. Раньше панель считалась от
     угла кнопки (absolute + calc от 100vh) и выходила за границы экрана —
     обрезался и заголовок, и поле ввода. Фиксированные отступы от всех
     четырёх краёв такого не допускают в принципе. */
  .rtc__panel {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    width: auto; max-width: none; height: auto; max-height: none;
  }
  .rtc__head { padding: 12px 14px; }
  .rtc__avatar { width: 34px; height: 34px; }
  .rtc__body { padding: 12px; }
  .rtc__msg { max-width: 88%; }
  /* Меньше 16px в поле ввода — iOS увеличивает страницу при фокусе. */
  .rtc__input { font-size: 16px; }
  .rtc__contacts input { font-size: 16px; }
}
