/* SPM Grand Mahal: chat bubble (bottom-left). Scoped under .spmc so it can't clash with the page. */
.spmc {
  --spmc-bg: #1d0b0e;          /* maroon-black */
  --spmc-panel: #26100f;
  --spmc-maroon: #6e1423;
  --spmc-gold: #d4a64a;        /* temple gold */
  --spmc-gold-soft: rgba(212, 166, 74, .18);
  --spmc-text: #f8f1e4;        /* jasmine white */
  --spmc-muted: #cbb9a0;
  --spmc-wa: #25d366;
  --spmc-radius: 18px;
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9000;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--spmc-text);
}
.spmc[lang="ta"] { line-height: 1.7; font-family: "Noto Sans Tamil", "Noto Serif Tamil", "Nirmala UI", "Latha", system-ui, sans-serif; }
.spmc *, .spmc *::before, .spmc *::after { box-sizing: border-box; }
.spmc svg { width: 20px; height: 20px; flex: none; display: block; }

/* ---------- bubble ---------- */
.spmc-bubble {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px 0 8px;
  border: 1px solid var(--spmc-gold); border-radius: 999px;
  background: linear-gradient(135deg, var(--spmc-maroon), var(--spmc-bg));
  color: var(--spmc-text); font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 0 0 4px var(--spmc-gold-soft);
  transition: transform .2s ease, box-shadow .2s ease;
}
.spmc-bubble:hover { transform: translateY(-2px); }
.spmc-bubble:focus-visible, .spmc button:focus-visible, .spmc a:focus-visible, .spmc-input:focus-visible {
  outline: 2px solid var(--spmc-gold); outline-offset: 2px;
}
.spmc-bubble-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--spmc-gold); color: var(--spmc-bg);
}
.spmc-bubble-icon svg { width: 22px; height: 22px; }
.spmc.is-open .spmc-bubble { padding-right: 8px; }
.spmc.is-open .spmc-bubble-label { display: none; }

/* ---------- panel ---------- */
.spmc-panel {
  position: absolute; left: 0; bottom: 70px;
  width: min(370px, calc(100vw - 32px));
  height: min(580px, calc(100vh - 120px));
  height: min(580px, calc(100dvh - 120px));
  display: flex; flex-direction: column;
  background: var(--spmc-panel);
  border: 1px solid rgba(212, 166, 74, .45); border-radius: var(--spmc-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  overflow: hidden;
  animation: spmc-in .22s ease-out;
}
.spmc-panel[hidden] { display: none; }
@keyframes spmc-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.spmc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, var(--spmc-maroon), #3a1216);
  border-bottom: 1px solid rgba(212, 166, 74, .35);
}
.spmc-mark {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--spmc-gold); color: var(--spmc-gold);
  font: 700 11px/1 Georgia, "Times New Roman", serif; letter-spacing: .08em;
}
.spmc-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.spmc-title { font-size: 15.5px; color: var(--spmc-text); line-height: 1.35; }
.spmc-sub { font-size: 12.5px; color: var(--spmc-muted); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spmc-close {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%;
  background: transparent; color: var(--spmc-text); cursor: pointer;
  display: grid; place-items: center;
}
.spmc-close:hover { background: rgba(255, 255, 255, .08); }

.spmc-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.spmc-msg {
  max-width: 88%; padding: 9px 13px; border-radius: 14px;
  white-space: normal; overflow-wrap: anywhere; font-size: 14.5px;
}
.spmc-bot { align-self: flex-start; background: rgba(255, 255, 255, .06); border: 1px solid rgba(212, 166, 74, .2); border-bottom-left-radius: 4px; }
.spmc-user { align-self: flex-end; background: var(--spmc-gold); color: var(--spmc-bg); border-bottom-right-radius: 4px; font-weight: 500; }
.spmc-typing { color: var(--spmc-muted); font-style: italic; }

.spmc-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 14px 10px; max-height: 132px; overflow-y: auto;
}
.spmc-chips:empty { display: none; }
.spmc-chip {
  display: inline-flex; align-items: center;
  min-height: 34px; padding: 5px 12px;
  border: 1px solid rgba(212, 166, 74, .55); border-radius: 999px;
  background: transparent; color: var(--spmc-text);
  font: inherit; font-size: 13px; text-decoration: none; cursor: pointer;
}
.spmc-chip:hover { background: var(--spmc-gold-soft); }
.spmc-chip-gold { background: var(--spmc-gold); color: var(--spmc-bg); border-color: var(--spmc-gold); font-weight: 600; }
.spmc-chip-gold:hover { background: #e2b85f; }
.spmc-chip-wa { border-color: var(--spmc-wa); }

.spmc-handoffs { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid rgba(212, 166, 74, .2); }
.spmc-handoff {
  flex: 1; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 12px; font-size: 13.5px; font-weight: 600; text-decoration: none; text-align: center;
}
.spmc-wa { background: var(--spmc-wa); color: #06341a; }
.spmc-call { background: transparent; color: var(--spmc-gold); border: 1px solid var(--spmc-gold); }
.spmc-handoff:hover { filter: brightness(1.08); }

.spmc-form { display: flex; gap: 8px; padding: 0 14px 14px; }
.spmc-input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px;
  border: 1px solid rgba(212, 166, 74, .4); border-radius: 12px;
  background: rgba(0, 0, 0, .25); color: var(--spmc-text);
  font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
.spmc-input::placeholder { color: var(--spmc-muted); opacity: .8; }
.spmc-send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px;
  background: var(--spmc-gold); color: var(--spmc-bg); cursor: pointer;
  display: grid; place-items: center;
}
.spmc.is-busy .spmc-send { opacity: .5; cursor: wait; }

/* ---------- phones ---------- */
@media (max-width: 480px) {
  .spmc-bubble-label { display: none; }
  .spmc-bubble { padding: 0 8px; }
  .spmc-panel { width: calc(100vw - 32px); height: calc(100vh - 110px); height: calc(100dvh - 110px); }
}

@media (prefers-reduced-motion: reduce) {
  .spmc-panel { animation: none; }
  .spmc-bubble { transition: none; }
}
