:root {
  --bg: #08080c;
  --surface: #111118;
  --surface2: #1a1a24;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text2: #8888a0;
  --text3: #555568;
  --accent-a: #3b82f6;
  --accent-a-dim: rgba(59, 130, 246, 0.12);
  --accent-b: #a855f7;
  --accent-b-dim: rgba(168, 85, 247, 0.12);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Layout */
.app-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  max-height: 100vh;
  position: sticky;
  top: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo svg { width: 28px; height: 28px; }
.logo .accent-a { color: var(--accent-a); }
.logo .accent-b { color: var(--accent-b); }

/* Setup form */
.setup-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin-bottom: 12px;
}

.model-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888a0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.model-select:focus {
  outline: none;
  border-color: var(--accent-a);
}

.model-select option { background: var(--surface2); color: var(--text); }

optgroup { color: var(--text2); font-weight: 600; }

.label-a { color: var(--accent-a); }
.label-b { color: var(--accent-b); }

.seed-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  resize: vertical;
  min-height: 80px;
}

.seed-input:focus { outline: none; border-color: var(--accent-a); }
.seed-input::placeholder { color: var(--text3); }

.turns-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.turns-input {
  width: 70px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.9rem;
  text-align: center;
}

.turns-input:focus { outline: none; border-color: var(--accent-a); }

.turns-label { font-size: 0.85rem; color: var(--text2); }

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  width: 100%;
}

.btn-start {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  color: white;
}

.btn-start:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-start:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-pause {
  background: var(--surface2);
  color: var(--yellow);
  border: 1px solid var(--border);
}

.btn-pause:hover { border-color: var(--yellow); }

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

/* Status indicator */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.idle { background: var(--text3); }
.status-dot.running { background: var(--green); animation: pulse 1.5s infinite; }
.status-dot.paused { background: var(--yellow); }
.status-dot.done { background: var(--accent-a); }
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Purity badge */
.purity-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
}

.purity-badge svg { width: 14px; height: 14px; }

/* Main content */
.main-content {
  padding: 24px;
  overflow-y: auto;
  max-height: 100vh;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text3);
  gap: 16px;
  text-align: center;
}

.empty-state svg { width: 64px; height: 64px; opacity: 0.3; }

.hero-image {
  width: 100%;
  max-width: 480px;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
  object-fit: cover;
}
.empty-state h2 { font-size: 1.3rem; color: var(--text2); }
.empty-state p { font-size: 0.9rem; max-width: 400px; line-height: 1.6; }

/* Conversation messages */
.conversation {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 40px;
}

.msg {
  display: flex;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 4px;
}

.msg-avatar.a { background: var(--accent-a-dim); color: var(--accent-a); }
.msg-avatar.b { background: var(--accent-b-dim); color: var(--accent-b); }

.msg-body { flex: 1; min-width: 0; }

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.msg-model {
  font-size: 0.8rem;
  font-weight: 700;
}

.msg-model.a { color: var(--accent-a); }
.msg-model.b { color: var(--accent-b); }

.msg-time {
  font-size: 0.7rem;
  color: var(--text3);
  font-family: var(--mono);
}

.msg-turn {
  font-size: 0.65rem;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
}

.msg-content {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.a .msg-content { border-left: 3px solid var(--accent-a); }
.msg.b .msg-content { border-left: 3px solid var(--accent-b); }

/* Typing indicator */
.typing {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  animation: fadeIn 0.3s ease;
}

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

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: bounce 1.4s infinite;
}

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

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.typing-label {
  font-size: 0.8rem;
  color: var(--text3);
}

/* History sidebar */
.history-section { margin-top: auto; }

.history-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
}

.history-item:hover { border-color: var(--border); }
.history-item.active { border-color: var(--accent-a); }

.history-models {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-meta {
  color: var(--text3);
  font-size: 0.75rem;
  font-family: var(--mono);
}

/* Responsive */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main-content { max-height: none; }
  .hero-image { max-width: 100%; }
}
