.sac-chat {
  --sac-accent: #111111;
  --sac-bg: #ffffff;
  --sac-bot: #f1f3f5;
  --sac-text: #1b1f23;
  max-width: 720px;
  margin: 1.5em auto;
  border: 1px solid #d8dee4;
  border-radius: 14px;
  background: var(--sac-bg);
  color: var(--sac-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

.sac-log {
  height: 440px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;      /* прокрутка не «протекает» на страницу под окном */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;               /* вертикальный свайп отдаём списку сообщений */
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sac-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

.sac-msg.sac-user {
  align-self: flex-end;
  align-items: flex-end;
}

.sac-msg.sac-bot {
  align-self: flex-start;
}

.sac-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.sac-user .sac-bubble {
  background: var(--sac-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sac-bot .sac-bubble {
  background: var(--sac-bot);
  border-bottom-left-radius: 4px;
}

.sac-pending .sac-bubble {
  opacity: 0.6;
  font-style: italic;
}

.sac-error .sac-bubble {
  background: #ffebe9;
  color: #82071e;
}

.sac-sources {
  margin-top: 6px;
  font-size: 12.5px;
}

.sac-sources-title {
  font-weight: 600;
}

.sac-sources ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.sac-sources a {
  color: var(--sac-accent);
  text-decoration: underline;
}

.sac-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #d8dee4;
  background: #fafbfc;
}

.sac-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  font-size: 16px;
}

.sac-input:focus {
  outline: 2px solid var(--sac-accent);
  outline-offset: -1px;
}

.sac-send {
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--sac-accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

.sac-send:disabled,
.sac-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.sac-langs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sac-lang {
  padding: 8px 14px;
  border: 1px solid var(--sac-accent);
  border-radius: 999px;
  background: #fff;
  color: var(--sac-accent);
  font-size: 13.5px;
  cursor: pointer;
}

.sac-lang:hover:not(:disabled),
.sac-lang-active {
  background: var(--sac-accent);
  color: #fff;
}

.sac-lang:disabled:not(.sac-lang-active) {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 480px) {
  .sac-log {
    height: 380px;
  }
  .sac-msg {
    max-width: 94%;
  }
}


/* Всплывающее окно: история должна прокручиваться внутри окна, а не растягивать его.
   Правила дублируют настройки в CSS всплывающего чата, чтобы работали и при старом/изменённом CSS из админки
   и не ломались стилями темы. */
.sac-float .sac-float-panel {
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.sac-float.sac-open .sac-float-panel {
  display: flex;
  max-height: 100vh;
  max-height: 100dvh;
}
.sac-float .sac-float-head {
  flex: 0 0 auto;
}
.sac-float .sac-chat {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.sac-float .sac-log {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sac-float .sac-form {
  flex: 0 0 auto;
}

.sac-bubble .sac-link {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

/* Кнопка «Начать новый диалог» */
.sac-reset {
  align-self: center;
  margin: 0 0 6px;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

.sac-reset:hover {
  color: var(--sac-accent);
}

/* Небольшая ссылка под полем ввода */
.sac-promo {
  flex: 0 0 auto;
  padding: 0 12px 10px;
  background: #fafbfc;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
}

.sac-promo-link {
  color: #8a909c;
  text-decoration: none;
  transition: color .15s;
}

.sac-promo-link::after {
  content: " \2197";
  font-size: .95em;
}

.sac-promo-link:hover,
.sac-promo-link:focus-visible {
  color: var(--sac-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sac-float .sac-promo {
  background: #fff;
  padding-bottom: 12px;
}

.sac-credit {
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: .01em;
  color: #b3b8c3;
}

.sac-credit a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
  transition: color .15s;
}

.sac-credit a:hover,
.sac-credit a:focus-visible {
  color: var(--sac-accent);
}


/* ===== Лапка котика: тянется к курсору и пытается его поймать (логика в chat.js, initPaw) =====
   Лежит внутри .sac-float-btn позади шара: «выглядывает» из-за него.
   Стили здесь (а не в CSS из админки), чтобы работали при любом сохранённом float_css. */
.sac-float-btn { z-index: 1; }

.sac-paw {
  --len: 10px;
  --curl: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

/* «рука» — пушистая: мягкий ореол по краю вместо чёткой границы */
.sac-paw-arm {
  position: absolute;
  left: 0;
  top: -10px;
  width: var(--len);
  height: 20px;
  border-radius: 10px;
  background: linear-gradient(to right, var(--sac-orb-core, #4f3df0) 0%, #7a6df5 45%, #b9b1fa 100%);
  box-shadow: 0 0 5px 2px rgba(143, 130, 250, .55);
}

/* ладошка */
.sac-paw-hand {
  position: absolute;
  left: var(--len);
  top: 0;
  width: 30px;
  height: 26px;
  margin: -13px 0 0 -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #f3f0ff 0%, #d9d3fc 62%, #b8aefa 100%);
  box-shadow:
    0 0 6px 2px rgba(143, 130, 250, .5),
    inset 0 -2px 4px rgba(111, 96, 243, .22);
}

/* пальчики с подушечками на передней кромке; при «хвате» (--curl) прижимаются к ладони */
.sac-toe {
  position: absolute;
  left: calc(21px - var(--curl) * 4px);
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f7f5ff, #d2cafc 80%);
  box-shadow: 0 0 4px 1px rgba(143, 130, 250, .5);
}
.sac-toe:nth-child(1) { top: 0; }
.sac-toe:nth-child(2) { top: 8.5px; left: calc(23px - var(--curl) * 4px); }
.sac-toe:nth-child(3) { top: 17px; }

/* розовая подушечка-«боб» */
.sac-pad {
  position: absolute;
  left: 7px;
  top: 8px;
  width: 11px;
  height: 10px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 40% 35%, #fbc4da, #f08db3);
  opacity: calc(1 - var(--curl) * .35);
}

@media (prefers-reduced-motion: reduce) {
  .sac-paw { display: none; }
}
