/* ═══════════════════════════════════════════════════════
   DIVERGENT IA — WIDGET v1.0.0
   Design: Intercom-level polish
═══════════════════════════════════════════════════════ */

/* ── Brand font ──────────────────────────────────────── */
@font-face {
  font-family: 'Rosnoc';
  src: url('../fonts/Rosnoc.otf') format('opentype');
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────── */
#mptia-root {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  --c1: #00cacc;
  --c2: #0077b6;

  /* RGB components so alpha variants track --c1/--c2 changes */
  --c1-r: 0;   --c1-g: 202; --c1-b: 204;
  --c2-r: 0;   --c2-g: 119; --c2-b: 182;
  --c1-10: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.10);
  --c1-12: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.12);
  --c1-14: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.14);
  --c1-18: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.18);
  --c1-30: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.30);
  --c1-50: rgba(var(--c1-r), var(--c1-g), var(--c1-b), 0.50);
  --c2-30: rgba(var(--c2-r), var(--c2-g), var(--c2-b), 0.30);
  --c2-35: rgba(var(--c2-r), var(--c2-g), var(--c2-b), 0.35);
  --c2-40: rgba(var(--c2-r), var(--c2-g), var(--c2-b), 0.40);
  --c2-50: rgba(var(--c2-r), var(--c2-g), var(--c2-b), 0.50);

  --surf0: #ffffff;
  --surf1: #f5f7fa;
  --bd: #e8edf5;
  --txt1: #0b1320;
  --txt2: #5a6a82;
  --ghost: #a8b5c8;
  --head: #0b1829;
  --head2: #0d2040;
  --head3: #091520;
  --hdr-txt: #ffffff;
  --hdr-txt2: rgba(255,255,255,.55);
  --hdr-btn-bd: rgba(255,255,255,.14);
  --hdr-btn-bg: rgba(255,255,255,.08);
  --hdr-btn-ico: rgba(255,255,255,.7);
  --hdr-btn-hvr: rgba(255,255,255,.16);
  --hdr-btn-ico-hvr: #ffffff;
  --head-glow: rgba(0,202,204,.4);
  --menu-bg: #ffffff;
  --menu-sh: 0 8px 30px rgba(0,0,0,.2);
  --menu-bd: rgba(0,0,0,.06);
  --menu-txt: #1e293b;
  --menu-hvr: rgba(0,0,0,.06);
  --bot-sh: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --usr-sh: 0 2px 14px var(--c2-30, rgba(var(--c2-r), var(--c2-g), var(--c2-b), 0.3));
  --win-sh: 0 20px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.1), 0 0 0 1px rgba(0,0,0,.06);
  --r: 20px;
  --rb: 18px;
  --spring: cubic-bezier(.34,1.52,.64,1);
  --out: cubic-bezier(.16,1,.3,1);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --gap-diff: 12px;
  color-scheme: light dark;
  transition: background .25s ease, border-color .25s ease, color .25s ease;
}

/* Override with color-mix only where supported */
@supports (color: color-mix(in srgb, red, blue)) {
  #mptia-root {
    --c1-10: color-mix(in srgb, var(--c1) 10%, transparent);
    --c1-12: color-mix(in srgb, var(--c1) 12%, transparent);
    --c1-14: color-mix(in srgb, var(--c1) 14%, transparent);
    --c1-18: color-mix(in srgb, var(--c1) 18%, transparent);
    --c1-30: color-mix(in srgb, var(--c1) 30%, transparent);
    --c1-50: color-mix(in srgb, var(--c1) 50%, transparent);
    --c2-30: color-mix(in srgb, var(--c2) 30%, transparent);
    --c2-35: color-mix(in srgb, var(--c2) 35%, transparent);
    --c2-40: color-mix(in srgb, var(--c2) 40%, transparent);
    --c2-50: color-mix(in srgb, var(--c2) 50%, transparent);
  }
}

#mptia-root, #mptia-root * {
  box-sizing: border-box; margin: 0; padding: 0;
}

#mptia-root {
  font-family: var(--font);
  position: fixed !important;
  bottom: 24px; right: 24px;
  z-index: 2147483646;
}
#mptia-root.mptia-left { right: auto; left: 24px; }

/* ── Toggle Button ───────────────────────────────────── */
/* Floating bubble above button — Intercom style */
#mptia-bubble {
  position: absolute;
  bottom: 76px;
  right: 0;
  max-width: 340px;
  min-width: 240px;
  width: max-content;
  background: #1b1f2e;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.32), 0 2px 8px rgba(0,0,0,.18);
  cursor: pointer;
  animation: mptia-bubble-in .38s cubic-bezier(.34,1.56,.64,1) forwards;
  border: 1px solid rgba(255,255,255,.06);
}

@keyframes mptia-bubble-in {
  from { opacity:0; transform: translateY(12px) scale(.9); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* Header — X sempre visível */
#mptia-bubble-header {
  display: flex;
  justify-content: flex-end;
  height: 10px;
  margin-bottom: 2px;
}

#mptia-bubble-close {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .18s, background .15s, transform .2s cubic-bezier(.34,1.56,.64,1);
  line-height: 1;
  padding: 0;
  opacity: 0;
  margin-top: -6px;
}

#mptia-bubble:hover #mptia-bubble-close {
  opacity: 1;
}

