:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16162a;
  --border: #2a2a4a;
  --border-hover: #3a3a6a;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6a6a8a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  padding: 40px 0 32px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon { font-size: 36px; }

.logo h1 {
  font-size: 42px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-secondary);
  font-size: 16px;
}

.repo-section { margin-bottom: 24px; }

.input-group {
  display: flex;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto 16px;
}

.repo-input {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-mono);
  transition: var(--transition);
}

.repo-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.repo-input::placeholder { color: var(--text-muted); }

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-send {
  padding: 12px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
}

.btn-send:hover:not(:disabled) { background: var(--accent-hover); }

.repo-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
}

.hint-btn {
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.hint-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.status {
  text-align: center;
  padding: 16px;
  margin-top: 16px;
  border-radius: var(--radius);
  font-size: 14px;
  animation: fadeIn 0.3s ease;
}

.status.info {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.status.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

.hidden { display: none !important; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  position: relative;
  top: 1px;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
}

.tab-content.active { display: block; }

.chat-container {
  display: flex;
  flex-direction: column;
  height: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.welcome-message h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.suggestion {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.message {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius);
  animation: slideUp 0.3s ease;
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.7;
}

.message-content {
  line-height: 1.7;
  white-space: pre-wrap;
}

.message-content code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}

.streaming::after {
  content: '▋';
  animation: blink 1s step-end infinite;
  color: var(--accent);
  margin-left: 2px;
}

@keyframes blink { 50% { opacity: 0; } }

.chat-input-group {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.graph-container {
  display: flex;
  height: 600px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.graph-viz {
  flex: 1;
  position: relative;
}

.graph-sidebar {
  width: 240px;
  padding: 20px;
  border-left: 1px solid var(--border);
  background: var(--bg-card);
  overflow-y: auto;
}

.graph-sidebar h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.file { background: #6366f1; }
.dot.function { background: #8b5cf6; }
.dot.contributor { background: #22c55e; }
.dot.issue { background: #ef4444; }
.dot.pr { background: #f59e0b; }
.dot.commit { background: #3b82f6; }
.dot.dependency { background: #ec4899; }

.node-details {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.node-details.hidden { display: none; }

#nodeJson {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.files-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 600px;
  overflow: hidden;
}

.files-list {
  padding: 20px;
  overflow-y: auto;
  height: 100%;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
}

.file-item:hover { background: var(--bg-tertiary); }

.file-icon { font-size: 16px; }

.file-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
}

.file-meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track { background: transparent; }

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

@media (max-width: 768px) {
  .app { padding: 16px; }
  .input-group { flex-direction: column; }
  .graph-container { flex-direction: column; }
  .graph-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .chat-container { height: 500px; }
}