.lc { --lc-gap: 16px; --lc-offset: 0px; font-family: var(--font, inherit); }
.lc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.lc-fab {
  position: fixed;
  right: max(var(--lc-gap), env(safe-area-inset-right, 0px));
  bottom: calc(var(--lc-gap) + var(--lc-offset) + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 26px;
  background: var(--brand);
  color: #fff;
  font: 600 14px/1 var(--font, inherit);
  box-shadow: var(--sh-brand);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.lc-fab:hover { background: var(--brand-hover); transform: translateY(-1px); }
.lc-fab:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.lc-fab .hi { width: 22px; height: 22px; }
.lc-fab__badge {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger, #C92C2C);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}
.lc-fab__badge[hidden] { display: none; }
.lc.is-open .lc-fab { visibility: hidden; }

.lc-panel {
  position: fixed;
  right: max(var(--lc-gap), env(safe-area-inset-right, 0px));
  bottom: calc(var(--lc-gap) + var(--lc-offset) + env(safe-area-inset-bottom, 0px));
  z-index: 8000;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 2 * var(--lc-gap)));
  height: min(600px, calc(100vh - 96px));
  height: min(600px, calc(100dvh - 96px));
  min-width: 0;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--r-xl, 20px);
  box-shadow: 0 24px 60px rgba(11, 18, 32, 0.22);
  animation: lc-in .18s ease-out;
}
.lc-panel[hidden] { display: none; }
@keyframes lc-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.lc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 14px 16px;
  background: var(--brand);
  color: #fff;
}
.lc-head__text { display: grid; gap: 2px; min-width: 0; }
.lc-title { margin: 0; color: #fff; font-size: 16px; line-height: 1.3; font-weight: 700; letter-spacing: normal; }
.lc-sub { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: 12.5px; line-height: 1.4; }
.lc-topic { margin: 4px 0 0; color: #fff; font-size: 12.5px; line-height: 1.4; overflow-wrap: break-word; }
.lc-topic[hidden] { display: none; }
.lc-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  margin: -4px -6px 0 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.lc-close:hover { background: rgba(255, 255, 255, 0.16); }
.lc-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.lc-body { flex: 1 1 auto; min-height: 0; padding: 14px 16px; overflow-y: auto; overscroll-behavior: contain; background: var(--surface-alt, #F1F4F8); }
.lc-hello { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.lc-log { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lc-log[hidden] { display: none; }
.lc-msg { display: grid; gap: 3px; max-width: 86%; min-width: 0; }
.lc-msg__bubble {
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.lc-msg__meta { color: var(--text-secondary); font-size: 11.5px; line-height: 1.3; overflow-wrap: break-word; }
.lc-msg--visitor { align-self: flex-end; justify-items: end; }
.lc-msg--visitor .lc-msg__bubble { background: var(--brand); border-color: var(--brand); color: #fff; }
.lc-msg--system { align-self: center; justify-items: center; max-width: 100%; }
.lc-msg--system .lc-msg__bubble { background: transparent; border: 0; padding: 2px 4px; color: var(--text-secondary); font-size: 12.5px; text-align: center; }

.lc-form { display: grid; gap: 12px; min-width: 0; margin: 0; }
.lc-form[hidden] { display: none; }
.lc-lead { margin: 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; }
.lc-lead[hidden] { display: none; }
.lc-field { display: grid; gap: 5px; min-width: 0; }
.lc-field > label:not(.checkbox) { font-size: 13px; font-weight: 500; color: var(--text); }
.lc-field input[type=text], .lc-field textarea { width: 100%; min-width: 0; }
.lc-field textarea { min-height: 76px; resize: vertical; }
.lc-field.is-invalid input[type=text], .lc-field.is-invalid textarea { border-color: var(--danger); }
.lc-error { margin: 0; color: var(--danger); font-size: 12.5px; line-height: 1.4; overflow-wrap: break-word; }
.lc-error:empty { display: none; }
.lc-consent { display: flex; align-items: flex-start; font-size: 13px; line-height: 1.45; }
.lc-consent input[type=checkbox] { flex: none; margin-top: 1px; }
.lc-consent > span { min-width: 0; overflow-wrap: break-word; }

.lc-down { flex: none; display: grid; gap: 8px; padding: 12px 16px; background: var(--danger-soft, #FDECEA); border-top: 1px solid var(--border); }
.lc-down[hidden] { display: none; }
.lc-down__title { margin: 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.lc-down__text { margin: 0; color: var(--text); font-size: 13px; line-height: 1.45; overflow-wrap: break-word; }
.lc-down__retry { justify-self: start; }
.lc-note { flex: none; margin: 0; padding: 8px 16px; background: var(--danger-soft, #FDECEA); color: var(--danger); font-size: 13px; line-height: 1.4; overflow-wrap: break-word; }
.lc-note[hidden] { display: none; }

.lc-compose { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: var(--surface, #fff); border-top: 1px solid var(--border); margin: 0; min-width: 0; }
.lc-compose[hidden] { display: none; }
.lc-compose textarea { flex: 1 1 auto; width: auto; min-width: 0; min-height: 44px; max-height: 132px; resize: none; line-height: 1.4; }
.lc-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.lc-send:hover { background: var(--brand-hover); }
.lc-send:disabled { opacity: 0.55; cursor: default; }
.lc-send:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }

/* Кабинет: на узком экране снизу панель вкладок */
@media (max-width: 914px) {
  body:has(.cx-tabbar) .lc { --lc-offset: 64px; }
}

@media (max-width: 640px) {
  .lc-fab { width: 52px; min-height: 52px; padding: 0; justify-content: center; }
  .lc-fab__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lc-panel {
    left: 8px;
    right: 8px;
    top: calc(8px + env(safe-area-inset-top, 0px));
    bottom: auto;
    width: auto;
    height: calc(100vh - 16px - env(safe-area-inset-top, 0px));
    height: calc(100dvh - 16px - env(safe-area-inset-top, 0px));
    border-radius: 16px;
  }
  /* Иначе iOS приближает страницу при фокусе на поле */
  .lc-field input[type=text], .lc-field textarea, .lc-compose textarea { font-size: 16px; }
  html.lc-open, html.lc-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .lc-panel { animation: none; }
  .lc-fab { transition: none; }
  .lc-fab:hover { transform: none; }
}

/* Редактор: кнопки там не срабатывают, окно показывается в потоке страницы по переключателю «Скрытые тексты» */
.lc--edit .lc-panel { position: static; width: auto; max-width: min(400px, 100%); height: auto; margin: 16px auto; overflow: visible; animation: none; }
.lc--edit .lc-body { overflow: visible; }

@media print {
  .lc { display: none; }
}
