#uc-chat {
  --uc-blue: #1e4fd6;
  --uc-blue-dark: #1740b8;
  --uc-spark: #2b6cff;
  --uc-light: #eef2ff;
  --uc-text: #12141a;
  --uc-line: #e4e7ec;
  --uc-pill-line: #10141c;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
}

/* ---------- Docked launcher pill (collapsed) ---------- */
.uc-launcher {
  display: inline-flex;
  position: relative;
  align-items: center;
  gap: 9px;
  padding: 13px 18px;
  border: 2px solid #7db4ff;
  border-radius: 16px 16px 6px 16px;
  background: #ffffff;
  color: var(--uc-text);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.1px;
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16), 0 12px 30px rgba(37, 99, 235, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.uc-launcher:hover { transform: translateY(-2px); border-color: var(--uc-blue); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.22), 0 16px 40px rgba(37, 99, 235, 0.34); }
.uc-launcher .uc-spark { color: var(--uc-spark); flex-shrink: 0; }
.uc-launcher .uc-chevron { color: #6b7280; margin-left: 2px; }
.uc-launcher .uc-badge {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(239,68,68,.5);
  animation: uc-pop 0.28s cubic-bezier(.16,1,.3,1);
}
#uc-chat.open .uc-launcher { display: none; }

/* Optional prompt bubble (error page). */
.uc-bubble-prompt {
  position: relative; max-width: 230px; margin: 0 4px 14px 0;
  background: #fff; color: #0f172a; border: 1px solid #eef0f4; border-radius: 14px;
  padding: 13px 30px 13px 15px; font-size: 14px; font-weight: 600; line-height: 1.4;
  box-shadow: 0 12px 34px rgba(20, 30, 50, 0.18); animation: uc-pop 0.32s cubic-bezier(0.16,1,0.3,1);
}
.uc-bubble-prompt::after { content:''; position:absolute; bottom:-7px; right:30px; width:13px; height:13px; background:#fff; border-right:1px solid #eef0f4; border-bottom:1px solid #eef0f4; transform:rotate(45deg); }
.uc-bubble-close { position:absolute; top:6px; right:9px; border:0; background:transparent; font-size:17px; line-height:1; color:#94a3b8; cursor:pointer; padding:0; }
.uc-bubble-close:hover { color:#475569; }
#uc-chat.open .uc-bubble-prompt { display: none; }
@keyframes uc-pop { from { opacity:0; transform: translateY(10px) scale(0.96);} to {opacity:1; transform:none;} }

/* ---------- Panel ---------- */
.uc-panel {
  position: relative;
  display: none;
  flex-direction: column;
  width: 348px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 96px);
  background: #fff;
  border: 1.5px solid #b7d4ff;
  border-radius: 16px;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12), 0 28px 70px rgba(37, 99, 235, 0.22);
  overflow: hidden;
  animation: uc-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
#uc-chat.open .uc-panel { display: flex; }
#uc-chat.open.expanded .uc-panel { width: 420px; height: min(660px, calc(100vh - 64px)); }
@keyframes uc-in { from { opacity:0; transform: translateY(16px) scale(0.98);} to {opacity:1; transform:none;} }

/* ---------- Header ---------- */
.uc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--uc-line);
  -webkit-user-select: none; user-select: none;
}
.uc-head-title {
  flex: 1; text-align: center; font-size: 15.5px; font-weight: 800; color: #000;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.uc-head-title .uc-spark { color: var(--uc-spark); }
.uc-headbtn {
  width: 34px; height: 34px; flex-shrink: 0; border: 0; background: transparent; color: #5b626d;
  border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.14s ease, color 0.14s ease;
}
.uc-headbtn:hover { background: #f2f4f7; color: #1f2733; }

/* ---------- Body ---------- */
.uc-body {
  flex: 1; overflow-y: auto; padding: 16px 16px; display: flex; flex-direction: column; gap: 9px; background: #fff;
}

/* Greeting (post-form) */
.uc-greeting { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.uc-greet-spark { color: var(--uc-spark); }
.uc-greeting p { margin: 0; font-size: 14px; line-height: 1.5; color: #23262d; }

/* Option pills */
.uc-opts { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 6px; }
.uc-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  max-width: 100%; padding: 12px 22px; border-radius: 24px;
  border: 1.5px solid var(--uc-pill-line); background: #fff; color: #10141c;
  font-size: 14.5px; font-weight: 700; cursor: pointer; text-align: center;
  transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease, box-shadow 0.14s ease;
}
.uc-pill svg { flex-shrink: 0; }
.uc-pill:hover { background: #10141c; color: #fff; }
.uc-pill:active { transform: scale(0.98); }
.uc-pill:disabled { opacity: 0.55; cursor: default; }

/* Footer (powered by + disclaimer) */
.uc-footer { margin-top: auto; padding-top: 22px; text-align: center; }
.uc-powered { font-size: 12.5px; color: #6b7280; font-weight: 700; margin-bottom: 8px; }
.uc-powered b { color: var(--uc-spark); }
.uc-disclaimer { font-size: 11.5px; line-height: 1.5; color: #9aa0aa; padding: 0 6px; }

/* Message bubbles */
.uc-bubble { max-width: 82%; padding: 11px 15px; font-size: 14px; line-height: 1.45; border-radius: 16px; word-wrap: break-word; }
.uc-bubble.agent { align-self: flex-start; background: var(--uc-light); color: #1c3aa8; border-bottom-left-radius: 5px; font-weight: 600; }
.uc-bubble.customer { align-self: flex-end; background: var(--uc-blue); color: #fff; border-bottom-right-radius: 5px; }

/* Typing indicator */
.uc-typing { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.uc-typing span { width:7px; height:7px; border-radius:50%; background:#1c3aa8; opacity:0.4; animation: uc-blink 1.2s infinite ease-in-out; }
.uc-typing span:nth-child(2){ animation-delay:0.2s; } .uc-typing span:nth-child(3){ animation-delay:0.4s; }
@keyframes uc-blink { 0%,80%,100%{ opacity:0.3; transform:scale(0.9);} 40%{ opacity:1; transform:scale(1);} }

/* ---------- Lead form (initial screen: greeting + fields, one cohesive view) ---------- */
.uc-form { padding: 2px 16px 16px; display: flex; flex-direction: column; gap: 9px; }
.uc-form .uc-greeting { margin-bottom: 6px; }
.uc-form .uc-welcome-text { margin: 0; font-size: 14px; line-height: 1.5; color: #23262d; }
.uc-form input { height: 42px; padding: 0 13px; border: 1px solid #d9dde2; border-radius: 10px; font-size: 13.5px; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.uc-form input:focus { border-color: var(--uc-blue); box-shadow: 0 0 0 3px rgba(30,79,214,0.12); }
.uc-form-err { color: #d43535; font-size: 12.5px; min-height: 4px; }
.uc-send-btn { height: 44px; border: 0; border-radius: 24px; background: var(--uc-blue); color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer; transition: background 0.15s; }
.uc-send-btn:hover { background: var(--uc-blue-dark); }
.uc-textarea { min-height: 62px; max-height: 130px; padding: 10px 13px; border: 1px solid #d9dde2; border-radius: 10px; font-size: 13.5px; font-family: inherit; resize: vertical; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.uc-textarea:focus { border-color: var(--uc-blue); box-shadow: 0 0 0 3px rgba(30,79,214,0.12); }
.uc-textarea::placeholder, .uc-form input::placeholder { color: #9aa0a8; }

/* ---------- Composer ---------- */
.uc-composer { position: relative; border-top: 1px solid var(--uc-line); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.uc-menu-btn { width: 40px; height: 40px; flex-shrink: 0; border: 0; background: transparent; color: #5b626d; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background 0.14s, color 0.14s; }
.uc-menu-btn:hover { background: #f2f4f7; color: #1f2733; }
.uc-menu { position: absolute; left: 12px; bottom: 60px; background: #fff; border: 1px solid var(--uc-line); border-radius: 12px; box-shadow: 0 12px 30px rgba(20,30,50,0.18); padding: 6px; z-index: 5; }
.uc-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 14px; font-size: 14px; font-weight: 700; color: #1f2733; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.uc-menu button svg { flex-shrink: 0; color: #5b626d; }
.uc-menu button:hover { background: #f2f4f7; }
.uc-menu button:hover svg { color: #1f2733; }
.uc-composer input { flex: 1; height: 44px; padding: 0 18px; border: 1px solid #cfd4dc; border-radius: 24px; font-size: 14px; outline: none; background: #fff; }
.uc-composer input:focus { border-color: var(--uc-blue); }
.uc-icon-btn { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 50%; background: var(--uc-blue); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s, transform 0.12s; }
/* Composer close (minimize) button — only shown on mobile, where the top header can be pushed out of reach by the keyboard. */
.uc-composer-close { display: none; }
.uc-icon-btn:hover { background: var(--uc-blue-dark); }
.uc-icon-btn:active { transform: scale(0.94); }

/* ---------- Idle "Start over" overlay (center) ---------- */
.uc-idle { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.86); backdrop-filter: blur(2px); z-index: 8; animation: uc-in 0.2s ease; }
.uc-idle-card { text-align: center; padding: 26px; }
.uc-idle-card p { margin: 0 0 16px; font-size: 15px; font-weight: 600; color: #23262d; }
.uc-idle-btn { border: 1.5px solid var(--uc-pill-line); background: #10141c; color: #fff; font-size: 14.5px; font-weight: 800; padding: 12px 28px; border-radius: 24px; cursor: pointer; transition: transform 0.12s ease, opacity 0.14s; }
.uc-idle-btn:hover { opacity: 0.9; }
.uc-idle-btn:active { transform: scale(0.97); }

/* ---------- Quick-reply topic pills ---------- */
.uc-quick-label { font-size: 12px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; color: #8a90a0; margin: 4px 0 2px; }
.uc-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.uc-quick-pill {
  border: 1px solid #d7dbe2; background: #f6f8fb; color: #23324d;
  font-size: 13px; font-weight: 700; padding: 8px 14px; border-radius: 20px; cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}
.uc-quick-pill:hover { background: var(--uc-blue); color: #fff; border-color: var(--uc-blue); }
.uc-quick-pill:active { transform: scale(0.97); }

/* ---------- Proactive teaser above the launcher ---------- */
.uc-teaser {
  position: relative; max-width: 250px; margin: 0 2px 14px 0;
  background: #fff; color: #12141a; border: 1px solid var(--uc-line); border-radius: 14px 14px 14px 4px;
  padding: 13px 30px 13px 15px; font-size: 14px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 14px 36px rgba(20, 30, 50, 0.20); animation: uc-pop 0.34s cubic-bezier(0.16,1,0.3,1);
}
.uc-teaser::after { content:''; position:absolute; bottom:-7px; right:26px; width:13px; height:13px; background:#fff; border-right:1px solid var(--uc-line); border-bottom:1px solid var(--uc-line); transform:rotate(45deg); }
.uc-teaser-close { position:absolute; top:6px; right:9px; border:0; background:transparent; font-size:17px; line-height:1; color:#9aa0aa; cursor:pointer; padding:0; }
.uc-teaser-close:hover { color:#475569; }
#uc-chat.open .uc-teaser { display: none; }

/* ---------- Agent reply preview (before auto-open) ---------- */
.uc-reply-preview {
  position: relative; display: flex; gap: 10px; align-items: flex-start; max-width: 270px; margin: 0 2px 14px 0;
  background: #fff; color: #12141a; border: 1px solid var(--uc-line); border-radius: 14px 14px 14px 4px;
  padding: 12px 14px; cursor: pointer;
  box-shadow: 0 14px 36px rgba(20, 30, 50, 0.22); animation: uc-pop 0.34s cubic-bezier(0.16,1,0.3,1);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.uc-reply-preview:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(20, 30, 50, 0.28); }
.uc-reply-preview::after { content:''; position:absolute; bottom:-7px; right:26px; width:13px; height:13px; background:#fff; border-right:1px solid var(--uc-line); border-bottom:1px solid var(--uc-line); transform:rotate(45deg); }
.uc-rp-spark { flex-shrink:0; width:30px; height:30px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:rgba(59,130,246,.12); color:var(--uc-spark); }
.uc-rp-main { min-width:0; }
.uc-rp-name { font-size:12px; font-weight:800; color:var(--uc-blue); margin-bottom:2px; }
.uc-rp-text { font-size:13.5px; font-weight:600; line-height:1.4; color:#12141a; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
#uc-chat.open .uc-reply-preview { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  #uc-chat { right: 16px; bottom: 16px; left: auto; align-items: flex-end; }
  .uc-launcher { font-size: 14.5px; padding: 12px 16px; }
  #uc-chat.open { left: 0; right: 0; bottom: 0; }
  .uc-panel, #uc-chat.open.expanded .uc-panel { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  #uc-expand { display: none; }
  .uc-body { padding: 16px 14px; }
  .uc-bubble { max-width: 88%; }
  .uc-pill { width: 100%; }
  /* iOS zooms the whole page when focusing an input under 16px — force 16px on mobile to prevent it. */
  .uc-composer input, .uc-form input, .uc-textarea { font-size: 16px; }
  /* Always-reachable close button in the composer (header can be scrolled away by the keyboard). */
  .uc-composer-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border: 0; background: #eef2f7; color: #334155; border-radius: 50%; cursor: pointer; transition: background 0.14s ease, color 0.14s ease; }
  .uc-composer-close:active { background: #dbe3ec; }
  .uc-composer { gap: 8px; }
  .uc-menu-btn { width: 38px; height: 38px; }
}

@supports (padding: max(0px)) {
  @media (max-width: 560px) {
    .uc-composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  }
}
