/* Chat flotante público — estilo WhatsApp + transiciones premium */
.cw-webchat-root {
  --cw-wc-cyan: #00f3ff;
  --cw-wc-mint: #00ff9d;
  --cw-wc-deep: #0a0a0f;
  --cw-wc-violet: #7c5cff;
  --cw-wa-bg: #0b141a;
  --cw-wa-header: #1f2c34;
  --cw-wa-in: #202c33;
  --cw-wa-out: #005c4b;
  --cw-wa-compose: #1f2c34;
  --cw-wa-input: #2a3942;
  --cw-wa-accent: #00a884;
  position: fixed;
  right: 1.1rem;
  bottom: 1.35rem;
  z-index: 10050;
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  color: #e9edef;
  /* No usar perspective aquí: en móvil rompe position:fixed del panel */
}

/* ── FAB: núcleo + aureolas (sin pastilla) ── */
.cw-webchat-fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 148px;
  height: 148px;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #e8f7ff;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  text-align: left;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease,
    filter 0.35s ease;
  animation: cwWcFabFloat 4.2s ease-in-out infinite;
  will-change: transform, opacity;
}

.cw-webchat-fab:hover,
.cw-webchat-fab:focus-visible {
  transform: scale(1.1) translateY(-4px);
  outline: none;
  filter: drop-shadow(0 12px 28px rgba(34, 211, 238, 0.35));
  animation-play-state: paused;
}

.cw-webchat-fab:active {
  transform: scale(0.94);
  transition-duration: 0.12s;
}

.cw-webchat-fab.is-open {
  animation: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.55) rotate(-12deg);
  filter: blur(6px);
}

.cw-webchat-fab-tag {
  position: absolute;
  right: calc(100% + 0.35rem);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  white-space: nowrap;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: left !important;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  color: #041018;
  background: linear-gradient(135deg, #67e8f9 0%, #a78bfa 55%, #34d399 100%);
  background-size: 180% 180%;
  box-shadow:
    0 8px 22px rgba(15, 23, 42, 0.28),
    0 0 18px rgba(34, 211, 238, 0.35);
  pointer-events: none;
  opacity: 0;
  animation:
    cwWcTagIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards,
    cwWcTagShimmer 4s ease-in-out 1.2s infinite;
}

.cw-webchat-fab.is-open .cw-webchat-fab-tag {
  animation: none;
  opacity: 0;
  transform: translateY(-50%) translateX(16px) scale(0.9);
}

.cw-webchat-fab-tag::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background: #a78bfa;
  transform: rotate(45deg);
  border-radius: 2px;
}

.cw-webchat-fab-orb {
  position: relative;
  width: 136px;
  height: 136px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  perspective: 640px;
  background: transparent;
  overflow: visible;
}

.cw-webchat-fab-halo {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 212, 232, 0.28) 0%, transparent 68%);
  animation: cwWcHalo 3.8s ease-in-out infinite;
  pointer-events: none;
}

.cw-webchat-fab-halo--2 {
  inset: -18px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.22) 0%, transparent 70%);
  animation-delay: 1.1s;
}

.cw-webchat-fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.45);
  animation: cwWcRing 2.8s ease-out infinite;
  pointer-events: none;
}

.cw-webchat-fab-ring--2 {
  inset: -14px;
  border-color: rgba(168, 85, 247, 0.4);
  animation-delay: 0.9s;
}

.cw-webchat-fab-ring--3 {
  inset: -24px;
  border-color: rgba(45, 212, 191, 0.35);
  animation-delay: 1.8s;
}

.cw-webchat-fab-core-layer {
  position: absolute;
  border-radius: 50%;
  transform-style: preserve-3d;
}

.cw-webchat-fab-core-inner {
  width: 48px;
  height: 48px;
  z-index: 8;
  background: radial-gradient(
    circle at 28% 26%,
    #ffffff 0%,
    #a5f3fc 28%,
    #22d3ee 52%,
    #a855f7 78%,
    #0f172a 100%
  );
  box-shadow:
    0 0 22px rgba(34, 211, 238, 0.85),
    0 0 42px rgba(168, 85, 247, 0.5),
    inset 0 0 14px rgba(255, 255, 255, 0.55);
  animation: cwWcPulse 3.2s ease-in-out infinite;
}