#mptia-bubble-close:hover {
  background: rgba(255,255,255,.25);
}

#mptia-bubble-close svg {
  width: 12px;
  height: 12px;
  display: block;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}

#mptia-bubble-close:active,
#mptia-bubble-close.mptia-close-tap {
  transform: scale(.85);
}
#mptia-bubble-close:active svg,
#mptia-bubble-close.mptia-close-tap svg {
  transform: rotate(90deg) scale(.8);
}

/* Body — avatar + content (texto + time) lado a lado */
#mptia-bubble-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#mptia-bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--c1, #00cacc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 2px;
}

#mptia-bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

/* Content wrapper — texto + time na mesma coluna */
#mptia-bubble-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 6px;
}

/* Mensagem */
#mptia-bubble-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: rgba(255,255,255,.92);
  word-break: break-word;
}

/* Footer — "Nome • tempo" alinhado com o texto */
#mptia-bubble-time {
  font-size: 11.5px;
  color: rgba(255,255,255,.5);
  letter-spacing: .01em;
}

/* Dark mode bubble — elevates on dark backgrounds */
#mptia-root.mptia-dark #mptia-bubble {
  background: #2a3347;
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06);
}

#mptia-btn {
  position: relative;
  width: 60px; height: 60px;
  border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  box-shadow: 0 4px 20px var(--c2-35, rgba(0,119,182,.35)), 0 1px 4px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center;
  outline: none; -webkit-tap-highlight-color: transparent; touch-action: none;
  transition: transform .28s var(--spring, cubic-bezier(.34,1.52,.64,1)), box-shadow .35s ease, background .35s ease;
}
#mptia-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: var(--c1-18);
  animation: mptia-glow 2.4s ease-in-out infinite;
  z-index: -1;
}
@keyframes mptia-glow {
  0%   { transform: scale(1); opacity: .6; }
  50%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1); opacity: .6; }
}
#mptia-btn:hover { transform: scale(1.1); box-shadow: 0 10px 32px var(--c2-40, rgba(0,119,182,.4)), 0 2px 8px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.22); }
#mptia-btn:active { transform: scale(.88); transition-duration: .07s; }
#mptia-btn .ico { position: absolute; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;   transition: opacity .22s ease, transform .28s var(--spring, cubic-bezier(.34,1.52,.64,1)); }
#mptia-btn .ico svg { width: 100%; height: 100%; fill: #fff; }
#mptia-btn .ico-open  { opacity: 1; transform: scale(1) rotate(0deg); }
#mptia-btn .ico-close { opacity: 0; transform: scale(.3) rotate(-90deg); }
#mptia-root.open #mptia-btn .ico-open  { opacity: 0; transform: scale(.3) rotate(90deg); }
#mptia-root.open #mptia-btn .ico-close { opacity: 1; transform: scale(1) rotate(0deg); }

#mptia-dot {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px;
  background: #ff3b5c; border-radius: 11px; border: 2.5px solid #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  padding: 0 6px; line-height: 1;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(255,59,92,.35);
}
#mptia-dot.on {
  display: flex;
  animation: mptia-badge-pop .4s cubic-bezier(.34,1.52,.64,1) forwards,
             mptia-badge-attention 2.6s ease 1s infinite;
}
#mptia-dot::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; background: rgba(255,59,92,.2);
  animation: mptia-badge-pulse 2.4s ease infinite 1.2s;
  z-index: -1;
}
#mptia-dot:empty::after { display: none; }
@keyframes mptia-badge-pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes mptia-badge-attention {
  0%, 100% { transform: scale(1); }
  5% { transform: scale(1.15); }
  10% { transform: scale(1); }
  15% { transform: scale(1.1); }
  20% { transform: scale(1); }
}
@keyframes mptia-badge-pulse { 0%,100% { transform: scale(1); opacity: .5; } 50% { transform: scale(1.8); opacity: 0; } }

/* ── Window ──────────────────────────────────────────── */
#mptia-win {
  position: absolute; bottom: 76px; right: 0;
  width: 375px; height: 590px;
  display: flex; flex-direction: column;
  background: var(--surf1);
  border-radius: var(--r); overflow: hidden;
  box-shadow: var(--win-sh);
  opacity: 0; transform: translateY(18px) scale(.95);
  transform-origin: bottom right; pointer-events: none;
  transition: opacity .22s ease, transform .28s var(--out, cubic-bezier(.16,1,.3,1));
  will-change: opacity, transform;
}
#mptia-root.mptia-left #mptia-win { right: auto; left: 0; transform-origin: bottom left; }
#mptia-root.open #mptia-win { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ── Header ──────────────────────────────────────────── */
#mptia-head {
  flex-shrink: 0;
  background: linear-gradient(150deg, var(--head) 0%, var(--head2) 55%, var(--head3) 100%);
  padding: 12px 14px 10px;
  display: flex; align-items: center; gap: 8px;
  position: relative;
  min-height: 62px;
}
#mptia-head::after {
  content: ''; position: absolute;
  bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--head-glow, rgba(0,202,204,.4)) 30%, var(--c2-50, rgba(0,119,182,.5)) 70%, transparent);
}

