/* Brain Star Map — Research Console
   Dark-space theme matching the star-map corpus visualizer.
   The embed-auth block (auth bar) is styled, not replaced — the scaffold's
   auth plumbing in app.js is untouched. */

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

:root {
  --bg: #020205;
  --bg-raised: #0a0a14;
  --panel: rgba(15, 23, 42, 0.55);
  --panel-solid: #0d1322;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.32);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #0f52ba;
  --accent-2: #e0115f;
  --violet: #8b5cf6;
  --emerald: #10b981;
  --amber: #f59e0b;
  --teal: #14b8a6;
  --pink: #ec4899;
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- starfield background ---------- */
.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(15, 82, 186, 0.22), transparent 60%),
    radial-gradient(ellipse 60% 40% at 85% 110%, rgba(224, 17, 95, 0.10), transparent 60%),
    var(--bg);
}
.starfield::before, .starfield::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 24%, rgba(255,255,255,0.55), transparent 100%),
    radial-gradient(1px 1px at 27% 62%, rgba(255,255,255,0.35), transparent 100%),
    radial-gradient(1.5px 1.5px at 41% 12%, rgba(255,255,255,0.5), transparent 100%),
    radial-gradient(1px 1px at 58% 81%, rgba(255,255,255,0.4), transparent 100%),
    radial-gradient(1px 1px at 71% 33%, rgba(255,255,255,0.55), transparent 100%),
    radial-gradient(1.5px 1.5px at 84% 68%, rgba(255,255,255,0.45), transparent 100%),
    radial-gradient(1px 1px at 92% 15%, rgba(255,255,255,0.5), transparent 100%),
    radial-gradient(1px 1px at 6% 88%, rgba(255,255,255,0.4), transparent 100%),
    radial-gradient(1px 1px at 49% 47%, rgba(255,255,255,0.3), transparent 100%),
    radial-gradient(1.2px 1.2px at 34% 91%, rgba(139,92,246,0.5), transparent 100%),
    radial-gradient(1.2px 1.2px at 88% 42%, rgba(16,185,129,0.5), transparent 100%),
    radial-gradient(1px 1px at 65% 8%, rgba(224,17,95,0.5), transparent 100%);
  background-repeat: repeat;
  background-size: 340px 340px;
}
.starfield::after {
  animation: drift 90s linear infinite;
  opacity: 0.5;
}
@keyframes drift {
  from { transform: translateY(0); }
  to   { transform: translateY(-340px); }
}

[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 20px 28px 0;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  font-size: 26px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(15, 82, 186, 0.9);
  animation: twinkle 3.2s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.92); }
}
.brand-text h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #f8fafc, #c7d2fe);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-text p { font-size: 11px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.02em; }

#auth-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-state { font-size: 11px; color: var(--emerald); }
.auth-error { font-size: 12px; color: #fb7185; max-width: 320px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-auth {
  background: linear-gradient(135deg, #0f52ba, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 18px rgba(15, 82, 186, 0.45);
}
.btn-auth:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(15, 82, 186, 0.6);
  filter: brightness(1.08);
}
.btn-ghost {
  background: rgba(148, 163, 184, 0.08);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: rgba(148, 163, 184, 0.16); color: var(--text); }
.btn-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #7dd3fc;
  box-shadow: 0 0 8px rgba(125, 211, 252, 0.9);
}
.btn-lg { padding: 12px 22px; font-size: 14px; }

.btn-primary {
  background: linear-gradient(135deg, #0f52ba, #2563eb);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  padding: 11px 22px;
  font-size: 14px;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(37, 99, 235, 0.55);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-arrow { font-size: 11px; }

/* ---------- main layout ---------- */
main { flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; padding: 20px 28px 40px; }

/* ---------- signed-out gate ---------- */
.gate { display: flex; justify-content: center; align-items: center; min-height: 55vh; }
.gate-card {
  max-width: 480px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.gate-icon {
  font-size: 34px;
  color: var(--accent-2);
  text-shadow: 0 0 22px rgba(224, 17, 95, 0.8);
  margin-bottom: 14px;
}
.gate-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.gate-card p { font-size: 13.5px; line-height: 1.65; color: var(--text-muted); margin-bottom: 26px; }

/* ---------- agent nav ---------- */
.agent-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.agent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.18s ease;
  backdrop-filter: blur(8px);
}
.agent-chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.agent-chip.active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--chip-color, var(--accent)) 45%, transparent);
}
.chip-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--chip-color, var(--accent));
  box-shadow: 0 0 8px var(--chip-color, var(--accent));
}
.agent-chip.active .chip-dot { box-shadow: 0 0 10px var(--chip-color, var(--accent)); }