.cw-webchat-fab-core-inner::before {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.4) 0%, transparent 70%);
  animation: cwWcHalo 3.2s ease-in-out infinite;
}

.cw-webchat-fab-core-middle {
  width: 76px;
  height: 76px;
  z-index: 4;
  border: 1.5px solid rgba(103, 232, 249, 0.4);
  background: radial-gradient(
    circle,
    rgba(0, 212, 232, 0.24) 0%,
    rgba(168, 85, 247, 0.16) 48%,
    transparent 72%
  );
  box-shadow: inset 0 0 16px rgba(34, 211, 238, 0.22);
  animation: cwWcCoreTilt 14s linear infinite;
}

.cw-webchat-fab-core-outer {
  width: 102px;
  height: 102px;
  z-index: 2;
  border: 1px solid rgba(168, 85, 247, 0.32);
  background: radial-gradient(
    circle,
    rgba(0, 212, 232, 0.14) 0%,
    rgba(34, 211, 166, 0.1) 40%,
    transparent 70%
  );
  animation: cwWcCoreTiltRev 18s linear infinite;
}

.cw-webchat-fab-orbit {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid rgba(103, 232, 249, 0.55);
  box-shadow:
    0 0 10px rgba(34, 211, 238, 0.25),
    inset 0 0 8px rgba(168, 85, 247, 0.12);
  transform-style: preserve-3d;
  z-index: 6;
}

.cw-webchat-fab-orbit-1 {
  width: 108px;
  height: 108px;
  border-color: rgba(34, 211, 238, 0.72);
  animation: cwWcOrbit1 7s linear infinite;
}

.cw-webchat-fab-orbit-2 {
  width: 94px;
  height: 94px;
  border-color: rgba(192, 132, 252, 0.7);
  animation: cwWcOrbit2 9.5s linear infinite reverse;
}

.cw-webchat-fab-orbit-3 {
  width: 80px;
  height: 80px;
  border-color: rgba(45, 212, 191, 0.65);
  animation: cwWcOrbit3 6.2s linear infinite;
}

.cw-webchat-fab-sat {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff 0%, #67e8f9 55%, #22d3ee 100%);
  box-shadow:
    0 0 8px rgba(34, 211, 238, 0.95),
    0 0 14px rgba(168, 85, 247, 0.55);
}

.cw-webchat-fab-orbit-2 .cw-webchat-fab-sat {
  background: radial-gradient(circle at 30% 30%, #fff 0%, #e9d5ff 50%, #c084fc 100%);
  width: 8px;
  height: 8px;
  margin-left: -4px;
}

.cw-webchat-fab-orbit-3 .cw-webchat-fab-sat {
  background: radial-gradient(circle at 30% 30%, #fff 0%, #99f6e4 50%, #2dd4bf 100%);
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  top: auto;
  bottom: -3px;
}

@keyframes cwWcFabFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes cwWcTagIn {
  from { opacity: 0; transform: translateY(-50%) translateX(18px) scale(0.92); }
  to { opacity: 1; transform: translateY(-50%) translateX(0) scale(1); }
}

@keyframes cwWcTagShimmer {
  0%, 100% { background-position: 0% 50%; filter: brightness(1); }
  50% { background-position: 100% 50%; filter: brightness(1.1); }
}

@keyframes cwWcHalo {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.1); }
}

@keyframes cwWcPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.16); }
}

@keyframes cwWcRing {
  0% { transform: scale(0.88); opacity: 0.55; }
  100% { transform: scale(1.55); opacity: 0; }
}

@keyframes cwWcCoreTilt {
  0% { transform: rotateX(18deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(18deg) rotateY(360deg) rotateZ(360deg); }
}

@keyframes cwWcCoreTiltRev {
  0% { transform: rotateX(-22deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(-22deg) rotateY(-360deg) rotateZ(-360deg); }
}

@keyframes cwWcOrbit1 {
  0% { transform: rotateX(68deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(68deg) rotateY(360deg) rotateZ(360deg); }
}

@keyframes cwWcOrbit2 {
  0% { transform: rotateX(62deg) rotateY(40deg) rotateZ(0deg); }
  100% { transform: rotateX(62deg) rotateY(40deg) rotateZ(-360deg); }
}

@keyframes cwWcOrbit3 {
  0% { transform: rotateX(74deg) rotateY(-30deg) rotateZ(0deg); }
  100% { transform: rotateX(74deg) rotateY(-30deg) rotateZ(360deg); }
}

/* ── Panel estilo WhatsApp + apertura premium ── */
.cw-webchat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 1.4rem));
  height: min(580px, calc(100vh - 2rem));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  color: #e9edef;
  background: var(--cw-wa-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 168, 132, 0.12),
    0 0 40px rgba(0, 168, 132, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 24px, 0) scale(0.96);
  transform-origin: bottom right;
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.32s;
  will-change: transform, opacity;
}

