#kiwl-cs-root {
  --kiwl-cs-primary: #2563eb;
  --kiwl-cs-primary-dark: #1d4ed8;
  --kiwl-cs-green: #22c55e;
  --kiwl-cs-green-dark: #16a34a;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
}

#kiwl-cs-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483002;
  pointer-events: auto;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kiwl-cs-primary), #1e40af);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

#kiwl-cs-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.55);
}

#kiwl-cs-fab svg { width: 28px; height: 28px; }

#kiwl-cs-fab .kiwl-cs-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: kiwl-cs-pulse 2s infinite;
}

@keyframes kiwl-cs-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

#kiwl-cs-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 2147483001;
  pointer-events: auto;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: min(520px, calc(100vh - 120px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}

#kiwl-cs-panel.kiwl-cs-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.kiwl-cs-header {
  background: linear-gradient(135deg, var(--kiwl-cs-primary), #1e40af);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.kiwl-cs-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.kiwl-cs-header-info h3 { margin: 0; font-size: 15px; font-weight: 600; }
.kiwl-cs-header-info p { margin: 2px 0 0; font-size: 12px; opacity: 0.9; }

.kiwl-cs-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kiwl-cs-close:hover { background: rgba(255, 255, 255, 0.25); }

.kiwl-cs-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}

.kiwl-cs-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  animation: kiwl-cs-fadein 0.35s ease;
}

@keyframes kiwl-cs-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.kiwl-cs-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.kiwl-cs-msg-user {
  align-self: flex-end;
  background: var(--kiwl-cs-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.kiwl-cs-page-card {
  align-self: flex-start;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 14px;
  max-width: 92%;
  font-size: 13px;
  color: #1e40af;
}

.kiwl-cs-page-card strong { display: block; margin-bottom: 4px; color: #1e3a8a; }
.kiwl-cs-page-card span { color: #475569; font-size: 12px; word-break: break-all; }

.kiwl-cs-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
}

.kiwl-cs-option-btn {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12.5px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.kiwl-cs-option-btn:hover {
  border-color: var(--kiwl-cs-primary);
  color: var(--kiwl-cs-primary);
  background: #eff6ff;
}

.kiwl-cs-footer {
  padding: 12px 16px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.kiwl-cs-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  background: var(--kiwl-cs-green);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.kiwl-cs-wa-btn:hover { background: var(--kiwl-cs-green-dark); color: #fff; }

.kiwl-cs-wa-btn svg { width: 22px; height: 22px; flex-shrink: 0; }

.kiwl-cs-footer-note {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
}

@media (max-width: 480px) {
  #kiwl-cs-fab { bottom: 16px; right: 16px; width: 56px; height: 56px; }
  #kiwl-cs-panel { bottom: 84px; right: 16px; }
}
