* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a25;
  --border: #1e1e2e;
  --text: #e0e0e8;
  --text-muted: #6b6b80;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --danger: #ef4444;
  --gemini: #4285F4;
  --grok: #1DA1F2;
  --qwen: #8B5CF6;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
header {
  text-align: center;
  padding: 32px 0 16px;
}

header h1 {
  font-size: 2rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--gemini), var(--qwen), var(--grok));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

/* Agent badges */
.agents-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 20px 0;
  flex-wrap: wrap;
}

.agent-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  transition: all 0.2s;
}

.agent-badge:hover {
  background: var(--surface-hover);
  border-color: #2a2a3e;
  transform: translateY(-1px);
}

.agent-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px currentColor;
}

.agent-model {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

/* Topic form */
.topic-form {
  display: flex;
  gap: 10px;
  padding: 20px 0;
}

.topic-form input {
  flex: 1;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
}

.topic-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topic-form input::placeholder {
  color: var(--text-muted);
}

#random-btn {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}

#random-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

#random-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#random-btn.spinning {
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.topic-form button#start-btn {
  padding: 14px 28px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.topic-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.topic-form button:active {
  transform: translateY(0);
}

.topic-form button:disabled {
  background: #252530;
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Mode toggle */
.mode-toggle {
  display: flex;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

.mode-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.mode-btn:hover:not(.active) {
  background: var(--surface-hover);
}

/* Next button */
.next-btn {
  padding: 10px 24px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.next-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.5);
}

.next-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Chat area */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scroll-behavior: smooth;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Chat bubbles */
.chat-bubble {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: background 0.2s;
}

.chat-bubble:hover {
  background: var(--surface-hover);
}

.chat-bubble[data-agent="gemini"] {
  border-left: 3px solid var(--gemini);
}

.chat-bubble[data-agent="grok"] {
  border-left: 3px solid var(--grok);
}

.chat-bubble[data-agent="qwen"] {
  border-left: 3px solid var(--qwen);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bubble-avatar {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #1a1a28;
}

.bubble-body {
  flex: 1;
  min-width: 0;
}

.bubble-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.bubble-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.bubble-time {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: "SF Mono", Monaco, monospace;
}

.bubble-content {
  line-height: 1.7;
  font-size: 0.95rem;
  word-wrap: break-word;
  color: #d0d0dc;
}

/* Reply quote */
.reply-quote {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 2px solid var(--accent);
  background: rgba(99, 102, 241, 0.06);
  border-radius: 0 8px 8px 0;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.2s;
  overflow: hidden;
}

.reply-quote:hover {
  background: rgba(99, 102, 241, 0.12);
}

.reply-name {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.reply-text {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bubble footer */
.bubble-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  min-height: 22px;
}

/* Reactions */
.reactions-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-size: 0.78rem;
  cursor: default;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Emoji trigger */
.emoji-trigger {
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  position: relative;
  padding: 2px;
  display: flex;
  align-items: center;
}

.chat-bubble:hover .emoji-trigger {
  opacity: 1;
}

.emoji-trigger:hover {
  color: var(--accent);
}

/* Emoji picker */
.emoji-picker {
  position: absolute;
  bottom: 24px;
  right: 0;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: #1e1e2e;
  border: 1px solid #2e2e42;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 10;
  animation: popIn 0.15s ease;
}

.emoji-btn {
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s;
}

.emoji-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Highlight on scroll-to */
.chat-bubble.highlight {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline 0.3s;
}

/* Typing indicator */
.typing-indicator {
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 0;
}

.typing-indicator:empty {
  display: none;
}

.typing-dots {
  display: inline-flex;
  gap: 5px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Controls */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.message-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: "SF Mono", Monaco, monospace;
}

.stop-btn {
  padding: 10px 24px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.stop-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.hidden {
  display: none !important;
}

/* Error message */
.error-bubble {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.2);
}

.error-text {
  color: #fca5a5;
  font-size: 0.85rem;
}

/* Status message */
.status-message {
  text-align: center;
  color: var(--text-muted);
  padding: 16px;
  font-size: 0.85rem;
  position: relative;
}

.status-message::before,
.status-message::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}

.status-message::before {
  left: 0;
}

.status-message::after {
  right: 0;
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
  width: 5px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: #252535;
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: #35354a;
}

/* Responsive */
@media (max-width: 480px) {
  .container {
    padding: 16px 12px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .agents-bar {
    gap: 6px;
  }

  .agent-badge {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .topic-form {
    flex-direction: column;
  }

  .topic-form button,
  .mode-toggle {
    width: 100%;
  }

  .mode-btn {
    flex: 1;
  }

  .chat-bubble {
    padding: 12px;
    gap: 10px;
  }
}