.cw-webchat-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 168, 132, 0.18),
    0 0 56px rgba(0, 168, 132, 0.14);
}

.cw-webchat-panel.is-closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 16px, 0) scale(0.97);
}

.cw-webchat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(180deg, #1f2c34 0%, #1a252d 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
  animation: cwWcHeadSlide 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.cw-webchat-head-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.cw-webchat-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0f172a;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.35);
}

.cw-webchat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cw-webchat-avatar::after {
  content: '';
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid #1f2c34;
  animation: cwWcOnlinePulse 2.2s ease-in-out infinite;
  z-index: 1;
}

.cw-webchat-head h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-webchat-head p {
  margin: 0.12rem 0 0;
  font-size: 0.72rem;
  color: #25d366;
  opacity: 1;
}

.cw-webchat-head-actions {
  display: flex;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.cw-webchat-iconbtn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cw-webchat-iconbtn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.08);
}

.cw-webchat-iconbtn.is-on {
  background: rgba(37, 211, 102, 0.18);
  color: #25d366;
}

/* Fondo WhatsApp real: color + doodle sutil SIEMPRE visible (no ::before) */
.cw-webchat-log {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: #e9edef;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  background-color: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.055' stroke-width='1.2' stroke-linecap='round'%3E%3Cpath d='M28 40c8-2 14 6 10 12M52 86c-4 7 2 14 9 10M96 32c6 4 4 14-3 14M140 70c8 0 10 10 3 14M188 38c5 6-1 14-8 11M220 78c7-3 14 4 10 10M34 140c7 3 6 13-2 14M78 168c-3 8 5 14 11 9M124 132c8 2 9 12 1 15M166 176c6-4 14 1 12 9M210 148c5 7-2 14-9 11M46 214c8 1 11 10 4 14M98 228c-4 7 3 13 10 9M158 210c7 4 5 13-3 14M206 232c6-3 13 3 11 10M18 96c3-2 6 0 5 3M72 118h6M112 98c2 2 0 5-2 4M184 112l5 3M236 168c2-2 5 0 4 3M62 48l4-2M170 52h5M230 52c2 2 0 4-2 3'/%3E%3Ccircle cx='44' cy='118' r='2.2' fill='%23ffffff' fill-opacity='0.04' stroke='none'/%3E%3Ccircle cx='132' cy='54' r='2' fill='%23ffffff' fill-opacity='0.04' stroke='none'/%3E%3Ccircle cx='198' cy='124' r='2.4' fill='%23ffffff' fill-opacity='0.04' stroke='none'/%3E%3Ccircle cx='88' cy='206' r='2' fill='%23ffffff' fill-opacity='0.04' stroke='none'/%3E%3Ccircle cx='176' cy='198' r='2.2' fill='%23ffffff' fill-opacity='0.04' stroke='none'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 260px 260px;
  background-attachment: local;
  animation: cwWcLogFade 0.55s ease 0.12s both;
}

.cw-webchat-msg {
  position: relative;
  z-index: 1;
  max-width: 84%;
  padding: 0.5rem 0.65rem 0.4rem;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.18);
  border: 0;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  animation: cwWcBubbleIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.cw-webchat-msg.is-instant {
  opacity: 1;
  transform: none;
  animation: none;
}

.cw-webchat-msg small {
  display: block;
  font-size: 0.62rem;
  opacity: 0.55;
  margin-bottom: 0.15rem;
  color: rgba(255, 255, 255, 0.55);
}

.cw-webchat-msg.is-bot {
  align-self: flex-start;
  background: var(--cw-wa-in);
  color: #e9edef;
  border-top-left-radius: 0;
}

