.lz-tg-chat-root {
  --lz-tg-primary: #446084;
  --lz-tg-primary-hover: #37506c;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 99999;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: #1f2933;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.lz-tg-chat-root[hidden] {
  display: none !important;
}

.lz-tg-launcher {
  appearance: none;
  border: 0;
  background: var(--lz-tg-primary);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(31, 41, 51, 0.16);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.lz-tg-launcher:hover {
  background: var(--lz-tg-primary-hover);
  box-shadow: 0 8px 20px rgba(31, 41, 51, 0.2);
}

.lz-tg-launcher:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lz-tg-launcher-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.lz-tg-launcher-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.lz-tg-launcher.is-open {
  padding: 10px 12px;
  border-radius: 999px;
}

.lz-tg-launcher.is-open .lz-tg-launcher-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.lz-tg-panel {
  width: min(360px, calc(100vw - 28px));
  height: min(480px, calc(100vh - 100px));
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.lz-tg-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.lz-tg-panel[hidden] {
  display: none !important;
}

.lz-tg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--lz-tg-primary);
  color: #fff;
}

.lz-tg-header-text {
  min-width: 0;
}

.lz-tg-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.lz-tg-header-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  opacity: 0.95;
}

.lz-tg-header-sub::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3dd68c;
  box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55);
  flex: 0 0 8px;
  animation: lz-tg-online-pulse 2.2s ease-out infinite;
}

.lz-tg-header-sub.is-offline::before {
  background: #9aa5b1;
  box-shadow: none;
  animation: none;
}

@keyframes lz-tg-online-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0.55);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(61, 214, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 214, 140, 0);
  }
}

.lz-tg-header-close {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  flex: 0 0 32px;
}

.lz-tg-header-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lz-tg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f5f7fa;
}

.lz-tg-empty {
  margin: 28px 8px 0;
  text-align: center;
  color: #627d98;
  font-size: 13px;
}

.lz-tg-empty[hidden] {
  display: none !important;
}

.lz-tg-msg {
  margin: 0 0 10px;
  max-width: 82%;
  padding: 8px 11px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e4e7eb;
  white-space: pre-wrap;
  word-break: break-word;
  animation: lz-tg-fade-in 0.16s ease;
}

.lz-tg-msg.is-visitor {
  margin-left: auto;
  background: #e8f0fe;
  border-color: #c5d4f0;
  border-bottom-right-radius: 4px;
}

.lz-tg-msg.is-staff {
  margin-right: auto;
  background: #fff;
  border-bottom-left-radius: 4px;
}

.lz-tg-msg.is-system {
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  background: transparent;
  border-style: dashed;
  color: #52606d;
  font-size: 13px;
  text-align: center;
}

.lz-tg-msg-meta {
  display: block;
  margin-top: 5px;
  color: #829ab1;
  font-size: 11px;
}

.lz-tg-composer,
.lz-tg-gate {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e4e7eb;
  background: #fff;
}

.lz-tg-composer textarea,
.lz-tg-gate input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #c9d2db;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  resize: none;
}

.lz-tg-composer textarea:focus,
.lz-tg-gate input:focus {
  outline: 2px solid rgba(68, 96, 132, 0.35);
  outline-offset: 1px;
  border-color: var(--lz-tg-primary);
}

.lz-tg-composer-actions {
  display: flex;
  justify-content: flex-end;
}

.lz-tg-composer button,
.lz-tg-gate button {
  appearance: none;
  border: 0;
  background: var(--lz-tg-primary);
  color: #fff;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.lz-tg-composer button:hover,
.lz-tg-gate button:hover {
  background: var(--lz-tg-primary-hover);
}

.lz-tg-composer button:disabled,
.lz-tg-gate button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.lz-tg-error {
  color: #9b1c1c;
  font-size: 12px;
  margin: 0;
  padding: 0 10px 8px;
  background: #fff;
}

.lz-tg-error[hidden] {
  display: none !important;
}

@keyframes lz-tg-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile PDP: cart + chat launcher are both position:fixed twins. */
@media (max-width: 849px) {
  body.single-product .product-summary form.cart > .single_add_to_cart_button,
  body.single-product .product-info form.cart > .single_add_to_cart_button,
  body.single-product .lz-tg-launcher,
  body.single-product .lz-tg-launcher.is-open {
    position: fixed !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    box-sizing: border-box !important;
    padding: 0 12px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 8px !important;
    line-height: 1.2 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 28px rgba(38, 55, 70, 0.22) !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    width: calc((100vw - 32px) / 2) !important;
    max-width: calc((100vw - 32px) / 2) !important;
  }

  body.single-product .product-summary form.cart > .single_add_to_cart_button,
  body.single-product .product-info form.cart > .single_add_to_cart_button {
    left: 12px !important;
    right: auto !important;
    z-index: 99998 !important;
  }

  body.single-product .lz-tg-launcher,
  body.single-product .lz-tg-launcher.is-open {
    left: auto !important;
    right: 12px !important;
    z-index: 99999 !important;
    gap: 6px !important;
    overflow: hidden !important;
  }

  /* Root only hosts the panel, above the dual CTA bar. */
  body.single-product .lz-tg-chat-root {
    left: 12px;
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: auto;
    align-items: stretch;
    gap: 0;
    pointer-events: none;
  }

  body.single-product .lz-tg-chat-root > * {
    pointer-events: auto;
  }

  body.single-product .lz-tg-launcher-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
  }

  body.single-product .lz-tg-launcher-icon svg {
    width: 16px;
    height: 16px;
  }

  body.single-product .lz-tg-panel {
    width: 100%;
    height: min(480px, calc(100vh - 120px - env(safe-area-inset-bottom, 0px)));
    align-self: stretch;
  }
}

@media (min-width: 768px) {
  .lz-tg-chat-root {
    right: 24px;
    bottom: 24px;
  }

  .lz-tg-panel {
    width: 400px;
    height: 520px;
  }

  .lz-tg-composer {
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
  }

  .lz-tg-composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
  }

  .lz-tg-composer-actions {
    flex: 0 0 auto;
  }

  .lz-tg-composer button {
    min-width: 72px;
    min-height: 44px;
  }

  .lz-tg-launcher {
    padding: 12px 18px;
  }
}
