/* Плавающий виджет поддержки: механика и размеры sara.fun, цвета бренда через --accent* */
.sw {
  --sw-ease: cubic-bezier(.2, .7, .2, 1);
  --sw-lift: 0px;
  --sw-gutter: 0px;
  font-family: 'Manrope', system-ui, sans-serif;
}

/* Кнопка */
.sw-fab {
  position: fixed;
  right: calc(24px + var(--sw-gutter));
  bottom: calc(24px + var(--sw-lift));
  z-index: 45;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 26px rgba(var(--accent-rgb), .35);
  cursor: pointer;
  opacity: 0;
  transition: background .15s var(--sw-ease), translate .15s var(--sw-ease), scale .15s var(--sw-ease);
  -webkit-tap-highlight-color: transparent;
}
.sw-fab.is-in { opacity: 1; animation: sw-enter .5s cubic-bezier(.34, 1.56, .64, 1) backwards; }
.sw-fab:hover { background: var(--accent-hover); }
.sw-fab:active { scale: .97; }
.sw-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw-fab.is-wiggle { animation: sw-wiggle .6s ease-in-out; }
.sw-fab::before,
.sw-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}
.sw-fab.is-pulse::before { animation: sw-pulse 1.6s ease-out; }
.sw-fab.is-pulse::after { animation: sw-pulse 1.6s ease-out .45s; }

@media (hover: hover) and (pointer: fine) {
  .sw-fab.is-ready:hover { translate: 0 -3px; scale: 1.08; }
  .sw-fab.is-ready[aria-expanded="false"]:hover .sw-fab__chat { animation: sw-icon-wiggle .6s ease-in-out; }
}

.sw-fab__chat,
.sw-fab__x {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity .2s var(--sw-ease), rotate .2s var(--sw-ease);
}
.sw-fab__x { opacity: 0; rotate: -90deg; }
.sw-fab[aria-expanded="true"] .sw-fab__chat { opacity: 0; rotate: 90deg; }
.sw-fab[aria-expanded="true"] .sw-fab__x { opacity: 1; rotate: 0deg; }

.sw-fab__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}
.sw-fab__badge[hidden] { display: none; }
.sw-fab__badge.is-bump { animation: sw-bump .3s var(--sw-ease); }

@keyframes sw-enter {
  from { opacity: 0; translate: 0 20px; scale: .6; }
  60% { opacity: 1; }
}
@keyframes sw-wiggle {
  20% { rotate: -8deg; }
  40% { rotate: 8deg; }
  60% { rotate: -6deg; }
  80% { rotate: 4deg; }
}
@keyframes sw-icon-wiggle {
  25% { rotate: -10deg; }
  50% { rotate: 8deg; }
  75% { rotate: -4deg; }
}
@keyframes sw-pulse {
  from { opacity: .45; scale: 1; }
  to { opacity: 0; scale: 1.6; }
}
@keyframes sw-bump {
  50% { scale: 1.25; }
}
@keyframes sw-spin {
  to { rotate: 360deg; }
}

/* Подсказка */
.sw-hint {
  position: fixed;
  right: calc(24px + var(--sw-gutter));
  bottom: calc(92px + var(--sw-lift));
  z-index: 44;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--divider);
  border-radius: 14px;
  background: var(--bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
  opacity: 0;
  translate: 0 8px;
  transition: opacity .22s var(--sw-ease), translate .22s var(--sw-ease);
}
.sw-hint[hidden] { display: none; }
.sw-hint.is-in { opacity: 1; translate: none; }
.sw-hint__text {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}
.sw-hint__x {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.sw-hint__x:hover { color: var(--text); }

/* Слой и окно */
.sw-layer {
  position: fixed;
  inset: 0;
  z-index: 9500;
  opacity: 0;
  transition: opacity .22s var(--sw-ease);
}
.sw-layer[hidden] { display: none; }
.sw-layer[data-state="open"] { opacity: 1; }

.sw-panel {
  position: absolute;
  right: calc(24px + var(--sw-gutter));
  bottom: calc(92px + var(--sw-lift));
  width: 380px;
  max-height: calc(100dvh - 116px - var(--sw-lift));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .3);
  outline: none;
  translate: 0 16px;
  scale: .98;
  transition: translate .28s var(--sw-ease), scale .28s var(--sw-ease);
}
.sw-layer[data-state="open"] .sw-panel { translate: none; scale: none; }
.sw-panel.is-chat { height: min(560px, calc(100dvh - 116px - var(--sw-lift))); }

@media (min-width: 768px) {
  .sw-fab[aria-expanded="true"] { z-index: 9501; }
}