.cw-webchat-msg.is-bot::before {
  content: '';
  position: absolute;
  top: 0;
  left: -6px;
  border-top: 6px solid var(--cw-wa-in);
  border-left: 6px solid transparent;
}

.cw-webchat-msg.is-user {
  align-self: flex-end;
  background: var(--cw-wa-out);
  color: #e9edef;
  border-top-right-radius: 0;
}

.cw-webchat-msg.is-user::before {
  content: '';
  position: absolute;
  top: 0;
  right: -6px;
  border-top: 6px solid var(--cw-wa-out);
  border-right: 6px solid transparent;
}

.cw-webchat-msg.is-system {
  align-self: center;
  max-width: 92%;
  background: rgba(17, 27, 33, 0.9);
  color: rgba(233, 237, 239, 0.88);
  font-size: 0.74rem;
  border-radius: 8px;
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.cw-webchat-msg.is-system::before {
  display: none;
}

.cw-webchat-progress {
  position: relative;
  z-index: 2;
  padding: 0.4rem 0.9rem;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: rgba(233, 237, 239, 0.7);
  background: #111b21;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex: 0 0 auto;
}

.cw-webchat-compose {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.7rem 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: var(--cw-wa-compose);
  flex: 0 0 auto;
  animation: cwWcComposeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

.cw-webchat-compose input {
  border-radius: 22px;
  border: 0;
  background: var(--cw-wa-input);
  color: #e9edef;
  padding: 0.65rem 0.95rem;
  font: inherit;
  min-width: 0;
  transition: box-shadow 0.25s ease, background 0.25s ease;
}

.cw-webchat-compose input::placeholder {
  color: rgba(233, 237, 239, 0.45);
}

.cw-webchat-compose input:focus {
  outline: none;
  box-shadow: 0 0 0 1px rgba(0, 168, 132, 0.5);
  background: #314650;
}

.cw-webchat-mic {
  border: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  color: #d1d7db;
  background: #2a3942;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
  flex: 0 0 auto;
}

.cw-webchat-mic-svg {
  display: block;
  pointer-events: none;
}

.cw-webchat-mic:hover {
  background: #314650;
  color: #fff;
  transform: scale(1.06);
}

.cw-webchat-mic.is-listening {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45);
  animation: cwWcMicPulse 1.2s ease-out infinite;
}

.cw-webchat-mic.is-listening:hover {
  background: #b91c1c;
}

.cw-webchat-mic.is-unavailable {
  opacity: 0.5;
}

.cw-webchat-mic[hidden] {
  display: none !important;
}

@keyframes cwWcMicPulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.cw-webchat-send {
  border: 0;
  border-radius: 50%;
  width: 46px;
  height: 46px;
  padding: 0;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  color: #fff;
  background: var(--cw-wa-accent);
  box-shadow: 0 6px 16px rgba(0, 168, 132, 0.35);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, background 0.2s ease;
}

.cw-webchat-send:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 8px 22px rgba(0, 168, 132, 0.45);
  background: #00b894;
}

.cw-webchat-send:active:not(:disabled) {
  transform: scale(0.94);
}

.cw-webchat-send:disabled {
  opacity: 0.55;
  cursor: wait;
}

.cw-webchat-captcha {
  padding: 0.55rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: #111b21;
  flex: 0 0 auto;
}

.cw-webchat-captcha[hidden] {
  display: none !important;
}

