:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #171a2b;
  --muted: #666b85;
  --border: #dfe2ee;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --user: #4f46e5;
  --bot: #eceefb;
  --danger: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1120;
    --surface: #171a2e;
    --text: #eceffb;
    --muted: #9aa0bd;
    --border: #2a2e4a;
    --accent: #7c83ff;
    --accent-text: #0f1120;
    --user: #7c83ff;
    --bot: #22263f;
    --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}
.app {
  max-width: 760px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.top { display: flex; justify-content: space-between; align-items: center; }
.top h1 { font-size: 1.25rem; margin: 0; }
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
}
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.messages {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty { margin: auto; color: var(--muted); text-align: center; }
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user { align-self: flex-end; background: var(--user); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.pending { color: var(--muted); font-style: italic; }
.error {
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.9rem;
}
.composer { display: flex; gap: 8px; align-items: flex-end; }
textarea {
  flex: 1;
  font: inherit;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
#send { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
#send:disabled { opacity: 0.6; cursor: not-allowed; }