.sw-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  border-bottom: 1px solid var(--divider);
}
.sw-head__ava {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}
.sw-head__title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--text);
}
.sw-head__x {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
}
.sw-head__x:hover { color: var(--text); }
.sw-head__x:focus-visible,
.sw-hint__x:focus-visible,
.sw-hint__text:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sw-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sw-body.is-loading {
  min-height: 220px;
  align-items: center;
  justify-content: center;
}
.sw-body.is-loading::before {
  content: '';
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: sw-spin .8s linear infinite;
}

/* Чат */
.sw-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sw-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}
.sw-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.sw-msg--mine { align-items: flex-end; }
.sw-bubble {
  max-width: 80%;
  padding: 10px 13px;
  border: 1px solid var(--divider);
  border-radius: 16px 16px 16px 4px;
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.sw-msg--mine .sw-bubble {
  border-color: var(--accent);
  border-radius: 16px 16px 4px 16px;
  background: var(--accent);
  color: #fff;
}
.sw-bubble__img {
  display: block;
  margin-top: 6px;
  max-width: 100%;
  max-height: 220px;
  border-radius: 10px;
}
.sw-bubble__img:first-child { margin-top: 0; }
.sw-msg__time { font-size: 11px; color: var(--text-dim); }
.sw-empty {
  margin: auto 0;
  padding: 0 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  text-align: center;
}
.sw-note {
  align-self: center;
  max-width: 90%;
  padding: 8px 13px;
  border: 1px dashed rgba(var(--accent-rgb), .35);
  border-radius: 12px;
  background: rgba(var(--accent-rgb), .08);
  color: var(--accent);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
}

.sw-compose {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 16px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--chip-border);
  border-radius: 15px;
  background: var(--bg);
}
.sw-compose:focus-within { border-color: var(--accent); }
.sw-compose__input {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  padding: 8px 0;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  field-sizing: content;
}
.sw-compose__input::placeholder { color: var(--text-dim); }
.sw-send {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.sw-send:hover { background: var(--accent-hover); }
.sw-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sw-foot {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  padding: 8px 16px 12px;
}
.sw-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.sw-link:hover { color: var(--accent); }

.sw-error {
  margin: 6px 16px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: #DC4444;
}
.sw-error[hidden] { display: none; }
.sw-error--field { margin: 0; }
.sw-error--form {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(220, 68, 68, .08);
}

.sw .is-busy { pointer-events: none; color: transparent !important; }
.sw .is-busy::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 13px;
  height: 13px;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sw-spin .7s linear infinite;
}
.sw-send.is-busy svg { visibility: hidden; }

/* Форма гостя */
.sw-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 20px;
}
.sw-form__lead { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-muted); }
.sw-field { display: flex; flex-direction: column; gap: 7px; }
.sw-field__label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.sw-input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  box-sizing: border-box;
}
.sw-input:focus { border-color: var(--accent); }
textarea.sw-input {
  height: auto;
  min-height: 104px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}
.sw-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.sw-turnstile:empty { display: none; }
.sw-submit {
  position: relative;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.sw-submit:hover { background: var(--accent-hover); }
.sw-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Экран «отправлено» и ошибка загрузки */
.sw-sent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 22px;
  text-align: center;
}
.sw-sent__ico {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 138, 91, .12);
  color: #1F8A5B;
}
.sw-sent__title { font-size: 17px; font-weight: 800; color: var(--text); }
.sw-sent__text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-muted); overflow-wrap: anywhere; }
.sw-sent__btn {
  margin-top: 4px;
  padding: 9px 14px;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sw-sent__btn:hover { border-color: var(--accent); color: var(--accent); }

/* Телефон: лист снизу, клавиатура и safe-area */
@media (max-width: 767px) {
  .sw-fab { right: 16px; bottom: calc(16px + var(--sw-lift)); }
  .sw-hint {
    right: 82px;
    bottom: calc(24px + var(--sw-lift));
    max-width: calc(100vw - 98px);
  }
  .sw-layer {
    inset: auto 0 auto 0;
    top: var(--sw-vv-top, 0px);
    height: var(--sw-vv-h, 100%);
    background: rgba(16, 14, 12, .45);
  }
  .sw-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: min(88dvh, var(--sw-vv-h, 100dvh));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .2);
    translate: 0 100%;
    scale: none;
  }
  .sw-panel.is-chat { height: min(88dvh, var(--sw-vv-h, 100dvh)); }
  .sw-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .sw-form { padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  .sw-layer.is-kb .sw-foot { padding-bottom: 12px; }
  .sw-layer.is-kb .sw-form { padding-bottom: 18px; }
  .sw-compose__input,
  .sw-input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-fab,
  .sw-fab::before,
  .sw-fab::after,
  .sw-fab__chat,
  .sw-fab__x,
  .sw-fab__badge,
  .sw-hint,
  .sw-layer,
  .sw-panel {
    animation: none !important;
    transition-duration: 0s !important;
  }
}
