.whatsapp-widget {
  position: fixed;
  z-index: 180;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(88px, calc(76px + env(safe-area-inset-bottom)));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.whatsapp-launcher {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform .2s ease, box-shadow .2s ease;
}

.whatsapp-launcher:hover,
.whatsapp-launcher:focus-visible {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 9px 24px rgba(0, 0, 0, .3);
}

.whatsapp-launcher svg {
  width: 38px;
  height: 38px;
  fill: currentColor;
}

.whatsapp-chat {
  position: fixed;
  width: min(326px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 7px;
  background: #ebe6e2;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
  pointer-events: none;
}

.whatsapp-widget.is-open .whatsapp-chat {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
  pointer-events: auto;
}

.whatsapp-widget.is-holding .whatsapp-launcher { box-shadow: 0 0 0 6px rgba(37, 211, 102, .3); }
.whatsapp-widget.is-dragging .whatsapp-launcher { cursor: grabbing; transform: none; }

.whatsapp-widget.is-dismissed .whatsapp-chat {
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
}

.whatsapp-chat header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 12px;
  background: #25d366;
  color: #fff;
}

.whatsapp-chat header strong { font-size: 1rem; }

.whatsapp-chat header button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  cursor: pointer;
}

.whatsapp-chat > p {
  margin: 13px 15px;
  padding: 13px 12px;
  border-radius: 5px;
  background: #fff;
  color: #6c6c6c;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  line-height: 1.45;
}

.whatsapp-chat form {
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  gap: 8px;
  max-width: none;
  margin: 0;
  padding: 12px 14px;
  background: #fff;
}

.whatsapp-chat textarea {
  width: 100%;
  min-height: 58px;
  resize: none;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  background: #fff;
  color: #222;
  font: inherit;
}

.whatsapp-chat form button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #333;
  cursor: pointer;
}

.whatsapp-chat form button:hover { color: #25a954; }
.whatsapp-chat form button svg { width: 29px; height: 29px; fill: currentColor; }

@media (max-width: 520px) {
  .whatsapp-widget { right: 16px; bottom: max(88px, calc(76px + env(safe-area-inset-bottom))); }
  .whatsapp-launcher { width: 58px; height: 58px; }
  .whatsapp-launcher svg { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-chat,
  .whatsapp-launcher { transition: none; }
}
