/* ================= Portfolio Assistant widget ================= */
:root {
  --cb-panel-bg: rgba(255, 255, 255, 0.92);
  --cb-bot-bubble: rgba(99, 102, 241, 0.08);
  --cb-border: rgba(0, 0, 0, 0.08);
  --cb-input-bg: rgba(0, 0, 0, 0.03);
}
[data-theme="dark"] {
  --cb-panel-bg: rgba(20, 27, 45, 0.94);
  --cb-bot-bubble: rgba(255, 255, 255, 0.06);
  --cb-border: rgba(255, 255, 255, 0.12);
  --cb-input-bg: rgba(255, 255, 255, 0.06);
}

#cb-root { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* Floating button */
.cb-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.2s ease;
  animation: cb-pulse 2.8s infinite;
}
.cb-fab:hover { transform: scale(1.08); box-shadow: 0 14px 38px rgba(236, 72, 153, 0.5); }
.cb-fab.cb-hidden { opacity: 0; pointer-events: none; transform: scale(0.6); }

@keyframes cb-pulse {
  0% { box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45), 0 0 0 0 rgba(99, 102, 241, 0.35); }
  70% { box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45), 0 0 0 16px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 10px 30px rgba(99, 102, 241, 0.45), 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Panel */
.cb-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 70vh;
  max-height: 560px;
  background: var(--cb-panel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--cb-border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2001;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.cb-panel.cb-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* Header */
.cb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}
.cb-head-info { display: flex; align-items: center; gap: 10px; }
.cb-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,0.6); }
.cb-title { font-weight: 700; font-size: 0.98rem; line-height: 1.1; }
.cb-status { font-size: 0.72rem; opacity: 0.85; }
.cb-close { background: none; border: none; color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer; opacity: 0.9; padding: 0 4px; }
.cb-close:hover { opacity: 1; }

/* Message area */
.cb-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.cb-body::-webkit-scrollbar { width: 6px; }
.cb-body::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 6px; }

.cb-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.cb-msg.cb-user { flex-direction: row-reverse; }
.cb-msg-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.cb-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 78%;
  word-wrap: break-word;
}
.cb-bot .cb-bubble { background: var(--cb-bot-bubble); color: var(--text); border-bottom-left-radius: 4px; }
.cb-user .cb-bubble { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-bottom-right-radius: 4px; }

/* Typing dots */
.cb-typing { display: flex; gap: 4px; align-items: center; }
.cb-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-light); opacity: 0.6; animation: cb-blink 1.2s infinite; }
.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cb-blink { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Suggested question chips */
.cb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 10px; }
.cb-chips-min { max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; opacity: 0; transition: all 0.3s ease; }
.cb-chip {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 30px;
  padding: 7px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}
.cb-chip:hover { background: var(--primary); color: #fff; }

/* Input */
.cb-input-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--cb-border); }
.cb-input {
  flex: 1;
  border: none;
  outline: none;
  background: var(--cb-input-bg);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-family: inherit;
}
.cb-input::placeholder { color: var(--text-light); }
.cb-send {
  width: 40px; height: 40px; flex-shrink: 0;
  border: none; border-radius: 50%; cursor: pointer;
  color: #fff; background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease;
}
.cb-send:hover { transform: scale(1.1); }

@media (max-width: 480px) {
  .cb-panel { height: 78vh; max-height: none; bottom: 16px; right: 16px; }
  .cb-fab { bottom: 16px; right: 16px; }
}