/* Виджет «Чат с продавцом» — канал website → CRM queue
   FAB + стек мессенджеров (референс: раскрывающееся меню каналов) */
.zp-site-chat-launcher {
  position: fixed;
  /* Отступ слева от правого края: бейдж unread выступает за FAB (~4px). */
  right: max(28px, calc(12px + env(safe-area-inset-right, 0px)));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 12040;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.zp-site-chat-launcher > * {
  pointer-events: auto;
}

.zp-site-chat-launcher__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.zp-site-chat-launcher__stack[hidden] {
  display: none !important;
}

.zp-site-chat-launcher__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 6px 16px rgba(36, 22, 74, 0.18);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: zp-site-chat-launcher-in 0.22s ease both;
}

.zp-site-chat-launcher__btn:nth-child(1) {
  animation-delay: 0.04s;
}
.zp-site-chat-launcher__btn:nth-child(2) {
  animation-delay: 0.07s;
}
.zp-site-chat-launcher__btn:nth-child(3) {
  animation-delay: 0.1s;
}
.zp-site-chat-launcher__btn:nth-child(4) {
  animation-delay: 0.13s;
}
.zp-site-chat-launcher__btn:nth-child(5) {
  animation-delay: 0.16s;
}

.zp-site-chat-launcher__btn:hover,
.zp-site-chat-launcher__btn:focus-visible {
  outline: none;
  transform: scale(1.06);
  box-shadow: 0 8px 20px rgba(36, 22, 74, 0.26);
}

.zp-site-chat-launcher__btn img {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
}

.zp-site-chat-launcher__btn--site img {
  box-shadow: 0 2px 8px rgba(100, 64, 191, 0.28);
}

@keyframes zp-site-chat-launcher-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.zp-site-chat-fab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #6440bf;
  color: #fff;
  box-shadow: 0 8px 24px rgba(36, 22, 74, 0.32);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

body.zp-site-chat-launcher-open .zp-site-chat-fab {
  background: #5535a8;
}

.zp-site-chat-fab__icon {
  width: 42px;
  height: 42px;
  display: block;
  flex-shrink: 0;
  background: center / 26px 26px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8.5 8.5 0 0 1-8.5 8.5H7l-4 3V12A8.5 8.5 0 1 1 21 12Z'/%3E%3C/svg%3E");
}

.zp-site-chat-fab:hover,
.zp-site-chat-fab:focus-visible {
  background: #5535a8;
  outline: none;
  transform: scale(1.04);
  box-shadow: 0 10px 28px rgba(36, 22, 74, 0.38);
}

.zp-site-chat-fab:active {
  transform: scale(0.98);
}

.zp-site-chat-fab__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
}

.zp-site-chat-fab__badge[hidden] {
  display: none !important;
}

/* Тост нового сообщения (закрытая панель чата) */
.zp-site-chat-toast {
  position: fixed;
  right: max(28px, calc(12px + env(safe-area-inset-right, 0px)));
  bottom: max(88px, calc(72px + env(safe-area-inset-bottom, 0px)));
  z-index: 12050;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: min(340px, calc(100vw - 40px));
  padding: 0;
  pointer-events: none;
  animation: zp-site-chat-toast-in 0.28s ease both;
}

.zp-site-chat-toast__card {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #1f1633;
  text-align: left;
  box-shadow: 0 12px 32px rgba(36, 22, 74, 0.22);
  cursor: pointer;
  font: inherit;
}

.zp-site-chat-toast__card:hover,
.zp-site-chat-toast__card:focus-visible {
  outline: none;
  box-shadow: 0 14px 36px rgba(36, 22, 74, 0.28);
}

.zp-site-chat-toast__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #6440bf
    center / 20px 20px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8.5 8.5 0 0 1-8.5 8.5H7l-4 3V12A8.5 8.5 0 1 1 21 12Z'/%3E%3C/svg%3E");
}

.zp-site-chat-toast__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.zp-site-chat-toast__title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.zp-site-chat-toast__text {
  font-size: 12px;
  line-height: 1.35;
  color: #5b5270;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.zp-site-chat-toast__close {
  pointer-events: auto;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(36, 22, 74, 0.08);
  color: #3b3350;
  cursor: pointer;
  position: relative;
}

.zp-site-chat-toast__close::before {
  content: "\00D7";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

@keyframes zp-site-chat-toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 575px) {
  .zp-site-chat-toast {
    right: max(16px, env(safe-area-inset-right, 0px));
    left: max(16px, env(safe-area-inset-left, 0px));
    bottom: max(96px, calc(80px + env(safe-area-inset-bottom, 0px)));
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zp-site-chat-toast {
    animation: none;
  }
}

body.zp-site-chat-open .zp-site-chat-toast {
  display: none !important;
}

.zp-site-chat-launcher__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
  pointer-events: none;
}