/* Avatar */
#mptia-hav {
  flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.2);
  position: relative;
}
#mptia-hav::after { content: ''; position: absolute; inset: 0; border-radius: 12px; border: 1px solid rgba(255,255,255,.15); }
#mptia-hav svg { width: 20px; height: 20px; fill: #fff; }
#mptia-hav img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Info block — perfectly centered with avatar */
#mptia-hinfo {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
  align-self: center;
  line-height: 1;
}
#mptia-hname {
  font-size: 15px; font-weight: 600;
  letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--hdr-txt, #fff);
}
#mptia-hstatus {
  display: flex; align-items: center; gap: 5px;
  margin-top: 4px;
}
#mptia-hdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #20e070; flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(32,224,112,.6);
  animation: mptia-pulse 2.8s ease-out infinite;
}
@keyframes mptia-pulse { 0% { box-shadow: 0 0 0 0 rgba(32,224,112,.6); } 70% { box-shadow: 0 0 0 6px rgba(32,224,112,0); } 100% { box-shadow: 0 0 0 0 rgba(32,224,112,0); } }
@keyframes mpt-spin-dot { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }
#mptia-hstatus span {
  color: var(--hdr-txt2, rgba(255,255,255,.55));
  font-size: 11px; font-weight: 400;
}

/* Icon buttons — menu + close, perfectly aligned */
#mptia-menu-wrap { position: relative; flex-shrink: 0; display: flex; align-items: center; }
#mptia-menu-btn,
#mptia-hx {
  flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--hdr-btn-bd, rgba(255,255,255,.14));
  background: var(--hdr-btn-bg, rgba(255,255,255,.08));
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--hdr-btn-ico, rgba(255,255,255,.7));
  transition: background .18s, color .18s, transform .18s;
  padding: 0; line-height: 1; outline: none;
  -webkit-tap-highlight-color: transparent;
}
#mptia-menu-btn:hover,
#mptia-hx:hover {
  background: var(--hdr-btn-hvr, rgba(255,255,255,.16));
  color: var(--hdr-btn-ico-hvr, #fff);
}
#mptia-hx:hover { transform: rotate(90deg); }
#mptia-menu-btn:focus-visible,
#mptia-hx:focus-visible { outline: 2px solid var(--c1); outline-offset: 2px; }
#mptia-hx svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; }

/* Three-dots dropdown */
#mptia-menu-drop {
  display: none; position: absolute; z-index: 20;
  top: 100%; right: 0; left: auto; bottom: auto;
  min-width: 180px; margin-top: 6px;
  background: var(--menu-bg, #fff); border-radius: 12px;
  box-shadow: var(--menu-sh, 0 8px 30px rgba(0,0,0,.2));
  overflow: hidden; padding: 6px;
  border: 1px solid var(--menu-bd, rgba(0,0,0,.06));
}
#mptia-menu-drop button {
  display: block; width: 100%; padding: 9px 14px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; text-align: left;
  border-radius: 8px; transition: background .14s;
  white-space: nowrap;
  color: var(--menu-txt, #1e293b);
}
#mptia-menu-drop button:hover { background: var(--menu-hvr, rgba(0,0,0,.06)); }
#mptia-menu-drop button:focus-visible { outline: 2px solid var(--c1); outline-offset: -2px; }

/* ── Messages ────────────────────────────────────────── */
#mptia-msgs {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 20px 14px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surf1);
  scroll-behavior: smooth; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.1) transparent;
}

/* Preloader — three bouncing dots */
#mptia-loader {
  display: none; align-items: center; justify-content: center; gap: 6px;
  padding: 40px 0;
}
#mptia-loader span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c1);
  animation: mptia-loader-bounce 1.2s ease-in-out infinite;
}
#mptia-loader span:nth-child(2) { animation-delay: .16s; }
#mptia-loader span:nth-child(3) { animation-delay: .32s; }
@keyframes mptia-loader-bounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

#mptia-msgs::-webkit-scrollbar { width: 3px; }
#mptia-msgs::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 3px; }
#mptia-msgs::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.18); }

@keyframes mptia-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }

/* Quick reply chips */
#mptia-root .mptia-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 14px 8px;
  margin-left: 36px;
  animation: mptia-chips-in .35s cubic-bezier(.16,1,.3,1) both;
}
@keyframes mptia-chips-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#mptia-root .mptia-chip {
  background: var(--surf0); border: 1px solid var(--c1-30);
  color: var(--c1); border-radius: 16px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s;
  font-family: var(--font);
  animation: mptia-chip-in .4s cubic-bezier(.34,1.56,.64,1) both;
  animation-delay: inherit;
  user-select: none;
}
@keyframes mptia-chip-in {
  from { opacity: 0; transform: scale(.85) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
#mptia-root .mptia-chip:hover {
  background: var(--c1-10); border-color: var(--c1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--c1-18);
}
#mptia-root .mptia-chip:active {
  transform: scale(.94);
  transition-duration: .06s;
}

/* Copy-to-clipboard button on bot messages */
#mptia-root .mb-wrap { position: relative; flex: 1; min-width: 0; }
#mptia-root .mb-copy {
  position: absolute; top: 6px; right: 6px;
  background: var(--surf1); border: 1px solid var(--bd);
  border-radius: 6px; padding: 3px 6px;
  font-size: 11px; color: var(--txt2); cursor: pointer;
  opacity: 0; transition: opacity .15s;
  display: flex; align-items: center; gap: 3px;
  font-family: var(--font); z-index: 2;
}
#mptia-root .mb:hover .mb-copy { opacity: 1; }

