.tg-chat {
  position: fixed;
  left: auto;
  right: 18px;
  bottom: 18px;
  z-index: 1080;
  font-family: Arial, Helvetica, sans-serif;
}

.tg-chat__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.28);
  cursor: pointer;
  animation: tg-chat-pulse 60s infinite;
}

.tg-chat__button:hover,
.tg-chat__button:focus {
  background: #115e59;
  outline: none;
}

.tg-chat.is-open .tg-chat__button {
  animation: none;
}

.tg-chat__plus {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  font-size: 2.15rem;
  line-height: 1;
  font-weight: 900;
}

.tg-chat__panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  display: none;
  width: min(380px, calc(100vw - 36px));
  max-height: min(640px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 26px 68px rgba(15, 23, 42, 0.28);
}

.tg-chat.is-open .tg-chat__panel {
  display: flex;
  flex-direction: column;
}

body.tg-chat-open {
  overflow: auto;
}

.tg-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0f172a, #134e4a);
  color: #ffffff;
}

.tg-chat__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.tg-chat__subtitle {
  display: none;
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
}

.tg-chat__close {
  border: 0;
  background: transparent;
  color: #ffffff;
  opacity: 0.78;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.tg-chat__close:hover,
.tg-chat__close:focus {
  opacity: 1;
  outline: none;
}

.tg-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
  background: #f7fafc;
  min-height: 300px;
  max-height: 390px;
}

.tg-chat__msg {
  max-width: 92%;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.tg-chat__msg--bot {
  align-self: flex-start;
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.tg-chat__msg--user {
  align-self: flex-end;
  background: #0f766e;
  color: #ffffff;
}

.tg-chat__options {
  display: none;
  gap: 8px;
  padding: 0 16px 16px;
  background: #f7fafc;
}

.tg-chat__option {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: #111827;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.tg-chat__option:hover,
.tg-chat__option:focus {
  border-color: #0f766e;
  outline: none;
}

.tg-chat__ask,
.tg-chat__form {
  display: none;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.tg-chat.is-open:not(.is-lead) .tg-chat__ask {
  display: grid;
}

.tg-chat.is-lead .tg-chat__form {
  display: grid;
}

.tg-chat__field {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  resize: vertical;
}

.tg-chat__field:focus {
  border-color: #0f766e;
  outline: none;
}

.tg-chat__submit {
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: #0f766e;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.tg-chat__submit:hover,
.tg-chat__submit:focus {
  background: #115e59;
  outline: none;
}

.tg-chat__note {
  display: none;
  margin: 0;
  color: #5b6472;
  font-size: 0.82rem;
}

.tg-chat.is-lead .tg-chat__note {
  display: block;
}

@media (max-width: 575px) {
  .tg-chat {
    left: auto;
    right: 12px;
    bottom: 12px;
  }

  .tg-chat__button {
    width: 58px;
    margin-left: auto;
    justify-content: center;
  }

  .tg-chat__panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 82px;
    width: auto;
    max-height: min(76vh, 620px);
    border-radius: 14px;
  }

  .tg-chat__messages {
    flex: 1 1 auto;
    min-height: 220px;
    max-height: none;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .tg-chat__ask,
  .tg-chat__form {
    flex: 0 0 auto;
    padding: 10px;
  }

  .tg-chat__field {
    font-size: 16px;
  }

  .tg-chat__ask textarea {
    min-height: 46px;
    max-height: 96px;
  }

  .tg-chat.is-open .tg-chat__panel {
    display: flex;
  }
}

@keyframes tg-chat-pulse {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.24);
  }
  1% {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0.16), 0 22px 42px rgba(15, 23, 42, 0.3);
  }
  2% {
    transform: translateY(0) scale(1);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.24);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.24);
  }
}
