#pw-chat {
  position: fixed; right: 18px; bottom: 18px; z-index: 9999;
  font-family: inherit;
}

/* Bubble */
.pw-chat-bubble {
  position: relative;
  width: 64px; height: 64px; border-radius: 50%; border: 0; padding: 0;
  cursor: pointer; overflow: visible;
  background: var(--pw-primary);
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  animation: pw-breathe 3.4s ease-in-out infinite;
}
.pw-chat-bubble:hover {
  animation-play-state: paused;
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
}
.pw-chat-bubble-avatar {
  width: 54px; height: 54px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff;
  display: block;
}
.pw-chat-bubble-badge {
  position: absolute; top: 2px; right: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
  animation: pw-pulse 2s ease-in-out infinite;
}
.pw-chat-bubble-enter { animation: pw-bounce-in 700ms cubic-bezier(.34,1.56,.64,1) 1, pw-breathe 3.4s ease-in-out 700ms infinite; }

#pw-chat.pw-chat-open .pw-chat-bubble { transform: scale(0); pointer-events: none; opacity: 0; }

/* Teaser bubble */
.pw-chat-teaser {
  position: absolute;
  right: 8px;
  bottom: 80px;
  width: max-content;
  max-width: min(420px, calc(100vw - 110px));
  white-space: nowrap;
  background: #fff;
  color: #000;
  border: 2px solid #000;
  border-radius: 22px;
  box-shadow: 4px 8px 20px rgba(0,0,0,.35);
  padding: 10px 34px 10px 16px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  animation: pw-teaser-in .45s cubic-bezier(.34,1.56,.64,1), pw-teaser-wobble 2.6s ease-in-out .9s 2;
  transform-origin: right center;
}
.pw-chat-teaser::before {
  content: '';
  position: absolute;
  bottom: -16px;
  right: 22px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-top: 16px solid #000;
}
.pw-chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -11px;
  right: 24px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-top: 11px solid #fff;
}
.pw-chat-teaser-close {
  position: absolute;
  top: 4px; right: 6px;
  width: 22px; height: 22px;
  border: 0; background: transparent;
  color: rgba(0,0,0,.55); font-size: 18px; line-height: 1;
  cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.pw-chat-teaser-close:hover { background: rgba(0,0,0,.1); color: #000; }
#pw-chat.pw-chat-open .pw-chat-teaser { display: none; }

/* Panel */
.pw-chat-panel {
  position: absolute; right: 0; bottom: 80px;
  width: 360px; max-width: calc(100vw - 24px);
  height: 520px; max-height: calc(100vh - 120px);
  background: #fff; border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(14px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease, width .25s ease, height .25s ease;
}
.pw-chat-panel.pw-chat-panel--open {
  opacity: 1; pointer-events: auto;
  transform: translateY(0) scale(1);
}
.pw-chat-panel.pw-chat-panel--expanded {
  width: 460px; height: 640px;
}

/* Header */
.pw-chat-header {
  background: var(--pw-primary); color: #fff;
  padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
}
.pw-chat-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pw-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.6);
  flex-shrink: 0;
  transition: transform .25s ease;
}
.pw-chat-avatar.pw-chat-avatar--bob { animation: pw-bob .55s ease; }
.pw-chat-header-text { line-height: 1.15; min-width: 0; }
.pw-chat-header-title { font-weight: 700; font-size: 15px; }
.pw-chat-header-sub {
  font-size: 11.5px; opacity: .9; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pw-chat-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pw-chat-expand, .pw-chat-close {
  background: transparent; border: 0; color: #fff; cursor: pointer; line-height: 1;
  padding: 6px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.pw-chat-expand:hover, .pw-chat-close:hover { background: rgba(255,255,255,.15); }
.pw-chat-close { font-size: 22px; width: 28px; height: 28px; }
.pw-chat-icon-shrink { display: none; }
.pw-chat-panel--expanded .pw-chat-icon-expand { display: none; }
.pw-chat-panel--expanded .pw-chat-icon-shrink { display: block; }

/* Messages */
.pw-chat-messages {
  flex: 1; padding: 14px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  background: #f6f7f9;
  scroll-behavior: smooth;
}
.pw-chat-msg {
  max-width: 80%; padding: 9px 12px; border-radius: 14px;
  line-height: 1.4; white-space: pre-wrap; word-wrap: break-word;
  animation: pw-msg-in .25s ease;
}
.pw-chat-msg.bot  { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; border-bottom-left-radius: 4px; }
.pw-chat-msg.user { align-self: flex-end;   background: var(--pw-primary); color: #fff; border-bottom-right-radius: 4px; }

/* Typing dots */
.pw-chat-typing {
  align-self: flex-start; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 14px; border-bottom-left-radius: 4px;
  padding: 10px 14px; display: inline-flex; gap: 4px;
  animation: pw-msg-in .2s ease;
}
.pw-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9aa0a6; display: inline-block;
  animation: pw-dot 1.1s ease-in-out infinite;
}
.pw-chat-typing span:nth-child(2) { animation-delay: .15s; }
.pw-chat-typing span:nth-child(3) { animation-delay: .30s; }

/* Form */
.pw-chat-form {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px;
  border-top: 1px solid #eee; background: #fff;
}
.pw-chat-input {
  flex: 1; resize: none; border: 1px solid #ddd; border-radius: 10px;
  padding: 9px 11px; font: inherit; max-height: 110px;
  transition: border-color .15s ease;
}
.pw-chat-input:focus { outline: none; border-color: var(--pw-primary); }
.pw-chat-send {
  border: 0; background: var(--pw-primary); color: #fff;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, opacity .15s ease;
}
.pw-chat-send:hover:not(:disabled) { transform: scale(1.06); }
.pw-chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* Lead form card */
.pw-chat-leadform {
  align-self: stretch; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
  animation: pw-msg-in .25s ease;
}
.pw-chat-leadform label { font-size: 12px; color: #555; display: flex; flex-direction: column; gap: 4px; }
.pw-chat-leadform input, .pw-chat-leadform textarea {
  border: 1px solid #ddd; border-radius: 8px; padding: 7px 9px; font: inherit;
}
.pw-chat-leadform input:focus, .pw-chat-leadform textarea:focus { outline: none; border-color: var(--pw-primary); }
.pw-chat-leadform button {
  border: 0; background: var(--pw-primary); color: #fff;
  padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 600;
  transition: opacity .15s ease;
}
.pw-chat-leadform button:disabled { opacity: .6; }
.pw-chat-leadform .pw-chat-consent {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: #555;
  cursor: pointer;
}
.pw-chat-leadform .pw-chat-consent input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--pw-primary);
}
.pw-chat-leadform .pw-chat-consent a {
  color: var(--pw-primary);
  text-decoration: underline;
}

/* Keyframes */
@keyframes pw-breathe {
  0%, 100% { box-shadow: 0 6px 20px rgba(0,0,0,.22); transform: scale(1); }
  50%      { box-shadow: 0 6px 28px rgba(0,0,0,.32), 0 0 0 6px rgba(0,0,0,0); transform: scale(1.035); }
}
@keyframes pw-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
@keyframes pw-bounce-in {
  0%   { transform: translateY(80px) scale(.4); opacity: 0; }
  60%  { transform: translateY(-10px) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes pw-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pw-dot {
  0%, 80%, 100% { transform: translateY(0);    opacity: .4; }
  40%           { transform: translateY(-5px); opacity: 1;  }
}
@keyframes pw-bob {
  0%, 100% { transform: translateY(0)    rotate(0); }
  30%      { transform: translateY(-4px) rotate(-4deg); }
  60%      { transform: translateY(0)    rotate(3deg); }
}
@keyframes pw-teaser-in {
  from { opacity: 0; transform: translateX(14px) scale(.88); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}
@keyframes pw-teaser-wobble {
  0%, 100% { transform: translateX(0)    rotate(0); }
  25%      { transform: translateX(-3px) rotate(-1.5deg); }
  75%      { transform: translateX(3px)  rotate(1.5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .pw-chat-bubble, .pw-chat-bubble-enter, .pw-chat-bubble-badge,
  .pw-chat-avatar, .pw-chat-typing span, .pw-chat-msg, .pw-chat-leadform,
  .pw-chat-teaser {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 480px) {
  .pw-chat-panel {
    position: fixed; right: 12px; left: 12px; bottom: 92px;
    width: auto; max-width: none;
  }
  .pw-chat-panel.pw-chat-panel--expanded {
    width: auto; height: calc(100vh - 120px);
  }
  .pw-chat-teaser {
    right: 8px;
    bottom: 80px;
    max-width: calc(100vw - 24px);
  }
}
