/**
 * CPMBazar Chatbot Widget Stylesheet.
 * Clean Graphite/Ink neutral + Cobalt Blue accent chat UI.
 */

:root {
  --cpm-chat-bg: #121722;
  --cpm-chat-surface: #171d2b;
  --cpm-chat-surface-hover: #1e2638;
  --cpm-chat-border: rgba(148, 163, 184, 0.16);
  --cpm-chat-primary: #2563eb;
  --cpm-chat-primary-hover: #1d4ed8;
  --cpm-chat-text: #f1f5f9;
  --cpm-chat-muted: #94a3b8;
  --cpm-chat-user-bubble: #1d4ed8;
  --cpm-chat-bot-bubble: #171d2b;
  --cpm-chat-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --cpm-chat-bg: #FFFFFF;
  --cpm-chat-surface: #F8FAFC;
  --cpm-chat-surface-hover: #F1F5F9;
  --cpm-chat-border: #CBD5E1;
  --cpm-chat-primary: #2563eb;
  --cpm-chat-primary-hover: #1d4ed8;
  --cpm-chat-text: #0F172A;
  --cpm-chat-muted: #475569;
  --cpm-chat-user-bubble: #2563eb;
  --cpm-chat-bot-bubble: #F1F5F9;
  --cpm-chat-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .cpm-chat-input-field {
  background: #FFFFFF !important;
  color: #0F172A !important;
  border-color: #CBD5E1 !important;
}

[data-theme="light"] .cpm-chat-teaser {
  background: #FFFFFF;
  border-color: #CBD5E1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

/* Floating Launcher Button */
.cpm-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: 1px solid #2563eb;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-chat-launcher, 400);
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1), border-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .cpm-chat-launcher:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
  }
}

.cpm-chat-launcher:active {
  transform: translateY(0);
}

.cpm-chat-launcher svg {
  width: 26px;
  height: 26px;
  transition: transform 0.2s ease;
}

.cpm-chat-launcher.is-active svg {
  transform: rotate(90deg);
}

.cpm-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2px solid var(--cpm-chat-bg, #121722);
  border-radius: 50%;
}

/* Floating Welcome Teaser Bubble (First-time visitors only) */
.cpm-chat-teaser {
  position: fixed;
  bottom: 24px;
  right: 92px;
  max-width: 290px;
  background: var(--cpm-chat-bg);
  border: 1px solid var(--cpm-chat-border);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(79, 126, 240, 0.15);
  padding: 12px 14px;
  z-index: var(--z-chat-teaser, 390);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--cpm-chat-text);
  font-size: 0.82rem;
  line-height: 1.4;
  box-sizing: border-box;
  animation: cpmTeaserFadeIn 0.25s ease-out;
}

.cpm-chat-teaser-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  outline: none;
}
.cpm-chat-teaser-content:focus-visible {
  outline: 2px solid var(--cpm-chat-primary);
  border-radius: 6px;
}

.cpm-chat-teaser-title {
  font-weight: 700;
  color: var(--accent, #60a5fa);
  font-size: 0.84rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cpm-chat-teaser-text {
  color: var(--cpm-chat-text);
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0;
}

.cpm-chat-teaser-bn {
  color: var(--cpm-chat-muted);
  font-size: 0.72rem;
  line-height: 1.3;
  margin-top: 4px;
}

.cpm-chat-teaser-close {
  background: none;
  border: none;
  color: var(--cpm-chat-muted);
  cursor: pointer;
  padding: 4px;
  margin: -4px -4px 0 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 150ms ease, background-color 150ms ease;
  min-width: 24px;
  min-height: 24px;
}
.cpm-chat-teaser-close:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}
.cpm-chat-teaser-close:focus-visible {
  outline: 2px solid var(--cpm-chat-primary);
}

@keyframes cpmTeaserFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Chat Container Window */
.cpm-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--cpm-chat-bg);
  border: 1px solid var(--cpm-chat-border);
  border-radius: 16px;
  box-shadow: var(--cpm-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-chat-window, 1000);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
}

