:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1c2029;
  --accent: #e8a23d;
  --accent-dim: #b57f2e;
  --link: #4fd1c5;
  --text: #ededee;
  --muted: #8a8f98;
  --muted-2: #5a5f68;
  --border: #262a33;
  --danger: #e2626b;
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.accent { color: var(--accent); }

/* thin scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- Layout ---------- */
.page { min-height: 100vh; display: flex; justify-content: center; }
.wrap {
  width: 100%;
  max-width: 760px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
}

.header { padding: 34px 4px 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.radar {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 12px rgba(232, 162, 61, .6);
  display: inline-block;
}
.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500; font-size: 30px;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 8px 0 0 26px;
  font-family: var(--font-mono);
  font-size: 12px; color: var(--muted);
  letter-spacing: 0.02em;
}

.stream {
  flex: 1;
  display: flex; flex-direction: column; gap: 16px;
  padding: 8px 0 12px;
  overflow-y: auto;
}

/* ---------- Empty state ---------- */
.empty {
  margin-top: 24px;
  padding: 28px 24px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.empty-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px; line-height: 1.5;
}
.empty-hint { margin: 12px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* ---------- Result card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.card-num {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--accent);
  letter-spacing: 0.08em;
}
.deep-badge {
  font-family: var(--font-mono);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--bg); background: var(--accent);
  border-radius: 6px; padding: 2px 8px;
}
.question {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 500; font-size: 21px; line-height: 1.35;
  overflow-wrap: anywhere;
}
.prose p {
  margin: 0 0 12px;
  font-size: 15px; line-height: 1.68; color: #dcdde0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.section {
  margin-top: 6px; margin-bottom: 16px;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.section-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 600; font-size: 16px; color: var(--accent);
  overflow-wrap: anywhere;
}

/* ---------- Sources ---------- */
.sources { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.sources-label {
  font-family: var(--font-mono);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted-2); margin-bottom: 10px;
}
.source-list { list-style: none; margin: 0; padding: 0; }
.source-item { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.source-num { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); min-width: 16px; }
.source-link { font-size: 13.5px; color: var(--link); line-height: 1.5; overflow-wrap: anywhere; }

/* ---------- Loading (scan-line) ---------- */
.loading-card { padding-top: 22px; padding-bottom: 22px; position: relative; overflow: hidden; }
.loading-row { display: flex; align-items: center; gap: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.loading-text { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }

.scan::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  box-shadow: 0 0 18px 2px rgba(232, 162, 61, .55);
  animation: scanline 1.5s cubic-bezier(.4, 0, .2, 1) infinite;
}
.scan::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(232, 162, 61, .06), transparent 40%);
  pointer-events: none;
  animation: scanglow 1.5s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes scanline {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(120px); opacity: 0; }
}
@keyframes scanglow {
  0% { transform: translateY(0); opacity: .7; }
  100% { transform: translateY(120px); opacity: 0; }
}
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { opacity: .25; } }

/* ---------- Composer ---------- */
.composer { padding: 6px 0 22px; }
.error {
  margin-bottom: 10px; padding: 10px 14px; border-radius: 10px;
  background: rgba(226, 98, 107, .1); border: 1px solid rgba(226, 98, 107, .35);
  color: var(--danger); font-size: 13px;
}
.toggle-row { margin-bottom: 10px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 6px 12px 6px 8px;
  font-size: 12.5px; font-family: var(--font-mono); letter-spacing: 0.02em;
  transition: all .15s ease;
}
.toggle.on { color: var(--accent); border-color: var(--accent-dim); background: rgba(232, 162, 61, .08); }
.toggle-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted-2); display: inline-block; transition: all .15s ease;
}
.toggle.on .toggle-dot {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 40%, transparent 45%);
  box-shadow: 0 0 8px rgba(232, 162, 61, .5);
}

.input-row {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px;
}
#input {
  flex: 1; resize: none; max-height: 160px;
  background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--font-ui);
  font-size: 15px; line-height: 1.5; padding: 8px;
  overflow-wrap: anywhere;
}
.send {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; border: none;
  background: var(--accent); color: var(--bg);
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s ease;
}
.send:disabled { background: var(--surface-2); color: var(--muted-2); cursor: not-allowed; }