.zp-site-chat-launcher__badge[hidden] {
  display: none !important;
}

@keyframes zp-chat-fab-ping {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 8px 24px rgba(36, 22, 74, 0.32);
  }
  40% {
    transform: scale(1.1);
    box-shadow: 0 0 0 10px rgba(225, 29, 72, 0.22), 0 10px 28px rgba(36, 22, 74, 0.35);
  }
}

@keyframes zp-chat-badge-ping {
  0%,
  100% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.28);
  }
  70% {
    transform: scale(0.92);
  }
}

.zp-site-chat-fab.is-ping {
  animation: zp-chat-fab-ping 0.75s ease 2;
}

.zp-site-chat-fab__badge.is-ping,
.zp-site-chat-launcher__badge.is-ping {
  animation: zp-chat-badge-ping 0.55s ease 2;
}

.zp-site-chat-launcher__btn.is-ping {
  animation: zp-chat-fab-ping 0.75s ease 2;
}

@media (prefers-reduced-motion: reduce) {
  .zp-site-chat-fab.is-ping,
  .zp-site-chat-fab__badge.is-ping,
  .zp-site-chat-launcher__badge.is-ping,
  .zp-site-chat-launcher__btn.is-ping {
    animation: none;
  }
}

body.zp-site-chat-open .zp-site-chat-launcher {
  display: none;
}

.zp-site-chat-scrim {
  position: fixed;
  inset: 0;
  z-index: 12040;
  display: none;
  background: #17122f;
  pointer-events: none;
}

body.zp-site-chat-open .zp-site-chat-scrim:not([hidden]) {
  display: block;
}

/* Страница не скроллится под чатом — только лента сообщений */
html.zp-site-chat-scroll-lock,
body.zp-site-chat-scroll-lock {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
  height: 100%;
}

body.zp-site-chat-scroll-lock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

.zp-site-chat,
.zp-site-chat * {
  touch-action: manipulation;
}

.zp-site-chat__messages {
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.zp-site-chat__text {
  touch-action: auto;
}

/* Мобильное меню открыто — FAB не перекрывает иконки/соцсети в drawer */
body.menu-open .zp-site-chat-launcher {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.zp-site-chat {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 12050;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 24px));
  height: min(560px, calc(100dvh - 24px));
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(36, 22, 74, 0.28);
  font-family: var(--zp-font-ui, Nunito, sans-serif);
}

.zp-site-chat[hidden] {
  display: none !important;
}

.zp-site-chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  background: #6440bf;
  color: #fff;
}

.zp-site-chat__head-text {
  flex: 1;
  min-width: 0;
}

