:root {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --panel: #161b27;
  --panel-2: #1d2333;
  --border: #262d40;
  --text: #e7ecf5;
  --muted: #97a2b8;
  --accent: #7aa7ff;
  --accent-2: #5fd0c4;
  --warn: #f3c969;
  --error: #ff6b6b;
  --ok: #4ade80;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fc;
    --bg-2: #eef2f9;
    --panel: #ffffff;
    --panel-2: #f3f6fc;
    --border: #dde3ee;
    --text: #0f1626;
    --muted: #5b6680;
    --accent: #2563eb;
    --accent-2: #0d9488;
    --warn: #b45309;
    --error: #dc2626;
    --ok: #16a34a;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(122,167,255,0.12), transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--panel); padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); text-decoration: none;
  z-index: 50;
}
.skip:focus { left: 12px; top: 12px; }

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.hero { margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 22px rgba(122,167,255,0.35);
  flex: none;
}
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -0.01em; }
.tag { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.lede { margin: 6px 0 0; color: var(--muted); font-size: 0.96rem; }
.lede strong { color: var(--text); }
code { font-family: var(--mono); font-size: 0.85em; background: var(--panel-2); padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); }

.status-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 16px 0 14px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-label { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot-ready { background: var(--ok); box-shadow: 0 0 0 3px rgba(74,222,128,0.18); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(243,201,105,0.18); }
.dot-error { background: var(--error); box-shadow: 0 0 0 3px rgba(255,107,107,0.18); }

.load-progress {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.load-progress-bar {
  height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden;
}
#loadBar {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}
.load-label { display: block; margin-top: 8px; font-size: 0.8rem; color: var(--muted); font-family: var(--mono); word-break: break-word; }

#log {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 14px;
}
.msg {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-width: 100%;
}
.msg.user {
  align-self: flex-end;
  max-width: 80%;
  background: linear-gradient(135deg, rgba(122,167,255,0.18), rgba(95,208,196,0.12));
  border-color: rgba(122,167,255,0.35);
}
.msg.bot .answer { white-space: pre-wrap; word-break: break-word; }
.msg.bot.intro { background: transparent; border-style: dashed; color: var(--muted); }
.msg.bot.intro .answer { color: var(--muted); }

.cite {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}
.cite b { color: var(--text); font-family: var(--sans); }
.cite .src {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  margin: 2px 4px 0 0;
  color: var(--accent-2);
}

.meta {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--muted);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

#askForm {
  display: flex; gap: 10px;
  position: sticky; bottom: 0;
  background: linear-gradient(var(--bg), var(--bg) 60%, transparent);
  padding: 12px 0 4px;
}
#q {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122,167,255,0.18); }
#q::placeholder { color: var(--muted); }
#send {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0b0e14;
  font-weight: 600;
  border-radius: 12px;
  padding: 0 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s;
}
#send:hover { opacity: 0.92; }
#send:active { transform: translateY(1px); }
#send:disabled { opacity: 0.5; cursor: default; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.examples button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.examples button:hover { border-color: var(--accent); color: var(--text); background: var(--panel-2); }

.hint { color: var(--muted); font-size: 0.78rem; margin: 6px 0 0; }

@media (max-width: 560px) {
  #askForm { flex-direction: column; }
  #send { padding: 12px; }
  .msg.user { align-self: stretch; max-width: 100%; }
}