/* Character counter */
#mptia-char-count {
  font-size: 10px; color: var(--ghost);
  text-align: right; padding: 0 16px 4px;
  display: none;
}
#mptia-char-count.warn { color: #e07020; display: block; }
#mptia-char-count.danger { color: #d03030; display: block; }

/* GDPR consent bar */
#mptia-consent {
  flex-shrink: 0;
  display: none;
  padding: 8px 14px 4px;
  background: var(--surf0);
  border-top: 1px solid var(--bd);
  font-size: 11px; color: var(--txt2); line-height: 1.4;
}
#mptia-consent label { display: flex; align-items: flex-start; gap: 6px; cursor: pointer; }
#mptia-consent input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }

/* Bot row */
#mptia-root .mb {
  display: flex; align-items: flex-end; gap: 8px;
  align-self: stretch; width: 100%;
  animation: mptia-in .22s var(--out, cubic-bezier(.16,1,.3,1)) both;
}
#mptia-root .mb + .mb                       { margin-top: 3px; }
#mptia-root .mu + .mb,
#mptia-root .mwa-wrap + .mb,
#mptia-root .merr + .mb                     { margin-top: 12px; }

#mptia-root .mb-av {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: 1px;
  box-shadow: 0 1px 5px rgba(0,0,0,.12);
}
#mptia-root .mb-av svg { width: 14px; height: 14px; fill: #fff; }
#mptia-root .mb-av img { width: 28px; height: 28px; object-fit: cover; }
#mptia-root .mb.grp .mb-av { visibility: hidden; }

#mptia-root .mb-txt {
  background: var(--surf0); color: #1a2535;
  padding: 9px 14px;
  border-radius: var(--rb) var(--rb) var(--rb) 5px;
  font-size: 13.5px; font-weight: 400; line-height: 1.6;
  word-break: break-word; overflow-wrap: anywhere; white-space: pre-line;
  box-shadow: var(--bot-sh); border: 1px solid rgba(0,0,0,.04);
  min-width: 0; flex: 1 1 auto; max-width: 100%;
}
/* Grouped bot bubbles — middle of sequence: no tail */
#mptia-root .mb.grp .mb-txt {
  border-radius: 5px var(--rb) var(--rb) 5px;
}
/* First bot bubble — tail only at bottom-left */
#mptia-root .mb.grp-first .mb-txt {
  border-radius: var(--rb) var(--rb) var(--rb) 5px;
}
#mptia-root .mb-txt a { color: var(--c2); text-decoration: underline; }
#mptia-root .mb-ts {
  color: var(--ghost); font-size: 10.5px; letter-spacing: .02em;
  margin-top: 3px; padding-left: 0; user-select: none;
}
#mptia-root .mb.grp .mb-ts { padding-left: 0; }

/* User row */
#mptia-root .mu {
  display: flex; justify-content: flex-end;
  align-self: flex-end; max-width: min(80%, 285px);
  animation: mptia-in .22s var(--out) both;
}
#mptia-root .mu + .mu                       { margin-top: 3px; }
#mptia-root .mb + .mu,
#mptia-root .mwa-wrap + .mu,
#mptia-root .merr + .mu                     { margin-top: 12px; }

#mptia-root .mu-txt {
  background: linear-gradient(145deg, var(--c1), var(--c2)); color: #fff;
  padding: 9px 14px;
  border-radius: var(--rb) var(--rb) 5px var(--rb);
  font-size: 13.5px; line-height: 1.55;
  word-break: break-word; overflow-wrap: anywhere; white-space: pre-line;
  box-shadow: var(--usr-sh); min-width: 0;
}
/* Grouped user bubbles — middle: no tail */
#mptia-root .mu.grp .mu-txt {
  border-radius: var(--rb) 5px 5px var(--rb);
}
/* First user bubble */
#mptia-root .mu.grp-first .mu-txt {
  border-radius: var(--rb) var(--rb) 5px var(--rb);
}
#mptia-root .mu-txt a { color: rgba(255,255,255,.85); text-decoration: underline; }

/* Typing indicator */
#mptia-root .mptyp {
  display: flex; align-items: flex-end; gap: 8px;
  align-self: flex-start; margin-top: 10px;
  animation: mptia-in .2s ease both;
}
#mptia-root .mptyp-bub {
  background: var(--surf0);
  border-radius: var(--rb) var(--rb) var(--rb) 5px;
  padding: 11px 14px; display: flex; gap: 4px; align-items: center;
  box-shadow: var(--bot-sh); border: 1px solid rgba(0,0,0,.04);
}
#mptia-root .mptyp-bub span {
  display: block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ghost);
  animation: mptia-dot-bounce .9s ease infinite;
}
#mptia-root .mptyp-bub span:nth-child(2) { animation-delay: .15s; }
#mptia-root .mptyp-bub span:nth-child(3) { animation-delay: .30s; }
@keyframes mptia-dot-bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* Error card */
#mptia-root .merr {
  align-self: flex-start; display: flex; align-items: center; gap: 10px;
  background: var(--surf0); border: 1px solid #ffd6d6;
  border-radius: 14px; padding: 11px 14px;
  max-width: min(84%, 300px); animation: mptia-in .2s ease both;
  box-shadow: var(--bot-sh); margin-top: 10px;
}
#mptia-root .merr-ico { flex-shrink: 0; width: 15px; height: 15px; }
#mptia-root .merr-ico svg { width: 15px; height: 15px; fill: #e53e3e; }
#mptia-root .merr-txt { color: var(--txt2); font-size: 13px; flex: 1; }
#mptia-root .merr-btn {
  flex-shrink: 0; background: linear-gradient(145deg, var(--c1), var(--c2));
  color: #fff; border: none; border-radius: 20px;
  padding: 5px 13px; font-size: 12px; font-weight: 600;
  font-family: var(--font); cursor: pointer;
  transition: opacity .15s, transform .18s var(--spring, cubic-bezier(.34,1.52,.64,1));
}
#mptia-root .merr-btn:hover { opacity: .88; transform: scale(1.05); }

