/* Teléfono y conversación de muestra, con colores propios para ambos temas. */
#demo, .chat-expanded {
  --wa-background: #efeae2;
  --wa-panel: #f7f9fa;
  --wa-header: #075e54;
  --wa-incoming: #fff;
  --wa-outgoing: #d9fdd3;
  --wa-text: #111b21;
  --wa-secondary: #667781;
  --wa-divider: #dde5e8;
  --wa-chip: #fff;
  --wa-accent: #007c66;
}
.dark #demo, .dark .chat-expanded {
  --wa-background: #0b141a;
  --wa-panel: #111b21;
  --wa-header: #202c33;
  --wa-incoming: #202c33;
  --wa-outgoing: #005c4b;
  --wa-text: #e9edef;
  --wa-secondary: #aebac1;
  --wa-divider: #2a3942;
  --wa-chip: #202c33;
  --wa-accent: #42d7b4;
}
#demo .demo-grid { grid-template-columns: minmax(0,1fr) minmax(0,410px); align-items: center; gap: 50px; padding: 36px; }
#demo .demo-explainer { max-width: 520px; }
.chat-preview { display: grid; justify-items: center; gap: 18px; min-width: 0; }
.chat-preview-hint { margin: 0; color: var(--text-secondary); font-size: 12px; text-align: center; }
.chat-preview-hint .material-symbols-outlined { color: var(--yellow); font-size: 17px; margin-right: 5px; }
.phone.chat-phone {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 380px;
  height: 704px;
  min-width: 0;
  margin: 0;
  border: 8px solid #20272d;
  border-radius: 44px;
  outline: 1px solid #45515a;
  overflow: hidden;
  background: var(--wa-panel);
  color: var(--wa-text);
  box-shadow: 0 28px 60px -24px #0006, 0 2px 4px #0002;
  isolation: isolate;
}
.phone-status { flex: 0 0 34px; position: relative; display: flex; align-items: center; justify-content: space-between; padding: 0 19px; background: var(--wa-panel); font: 700 11px/1 sans-serif; color: var(--wa-text); }
.phone-status::after { content: ''; position: absolute; width: 92px; height: 21px; border-radius: 0 0 15px 15px; top: 0; left: 50%; transform: translateX(-50%); background: #11161b; }
.phone-status-icons { display: flex; align-items: center; gap: 3px; }
.phone-status-icons .material-symbols-outlined { font-size: 15px; }
.chat-phone .wa-header { flex: 0 0 auto; padding: 12px 10px; gap: 9px; min-height: 72px; border: 0; background: var(--wa-header); color: #fff; }
.wa-back { font-size: 20px; flex-shrink: 0; }
.chat-phone .wa-avatar { position: relative; flex: 0 0 38px; width: 38px; height: 38px; background: #d9fdd3; border: 0; font-size: 22px; }
.chat-phone .wa-avatar::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; background: #25d366; border: 2px solid var(--wa-header); border-radius: 50%; }
.wa-contact { min-width: 0; flex: 1; }
.chat-phone .wa-header strong { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-phone .wa-header small { color: #c4e5dc; font-size: 10px; margin-top: 3px; }
.dark .chat-phone .wa-header small { color: #aebac1; }
.chat-expand { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid #ffffff30; border-radius: 50%; color: #fff; background: #ffffff0c; cursor: pointer; }
.chat-expand .material-symbols-outlined { font-size: 21px; }
.chat-phone .wa-chat {
  flex: 1 1 auto;
  min-height: 160px;
  height: auto;
  gap: 12px;
  padding: 17px 15px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #8a9a9866 transparent;
  background-color: var(--wa-background);
  background-image: url('/img/chat-wallpaper.svg');
  background-size: 300px 340px;
}
.chat-phone .bubble { position: relative; flex-shrink: 0; max-width: 91%; border: 0; border-radius: 9px; padding: 9px 11px 6px; font-size: 12px; line-height: 1.55; box-shadow: 0 1px 1px #0b141a16; color: var(--wa-text); }
.chat-phone .bubble.in { background: var(--wa-incoming); border-top-left-radius: 0; }
.chat-phone .bubble.out { background: var(--wa-outgoing); border-top-right-radius: 0; }
.chat-phone .bubble::before { content: ''; position: absolute; top: 0; width: 7px; height: 10px; }
.chat-phone .bubble.in::before { left: -6px; background: var(--wa-incoming); clip-path: polygon(0 0,100% 0,100% 100%); }
.chat-phone .bubble.out::before { right: -6px; background: var(--wa-outgoing); clip-path: polygon(0 0,100% 0,0 100%); }
.bubble-text b { font-weight: 700; }
.message-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-height: 16px; margin-top: 2px; color: var(--wa-secondary); }
.chat-phone .bubble .time { font-size: 9px; margin: 0; line-height: 1; opacity: 1; }
.message-read { font-size: 15px; color: #008bb0; }
.dark .message-read { color: #53bdeb; }
.chat-phone .day-sep { align-self: center; flex-shrink: 0; padding: 4px 9px; margin-bottom: 4px; border-radius: 7px; background: var(--wa-incoming); color: var(--wa-secondary); font-size: 8px; font-weight: 600; letter-spacing: .04em; box-shadow: 0 1px 2px #0001; }
.chat-phone .wa-quick { flex: 0 0 auto; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; padding: 11px; border: 0; border-top: 1px solid var(--wa-divider); background: var(--wa-panel); }
.chat-phone .wa-quick:empty { display: none; }
.chat-phone .chip { min-height: 40px; padding: 7px 8px; border-radius: 18px; border: 1px solid var(--wa-divider); background: var(--wa-chip); color: var(--wa-accent); font-size: 10px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; transition: background-color 160ms ease, transform 160ms cubic-bezier(.23,1,.32,1); }
.chat-phone .chip.cta { grid-column: 1/-1; background: #008069; color: #fff; }
.wa-composer { flex: 0 0 43px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid var(--wa-divider); background: var(--wa-panel); color: var(--wa-secondary); }
.wa-composer p { flex: 1; min-width: 0; font-size: 10px; margin: 0; }
.wa-composer .material-symbols-outlined { font-size: 19px; }
.wa-composer > .material-symbols-outlined:last-child { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #008069; color: #fff; font-size: 17px; }
.chat-phone .demo-reset { flex: 0 0 39px; min-height: 39px; font-size: 10px; background: var(--wa-panel); color: var(--wa-accent); border-color: var(--wa-divider); }
.phone-home { flex: 0 0 19px; display: grid; place-items: center; background: var(--wa-panel); }
.phone-home::after { content: ''; width: 100px; height: 4px; border-radius: 9px; background: var(--wa-text); opacity: .65; }
.chat-phone .typing { display: flex; align-items: center; gap: 4px; padding: 5px 1px; min-height: 18px; }
.chat-phone .typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--wa-secondary); animation: chat-typing 850ms ease-in-out infinite; }
.chat-phone .typing span:nth-child(2) { animation-delay: 120ms; }
.chat-phone .typing span:nth-child(3) { animation-delay: 240ms; }
.chat-expanded { width: min(550px,calc(100% - 24px)); height: min(900px,calc(100dvh - 24px)); max-width: none; max-height: none; border: 0; padding: 0; margin: auto; background: transparent; color: var(--wa-text); overflow: visible; }
.chat-expanded:not([open]) { display: none; }
.chat-expanded::backdrop { background: #030a10c9; backdrop-filter: blur(6px); }
.chat-expanded .chat-phone { max-width: none; height: 100%; border-radius: 40px; }
.chat-expanded .wa-chat { padding: 20px 22px; }
.chat-expanded .bubble { font-size: 15px; max-width: 88%; padding: 11px 13px 7px; }
.chat-expanded .chip { min-height: 44px; font-size: 12px; }
.chat-expanded .wa-header { padding: 12px 16px; }
.chat-expanded .wa-header strong { font-size: 15px; }
.chat-expanded .wa-header small { font-size: 11px; }
.chat-expanded .wa-composer p { font-size: 12px; }
@media (hover: hover) and (pointer: fine) {
  .chat-expand:hover { background: #ffffff26; }
  .chat-phone .chip:hover { background: var(--wa-outgoing); border-color: var(--wa-accent); }
  .chat-phone .chip:active { transform: scale(.97); }
}
@media (max-width: 940px) {
  #demo .demo-grid { gap: 25px; padding: 26px; grid-template-columns: minmax(0,1fr) minmax(0,360px); }
}
@media (max-width: 760px) {
  #demo .demo-grid { grid-template-columns: minmax(0,1fr); gap: 26px; padding: 22px 16px; }
  #demo .demo-explainer { padding: 0 4px; }
  .phone.chat-phone { max-width: 370px; height: 670px; border-width: 6px; border-radius: 38px; }
  .chat-phone .wa-header { gap: 7px; padding-inline: 8px; }
  .wa-back { display: none; }
  .chat-phone .wa-header strong { font-size: 12px; }
  .chat-phone .wa-avatar { flex-basis: 34px; width: 34px; height: 34px; font-size: 20px; }
  .chat-expand { flex-basis: 40px; width: 40px; height: 40px; }
  .chat-expanded { width: calc(100% - 16px); height: calc(100dvh - 16px); }
  .chat-expanded .chat-phone { height: 100%; max-width: none; border-radius: 32px; }
  .chat-expanded .wa-chat { padding: 16px 14px; }
  .chat-expanded .bubble { font-size: 14px; }
  .chat-expanded .wa-header { padding: 10px 12px; }
  .chat-expanded .wa-header strong { font-size: 14px; }
}
@media (max-height: 560px) {
  .chat-expanded .phone-status, .chat-expanded .phone-home, .chat-expanded .wa-composer { display: none; }
  .chat-expanded .wa-header { min-height: 56px; padding-block: 6px; }
  .chat-expanded .wa-chat { min-height: 70px; }
  .chat-expanded .wa-quick { padding: 6px; gap: 4px; }
  .chat-expanded .chip { min-height: 34px; }
}
@keyframes chat-typing { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .chat-phone .typing span { animation: none; }
  .chat-phone .chip { transition: none; }
}