.cpm-chat-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Window Header */
.cpm-chat-header {
  padding: 14px 16px;
  background: var(--cpm-chat-surface);
  border-bottom: 1px solid var(--cpm-chat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cpm-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cpm-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid var(--cpm-chat-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.cpm-chat-title-group h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--cpm-chat-text);
  line-height: 1.2;
}

.cpm-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #10b981;
  font-weight: 500;
}

.cpm-chat-status-dot {
  width: 6px;
  height: 6px;
  background: #10b981;
  border-radius: 50%;
}

@keyframes cpmPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.cpm-chat-close-btn {
  background: none;
  border: none;
  color: var(--cpm-chat-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.cpm-chat-close-btn:hover {
  color: var(--cpm-chat-text);
  background: var(--cpm-chat-surface-hover);
}

/* Chat Messages Area */
.cpm-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Anchor messages to the bottom so there is no large awkward gap */
.cpm-chat-messages > .cpm-chat-msg:first-child {
  margin-top: auto;
}

.cpm-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.cpm-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Message Bubble */
.cpm-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: cpmSlideIn 0.2s ease-out;
}

@keyframes cpmSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cpm-chat-msg.is-user {
  align-self: flex-end;
}

.cpm-chat-msg.is-bot {
  align-self: flex-start;
}

.cpm-chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.cpm-chat-msg.is-user .cpm-chat-bubble {
  background: var(--cpm-chat-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(79, 126, 240, 0.35);
}

.cpm-chat-msg.is-bot .cpm-chat-bubble {
  background: var(--cpm-chat-bot-bubble);
  color: var(--cpm-chat-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--cpm-chat-border);
}

.cpm-chat-bubble p {
  margin: 0 0 8px 0;
}

.cpm-chat-bubble p:last-child {
  margin-bottom: 0;
}

.cpm-chat-bubble a {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.cpm-chat-bubble a:hover {
  color: #93c5fd;
}

.cpm-chat-bubble strong {
  color: #ffffff;
  font-weight: 600;
}

.cpm-chat-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}

.cpm-chat-bubble li {
  margin-bottom: 4px;
}

.cpm-chat-time {
  font-size: 0.68rem;
  color: var(--cpm-chat-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.cpm-chat-msg.is-user .cpm-chat-time {
  text-align: right;
}

/* Quick Suggestion Chips */
.cpm-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.cpm-chat-chip {
  background: var(--cpm-chat-surface);
  border: 1px solid var(--cpm-chat-border);
  color: var(--cpm-chat-text);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.16s cubic-bezier(0.22, 1, 0.36, 1), color 0.16s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.16s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.cpm-chat-chip:hover {
  background: var(--cpm-chat-primary);
  color: #ffffff;
  border-color: var(--cpm-chat-primary);
}

/* Typing Indicator */
.cpm-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--cpm-chat-bot-bubble);
  border: 1px solid var(--cpm-chat-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.cpm-chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--cpm-chat-muted);
  border-radius: 50%;
  animation: cpmTyping 1.4s infinite ease-in-out both;
}

.cpm-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.cpm-chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes cpmTyping {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Footer & Input Box */
.cpm-chat-footer {
  padding: 12px;
  background: var(--cpm-chat-surface);
  border-top: 1px solid var(--cpm-chat-border);
}

.cpm-chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--cpm-chat-bg);
  border: 1px solid var(--cpm-chat-border);
  border-radius: 12px;
  padding: 6px 8px 6px 12px;
  transition: border-color 0.15s;
}

.cpm-chat-input-bar:focus-within {
  border-color: var(--cpm-chat-primary);
  box-shadow: 0 0 0 2px rgba(79, 126, 240, 0.2);
}

.cpm-chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cpm-chat-text);
  font-family: inherit;
  font-size: 0.88rem;
  resize: none;
  max-height: 90px;
  min-height: 24px;
  line-height: 1.4;
  padding: 2px 0;
}

