:root {
  --bg: #090b10;
  --surface: rgba(18, 22, 31, 0.84);
  --surface-solid: #12161f;
  --surface-hover: #181e2b;
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(99, 102, 241, 0.65);
  --text: #f3f5f8;
  --text-muted: #98a2b3;
  --accent: #6366f1;
  --accent-hover: #7c7ff5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --success: #10b981;
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ambient-glow {
  position: fixed;
  inset: -200px auto auto 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 520px;
  background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.18) 0%, rgba(14, 165, 233, 0.06) 45%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  backdrop-filter: blur(16px);
  background: rgba(9, 11, 16, 0.72);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #38bdf8);
  color: #fff;
}

.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 16px; }
.brand-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.topbar-links { display: flex; gap: 20px; }
.topbar-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}
.topbar-links a:hover { color: var(--text); }

.container {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 72px 20px 80px;
  transition: padding-top 0.3s ease;
}

.container.has-results { padding-top: 32px; }

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.container.has-results .hero {
  display: none;
}

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #a5b4fc;
  background: var(--accent-soft);
  border: 1px solid rgba(99, 102, 241, 0.28);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #b8c0d4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 560px;
  margin: 0 auto;
}

.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14), var(--shadow);
}

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

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

#questionInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 10px 0;
}

#questionInput::placeholder { color: #647084; }

.ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.ask-btn:hover:not(:disabled) { background: var(--accent-hover); }
.ask-btn:active:not(:disabled) { transform: scale(0.98); }
.ask-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.turnstile-slot {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.turnstile-slot:empty { display: none; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.18);
}

.status-area {
  margin-top: 26px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.status-area.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-area { margin-top: 28px; display: flex; flex-direction: column; gap: 24px; }

.answer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  box-shadow: var(--shadow);
}

.answer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.answer-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a5b4fc;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }

.answer-body { font-size: 15.5px; color: #e6eaf2; }
.answer-body p { margin-bottom: 12px; }
.answer-body p:last-child { margin-bottom: 0; }
.answer-body ul, .answer-body ol { margin: 10px 0 14px 22px; }
.answer-body li { margin-bottom: 6px; }
.answer-body a { color: #93c5fd; text-decoration: underline; }
.answer-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.media-gallery {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.media-card {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.media-card img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.media-card video {
  width: 100%;
  max-height: 260px;
  display: block;
  background: #000;
}

.media-caption {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.media-caption a { color: #a5b4fc; text-decoration: none; font-weight: 500; }

.sources-heading {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.source-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.topic-tag {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 6px;
  color: #cbd5e1;
}

.source-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 10, 0.88);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 26px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}

.hidden { display: none !important; }