/* WhatsApp CTA */
#mptia-root .mwa-wrap {
  align-self: flex-start; max-width: min(84%, 300px);
  animation: mptia-in .24s var(--out, cubic-bezier(.16,1,.3,1)) both; margin-top: 10px;
}
#mptia-root .mwa-card {
  background: var(--surf0); border: 1px solid var(--bd);
  border-radius: 16px; padding: 13px 14px;
  box-shadow: var(--bot-sh); display: flex; flex-direction: column; gap: 9px;
}
#mptia-root .mwa-label { color: var(--txt2); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
#mptia-root .mwa-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(145deg, #25d366, #1aad4d);
  color: #fff; text-decoration: none; border-radius: 10px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 600;
  font-family: var(--font); box-shadow: 0 3px 12px rgba(37,211,102,.3);
  transition: transform .2s var(--spring, cubic-bezier(.34,1.52,.64,1)), box-shadow .2s ease;
  -webkit-tap-highlight-color: transparent;
}
#mptia-root .mwa-link:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,211,102,.4); }
#mptia-root .mwa-link:active { transform: scale(.96); }
#mptia-root .mwa-link svg { width: 17px; height: 17px; fill: #fff; flex-shrink: 0; }

/* ── Input area ──────────────────────────────────────── */
#mptia-input-wrap {
  flex-shrink: 0; background: var(--surf0);
  border-top: 1px solid var(--bd); padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  overflow: hidden;
}
#mptia-form { display: flex; align-items: flex-end; gap: 8px; width: 100%; }

#mptia-inp {
  flex: 1; background: var(--surf1);
  border: 1.5px solid var(--bd); border-radius: 22px;
  padding: 9px 16px; font-size: 13.5px;
  font-family: var(--font); color: var(--txt1);
  resize: none; outline: none; line-height: 1.5;
  min-height: 40px; max-height: 110px;
  overflow-y: hidden; display: block; width: 100%;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
#mptia-inp:focus { border-color: var(--c1); background: var(--surf0);   box-shadow: 0 0 0 3px var(--c1-12, rgba(0,202,204,.12)); }
#mptia-inp::placeholder { color: #9CA3AF !important; font-size: 12px !important; line-height: 1.5 !important; font-weight: 400 !important; opacity: .45 !important; font-style: italic !important; }
#mptia-inp:-ms-input-placeholder { color: #9CA3AF !important; font-size: 12px !important; line-height: 1.5 !important; font-weight: 400 !important; opacity: .45 !important; font-style: italic !important; }
#mptia-inp::-webkit-input-placeholder { color: #9CA3AF !important; font-size: 12px !important; line-height: 1.5 !important; font-weight: 400 !important; opacity: .45 !important; font-style: italic !important; }
#mptia-inp:disabled { opacity: .5; cursor: not-allowed; }

#mptia-sbtn {
  flex-shrink: 0; width: 40px; height: 40px;
  border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(145deg, var(--c1), var(--c2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px var(--c2-30, rgba(0,119,182,.3)), inset 0 1px 0 rgba(255,255,255,.2);
  outline: none; -webkit-tap-highlight-color: transparent;
  transition: transform .22s var(--spring, cubic-bezier(.34,1.52,.64,1)), box-shadow .18s ease, opacity .15s;
  position: relative; overflow: hidden;
}
#mptia-sbtn:hover { transform: scale(1.1); box-shadow: 0 4px 18px var(--c2-40, rgba(0,119,182,.4)); }
#mptia-sbtn:active { transform: scale(.88); transition-duration: .07s; }
#mptia-sbtn:disabled { opacity: .3; cursor: not-allowed; transform: none !important; box-shadow: none; pointer-events: none; }
#mptia-sbtn[data-loading] { opacity: 1; cursor: wait; pointer-events: none; transform: none !important; }
#mptia-sbtn svg { width: 17px; height: 17px; fill: #fff; transform: translateX(1px); position: relative; }

/* ── Square shape (Intercom style) ───────────────────── */
#mptia-root.mptia-shape-square #mptia-btn {
  width: 56px; height: 56px;
  border-radius: 16px;
}
#mptia-root.mptia-shape-square #mptia-win {
  border-radius: 14px;
}
#mptia-root.mptia-shape-square #mptia-hav {
  border-radius: 12px;
}
#mptia-root.mptia-shape-square #mptia-hav::after {
  border-radius: 12px;
}
#mptia-root.mptia-shape-square .mb-av {
  border-radius: 10px;
}
@media (max-width: 500px) {
  #mptia-root.mptia-shape-square #mptia-btn {
    width: 52px; height: 52px;
    border-radius: 14px;
  }
  #mptia-root.mptia-shape-square #mptia-win {
    border-radius: 20px 20px 0 0;
  }
}