.zp-site-chat__title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.zp-site-chat__guest {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0.78;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zp-site-chat__guest[hidden] {
  display: none !important;
}

.zp-site-chat__close {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.zp-site-chat__close::before {
  content: "\00D7";
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
}

.zp-site-chat__meta {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #eeeef2;
  background: #faf9fc;
}

.zp-site-chat__meta input {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #e4e0ef;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
}

.zp-site-chat__messages {
  flex: 1 1 0%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  background: #f6f6f9;
}

.zp-site-chat__composer {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eeeef2;
  background: #fff;
}

.zp-site-chat__push-prompt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f3effc 0%, #ebe4ff 100%);
  border: 1px solid #d9cff5;
}

.zp-site-chat__push-prompt[hidden] {
  display: none !important;
}

.zp-site-chat__push-prompt-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.zp-site-chat__push-prompt-text strong {
  font-size: 13px;
  font-weight: 800;
  color: #3d2a7a;
  line-height: 1.25;
}

.zp-site-chat__push-prompt-text span {
  font-size: 12px;
  font-weight: 600;
  color: #5c5278;
  line-height: 1.35;
}

.zp-site-chat__push-prompt-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.zp-site-chat__push-enable {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #6440bf;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

.zp-site-chat__push-enable:disabled {
  opacity: 0.65;
  cursor: wait;
}

.zp-site-chat__push-dismiss {
  appearance: none;
  border: 0;
  background: transparent;
  color: #7a7196;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.zp-site-chat__push-dismiss:hover {
  background: rgba(100, 64, 191, 0.08);
  color: #3d2a7a;
}

.zp-site-chat__empty {
  margin: 24px 8px;
  color: #6b6580;
  font-size: 14px;
  text-align: center;
  line-height: 1.45;
}

.zp-site-chat__bubble {
  max-width: 88%;
  margin: 0 0 10px auto;
  padding: 10px 12px;
  border-radius: 16px 16px 4px 16px;
  background: #6440bf;
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.zp-site-chat__bubble--in {
  margin-left: 0;
  margin-right: auto;
  border-radius: 16px 16px 16px 4px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 1px 4px rgba(36, 22, 74, 0.08);
}

.zp-site-chat__bubble-time {
  display: block;
  margin-top: 6px;
  opacity: 0.72;
  font-size: 11px;
  font-weight: 600;
}

.zp-site-chat__media {
  margin: 8px 0 0;
}

.zp-site-chat__media--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.zp-site-chat__media--grid .zp-site-chat__att {
  margin-top: 0;
  min-width: 0;
}

.zp-site-chat__media:not(.zp-site-chat__media--grid) .zp-site-chat__att + .zp-site-chat__att {
  margin-top: 10px;
}

.zp-site-chat__media-link {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
}

.zp-site-chat__media-img {
  display: block;
  width: 100%;
  max-width: min(100%, 240px);
  max-height: 240px;
  height: auto;
  object-fit: cover;
  aspect-ratio: 1;
  background: rgba(0, 0, 0, 0.06);
}

.zp-site-chat__media:not(.zp-site-chat__media--grid) .zp-site-chat__media-img {
  max-width: min(100%, 240px);
  max-height: 240px;
  width: auto;
  aspect-ratio: auto;
  object-fit: contain;
}

.zp-site-chat__media-video {
  display: block;
  width: 100%;
  max-width: min(100%, 280px);
  max-height: 240px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.08);
}

.zp-site-chat__media--grid .zp-site-chat__media-video {
  max-width: none;
  width: 100%;
}

.zp-site-chat__att-meta,
.zp-site-chat__att-file,
.zp-site-chat__att-pdf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.zp-site-chat__att-pdf {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(100, 64, 191, 0.08);
  border: 1px solid rgba(100, 64, 191, 0.22);
}

.zp-site-chat__att-pdf-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.zp-site-chat__att-pdf-open {
  font-size: 13px;
  font-weight: 700;
  color: #6440bf;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.zp-site-chat__att-name {
  font-size: 13px;
  font-weight: 600;
  word-break: break-word;
}

.zp-site-chat__att-size {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.78;
  white-space: nowrap;
}

.zp-site-chat__download {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #6440bf;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.zp-site-chat__download:hover,
.zp-site-chat__download:focus-visible {
  background: #4c3191;
}

.zp-site-chat__files {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.zp-site-chat__forward {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-left: 3px solid rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.12);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
}

.zp-site-chat__phone-gate {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e4e0ef;
  border-radius: 14px;
  background: #faf9fc;
}

.zp-site-chat__phone-gate[hidden] {
  display: none !important;
}

.zp-site-chat__phone-gate-title {
  margin: 0;
  color: #1a1a1a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

.zp-site-chat__phone-gate-text {
  margin: 0;
  color: #5a5470;
  font-size: 13px;
  line-height: 1.4;
}

.zp-site-chat__phone-gate-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zp-site-chat__phone-prefix {
  flex-shrink: 0;
  color: #3d3558;
  font-size: 15px;
  font-weight: 700;
}

.zp-site-chat__phone-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #e4e0ef;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 15px;
}

.zp-site-chat__phone-submit {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: #6440bf;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.zp-site-chat__phone-submit[hidden] {
  display: none !important;
}

.zp-site-chat__phone-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.zp-site-chat__compose-main {
  display: grid;
  gap: 8px;
}

.zp-site-chat__compose-main[hidden] {
  display: none !important;
}

.zp-site-chat__captcha {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #e4e0ef;
  border-radius: 14px;
  background: #faf9fc;
}

.zp-site-chat__captcha[hidden] {
  display: none !important;
}

.zp-site-chat__captcha-label {
  margin: 0;
  color: #3d3558;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.zp-site-chat__captcha-box {
  width: 100%;
  min-height: 0;
}

.zp-site-chat__captcha-q {
  display: block;
  margin: 0 0 6px;
  color: #3d3558;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.zp-site-chat__captcha-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.zp-site-chat__captcha-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #ddd6ec;
  border-radius: 10px;
  background: #fff;
  color: #1a1228;
  font-size: 15px;
}

.zp-site-chat__captcha-refresh {
  flex: 0 0 auto;
  width: 40px;
  border: 1px solid #ddd6ec;
  border-radius: 10px;
  background: #fff;
  color: #4c3191;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.zp-site-chat__captcha-refresh:hover,
.zp-site-chat__captcha-refresh:focus-visible {
  background: #efeaf8;
  outline: none;
}

.zp-site-chat__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.zp-site-chat__text {
  flex: 1;
  box-sizing: border-box;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 12px;
  border: 1px solid #e4e0ef;
  border-radius: 14px;
  resize: none;
  overflow-y: auto;
  font: inherit;
  font-size: 16px; /* ≥16px — без автозума iOS при фокусе */
  line-height: 1.35;
  field-sizing: content;
}

.zp-site-chat__attach,
.zp-site-chat__send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

.zp-site-chat__attach {
  background: #f3effc;
  color: #6440bf;
  font-size: 20px;
  font-weight: 700;
}

.zp-site-chat__attach::before {
  content: "+";
}

.zp-site-chat__send {
  background: #6440bf;
  color: #fff;
}

.zp-site-chat__send::before {
  content: "\2191";
  font-size: 18px;
  font-weight: 800;
}

.zp-site-chat__send:disabled,
.zp-site-chat__attach:disabled {
  opacity: 0.45;
  cursor: default;
}

.zp-site-chat__pending {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.zp-site-chat__pending--grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.zp-site-chat__pending-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zp-site-chat__pending-item--file {
  grid-column: 1 / -1;
}

.zp-site-chat__pending-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #f3effc;
  aspect-ratio: 1;
  line-height: 0;
}

.zp-site-chat__pending-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.zp-site-chat__pending-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(26, 26, 26, 0.72);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.zp-site-chat__pending-remove::before {
  content: "\00D7";
  font-size: 16px;
  font-weight: 700;
}

.zp-site-chat__pending-size {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #5c5470;
  text-align: center;
}

.zp-site-chat__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3effc;
  color: #3b135c;
  font-size: 12px;
  font-weight: 600;
}

.zp-site-chat__chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.zp-site-chat__chip button::before {
  content: "\00D7";
}

.zp-site-chat__opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #5c5470;
}

.zp-site-chat__opts label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.zp-site-chat__status {
  min-height: 16px;
  margin: 0;
  color: #8b3a4a;
  font-size: 12px;
  font-weight: 600;
}

.zp-site-chat__status.is-ok {
  color: #2f6b45;
}

.zp-site-chat__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (max-width: 575px) {
  .zp-site-chat {
    right: 0;
    left: 0;
    top: var(--zp-chat-vv-top, 0px);
    bottom: auto;
    width: 100%;
    max-width: 100%;
    /* JS пишет --zp-chat-vv-h при клавиатуре; без неё — svh (не прыгает как dvh). */
    height: var(--zp-chat-vv-h, 100svh);
    max-height: var(--zp-chat-vv-h, 100svh);
    border-radius: 0;
    box-sizing: border-box;
  }

  .zp-site-chat__head {
    position: relative;
    top: auto;
    z-index: 5;
    flex-shrink: 0;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }

  .zp-site-chat__close {
    position: relative;
    z-index: 6;
    margin-left: auto;
  }

  .zp-site-chat__messages {
    flex: 1 1 0%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .zp-site-chat__composer {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .zp-site-chat.is-kb-open .zp-site-chat__composer {
    /* Keyboard already eats bottom inset — don't double-pad. */
    padding-bottom: 8px;
  }

  .zp-site-chat.is-kb-open .zp-site-chat__head {
    padding-top: 10px;
  }

  .zp-site-chat__row,
  .zp-site-chat__compose-main,
  .zp-site-chat__phone-gate,
  .zp-site-chat__captcha-box {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .zp-site-chat__text {
    min-width: 0;
    max-width: 100%;
  }

  .zp-site-chat-launcher {
    right: max(22px, calc(10px + env(safe-area-inset-right, 0px)));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  body.page-product-detail .zp-site-chat-launcher,
  body.zp-product-detail-page .zp-site-chat-launcher {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
}

/* PWA / tabbar phone widths: same fullscreen chat shell as ≤575 */
@media (max-width: 900px) {
  body.has-zp-tabbar .zp-site-chat,
  html.zp-standalone .zp-site-chat {
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    box-sizing: border-box;
  }
}

@media (display-mode: standalone) {
  body.zp-site-chat-open .zp-site-chat__composer,
  body.has-zp-tabbar .zp-site-chat__composer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .zp-site-chat.is-kb-open .zp-site-chat__composer {
    padding-bottom: 8px;
  }

  .zp-site-chat__phone-gate,
  .zp-site-chat__captcha-box {
    max-width: 100%;
    overflow: visible;
  }

  .zp-site-chat {
    width: 100%;
    max-width: 100%;
  }
}
