:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #8b97a3;
  --accent: #4a9eff;
  --user: #223547;
  --warn-bg: #3a2a18;
  --warn-line: #6b4b1f;
  --warn-text: #ffd9a0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
}
header h1 { font-size: 16px; margin: 0; font-weight: 600; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { height: 30px; width: auto; display: block; }
.brand .subtitle { font-size: 14px; font-weight: 600; color: var(--text); opacity: 0.85; white-space: nowrap; }
header .spacer { flex: 1; }
.mode {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.mode button {
  background: none; border: none; color: var(--muted);
  padding: 7px 14px; cursor: pointer; font-size: 13px;
}
.mode button.active { background: var(--accent); color: #fff; }

#chat { flex: 1; overflow-y: auto; padding: 24px; max-width: 840px; width: 100%; margin: 0 auto; }
.empty { color: var(--muted); text-align: center; margin-top: 48px; line-height: 1.6; }
.empty .hint { font-size: 13px; opacity: 0.8; }

.msg { margin-bottom: 18px; line-height: 1.55; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg.user { text-align: right; }
.msg.user .bubble { background: var(--user); display: inline-block; text-align: left; }
.bubble {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; white-space: pre-wrap; word-wrap: break-word;
}
.bubble.notfound { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-text); }

.msg-actions { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copy-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.copy-btn:hover { color: var(--text); }

.sources { font-size: 12px; color: var(--muted); margin-top: 8px; }
.sources .label { margin-right: 6px; }
.chip {
  display: inline-block; background: var(--panel); border: 1px solid var(--line);
  color: var(--accent); border-radius: 999px; padding: 3px 10px; margin: 2px 4px 2px 0;
  font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.source-preview {
  margin-top: 8px; background: #0c1116; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap;
}
.source-preview h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

.presets {
  max-width: 840px; width: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.presets button {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.presets button:hover { color: var(--text); border-color: var(--accent); }

#composer {
  display: flex; gap: 10px; padding: 14px 24px 18px; border-top: 1px solid var(--line);
  max-width: 840px; width: 100%; margin: 0 auto;
}
textarea {
  flex: 1; resize: none; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 11px 13px; font-size: 14px;
  font-family: inherit; min-height: 46px; max-height: 180px;
}
button.send {
  background: var(--accent); border: none; color: #fff; border-radius: 10px;
  padding: 0 22px; font-size: 14px; cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