/* ── Brand footer ────────────────────────────────────── */
#mptia-brand {
  flex-shrink: 0; text-align: center;
  padding: 5px 0 7px; font-size: 10.5px; color: var(--ghost);
  background: var(--surf0); border-top: 1px solid var(--bd); letter-spacing: .01em;
}
#mptia-brand a { color: var(--txt2); text-decoration: none; font-weight: 500; font-family: 'Rosnoc', var(--font); letter-spacing: .01em; transition: color .15s; }
#mptia-brand a:hover { color: var(--c1); }

/* ── Mobile ≤ 500px ──────────────────────────────────── */
@media (max-width: 500px) {
  #mptia-root { bottom: 14px; right: 14px; }
  #mptia-root.mptia-left { right: auto; left: 14px; }
  #mptia-btn { width: 56px; height: 56px; }
  #mptia-btn::before { display: none; }
  #mptia-win { position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; overflow: visible; overscroll-behavior: contain; transform: translateY(100%); }
  #mptia-root.open #mptia-win { transform: translateY(0); }
  #mptia-modal-overlay, #mptia-loading-overlay { border-radius: 0; }
  #mptia-msgs { flex: 1; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; padding: 14px 12px 8px; }
  #mptia-input-wrap { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)); }
  #mptia-root .mu { max-width: 92%; }
  #mptia-root .merr, #mptia-root .mwa-wrap { max-width: 92%; }
  #mptia-root .mb-txt, #mptia-root .mu-txt { font-size: 15px; }
  #mptia-root .mb-wrap { flex: 1; min-width: 0; }
  #mptia-inp { font-size: 16px; }
  #mptia-inp::placeholder,
  #mptia-inp::-webkit-input-placeholder,
  #mptia-inp:-ms-input-placeholder { font-size: 14px !important; }
  #mptia-head { padding: 16px 16px 14px; min-height: 76px; }
  #mptia-head::after { height: 2px; }
  #mptia-hav { width: 48px; height: 48px; border-radius: 14px; }
  #mptia-hav::after { border-radius: 14px; }
  #mptia-hname { font-size: 18px; }
  #mptia-hstatus span { font-size: 13px; }
  #mptia-menu-btn, #mptia-hx { width: 36px; height: 36px; }
  #mptia-bubble { bottom: 72px; right: 0; max-width: calc(100vw - 56px); min-width: 220px; font-size: 14px; padding: 12px 16px; }
  #mptia-root.open #mptia-bubble { display: none; }
  #mptia-bubble-text { font-size: 14px; }
  #mptia-bubble-time { font-size: 12px; }
  #mptia-bubble-close { opacity: 1; width: 28px; height: 28px; margin-top: -10px; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
  #mptia-bubble-close svg { width: 16px; height: 16px; }
}

/* ── Tablet ──────────────────────────────────────────── */
@media (min-width: 501px) and (max-width: 768px) {
  #mptia-win { width: 400px; height: 560px; }
  #mptia-bubble { max-width: 340px; bottom: 76px; padding: 12px 16px; }
  #mptia-root.open #mptia-bubble { display: none; }
  #mptia-bubble-close { opacity: 1; width: 26px; height: 26px; margin-top: -9px; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
  #mptia-bubble-close svg { width: 15px; height: 15px; }
}

/* ── Desktop ≥ 769px ─────────────────────────────────── */
@media (min-width: 769px) {
  #mptia-win { width: 380px; height: min(620px, 75vh); }
  #mptia-root .mu { max-width: min(80%, 285px); }
  #mptia-root .mb-txt, #mptia-root .mu-txt { font-size: 14px; }
  #mptia-root .merr, #mptia-root .mwa-wrap { max-width: min(75%, 330px); }
  #mptia-msgs { padding: 20px 14px 12px; gap: 8px; }
  #mptia-inp { font-size: 14px; }
  #mptia-head { padding: 14px 16px 12px; min-height: 66px; }
  #mptia-hav { width: 44px; height: 44px; }
  #mptia-hname { font-size: 15px; }
  #mptia-hstatus span { font-size: 11px; }
}

/* ── Large Desktop ≥ 1200px ───────────────────────────── */
@media (min-width: 1200px) {
  #mptia-win { width: 400px; height: min(660px, 78vh); }
  #mptia-root .mu { max-width: min(80%, 300px); }
  #mptia-root .mb-txt, #mptia-root .mu-txt { font-size: 14.5px; }
  #mptia-root .merr, #mptia-root .mwa-wrap { max-width: min(80%, 360px); }
  #mptia-msgs { padding: 22px 16px 14px; gap: 9px; }
  #mptia-inp { font-size: 14px; padding: 10px 18px; }
  #mptia-head { padding: 16px 18px 12px; min-height: 70px; }
  #mptia-hav { width: 46px; height: 46px; }
  #mptia-hname { font-size: 16px; }
  #mptia-hstatus span { font-size: 12px; }
  #mptia-brand { padding: 6px 0 8px; font-size: 11px; }
}