/* ---------- console grid ---------- */
.console-grid {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 18px;
  align-items: start;
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  position: sticky;
  top: 20px;
}
.agent-card-head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.agent-orb {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff 0%, var(--card-color, var(--accent)) 45%, transparent 75%);
  box-shadow: 0 0 20px var(--card-color, var(--accent));
  flex-shrink: 0;
}
.agent-card h2 { font-size: 16.5px; font-weight: 600; }
.agent-card p { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 3px; }
.agent-badges { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.agent-badges li {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}
.agent-kind {
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  line-height: 1.55;
}

/* ---------- console main ---------- */
.console-main {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-line {
  font-size: 12px;
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.status-line::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: #60a5fa;
  animation: pulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.9);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.answer-meta, .sources-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.answer-state { font-size: 10px; letter-spacing: 0.06em; color: var(--emerald); font-weight: 500; }
.answer-state.working { color: #93c5fd; }

.answer-area, .sources-area, .report-area {
  background: rgba(2, 2, 5, 0.45);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.answer-text {
  font-size: 13.5px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
  color: #dbe4f0;
}
.answer-text .cite {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.15);
  border-radius: 5px;
  padding: 0 5px;
  margin: 0 1px;
}

.sources-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.sources-list a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
  transition: all 0.16s ease;
}
.sources-list a:hover {
  border-color: var(--border-strong);
  background: rgba(15, 82, 186, 0.12);
  transform: translateX(3px);
}
.src-idx {
  font-family: var(--mono);
  font-size: 11px;
  color: #7dd3fc;
  background: rgba(15, 82, 186, 0.3);
  border-radius: 5px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.src-title { font-size: 13px; font-weight: 500; flex: 1; line-height: 1.45; }
.src-year {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.src-ext { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }

/* pipe feed — live paper events */
.feed-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(148, 163, 184, 0.05);
  margin-bottom: 6px;
  animation: feed-in 0.25s ease;
}
@keyframes feed-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.feed-year {
  font-family: var(--mono);
  font-size: 11px;
  color: #5eead4;
  background: rgba(13, 148, 136, 0.18);
  border-radius: 5px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.feed-title { font-size: 12.5px; flex: 1; line-height: 1.45; color: #d7e3ef; }
.feed-link { color: #5eead4; text-decoration: none; font-size: 12px; flex-shrink: 0; }
.feed-link:hover { text-decoration: underline; }

.report-text {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #b7c5d8;
  max-height: 300px;
  overflow-y: auto;
}
.report-text::-webkit-scrollbar, .answer-text::-webkit-scrollbar { width: 6px; }
.report-text::-webkit-scrollbar-thumb, .answer-text::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.2); border-radius: 3px; }

/* ---------- composer ---------- */
.composer { display: flex; flex-direction: column; gap: 11px; }
.composer-inputs { display: flex; flex-direction: column; gap: 11px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.field textarea, .field input {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--text);
  background: rgba(2, 2, 5, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.55;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.field textarea:focus, .field input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.field .hint { font-size: 11px; color: var(--text-faint); }
.composer-actions { display: flex; justify-content: flex-end; }

/* ---------- footer ---------- */
.footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  padding: 18px 28px 26px;
  line-height: 1.6;
}
.footer a { color: #93c5fd; text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .console-grid { grid-template-columns: 1fr; }
  .agent-card { position: static; }
  .topbar { padding: 16px 18px 0; }
  main { padding: 16px 18px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .starfield::after, .brand-mark { animation: none; }
}
