:root {
  --bg: #0a0d14;
  --panel: #12161f;
  --panel-2: #181e2a;
  --line: #273041;
  --text: #e8edf5;
  --muted: #9fb0c3;
  --accent: #5ea0ff;
  --good: #3ecf8e;
  --warn: #f0b64f;
  --bad: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 70% -10%, #1a2433, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

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

header {
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.2px;
  font-weight: 700;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status {
  margin: 14px 0 6px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.chip strong {
  color: var(--text);
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.dot.ready { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.error { background: var(--bad); }

.progress {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--accent), #8fc1ff);
  transition: width 160ms ease;
}

.progress-label {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.conversation {
  margin: 18px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 140px;
}

.msg {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  max-width: 86%;
}

.msg.user {
  align-self: flex-end;
  background: var(--panel-2);
}

.msg.bot {
  align-self: flex-start;
  background: var(--panel);
}

.msg.system {
  color: var(--muted);
  font-size: 0.9rem;
}

.msg .answer {
  white-space: pre-wrap;
  word-break: break-word;
}

.msg .cite {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--accent);
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}

.msg .cite b {
  color: var(--muted);
  font-weight: 600;
}

.msg .meta {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.composer {
  display: flex;
  gap: 10px;
  margin: 6px 0 8px;
}

#q {
  flex: 1;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font: inherit;
}

#q::placeholder { color: #8a9ab3; }

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

button {
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #04122b;
  font-weight: 650;
  cursor: pointer;
  transition: transform 60ms ease, filter 60ms ease;
}

button:hover { filter: brightness(1.03); }
button:active { transform: translateY(1px); }

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.examples button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 6px 11px;
  border-radius: 999px;
}

.examples button:hover {
  color: var(--text);
  border-color: #3a475e;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 10px;
}

.muted { color: var(--muted); }

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
  .msg { transition: none; }
}

/* High contrast focus */
@media (prefers-contrast: more) {
  .chip { border-color: #5a6a85; }
  #q, .msg { border-color: #5a6a85; }
}
