/* ── Chat Widget ─────────────────────────────────────────────────── */

.cw-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(74, 222, 128, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.cw-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(74, 222, 128, 0.4);
}

.cw-bubble.open {
  display: none;
}

.cw-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
}

.cw-backdrop.open {
  display: block;
}

.cw-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  height: 540px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.cw-panel.open {
  display: flex;
}

.cw-panel.maximized {
  width: 480px;
  height: 680px;
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%);
  border-radius: 20px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}

.cw-header {
  padding: 14px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cw-header-title {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cw-header-title .cw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.cw-npc-badge {
  font-size: 11px;
  background: var(--accent-glow);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.cw-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.cw-close:hover { color: var(--text); }

.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cw-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.cw-msg.user {
  align-self: flex-end;
  background: var(--accent-glow);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.cw-msg.assistant {
  align-self: flex-start;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.cw-msg .cw-emotion {
  display: block;
  font-size: 11px;
  color: var(--cyan);
  margin-top: 4px;
}

.cw-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  max-height: 360px;
  overflow-y: auto;
}

.cw-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.cw-btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.cw-typing {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  display: none;
  align-items: center;
  gap: 6px;
}

.cw-typing.visible { display: flex; }

.cw-typing-dots {
  display: flex;
  gap: 4px;
}

.cw-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: cw-bounce 1.4s ease-in-out infinite;
}

.cw-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.cw-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.cw-input-area {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.cw-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.cw-input:focus { border-color: var(--accent); }

.cw-send {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.cw-send:hover { filter: brightness(1.1); }
.cw-send:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 480px) {
  .cw-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    border-radius: 12px;
  }
}