/* Bloqueo de scroll de fondo (móvil) sin position:fixed en body */
html.cw-webchat-noscroll,
body.cw-webchat-noscroll {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

body.cw-webchat-noscroll .cw-webchat-panel,
body.cw-webchat-noscroll .cw-webchat-log,
body.cw-webchat-noscroll .cw-webchat-compose {
  touch-action: manipulation;
}

body.cw-webchat-noscroll .cw-webchat-log {
  touch-action: pan-y;
}

@keyframes cwWcHeadSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

@keyframes cwWcComposeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes cwWcLogFade {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

@keyframes cwWcBubbleIn {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cwWcOnlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .cw-webchat-fab,
  .cw-webchat-fab-tag,
  .cw-webchat-fab-halo,
  .cw-webchat-fab-ring,
  .cw-webchat-fab-core-inner,
  .cw-webchat-fab-core-middle,
  .cw-webchat-fab-core-outer,
  .cw-webchat-fab-orbit,
  .cw-webchat-panel,
  .cw-webchat-msg,
  .cw-webchat-head,
  .cw-webchat-compose,
  .cw-webchat-log {
    animation: none !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
  }
  .cw-webchat-msg {
    opacity: 1;
    transform: none;
  }
  .cw-webchat-fab-tag {
    opacity: 1;
    transform: translateY(-50%);
  }
}

@media (max-width: 520px) {
  .cw-webchat-root {
    --cw-vv-height: 100dvh;
    --cw-vv-top: 0px;
    --cw-kb-offset: 0px;
    right: 0.75rem;
    bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
    left: auto;
    top: auto;
    width: auto;
    height: auto;
    z-index: 10060;
  }

  .cw-webchat-fab {
    position: relative;
    right: auto;
    bottom: auto;
    width: 96px;
    height: 96px;
    z-index: 2;
  }

  .cw-webchat-fab-orb {
    width: 90px;
    height: 90px;
  }

  .cw-webchat-fab-core-inner {
    width: 34px;
    height: 34px;
  }

  .cw-webchat-fab-core-middle {
    width: 54px;
    height: 54px;
  }

  .cw-webchat-fab-core-outer {
    width: 72px;
    height: 72px;
  }

  .cw-webchat-fab-orbit-1 { width: 78px; height: 78px; }
  .cw-webchat-fab-orbit-2 { width: 68px; height: 68px; }
  .cw-webchat-fab-orbit-3 { width: 58px; height: 58px; }

  .cw-webchat-fab-tag {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.36rem 0.62rem;
    right: calc(100% + 0.35rem);
    left: auto;
    max-width: none;
    white-space: nowrap;
    line-height: 1.2;
    text-align: left !important;
    justify-content: flex-start;
    display: inline-flex;
  }

  .cw-webchat-fab-tag::after {
    /* flecha hacia el núcleo (derecha) */
    right: -5px;
    left: auto;
  }

  /*
   * Panel móvil estilo WhatsApp:
   * - Cabecera fija arriba
   * - Mensajes scrollables en el centro
   * - Barra de escribir pegada abajo del viewport visual
   *   (sube con el teclado; la cabecera no se mueve)
   */
  .cw-webchat-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--cw-vv-top, 0px);
    bottom: auto;
    width: 100%;
    width: 100dvw;
    height: var(--cw-vv-height, 100dvh);
    max-height: var(--cw-vv-height, 100dvh);
    border-radius: 0;
    border: 0;
    transform-origin: center center;
    box-shadow: none;
    padding-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 10070;
  }

  .cw-webchat-panel.is-open {
    transform: translate3d(0, 0, 0) scale(1);
    height: var(--cw-vv-height, 100dvh);
    max-height: var(--cw-vv-height, 100dvh);
  }

  .cw-webchat-panel.is-closing {
    transform: translate3d(0, 8%, 0) scale(1);
  }

  .cw-webchat-head {
    flex: 0 0 auto;
    position: relative;
    z-index: 6;
    padding: 0.65rem 0.75rem;
    padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
  }

  .cw-webchat-progress {
    flex: 0 0 auto;
  }

  .cw-webchat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.7rem 0.65rem 0.85rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .cw-webchat-msg {
    max-width: 88%;
    font-size: 0.92rem;
    padding: 0.55rem 0.7rem 0.45rem;
  }

  .cw-webchat-captcha {
    flex: 0 0 auto;
  }

  .cw-webchat-compose {
    flex: 0 0 auto;
    position: relative;
    z-index: 6;
    gap: 0.4rem;
    padding: 0.5rem 0.55rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: var(--cw-wa-compose);
  }

  .cw-webchat-compose input {
    font-size: 16px; /* evita zoom automático en iOS */
    min-height: 44px;
    padding: 0.7rem 0.9rem;
    border-radius: 24px;
  }

  .cw-webchat-mic,
  .cw-webchat-send {
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
  }

  .cw-webchat-iconbtn {
    width: 42px;
    height: 42px;
  }

  /* Con teclado abierto: cabecera sigue visible; compose sin safe-area extra */
  .cw-webchat-root.is-keyboard-open .cw-webchat-head {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .cw-webchat-root.is-keyboard-open .cw-webchat-compose {
    padding-bottom: 0.5rem;
  }
}
