/* ── Bubble ──────────────────────────────────────────────────────────────── */
#cbBubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
#cbBubble:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(37,99,235,.45);
}
.cb-badge {
  position: absolute;
  top: -2px; right: -2px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 17px; height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* ── Window ──────────────────────────────────────────────────────────────── */
#cbWindow {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 358px;
  max-height: 590px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(0,0,0,.14), 0 1px 4px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#cbWindow.cb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.cb-header {
  background: #fff;
  border-bottom: 1px solid #f0f2f5;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.cb-hav {
  width: 38px; height: 38px;
  background: #dbeafe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.cb-hinfo { flex: 1; min-width: 0; }
.cb-hname {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  line-height: 1.3;
}
.cb-hsub {
  font-size: 11.5px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-online-dot {
  width: 7px; height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}
.cb-header-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-icon-btn {
  background: none;
  border: none;
  color: #9ca3af;
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.cb-icon-btn:hover { background: #f3f4f6; color: #374151; }

/* ── Messages ────────────────────────────────────────────────────────────── */
.cb-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f9fafb;
}
.cb-msgs::-webkit-scrollbar { width: 4px; }
.cb-msgs::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.cb-msg-row { display: flex; }
.cb-msg-row.bot  { justify-content: flex-start; }
.cb-msg-row.user { justify-content: flex-end; }

.cb-bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: keep-all;
}
.cb-bubble.bot {
  background: #fff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.cb-bubble.user {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── 단일 선택 버튼 ────────────────────────────────────────────────────────── */
.cb-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 0;
}
.cb-chip {
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  color: #374151;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  font-family: inherit;
}
.cb-chip:hover, .cb-chip.sel {
  border-color: #2563eb;
  color: #2563eb;
  background: #eff6ff;
}

/* ── 복수 선택 ────────────────────────────────────────────────────────────── */
.cb-multi-wrap { display: flex; flex-direction: column; gap: 8px; }
.cb-tag-chip, .cb-check-chip {
  border-color: #d1d5db;
  color: #374151;
}
.cb-tag-chip.sel, .cb-check-chip.sel {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}
.cb-done-row { display: flex; gap: 7px; margin-top: 2px; }
.cb-skip-btn {
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  background: #fff;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.cb-skip-btn:hover { border-color: #d1d5db; color: #6b7280; }
.cb-done-btn {
  flex: 1;
  padding: 8px 14px;
  border-radius: 20px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.cb-done-btn:hover { background: #1d4ed8; }

/* ── 뒤로가기 ────────────────────────────────────────────────────────────── */
.cb-back-row {
  padding: 6px 14px 4px;
  background: #f9fafb;
  flex-shrink: 0;
}
.cb-back-btn {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.cb-back-btn:hover { color: #4b5563; }

/* ── 텍스트 입력 ─────────────────────────────────────────────────────────── */
.cb-input-area {
  padding: 10px 12px;
  border-top: 1px solid #f0f2f5;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  flex-shrink: 0;
}
#cbTextInput {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
  background: #f9fafb;
}
#cbTextInput:focus {
  border-color: #2563eb;
  background: #fff;
}
.cb-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.cb-send:hover { background: #1d4ed8; }

/* ── 확인 화면 ───────────────────────────────────────────────────────────── */
.cb-confirm-box {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 13px 15px;
}
.cb-confirm-row {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
}
.cb-confirm-row:last-of-type { border-bottom: none; }
.cb-cl { font-size: 11.5px; color: #9ca3af; min-width: 58px; padding-top: 1px; flex-shrink: 0; }
.cb-cv { font-size: 13px; color: #111827; font-weight: 600; flex: 1; word-break: break-all; }

.cb-action-btns { display: flex; gap: 8px; margin-top: 12px; }
.cb-btn-edit {
  flex: 1; padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s;
}
.cb-btn-edit:hover { border-color: #d1d5db; }
.cb-btn-submit {
  flex: 2; padding: 10px;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.cb-btn-submit:hover    { background: #1d4ed8; }
.cb-btn-submit:disabled { background: #93c5fd; cursor: default; }

/* ── 완료 ────────────────────────────────────────────────────────────────── */
.cb-success {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
}
.cb-success-icon { font-size: 38px; margin-bottom: 8px; }
.cb-success h3 { font-size: 15px; color: #111827; margin: 0 0 6px; font-weight: 700; }
.cb-success p  { font-size: 13px; color: #6b7280; line-height: 1.6; margin: 0 0 4px; }

/* ── 모바일 ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cbWindow {
    bottom: calc(60px + env(safe-area-inset-bottom));
    right: 0;
    width: 100%;
    max-height: calc(93dvh - 60px - env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }
  #cbBubble {
    bottom: calc(76px + env(safe-area-inset-bottom));
    right: 16px;
  }
}

/* 하단 네비게이션 바가 있는 환경 (481px~768px) */
@media (min-width: 481px) and (max-width: 768px) {
  #cbBubble {
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  #cbWindow {
    bottom: calc(136px + env(safe-area-inset-bottom));
  }
}
