:root {
  --bg: #0a0d0b;
  --panel: #121613;
  --ink: #e9f5ec;
  --muted: #7c9686;
  --line: #223028;
  --accent: #ffb020;
  --accent-dim: rgba(255, 176, 32, 0.12);
  --accent-line: rgba(255, 176, 32, 0.4);
  --error: #ff5c5c;
  --error-dim: rgba(255, 92, 92, 0.12);
  --error-line: rgba(255, 92, 92, 0.4);
  --radius: 8px;
  --font-display: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --font-body: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  background:
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.012) 0px, rgba(255, 255, 255, 0.012) 1px, transparent 1px, transparent 3px),
    var(--bg);
}

h1, h2, h3, p { margin-top: 0; }

.shell { width: min(880px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 56px; }

.hero { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 40px; margin-bottom: 56px; padding-bottom: 40px; border-bottom: 1px solid var(--line); }
.hero-copy { max-width: 520px; }
.eyebrow { display: inline-block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 18px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.2rem, 6vw, 3.7rem); line-height: 1; letter-spacing: -0.02em; margin-bottom: 18px; text-shadow: 0 0 22px rgba(255, 176, 32, 0.22); }
h1::after { content: ""; display: inline-block; width: 0.5ch; height: 0.82em; margin-left: 0.12em; background: var(--accent); vertical-align: -0.08em; box-shadow: 0 0 8px rgba(255, 176, 32, 0.7); animation: cursor-blink 1.1s step-end infinite; }
.lede { color: var(--muted); font-size: 1.03rem; max-width: 460px; }
.hero-plot { flex-shrink: 0; position: relative; }
.hero-plot::before {
  content: "";
  position: absolute;
  inset: -30px;
  background: radial-gradient(circle, rgba(255, 176, 32, 0.14), transparent 70%);
  pointer-events: none;
}

@keyframes cursor-blink { 0%, 45% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { h1::after { animation: none; opacity: 0.7; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; }
.panel + .panel { margin-top: 22px; }

.stage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stage-tag { display: block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.stage-head h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
.stage-note { color: var(--muted); font-size: 0.8rem; font-family: var(--font-mono); }
.stage-note.is-ready { color: var(--accent); font-weight: 600; }

label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }

.dropzone { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 18px 20px; cursor: pointer; font-weight: 600; color: var(--ink); transition: border-color 0.15s ease, background 0.15s ease; }
.dropzone:hover { border-color: var(--accent); background: var(--accent-dim); }
.dropzone input[type="file"] { font-family: var(--font-mono); font-size: 0.82rem; max-width: 100%; color: var(--muted); }

.field-row { display: flex; gap: 24px; margin: 20px 0; flex-wrap: wrap; }
.field-row label { margin-bottom: 0; }
.field-row input { display: block; margin-top: 6px; width: 110px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--font-mono); font-size: 0.9rem; background: var(--bg); color: var(--ink); }

textarea { width: 100%; resize: vertical; min-height: 110px; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-family: var(--font-body); font-size: 0.98rem; margin-bottom: 16px; background: var(--bg); color: var(--ink); }
textarea::placeholder { color: var(--muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.button { display: inline-flex; align-items: center; gap: 8px; background: transparent; color: var(--accent); border: 1.5px solid var(--accent); border-radius: 6px; padding: 11px 19px; font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.button:hover { background: var(--accent); color: #0a0d0b; box-shadow: 0 0 16px rgba(255, 176, 32, 0.35); }

.notice { display: flex; align-items: flex-start; gap: 12px; border-radius: var(--radius); padding: 13px 16px; margin-top: 18px; font-size: 0.92rem; }
.notice-tag { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; flex-shrink: 0; margin-top: 2px; }
.notice.success { background: var(--accent-dim); border: 1px solid var(--accent-line); color: var(--ink); }
.notice.success .notice-tag { color: var(--accent); }
.notice.error { background: var(--error-dim); border: 1px solid var(--error-line); color: var(--ink); }
.notice.error .notice-tag { color: var(--error); }
.notice { animation: surface-in 0.35s ease-out; }

.answer { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 24px; animation: surface-in 0.4s ease-out; }
.answer h3 { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.answer-top { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.answer-main { flex: 1; min-width: 240px; }
.answer-text { white-space: pre-wrap; font-size: 1.02rem; line-height: 1.6; }

.answer-sources { margin-top: 22px; }
details { border-top: 1px solid var(--line); padding-top: 16px; color: var(--muted); }
summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink); }
.source { display: flex; gap: 14px; margin: 18px 0 0; }
.source-rank { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--accent-line); color: var(--accent); font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.source-body small { font-family: var(--font-mono); color: var(--muted); font-size: 0.75rem; }
.source-body p { margin: 4px 0 0; white-space: pre-wrap; font-size: 0.9rem; color: var(--ink); }

.retrieval-plot { width: 170px; height: 170px; overflow: visible; }
.retrieval-plot.is-ambient { width: 220px; height: 220px; opacity: 0.6; animation: plot-breathe 7s ease-in-out infinite; }
.plot-query { fill: var(--accent); filter: drop-shadow(0 0 6px rgba(255, 176, 32, 0.7)); }
.plot-node { fill: var(--panel); stroke: var(--accent); stroke-width: 1.6px; filter: drop-shadow(0 0 3px rgba(255, 176, 32, 0.4)); }
.plot-link { stroke: var(--accent-line); stroke-width: 1px; }
.plot-label { font-family: var(--font-mono); font-size: 9px; fill: var(--ink); text-anchor: middle; }
.plot-sweep { stroke: var(--accent); stroke-width: 1.2px; opacity: 0.55; filter: drop-shadow(0 0 3px rgba(255, 176, 32, 0.6)); animation: plot-rotate 4s linear infinite; }
.plot-sweep-tip { fill: var(--accent); filter: drop-shadow(0 0 4px rgba(255, 176, 32, 0.9)); animation: plot-rotate 4s linear infinite; }

@keyframes plot-breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.8; } }
@keyframes plot-rotate { to { transform: rotate(360deg); } }
@keyframes surface-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .retrieval-plot.is-ambient { animation: none; opacity: 0.55; }
  .plot-sweep, .plot-sweep-tip { animation: none; display: none; }
  .notice, .answer { animation: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.htmx-indicator { display: inline-flex; align-items: center; color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; margin-left: 14px; }
.htmx-indicator:not(.htmx-request) { display: none; }
.htmx-indicator .dots span { animation: dot-pulse 1.2s infinite; opacity: 0.2; }
.htmx-indicator .dots span:nth-child(2) { animation-delay: 0.2s; }
.htmx-indicator .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .htmx-indicator .dots span { animation: none; opacity: 1; } }
.runtime-note { text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 0.78rem; margin-top: 36px; letter-spacing: 0.02em; }

@media (max-width: 720px) { .hero { flex-direction: column; align-items: flex-start; } .hero-plot { display: none; } }
@media (max-width: 600px) { .shell { padding-top: 44px; } .panel { padding: 22px; } .field-row { flex-direction: column; gap: 14px; } .retrieval-plot:not(.is-ambient) { width: 130px; height: 130px; } }
