/* =====================================================================
   AI 顾问小橱窗 — 浅色主题
   ===================================================================== */

.cb {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.cb.is-ready { opacity: 1; transform: none; }

/* ---------- proactive tip ---------- */
.cb-tip {
  margin: 0;
  max-width: 240px;
  padding: 10px 14px;
  border-radius: 12px 12px 4px 12px;
  background: #ffffff;
  border: 1px solid var(--line, rgba(16, 24, 40, 0.12));
  color: var(--ink-2, #415063);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.16);
  animation: cb-tip-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cb-tip-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- launcher ---------- */
.cb-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: 1px solid rgba(15, 184, 156, 0.4);
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(47, 224, 192, 0.95), rgba(76, 125, 255, 0.9));
  color: #04221d;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(15, 184, 156, 0.3);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s;
}
.cb-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 42px rgba(15, 184, 156, 0.38); }
.cb-launcher:active { transform: translateY(0) scale(0.98); }
.cb-launcher::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 999px;
  border: 2px solid rgba(15, 184, 156, 0.55);
  animation: cb-ring 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes cb-ring {
  0% { transform: scale(1); opacity: 0.7; }
  70% { opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}
.cb-launcher-icon { display: grid; place-items: center; }
.cb-launcher-icon svg { width: 22px; height: 22px; }

.cb[data-state="open"] .cb-launcher {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
}

.cb-dot {
  position: absolute;
  top: -2px; right: -2px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #ff6b6b;
  border: 2px solid #ffffff;
  animation: cb-pulse 1.8s ease-in-out infinite;
}
@keyframes cb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* ---------- panel ---------- */
.cb-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(378px, calc(100vw - 32px));
  height: min(596px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, rgba(16, 24, 40, 0.12));
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22), 0 0 0 1px rgba(15, 184, 156, 0.08);
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  visibility: hidden;
  transition: opacity 0.34s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.34s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.34s;
}
.cb[data-state="open"] .cb-panel {
  opacity: 1;
  transform: none;
  visibility: visible;
  animation: cb-attract 3.6s ease-in-out infinite;
}
@keyframes cb-attract {
  0%, 100% { box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22), 0 0 0 1px rgba(15, 184, 156, 0.08); }
  50% { box-shadow: 0 24px 70px rgba(16, 24, 40, 0.22), 0 0 0 2px rgba(15, 184, 156, 0.45), 0 0 42px rgba(15, 184, 156, 0.25); }
}

