:root {
  --bg: #0a0b10;
  --bg-elev: #11131b;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --text: #e7eaf2;
  --text-muted: rgba(231, 234, 242, 0.62);
  --text-dim: rgba(231, 234, 242, 0.4);
  --accent: #7c5cff;
  --accent-2: #21d4a3;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --warn: #ffb14a;
  --grad: linear-gradient(135deg, #7c5cff 0%, #21d4a3 100%);
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, monospace;
  --radius: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(800px 400px at 80% -100px, rgba(124, 92, 255, 0.08), transparent 60%),
    radial-gradient(700px 350px at -10% 20%, rgba(33, 212, 163, 0.06), transparent 60%);
}

a { color: var(--accent-2); text-decoration: none; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
em { color: var(--text); font-style: normal; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 11, 16, 0.85);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--grad);
  box-shadow: 0 0 24px rgba(124, 92, 255, 0.35);
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 17px; }
.brand-tag { color: var(--text-muted); font-size: 13px; }
.stats { display: flex; gap: 22px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.stat-num { font-family: var(--font-mono); font-weight: 500; font-size: 14px; color: var(--text); }
.stat-lbl { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

/* container */
.container { max-width: 1180px; margin: 0 auto; padding: 56px 28px 80px; }

.intro h1 { font-size: 36px; line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 16px; max-width: 820px; font-weight: 700; }
.intro p { color: var(--text-muted); max-width: 760px; margin: 0 0 40px; font-size: 16px; }

/* ask */
.ask form {
  display: flex; gap: 10px;
  border: 1px solid var(--border-hover);
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(124, 92, 255, 0.05);
  transition: border-color .2s, box-shadow .2s;
}
.ask form:focus-within {
  border-color: rgba(124, 92, 255, 0.5);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(124, 92, 255, 0.12);
}
#ask-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font: inherit; font-size: 16px; padding: 14px 18px;
}
#ask-input::placeholder { color: var(--text-dim); }
#ask-btn {
  background: var(--grad); color: #0a0b10; border: none;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 0 22px; border-radius: 12px; cursor: pointer;
  transition: transform .15s, filter .15s;
}
#ask-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
#ask-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.example {
  font-size: 13px; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  transition: all .15s;
}
.example:hover {
  color: var(--text); border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

/* result */
.result { margin-top: 44px; }
.result-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
@media (max-width: 980px) { .result-grid { grid-template-columns: 1fr; } }

.answer-pane, .sources-pane {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 26px;
}
.pane-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.pane-header h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--text); letter-spacing: -0.01em; }
.timing, .hint { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }

.answer { font-size: 15.5px; line-height: 1.65; color: var(--text); }
.answer p { margin: 0 0 10px; }
.answer sup.cite {
  display: inline-block; vertical-align: super; font-size: 0.7em;
  color: var(--accent-2); cursor: pointer; padding: 0 2px;
  font-family: var(--font-mono); font-weight: 600;
}
.answer sup.cite:hover { color: var(--text); }

/* sources */
.sources { display: flex; flex-direction: column; gap: 10px; max-height: 720px; overflow-y: auto; padding-right: 6px; }
.source {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer; transition: all .15s;
}
.source:hover, .source.active { border-color: var(--border-hover); background: var(--bg-card-hover); }
.source.flash { box-shadow: 0 0 0 2px var(--accent), 0 0 36px rgba(124, 92, 255, 0.25); }
.src-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.src-idx {
  font-family: var(--font-mono); font-weight: 600; font-size: 11.5px;
  background: var(--accent-soft); color: var(--accent-2);
  padding: 2px 8px; border-radius: 999px;
}
.src-file { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.src-score { font-family: var(--font-mono); font-size: 11px; color: var(--accent-2); }
.src-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.badge {
  font-size: 10.5px; padding: 2px 7px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font-mono);
}
.badge.kind { background: rgba(124, 92, 255, 0.14); color: var(--accent); border-color: rgba(124, 92, 255, 0.25); }
.badge.supplier { background: rgba(33, 212, 163, 0.1); color: var(--accent-2); border-color: rgba(33, 212, 163, 0.2); }
.src-summary { color: var(--text); font-size: 13.5px; line-height: 1.5; }
.src-excerpt {
  margin-top: 10px; font-size: 12.5px; color: var(--text-muted);
  line-height: 1.55; white-space: pre-wrap; max-height: 0; overflow: hidden;
  transition: max-height .3s ease;
}
.source.open .src-excerpt { max-height: 600px; overflow-y: auto; padding-top: 8px; border-top: 1px dashed var(--border); }

/* loading */
.loading { margin-top: 44px; display: flex; gap: 22px; align-items: flex-start; }
.pulse {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.7);
  animation: pulse 1.6s infinite;
  margin-top: 4px;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.7); }
  70% { box-shadow: 0 0 0 18px rgba(124, 92, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0); }
}
.loading-text { display: flex; flex-direction: column; gap: 8px; }
.loading-text .step {
  color: var(--text-dim); font-family: var(--font-mono); font-size: 13px;
  transition: color .25s;
}
.loading-text .step.active { color: var(--text); }
.loading-text .step.done { color: var(--accent-2); }

/* under the hood */
.under-the-hood {
  margin-top: 64px; padding: 26px 28px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.under-the-hood h3 { margin: 0 0 16px; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.under-the-hood ol { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.under-the-hood li {
  counter-increment: step;
  display: flex; gap: 14px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px dashed var(--border);
  color: var(--text-muted); font-size: 14.5px;
}
.under-the-hood li:last-child { border-bottom: none; }
.under-the-hood li::before {
  content: counter(step, decimal-leading-zero);
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 4px;
  margin-top: 2px;
}
.step-tag {
  font-family: var(--font-mono); font-size: 11.5px;
  padding: 1px 7px; border-radius: 4px;
  background: rgba(33, 212, 163, 0.1); color: var(--accent-2);
  border: 1px solid rgba(33, 212, 163, 0.2);
  margin-right: 6px;
}
.footnote {
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px; line-height: 1.6;
}

/* scrollbar */
.sources::-webkit-scrollbar { width: 6px; }
.sources::-webkit-scrollbar-track { background: transparent; }
.sources::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
