:root {
  --bg-primary: #07090e;
  --bg-card: rgba(16, 22, 34, 0.85);
  --bg-surface: #0f172a;
  --border-color: rgba(16, 185, 129, 0.2);
  --border-glow: rgba(16, 185, 129, 0.4);
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.vector-icon {
  width: 44px;
  height: 44px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-emerald);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-emerald);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.35);
}

h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.highlight {
  color: var(--accent-emerald);
  text-shadow: 0 0 14px rgba(16, 185, 129, 0.4);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.badge {
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
}

.github-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-main);
  text-decoration: none;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.github-btn:hover {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.5rem;
  flex: 1;
}

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

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Samples */
.sample-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.sample-btn {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sample-btn:hover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
}

/* Textarea */
.textarea-wrapper {
  display: flex;
  flex-direction: column;
}

textarea {
  width: 100%;
  background: rgba(8, 12, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 1rem;
  color: #fff;
  font-family: 'Fira Code', monospace;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 150px;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--accent-emerald);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'Fira Code', monospace;
}

.btn-sm {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-sm:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
}

/* Search Box */
.search-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(8, 12, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
}

.search-icon {
  color: var(--text-muted);
}

.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #059669, var(--accent-emerald));
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.query-suggestions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
}

/* Results */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.4rem;
}

.result-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.result-card.top-match {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-index {
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.similarity-badge {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.result-snippet {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.result-snippet mark {
  background: rgba(16, 185, 129, 0.3);
  color: #fff;
  padding: 0 0.2rem;
  border-radius: 2px;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* 2D Vector Space Projection */
.canvas-container {
  background: #020408;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#vectorCanvas {
  width: 100%;
  height: 280px;
  display: block;
}

.canvas-legend {
  display: flex;
  gap: 1rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chunk-dot { background: var(--accent-purple); }
.query-dot { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.match-dot { background: var(--accent-emerald); box-shadow: 0 0 8px var(--accent-emerald); }

.telemetry-badge {
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--accent-cyan);
}

/* Telemetry Box */
.telemetry-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.telemetry-box h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.metric-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.metric-value {
  font-family: 'Fira Code', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-emerald);
}

/* Footer */
.app-footer {
  text-align: center;
  padding-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer a {
  color: var(--accent-emerald);
  text-decoration: none;
}