.cpm-chat-textarea::placeholder {
  color: var(--cpm-chat-muted);
}

.cpm-chat-send-btn {
  background: var(--cpm-chat-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease, opacity 150ms ease, transform 150ms ease;
  flex-shrink: 0;
}

@media (hover: hover) {
  .cpm-chat-send-btn:hover:not(:disabled) {
    background: var(--cpm-chat-primary-hover);
    transform: translateY(-1px);
  }
}

.cpm-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cpm-chat-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: var(--cpm-chat-muted);
  margin-top: 6px;
  padding: 0 4px;
}

.cpm-chat-char-count {
  font-variant-numeric: tabular-nums;
}

/* Background scroll lock when mobile sheet is open */
body.cpm-chat-scroll-locked {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

/* Dedicated Quick Chips Container (hidden on desktop, active on mobile) */
.cpm-chat-quick-chips {
  display: none;
}

/* Chatbot Interactive Proposal Card */
.cpm-chat-proposal-card {
  margin-top: 10px;
  background: rgba(13, 27, 46, 0.85);
  border: 1px solid rgba(79, 126, 240, 0.35);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.cpm-proposal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(79, 126, 240, 0.15);
  border-bottom: 1px solid rgba(79, 126, 240, 0.2);
}

.cpm-proposal-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cpm-proposal-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent, #60a5fa);
}

.cpm-proposal-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.cpm-proposal-row {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
}

.cpm-proposal-row strong,
.cpm-proposal-row span:last-child {
  color: #f1f5f9;
  font-weight: 500;
}

.cpm-proposal-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px 12px;
}

.cpm-btn-confirm-purchase {
  flex: 2;
  background: #059669;
  color: #ffffff;
  border: 1px solid #059669;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: none;
  transition: background-color 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.cpm-btn-confirm-purchase:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
}

.cpm-btn-confirm-purchase:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.cpm-btn-cancel-purchase {
  flex: 1;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.cpm-btn-cancel-purchase:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

/* Deposit Proposal Card */
.cpm-chat-deposit-card {
  border-color: rgba(1, 184, 254, 0.3) !important;
  box-shadow: 0 4px 16px rgba(1, 184, 254, 0.08);
}
.cpm-btn-confirm-deposit {
  min-height: 44px;
  transition: transform 0.15s, opacity 0.15s, background 0.15s;
}
.cpm-btn-confirm-deposit:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
.cpm-btn-confirm-deposit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.cpm-btn-cancel-deposit {
  min-height: 44px;
  transition: background 0.15s;
}
.cpm-btn-cancel-deposit:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25) !important;
}

