:root {
  --ec-primary: #0d1b2a;
  --ec-accent:  #1a8cff;
  --ec-bg:      #ffffff;
  --ec-radius:  14px;
  --ec-shadow:  0 8px 32px rgba(0,0,0,0.18);
}

#ec-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Speech bubble ── */
#ec-bubble {
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}
#ec-bubble.visible {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
}
#ec-bubble-inner {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.14);
  padding: 10px 12px 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  white-space: nowrap;
}
/* tail pointing down-right toward the button */
#ec-bubble-inner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 2px 2px 5px rgba(0,0,0,0.06);
}
#ec-bubble-online {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  animation: ec-pulse 2s infinite;
}
@keyframes ec-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(34,197,94,0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0   rgba(34,197,94,0); }
}
#ec-bubble-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
#ec-bubble-text strong {
  font-size: 13.5px;
  color: #0d1b2a;
  font-weight: 700;
}
#ec-bubble-text span {
  font-size: 11.5px;
  color: #22c55e;
  font-weight: 500;
}
#ec-bubble-close {
  background: none;
  border: none;
  font-size: 13px;
  color: #aaa;
  cursor: pointer;
  padding: 0 0 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
#ec-bubble-close:hover { color: #555; }

#ec-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ec-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--ec-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  position: relative;
}
#ec-btn:hover { background: #1a2e42; transform: scale(1.08); }
#ec-btn svg { width: 26px; height: 26px; fill: #fff; }

#ec-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e74c3c;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

#ec-window {
  width: 340px;
  background: var(--ec-bg);
  border-radius: var(--ec-radius);
  box-shadow: var(--ec-shadow);
  display: none;
  overflow: hidden;
  animation: ec-slide-up 0.22s ease;
}
#ec-window.open { display: block; }

@keyframes ec-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── shared header ── */
#ec-header, #ec-chat-header {
  background: var(--ec-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#ec-header-left, #ec-header-left2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
#ec-avatar, #ec-avatar2 {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ec-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#ec-avatar svg, #ec-avatar2 svg { width: 18px; height: 18px; fill: #fff; }
#ec-header-title, .ec-htitle { font-size: 14px; font-weight: 600; }
#ec-header-status, #ec-status-dot { font-size: 11px; opacity: 0.85; margin-top: 2px; }
#ec-close, #ec-close2 {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}
#ec-close:hover, #ec-close2:hover { color: #fff; }

/* ── Welcome screen ── */
#ec-welcome-body {
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#ec-intro-text {
  font-size: 13.5px;
  color: #444;
  line-height: 1.5;
  margin: 0;
}
#ec-name-label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
}
#ec-name-label span { font-weight: 400; color: #888; }
#ec-name-input {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
#ec-name-input:focus { border-color: var(--ec-accent); }
#ec-start-btn {
  background: var(--ec-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
#ec-start-btn:hover { background: #0070d8; }

/* ── Chat screen ── */
#ec-chat { display: flex; flex-direction: column; }

#ec-messages {
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f5f7fa;
  min-height: 220px;
  max-height: 280px;
}

.ec-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.ec-msg.visitor {
  align-self: flex-end;
  background: var(--ec-accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ec-msg.agent {
  align-self: flex-start;
  background: #fff;
  color: #1a1a1a;
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ec-msg.system {
  align-self: center;
  background: none;
  color: #999;
  font-size: 12px;
  font-style: italic;
  max-width: 100%;
  text-align: center;
}

#ec-input-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eee;
  gap: 8px;
}
#ec-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
}
#ec-input:focus { border-color: var(--ec-accent); }
#ec-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ec-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
#ec-send:hover { background: #0070d8; }
#ec-send svg { width: 16px; height: 16px; fill: #fff; }

@media (max-width: 420px) {
  #ec-window { width: calc(100vw - 32px); }
  #ec-launcher { right: 16px; bottom: 16px; }
}