/* ── Light mode ─────────────────────────────────────────── */
#mptia-root.mptia-light {
  --head:  #f0f6ff;
  --head2: #e8f0fe;
  --head3: #dfe9fa;
  --hdr-txt: #0b1829;
  --hdr-txt2: #6b7a99;
  --hdr-btn-bd: rgba(0,0,0,.08);
  --hdr-btn-bg: rgba(255,255,255,.6);
  --hdr-btn-ico: rgba(0,0,0,.4);
  --hdr-btn-hvr: rgba(255,255,255,.95);
  --hdr-btn-ico-hvr: rgba(0,0,0,.75);
  --head-glow: rgba(var(--c1-r), var(--c1-g), var(--c1-b), .15);
  --menu-bg: #fff;
  --menu-sh: 0 8px 30px rgba(0,0,0,.12);
  --menu-bd: rgba(0,0,0,.06);
  --menu-txt: #1e293b;
  --menu-hvr: rgba(0,0,0,.04);
}
#mptia-root.mptia-light #mptia-head {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
#mptia-root.mptia-light #mptia-head::after {
  opacity: .6;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.04) 30%, rgba(0,0,0,.06) 70%, transparent);
}
#mptia-root.mptia-light #mptia-hav {
  box-shadow: 0 2px 8px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.25);
}
#mptia-root.mptia-light #mptia-hav::after {
  border-color: rgba(0,0,0,.06);
}

/* ── Dark mode ──────────────────────────────────────────── */
#mptia-root.mptia-dark {
  --surf0: #1e2330;
  --surf1: #171c28;
  --bd:    #2a3347;
  --txt1:  #e8edf5;
  --txt2:  #8a9bb8;
  --ghost: #4a5a72;
  --head:  #0d1520;
  --head2: #091018;
  --head3: #080e18;
  --hdr-txt: #f1f5f9;
  --hdr-txt2: rgba(255,255,255,.5);
  --hdr-btn-bd: rgba(255,255,255,.12);
  --hdr-btn-bg: rgba(255,255,255,.06);
  --hdr-btn-ico: rgba(255,255,255,.6);
  --hdr-btn-hvr: rgba(255,255,255,.14);
  --hdr-btn-ico-hvr: #fff;
  --head-glow: rgba(var(--c1-r), var(--c1-g), var(--c1-b), .35);
  --menu-bg: #1e293b;
  --menu-sh: 0 8px 30px rgba(0,0,0,.5);
  --menu-bd: rgba(255,255,255,.08);
  --menu-txt: #e2e8f0;
  --menu-hvr: rgba(255,255,255,.08);
}
#mptia-root.mptia-dark #mptia-head::after {
  opacity: .6;
}
#mptia-root.mptia-dark .mb-txt {
  background: #222b3a;
  color: #dde4f0;
  border-color: rgba(255,255,255,.05);
}

#mptia-root.mptia-dark #mptia-msgs::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12);
}

#mptia-root.mptia-dark #mptia-msgs::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.2);
}

#mptia-root.mptia-dark #mptia-msgs {
  scrollbar-color: rgba(255,255,255,.12) transparent;
}
#mptia-root.mptia-dark #mptia-msgs {
  background: var(--surf1);
}
#mptia-root.mptia-dark #mptia-input-wrap {
  background: var(--surf0);
  border-top-color: var(--bd);
}
#mptia-root.mptia-dark #mptia-inp {
  background: #1a2236;
  color: var(--txt1);
  border-color: var(--bd);
}
#mptia-root.mptia-dark #mptia-inp::placeholder {
  color: #6B7280 !important; font-size: 12px !important; line-height: 1.5 !important; font-weight: 400 !important; opacity: .4 !important; font-style: italic !important;
}

#mptia-root.mptia-dark .merr {
  border-color: #5a2a2a;
}
#mptia-root.mptia-dark .merr-ico svg {
  fill: #f06a6a;
}
#mptia-root.mptia-dark .merr-txt {
  color: var(--txt1);
}

#mptia-root.mptia-dark #mptia-brand {
  background: var(--surf0);
  border-top-color: var(--bd);
}

