#kfcb-root * { box-sizing: border-box; }
.kfcb-widget { position: fixed; bottom: 18px; }
.kfcb-pos-right { right: 18px; }
.kfcb-pos-left { left: 18px; }

.kfcb-toggle {
  border: none;
  border-radius: 999px;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: var(--kfcb-accent);
  box-shadow: 0 10px 20px rgba(0,0,0,.2);
  cursor: pointer;
}
.kfcb-toggle img { width: 28px; height: 28px; filter: brightness(100%); }

.kfcb-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,.18);
  overflow: hidden;
  transform: translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.kfcb-pos-left .kfcb-panel { left: 0; right: auto; }

.kfcb-panel.kfcb-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.kfcb-header {
  background: var(--kfcb-primary);
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kfcb-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.kfcb-title img { width: 22px; height: 22px; border-radius: 4px; }

.kfcb-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.kfcb-messages {
  max-height: 420px;
  min-height: 160px;
  overflow: auto;
  padding: 12px;
  background: #fff;
}

.kfcb-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.kfcb-avatar img { width: 24px; height: 24px; border-radius: 50%; }
.kfcb-bubble {
  background: var(--kfcb-bubble);
  color: var(--kfcb-text);
  border-radius: 12px;
  padding: 8px 10px;
  max-width: 85%;
  line-height: 1.45;
  font-size: 14px;
  word-break: break-word;
}
.kfcb-bubble p { margin: 6px 0; }
.kfcb-bubble ul, .kfcb-bubble ol { margin: 6px 0 6px 20px; }
.kfcb-bubble a { text-decoration: underline; }

.kfcb-user { justify-content: flex-end; }
.kfcb-user .kfcb-bubble { background: #e5edff; }
.kfcb-user .kfcb-avatar { order: 2; }
.kfcb-user .kfcb-bubble { order: 1; }

.kfcb-form {
  border-top: 1px solid rgba(0,0,0,.08);
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
}
.kfcb-input {
  flex: 1;
  min-height: 38px;
  max-height: 160px;
  resize: none;
  border: 1px solid rgba(0,0,0,.16);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}
.kfcb-send {
  background: var(--kfcb-accent);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

/* typing dots */
.kfcb-typing { display: flex; gap: 4px; padding: 0 32px; margin-bottom: 12px; }
.kfcb-typing span {
  width: 6px; height: 6px; background: #c8c8c8; border-radius: 50%;
  display: inline-block; animation: kfcb-bounce 1s infinite;
}
.kfcb-typing span:nth-child(2){ animation-delay: .15s; }
.kfcb-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes kfcb-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .6; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px){
  .kfcb-panel { width: 92vw; }
}
