:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --border: #e3e3e6;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --user-bubble: #4f46e5;
  --assistant-bubble: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --panel: #1f1f24;
    --text: #f2f2f4;
    --muted: #a0a0a8;
    --border: #2e2e35;
    --accent: #7c74ff;
    --user-bubble: #4f46e5;
    --assistant-bubble: #24242b;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.brand { font-weight: 650; }
.hint { color: var(--muted); font-size: 12.5px; }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

.msg { display: flex; margin: 10px 0; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid var(--border);
  background: var(--assistant-bubble);
}
.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--accent-text);
  border-color: transparent;
}
.bubble .sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.bubble .sources a { color: var(--accent); }
.bubble.error { border-color: #d9534f; color: #d9534f; }

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.chip:hover { background: var(--bg); }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
#input {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
#input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#send {
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#send:disabled { opacity: 0.55; cursor: default; }

.cursor::after {
  content: "▍";
  animation: blink 1s steps(2) infinite;
  color: var(--muted);
}
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
