:root {
  color-scheme: dark;
  --bg: #0f1218;
  --panel: #161a22;
  --border: rgba(255,255,255,0.1);
  --text: #ffffff;
  --text-muted: rgba(255,255,255,0.55);
  --accent: #4d8dff;
  --good: #10b981;
  --bad: #ff4444;
  --ai-accent: #a78bfa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1a1f2b, #0a0c10);
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 320px;
  text-align: center;
}

.modal-card h1 { margin: 0 0 4px; letter-spacing: 0.05em; }
.tagline { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.modal-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1218;
  color: var(--text);
  margin-bottom: 16px;
  font-size: 14px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 14px;
}
button:hover { filter: brightness(1.1); }
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button:disabled {
  background: rgba(255,255,255,0.08);
  color: var(--text-dim, rgba(255,255,255,0.35));
  cursor: not-allowed;
  filter: none;
}

.app { max-width: 1100px; margin: 0 auto; padding: 0 24px 40px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.brand { font-weight: 700; letter-spacing: 0.05em; font-size: 18px; }
.version { color: var(--accent); font-weight: 500; margin-left: 6px; }

.conn-banner {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.conn-banner.bad { background: rgba(255,68,68,0.15); color: var(--bad); }
.conn-banner.ok { background: rgba(16,185,129,0.15); color: var(--good); }

.presence { display: flex; gap: 8px; flex-wrap: wrap; }
.presence-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.main {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
}

.activity-panel { grid-column: 1 / -1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.panel h2 { margin: 0 0 12px; font-size: 16px; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--text-muted); font-weight: 400; font-size: 13px; }

.committed-view, textarea {
  width: 100%;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

textarea { min-height: 140px; resize: vertical; margin-bottom: 10px; }

.hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

.variants-list { display: flex; flex-direction: column; gap: 12px; max-height: 480px; overflow-y: auto; }

.variant-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #0a0c10;
}

.variant-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.variant-author { font-weight: 600; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.badge.pass { background: rgba(16,185,129,0.15); color: var(--good); }
.badge.fail { background: rgba(255,68,68,0.15); color: var(--bad); }

.variant-code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  background: #05060a;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  max-height: 140px;
  overflow-y: auto;
}

.variant-actions { display: flex; gap: 8px; align-items: center; }
.vote-count { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.empty-state { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

.activity-list { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--text-muted); max-height: 160px; overflow-y: auto; }
.activity-list li { padding: 4px 0; border-bottom: 1px dashed var(--border); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-row { margin-top: 8px; }
.ai-row input,
.ai-instruction-mini {
  flex: 1;
  min-width: 140px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(167,139,250,0.35);
  background: #0a0c10;
  color: var(--text);
  font-size: 13px;
}

.merge-notice {
  background: rgba(16,185,129,0.12);
  color: var(--good);
  border: 1px solid rgba(16,185,129,0.35);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.ai-btn {
  background: transparent;
  border: 1px solid var(--ai-accent);
  color: var(--ai-accent);
}
.ai-btn:hover { background: rgba(167,139,250,0.12); filter: none; }
.ai-btn:disabled {
  border-color: var(--border);
  color: var(--text-dim, rgba(255,255,255,0.35));
}

#ai-compare-btn { margin-bottom: 12px; }

.ai-panel { grid-column: 1 / -1; border-color: rgba(167,139,250,0.35); }
.ai-panel h2 { color: var(--ai-accent); }

.ai-activity-list { display: flex; flex-direction: column; gap: 10px; }

.ai-entry {
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 8px;
  padding: 10px 12px;
  background: #0a0c10;
}

.ai-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.ai-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.ai-status.streaming { background: rgba(167,139,250,0.18); color: var(--ai-accent); }
.ai-status.done { background: rgba(16,185,129,0.15); color: var(--good); }
.ai-status.error { background: rgba(255,68,68,0.15); color: var(--bad); }

.ai-entry-text {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

.ai-review {
  font-size: 12px;
  color: var(--ai-accent);
  background: rgba(167,139,250,0.08);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

@media (max-width: 800px) {
  .main { grid-template-columns: 1fr; }
}
