:root {
  --bg: #0b0e14;
  --panel: #141a24;
  --panel-2: #1b2430;
  --line: #273141;
  --text: #e7edf5;
  --muted: #9fb0c3;
  --accent: #5ea0ff;
  --accent-ink: #04122b;
  --good: #46d39a;
  --warn: #ffcf6b;
  --bad: #ff7b7b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1100px 560px at 72% -12%, #16202e, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 0 0 10px 0;
  z-index: 10;
}
.skip-link:focus { left: 0; }

.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 26px 18px 56px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top { margin-bottom: 10px; }

.brand { display: flex; gap: 14px; align-items: flex-start; }

.logo {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--bg) 0 26%, transparent 27%),
    conic-gradient(from 130deg, #5ea0ff, #7fd4ff, #5ea0ff);
  box-shadow: 0 0 24px rgba(94, 160, 255, 0.35);
}

h1 { font-size: 1.32rem; margin: 0; letter-spacing: 0.2px; }
.assistant-tag { color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }
.tagline code, .footnote code { color: var(--accent); font-size: 0.85em; }

.status-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 16px 0 0;
}

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 0.8rem; color: var(--muted);
}
.chip b { color: var(--text); font-weight: 600; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.loading { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.ready { background: var(--good); }
.dot.unavailable { background: var(--bad); }

@keyframes pulse { 50% { opacity: 0.35; } }

.progress { margin: 12px 0 0; }
.progress[hidden] { display: none; }
.progress-bar {
  height: 5px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #7fd4ff);
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(94, 160, 255, 0.4);
}
.progress-text { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; }

.chat {
  flex: 1;
  display: flex; flex-direction: column; gap: 14px;
  margin: 20px 0;
  min-height: 160px;
}

.msg {
  max-width: 92%;
  padding: 12px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.msg.user { background: var(--panel-2); align-self: flex-end; }
.msg.bot { background: var(--panel); align-self: flex-start; width: 100%; max-width: 100%; }

.msg .answer { white-space: pre-wrap; min-height: 1.4em; }
.msg .answer .caret {
  display: inline-block; width: 8px; height: 1.05em;
  background: var(--accent); vertical-align: text-bottom;
  animation: pulse 0.8s ease-in-out infinite;
  border-radius: 2px;
}

.sources {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 10px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 0.76rem;
}
.sources .label { color: var(--muted); font-weight: 600; }
.source-chip {
  padding: 3px 9px; border-radius: 999px;
  background: rgba(94, 160, 255, 0.12);
  border: 1px solid rgba(94, 160, 255, 0.35);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

.meta { margin-top: 7px; font-size: 0.73rem; color: var(--muted); }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.suggestion {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  font: inherit; font-size: 0.8rem;
  padding: 7px 13px; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.suggestion:hover { border-color: var(--accent); color: var(--text); }
.suggestion:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.composer { display: flex; gap: 10px; }
#question {
  flex: 1;
  padding: 13px 15px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
}
#question::placeholder { color: #64778e; }
#question:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.composer button {
  padding: 13px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit; font-weight: 650;
  cursor: pointer;
}
.composer button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.composer button:disabled { opacity: 0.55; cursor: default; }
#stopBtn { background: var(--panel-2); color: var(--warn); border-color: var(--line); }

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

@media (max-width: 560px) {
  .msg { max-width: 100%; }
  .status-bar { gap: 6px; }
  .chip { font-size: 0.72rem; padding: 5px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .dot.loading, .msg .answer .caret { animation: none; }
  .progress-bar { transition: none; }
}