.cpm-chat-bubble pre {
  background: var(--bg, #0b0e14);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--accent, #60a5fa);
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.cpm-chat-bubble code {
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(37, 99, 235, 0.22);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8em;
  color: var(--accent, #60a5fa);
}

/* ==========================================================================
   Consolidated Mobile Breakpoint (max-width: 640px, or mobile landscape)
   Adapts cleanly to phone screens and soft keyboards via visualViewport API
   ========================================================================== */
@media (max-width: 640px), (max-height: 500px) and (orientation: landscape) {
  /* Floating launcher */
  .cpm-chat-launcher {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    right: 16px !important;
    width: 52px !important;
    height: 52px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  .cpm-chat-launcher svg {
    width: 24px !important;
    height: 24px !important;
  }

  /* First-time teaser welcome bubble */
  .cpm-chat-teaser {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    right: 16px !important;
    left: 16px !important;
    max-width: calc(100vw - 32px) !important;
  }
  .cpm-chat-teaser-close {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: -10px -10px 0 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .cpm-chat-teaser-close svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
  }

  /* Full-height sheet pinned strictly to the visual viewport */
  .cpm-chat-window {
    position: fixed !important;
    top: var(--cpm-vvt, 0px) !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: var(--cpm-vvh, 100dvh) !important;
    max-height: var(--cpm-vvh, 100dvh) !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: var(--z-chat-window, 1000) !important;
    display: flex !important;
    flex-direction: column !important;
    transform: none !important; /* Prevents transform coordinate shifts with keyboard */
  }

  .cpm-chat-window:not(.is-open) {
    display: none !important;
  }

  /* Sticky header pinned to the top of the visible screen */
  .cpm-chat-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    flex-shrink: 0 !important;
    padding-top: max(12px, env(safe-area-inset-top, 12px)) !important;
    padding-left: max(14px, env(safe-area-inset-left, 14px)) !important;
    padding-right: max(14px, env(safe-area-inset-right, 14px)) !important;
    padding-bottom: 12px !important;
    background: var(--cpm-chat-surface) !important;
    border-bottom: 1px solid var(--cpm-chat-border) !important;
  }

  .cpm-chat-close-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: -6px -6px -6px 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 10px !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  .cpm-chat-close-btn svg {
    width: 22px !important;
    height: 22px !important;
  }

  /* Messages area: instant scrolling for keyboard adjustments */
  .cpm-chat-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 12px 14px !important;
    scroll-behavior: auto !important; /* Instant jump prevents lagging behind keyboard */
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Anchor messages to bottom */
  .cpm-chat-messages > .cpm-chat-msg:first-child {
    margin-top: auto !important;
  }

  .cpm-chat-bubble {
    max-width: 90% !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    font-size: 0.9rem !important;
  }

  /* Hide chips inside welcome message on mobile so they don't duplicate the row above input */
  .cpm-chat-bubble .cpm-chat-chips {
    display: none !important;
  }

  /* Dedicated Quick-reply Chips Row directly above input */
  .cpm-chat-quick-chips {
    display: block !important;
    flex-shrink: 0 !important;
    background: var(--cpm-chat-surface) !important;
    border-top: 1px solid var(--cpm-chat-border) !important;
    padding: 8px 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
  }
  .cpm-chat-quick-chips::-webkit-scrollbar {
    display: none !important;
  }

  .cpm-chat-quick-chips .cpm-chat-chips-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .cpm-chat-quick-chips .cpm-chat-chip {
    flex-shrink: 0 !important;
    min-height: 44px !important;
    padding: 0 16px !important;
    font-size: 0.82rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  /* Compact input footer */
  .cpm-chat-footer {
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px)) !important;
    padding-left: max(12px, env(safe-area-inset-left, 12px)) !important;
    padding-right: max(12px, env(safe-area-inset-right, 12px)) !important;
    background: var(--cpm-chat-surface) !important;
    border-top: 1px solid var(--cpm-chat-border) !important;
  }

  .cpm-chat-input-bar {
    padding: 4px 6px 4px 12px !important;
    border-radius: 14px !important;
    align-items: center !important;
  }

  .cpm-chat-textarea {
    font-size: 16px !important; /* Critical: exactly 16px prevents iOS / Android Chrome auto-zoom */
    min-height: 24px !important;
    max-height: 80px !important;
    padding: 6px 0 !important;
  }

  .cpm-chat-send-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    -webkit-tap-highlight-color: transparent !important;
  }
  .cpm-chat-send-btn svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* Footer Meta: hide CPM AI label; hide char count unless >= 800 chars */
  .cpm-chat-footer-meta {
    margin-top: 2px !important;
    padding: 0 !important;
    justify-content: flex-end !important;
  }
  .cpm-chat-footer-meta > span:first-child {
    display: none !important; /* Hide 'CPM AI' brand text */
  }
  .cpm-chat-char-count {
    display: none; /* Controlled by JS: only displayed when length >= 800 */
    font-size: 0.72rem !important;
    color: var(--cpm-chat-muted) !important;
  }

  .cpm-chat-product-card,
  .cpm-chat-confirmation-card,
  .cpm-chat-proposal-card {
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cpm-chat-window, .cpm-chat-launcher, .cpm-chat-bubble, .cpm-chat-send-btn, .cpm-btn-confirm-purchase, .cpm-chat-teaser {
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }
}
