.ta-chat {
  --ta-chat-green: var(--green, #65715f);
  --ta-chat-green-dark: var(--green2, #4b5745);
  --ta-chat-paper: var(--paper, #fffefb);
  --ta-chat-soft: var(--soft, #fbf9f5);
  --ta-chat-text: var(--text, #2d2d2a);
  --ta-chat-muted: var(--muted, #746e65);
  --ta-chat-border: var(--border, #e6ded2);
  position: fixed;
  right: 22px;
  bottom: 92px;
  z-index: 320;
  color: var(--ta-chat-text);
  font-family: var(--sans, Manrope, Inter, sans-serif);
}

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

.ta-chat__fab {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--r-pill, 999px);
  color: #fff;
  background: var(--ta-chat-green);
  box-shadow: 0 14px 34px rgba(45, 45, 42, .2);
  font: 800 14px/1 var(--sans, Manrope, Inter, sans-serif);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.ta-chat__fab:hover {
  background: var(--ta-chat-green-dark);
  box-shadow: 0 17px 40px rgba(45, 45, 42, .24);
  transform: translateY(-1px);
}

.ta-chat__fab-icon,
.ta-chat__fab-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.ta-chat__fab-icon svg { fill: none; stroke: currentColor; stroke-width: 1.8; }

.ta-chat__panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  display: flex;
  width: min(430px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 150px));
  min-height: 520px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--ta-chat-border);
  border-radius: var(--r-card, 26px);
  background: var(--ta-chat-paper);
  box-shadow: var(--shadow, 0 22px 60px rgba(45, 45, 42, .1));
}

.ta-chat__header {
  display: flex;
  min-height: 82px;
  flex: 0 0 auto;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px 15px 26px;
  color: #fff;
  background: linear-gradient(145deg, var(--ta-chat-green), var(--ta-chat-green-dark));
}

.ta-chat__header-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ta-chat__header-brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.ta-chat__header strong { font-family: var(--serif, "Cormorant Garamond", serif); font-size: 28px; font-weight: 600; line-height: 1; }
.ta-chat__icon-button { display: grid; width: 42px; height: 42px; place-items: center; border: 0; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .08); font-size: 30px; font-weight: 300; line-height: 1; cursor: pointer; }
.ta-chat__icon-button:hover { background: rgba(255, 255, 255, .15); }

.ta-chat__stage {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--ta-chat-soft), #f4f0e9 100%);
}

.ta-chat__intro {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  padding: 34px 34px 28px;
}


.ta-chat__welcome {
  width: 100%;
  padding: 25px 30px;
  border: 1px solid rgba(230, 222, 210, .72);
  border-radius: var(--r-sm, 18px);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 20px rgba(45, 45, 42, .045);
}

.ta-chat__welcome p { margin: 0; color: var(--ta-chat-text); font-size: 16px; line-height: 1.55; }

.ta-chat__messages {
  display: grid;
  width: 100%;
  min-height: 0;
  align-content: start;
  gap: 11px;
  overflow-y: auto;
  padding: 22px;
}

.ta-chat__messages:empty { display: none; }
.ta-chat__message { display: grid; justify-self: start; max-width: 84%; padding: 10px 12px; border: 1px solid rgba(230, 222, 210, .72); border-radius: 16px 16px 16px 5px; background: #fff; box-shadow: 0 4px 14px rgba(45, 45, 42, .05); }
.ta-chat__message--customer { justify-self: end; border-color: transparent; border-radius: 16px 16px 5px; color: #fff; background: var(--ta-chat-green); }
.ta-chat__message span { font-size: 10px; font-weight: 800; opacity: .7; }
.ta-chat__message p { margin: 3px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.48; }
.ta-chat__message time { justify-self: end; font-size: 9px; opacity: .64; }

.ta-chat__message--waiting {
  justify-self: start;
  max-width: 84%;
  gap: 6px;
  padding: 11px 13px 12px;
  border: 1px solid rgba(230, 222, 210, .72);
  border-radius: 16px 16px 16px 5px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 4px 14px rgba(45, 45, 42, .05);
}

.ta-chat__message--waiting span {
  font-size: 10px;
  font-weight: 800;
  opacity: .72;
}

.ta-chat__message--waiting p {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.48;
}

.ta-chat__waiting-dots {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.ta-chat__waiting-dots i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ta-chat-green);
  opacity: .35;
  animation: ta-chat-wait 1.2s infinite ease-in-out;
}

.ta-chat__waiting-dots i:nth-child(2) { animation-delay: .15s; }
.ta-chat__waiting-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes ta-chat-wait {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: .35;
  }
  40% {
    transform: translateY(-3px);
    opacity: .95;
  }
}

.ta-chat__start,
.ta-chat__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  flex: 0 0 auto;
  align-items: end;
  padding: 15px 18px 17px;
  border-top: 1px solid var(--ta-chat-border);
  background: var(--ta-chat-paper);
}

.ta-chat__phone,
.ta-chat__profile-phone { grid-column: 1 / -1; }
.ta-chat__phone { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; color: var(--ta-chat-muted); font-size: 11px; font-weight: 800; }
.ta-chat__phone > span { align-self: end; }
.ta-chat__phone input { grid-column: 1 / -1; }
.ta-chat__phone small { grid-column: 1 / -1; font-weight: 600; opacity: .72; }
.ta-chat__phone small.is-error { color: var(--clay, #a85f4a); opacity: 1; }
.ta-chat__profile-phone { margin: 0; padding: 9px 11px; border-radius: 11px; color: var(--ta-chat-green-dark); background: var(--success-bg, #f4f6f1); font-size: 11px; font-weight: 700; }

.ta-chat__message-field { display: block; min-width: 0; }
.ta-chat input,
.ta-chat textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--ta-chat-border); border-radius: var(--r-btn, 14px); padding: 11px 13px; color: var(--ta-chat-text); background: #fff; font: 500 13px/1.45 var(--sans, Manrope, Inter, sans-serif); }
.ta-chat textarea { min-height: 48px; max-height: 110px; resize: none; }
.ta-chat input:focus,
.ta-chat textarea:focus { outline: none; border-color: var(--ta-chat-green); box-shadow: var(--focus-ring, 0 0 0 3px rgba(101, 113, 95, .16)); }
.ta-chat input::placeholder,
.ta-chat textarea::placeholder { color: #8b867f; opacity: 1; }

.ta-chat__send {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--ta-chat-green);
  cursor: pointer;
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}

.ta-chat__send:hover:not(:disabled) { background: var(--ta-chat-green-dark); transform: translateY(-1px); }
.ta-chat__send:disabled { cursor: not-allowed; opacity: .35; }
.ta-chat__send svg { width: 22px; height: 22px; fill: currentColor; }
.ta-chat__error { flex: 0 0 auto; padding: 0 18px 12px; color: var(--clay, #a85f4a); background: var(--ta-chat-paper); font-size: 12px; font-weight: 700; }
.ta-chat__finish { flex: 0 0 auto; margin: 0; padding: 0 18px 13px; border: 0; color: var(--ta-chat-muted); background: var(--ta-chat-paper); font-size: 11px; text-decoration: underline; cursor: pointer; }
.ta-chat__honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.ta-chat__sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 760px) {
  /* 152px, не 142: коло «Передзвоніть мені» закінчується на 142px
     (bottom:84 + 58px) — на 142 обидва кола торкались/накладались. */
  .ta-chat { right: 12px; bottom: calc(152px + env(safe-area-inset-bottom)); }
  .ta-chat__fab { width: 50px; padding: 0; justify-content: center; }
  .ta-chat__fab > span:last-child { display: none; }
  .ta-chat__panel { position: fixed; right: 10px; bottom: calc(86px + env(safe-area-inset-bottom)); width: calc(100vw - 20px); height: calc(100dvh - 108px); min-height: 0; border-radius: 22px; }
  .ta-chat__header { min-height: 74px; padding: 15px 16px 14px 20px; }
  .ta-chat__header strong { font-size: 25px; }
  .ta-chat__intro { padding: 26px 20px 22px; }

  .ta-chat__header-brand { gap: 8px; }
  .ta-chat__header-brand img { width: 40px; height: 40px; }
  .ta-chat__welcome { padding: 21px 24px; }
  .ta-chat__welcome p { font-size: 15px; }
  .ta-chat__messages { padding: 17px; }
  .ta-chat__start, .ta-chat__composer { padding: 13px 14px calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-height: 680px) and (min-width: 761px) {
  .ta-chat__panel { height: calc(100vh - 100px); min-height: 0; bottom: 56px; }
  .ta-chat__header { min-height: 84px; }
  .ta-chat__intro { padding-top: 24px; }
}

/* 761–900: bottom-nav видимий, і пігулка «Передзвоніть мені» докається
   право-вирівняною над ним (site.css, bottom:78) — чат піднімається на
   слот вище, щоб пігулки стояли стосом (чат зверху, дзвінок під ним),
   а не одна крізь одну. */
@media (max-width: 900px) and (min-width: 761px) {
  .ta-chat { bottom: calc(142px + env(safe-area-inset-bottom, 0px)); }
}

/* Мобільний конфігуратор: липкий config-бар займає низ екрана, і патч
   82.9.88.6.188.2 (site.css) піднімає коло «Передзвоніть мені» до
   ~152/156px одразу над ним — чат піднімається ще на слот, інакше два
   кола накладаються (site.css лишається незмінним: будь-який
   #configurator-селектор там хешується configurator section lock-ом). */
@media (max-width: 760px) {
  body:has(#configurator.page.active) .ta-chat {
    bottom: calc(220px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ta-chat * { scroll-behavior: auto !important; transition: none !important; }
  .ta-chat__waiting-dots i { animation: none !important; opacity: .55; }
}