/* head */
.cb-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  background: radial-gradient(120% 140% at 0% 0%, rgba(15, 184, 156, 0.1), transparent 60%);
}
.cb-avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(140deg, #2fe0c0, #4c7dff);
  box-shadow: 0 0 18px rgba(15, 184, 156, 0.3);
}
.cb-meta { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.cb-meta b { font-size: 14.5px; font-weight: 700; color: var(--ink, #131c27); }
.cb-status { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted, #5c6b7e); }
.cb-online {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #0fb89c;
  box-shadow: 0 0 8px #0fb89c;
}
.cb-close {
  margin-left: auto;
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2, rgba(16, 24, 40, 0.18));
  border-radius: 9px;
  background: rgba(16, 24, 40, 0.03);
  color: var(--ink-2, #415063);
  cursor: pointer;
  transition: background 0.22s, color 0.22s, border-color 0.22s;
}
.cb-close:hover { background: rgba(16, 24, 40, 0.07); color: var(--ink, #131c27); }

/* ---------- tabs ---------- */
.cb-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  background: rgba(16, 24, 40, 0.02);
}
.cb-tab {
  flex: 1 1 0;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted, #5c6b7e);
  font-family: inherit;
  font-size: 12.8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.22s, color 0.22s, border-color 0.22s;
}
.cb-tab:hover { color: var(--ink, #131c27); background: rgba(16, 24, 40, 0.05); }
.cb-tab.is-active {
  color: #04221d;
  background: linear-gradient(120deg, rgba(47, 224, 192, 0.94), rgba(76, 125, 255, 0.88));
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(15, 184, 156, 0.22);
}
.cb-tab:focus-visible { outline: 2px solid rgba(15, 184, 156, 0.7); outline-offset: 2px; }

/* ---------- views ---------- */
.cb-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cb-view[hidden] { display: none; }

/* ---------- showroom ---------- */
.cb-show {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 13px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 24, 40, 0.2) transparent;
}
.cb-show::-webkit-scrollbar { width: 6px; }
.cb-show::-webkit-scrollbar-thumb { background: rgba(16, 24, 40, 0.2); border-radius: 3px; }

.cb-show-intro {
  margin: 0 0 12px;
  font-size: 12.4px;
  line-height: 1.6;
  color: var(--muted, #5c6b7e);
}

.cb-pcard {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  margin-bottom: 9px;
  padding: 13px 14px 12px;
  text-align: left;
  border: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  border-radius: 13px;
  background: #ffffff;
  color: var(--ink, #131c27);
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: border-color 0.24s, background 0.24s, transform 0.24s;
}
.cb-pcard:hover {
  border-color: rgba(15, 184, 156, 0.42);
  background: rgba(15, 184, 156, 0.05);
  transform: translateY(-2px);
}
.cb-pcard:focus-visible { outline: 2px solid rgba(15, 184, 156, 0.7); outline-offset: 2px; }

.cb-pcard-top { display: flex; align-items: center; gap: 8px; }
.cb-pcard-idx {
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--faint, #8a9aae);
}
.cb-pcard-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 184, 156, 0.12);
  border: 1px solid rgba(15, 184, 156, 0.3);
  font-size: 10px;
  color: #0c8f78;
}
.cb-pcard-name { font-size: 14.4px; font-weight: 700; line-height: 1.35; color: var(--ink, #131c27); }
.cb-pcard-en {
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--faint, #8a9aae);
}
.cb-pcard-desc {
  margin-top: 3px;
  font-size: 12.4px;
  line-height: 1.6;
  color: var(--muted, #5c6b7e);
}
.cb-pcard-more {
  margin-top: 7px;
  font-size: 11.8px;
  font-weight: 600;
  color: #0c8f78;
}

/* detail */
.cb-show-back {
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 1px solid var(--line-2, rgba(16, 24, 40, 0.18));
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.03);
  color: var(--ink-2, #415063);
  font-family: inherit;
  font-size:11.8px;
  cursor: pointer;
  transition: background 0.22s, color 0.22s;
}
.cb-show-back:hover { background: rgba(16, 24, 40, 0.07); color: var(--ink, #131c27); }
.cb-detail-idx {
  margin: 0;
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--faint, #8a9aae);
}
.cb-detail-name { margin: 5px 0 2px; font-size: 17px; line-height: 1.3; font-weight: 700; color: var(--ink, #131c27); }
.cb-detail-en {
  margin: 0 0 10px;
  font-family: var(--mono, monospace);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--faint, #8a9aae);
}
.cb-detail-desc {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.72;
  color: var(--ink-2, #415063);
}
.cb-detail-points {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.cb-detail-points li {
  position: relative;
  padding-left: 16px;
  font-size: 12.6px;
  line-height: 1.6;
  color: var(--ink-2, #415063);
}
.cb-detail-points li::before {
  content: '';
  position: absolute;
  left: 3px; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #0fb89c;
  box-shadow: 0 0 7px rgba(15, 184, 156, 0.6);
}
.cb-card--detail { max-width: 100%; margin-top: 0; }
.cb-show-pane.is-in { animation: cb-slide-in 0.34s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes cb-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

/* cta bar */
.cb-show-cta {
  display: flex;
  gap: 8px;
  padding: 10px 13px 12px;
  border-top: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  background: rgba(16, 24, 40, 0.02);
}
.cb-btn {
  flex: 1 1 auto;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.8px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.22s, box-shadow 0.22s, background 0.22s;
}
.cb-btn--primary {
  color: #04221d;
  background: linear-gradient(120deg, #2fe0c0, #35c8ff);
  box-shadow: 0 6px 18px rgba(15, 184, 156, 0.24);
}
.cb-btn--ghost {
  flex: 0 0 auto;
  min-width: 68px;
  color: var(--ink-2, #415063);
  background: rgba(16, 24, 40, 0.04);
  border-color: var(--line-2, rgba(16, 24, 40, 0.18));
}
.cb-btn:hover { transform: translateY(-2px); }
.cb-btn:active { transform: none; }
.cb-btn:focus-visible { outline: 2px solid rgba(15, 184, 156, 0.7); outline-offset: 2px; }

/* log */
.cb-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 24, 40, 0.2) transparent;
}
.cb-log::-webkit-scrollbar { width: 6px; }
.cb-log::-webkit-scrollbar-thumb { background: rgba(16, 24, 40, 0.2); border-radius: 3px; }

.cb-msg { display: flex; gap: 9px; align-items: flex-start; }
.cb-msg.is-user { justify-content: flex-end; }
.cb-msg-avatar {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  margin-top: 2px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(140deg, #2fe0c0, #4c7dff);
}
.cb-bubble {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.6px;
  line-height: 1.68;
  color: var(--ink, #131c27);
  background: rgba(16, 24, 40, 0.04);
  border: 1px solid var(--line, rgba(16, 24, 40, 0.08));
  white-space: pre-wrap;
  word-break: break-word;
}
.cb-msg.is-user .cb-bubble {
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(120deg, rgba(47, 224, 192, 0.92), rgba(76, 125, 255, 0.85));
  color: #04221d;
  border-color: transparent;
  font-weight: 500;
}

/* stats card inside a bubble */
.cb-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 8px;
  max-width: 84%;
  background: var(--line, rgba(16, 24, 40, 0.10));
  border: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  border-radius: 12px;
  overflow: hidden;
}
.cb-card div {
  background: rgba(16, 24, 40, 0.03);
  padding: 11px 8px;
  text-align: center;
}
.cb-card b {
  display: block;
  font-family: var(--mono, monospace);
  font-size: 15px;
  color: #0c8f78;
  line-height: 1.1;
}
.cb-card span { display: block; margin-top: 4px; font-size: 10.5px; color: var(--muted, #5c6b7e); line-height: 1.3; }

/* typing */
.cb-typing .cb-bubble { display: flex; gap: 5px; padding: 14px; }
.cb-typing .cb-bubble i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted, #5c6b7e);
  animation: cb-bounce 1.1s ease-in-out infinite;
}
.cb-typing .cb-bubble i:nth-child(2) { animation-delay: 0.15s; }
.cb-typing .cb-bubble i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* chips */
.cb-chips {
  display: flex;
  gap: 8px;
  padding: 8px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cb-chips::-webkit-scrollbar { display: none; }
.cb-chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(15, 184, 156, 0.3);
  background: rgba(15, 184, 156, 0.08);
  color: var(--ink, #131c27);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.22s, border-color 0.22s, transform 0.22s;
}
.cb-chip:hover { background: rgba(15, 184, 156, 0.16); transform: translateY(-1px); }

/* input */
.cb-input {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line, rgba(16, 24, 40, 0.10));
  background: rgba(16, 24, 40, 0.02);
}
.cb-input textarea {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 96px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-2, rgba(16, 24, 40, 0.18));
  background: #ffffff;
  color: var(--ink, #131c27);
  font-family: inherit;
  font-size: 13.6px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}
.cb-input textarea::placeholder { color: var(--faint, #8a9aae); }
.cb-input textarea:focus {
  outline: none;
  border-color: rgba(15, 184, 156, 0.55);
  background: rgba(15, 184, 156, 0.04);
}
.cb-send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, #2fe0c0, #35c8ff);
  color: #04221d;
  cursor: pointer;
  transition: transform 0.22s, box-shadow 0.22s;
  box-shadow: 0 6px 18px rgba(15, 184, 156, 0.24);
}
.cb-send:hover { transform: translateY(-2px); }
.cb-send:active { transform: none; }

.cb-foot {
  margin: 0;
  padding: 0 14px 12px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--faint, #8a9aae);
  text-align: center;
}

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 620px) {
  .cb-panel {
    position: fixed;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: min(78vh, 640px);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .cb[data-state="open"] .cb-panel { transform: translateY(0); }
  .cb-launcher-text { display: none; }
  .cb-launcher { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .cb, .cb-panel, .cb-launcher, .cb-chip, .cb-send { transition-duration: 0.001ms !important; }
  .cb-tab, .cb-pcard, .cb-btn, .cb-show-back { transition-duration: 0.001ms !important; }
  .cb-pcard:hover, .cb-btn:hover { transform: none !important; }
  .cb-dot, .cb-typing .cb-bubble i, .cb-tip { animation: none !important; }
  .cb-show-pane.is-in { animation: none !important; }
  .cb-launcher::after { display: none !important; }
  .cb[data-state="open"] .cb-panel { animation: none !important; }
}