@media (prefers-color-scheme: dark) {
  #mptia-root:not(.mptia-light) {
    color-scheme: dark;
    --surf0: #1e2330;
    --surf1: #171c28;
    --bd:    #2a3347;
    --txt1:  #e8edf5;
    --txt2:  #8a9bb8;
    --ghost: #4a5a72;
    --head:  #0d1520;
    --head2: #091018;
    --head3: #080e18;
    --hdr-txt: #f1f5f9;
    --hdr-txt2: rgba(255,255,255,.5);
    --hdr-btn-bd: rgba(255,255,255,.12);
    --hdr-btn-bg: rgba(255,255,255,.06);
    --hdr-btn-ico: rgba(255,255,255,.6);
    --hdr-btn-hvr: rgba(255,255,255,.14);
    --hdr-btn-ico-hvr: #fff;
    --head-glow: rgba(var(--c1-r), var(--c1-g), var(--c1-b), .35);
    --menu-bg: #1e293b;
    --menu-sh: 0 8px 30px rgba(0,0,0,.5);
    --menu-bd: rgba(255,255,255,.08);
    --menu-txt: #e2e8f0;
    --menu-hvr: rgba(255,255,255,.08);
  }
  #mptia-root:not(.mptia-light) #mptia-head::after {
    opacity: .6;
  }
  #mptia-root:not(.mptia-light) .mb-txt {
    background: #222b3a;
    color: #dde4f0;
    border-color: rgba(255,255,255,.05);
  }
  #mptia-root:not(.mptia-light) #mptia-msgs {
    background: var(--surf1);
  }
  #mptia-root:not(.mptia-light) #mptia-input-wrap {
    background: var(--surf0);
    border-top-color: var(--bd);
  }
  #mptia-root:not(.mptia-light) #mptia-inp {
    background: #1a2236;
    color: var(--txt1);
    border-color: var(--bd);
  }
  #mptia-root:not(.mptia-light) #mptia-inp::placeholder {
    color: #6B7280 !important; font-size: 12px !important; line-height: 1.5 !important; font-weight: 400 !important; opacity: .4 !important; font-style: italic !important;
  }

  #mptia-root:not(.mptia-light) #mptia-msgs::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
  }
  #mptia-root:not(.mptia-light) #mptia-msgs::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.2);
  }
  #mptia-root:not(.mptia-light) #mptia-msgs {
    scrollbar-color: rgba(255,255,255,.12) transparent;
  }

  #mptia-root:not(.mptia-light) .merr {
    border-color: #5a2a2a;
  }
  #mptia-root:not(.mptia-light) .merr-ico svg {
    fill: #f06a6a;
  }
  #mptia-root:not(.mptia-light) .merr-txt {
    color: var(--txt1);
  }

  #mptia-root:not(.mptia-light) #mptia-brand {
    background: var(--surf0);
    border-top-color: var(--bd);
  }

  #mptia-root:not(.mptia-light) #mptia-bubble {
    background: #2a3347;
    border-color: rgba(255,255,255,.08);
    box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.25), 0 0 0 1px rgba(255,255,255,.06);
  }
}

/* ── Focus-visible — keyboard accessibility ──────────── */
#mptia-btn:focus-visible,
#mptia-sbtn:focus-visible,
#mptia-hx:focus-visible,
#mptia-bubble-close:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}
#mptia-root .mptia-chip:focus-visible,
#mptia-root .merr-btn:focus-visible,
#mptia-root .mwa-link:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}
#mptia-inp:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--c1-30);
}
#mptia-consent input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

/* ── Shake animation for input validation ───────────── */
@keyframes mptia-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
#mptia-inp.mptia-shake {
  animation: mptia-shake 0.4s ease;
}

/* ── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #mptia-root *, #mptia-root *::before, #mptia-root *::after {
    animation-duration: .01ms !important; transition-duration: .01ms !important;
  }
}

/* ── Custom confirm modal (replaces native confirm()) ──── */
#mptia-modal-overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-radius: var(--r); overflow: hidden;
}
#mptia-modal {
  background: var(--surf0);
  border-radius: 12px;
  padding: 24px 20px 20px;
  max-width: 280px;
  width: 100%;
  text-align: center;
  box-shadow: var(--menu-sh, 0 8px 30px rgba(0,0,0,.2));
  font-family: var(--font);
  animation: mptia-modal-in .2s ease;
}
@keyframes mptia-modal-in {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}
#mptia-modal-msg {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--txt1);
  margin-bottom: 18px;
}
#mptia-modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
#mptia-modal-confirm,
#mptia-modal-cancel {
  flex: 1;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity .15s, transform .18s var(--spring, cubic-bezier(.34,1.52,.64,1));
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
#mptia-modal-confirm {
  background: linear-gradient(145deg, var(--c1), var(--c2));
  color: #fff;
  box-shadow: 0 2px 10px var(--c2-30, rgba(0,119,182,.3));
}
#mptia-modal-cancel {
  background: var(--surf1);
  color: var(--txt2);
  border: 1px solid var(--bd);
}
#mptia-modal-confirm:hover {
  opacity: .88;
  transform: scale(1.04);
}
#mptia-modal-cancel:hover {
  background: var(--bd);
}
#mptia-modal-confirm:active {
  transform: scale(.94);
  transition-duration: .07s;
}
#mptia-modal-cancel:active {
  transform: scale(.96);
  transition-duration: .07s;
}
#mptia-modal-confirm:focus-visible,
#mptia-modal-cancel:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
}

/* Mobile modal adjustments */
@media (max-width: 500px) {
  #mptia-modal-overlay { padding: 16px; }
  #mptia-modal { padding: 20px 16px 16px; }
  #mptia-modal-msg { font-size: 14px; }
  #mptia-modal-confirm,
  #mptia-modal-cancel { font-size: 14px; padding: 10px 16px; }
}

/* ── Loading overlay (spinner + message) ──────────────── */
#mptia-loading-overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(255,255,255,.8);
  z-index: 19;
  border-radius: var(--r); overflow: hidden;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  animation: mptia-overlay-in .15s ease;
}
.mptia-dark #mptia-loading-overlay {
  background: rgba(30,30,30,.8);
}
@keyframes mptia-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.mptia-loading-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--c1-18);
  border-top-color: var(--c1);
  border-radius: 50%;
  animation: mptia-spin .7s linear infinite;
}
@keyframes mptia-spin {
  to { transform: rotate(360deg); }
}
.mptia-loading-msg {
  font-size: 12px;
  color: var(--txt2);
}
