:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #18181b;
  --border: #27272a;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #3b82f6;
  --user: #27272a;
  --bot: #1e293b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.wrap {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
h1 { font-size: 1.5rem; margin: 0 0 0.25rem; }
.sub { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.95rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; }
input, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: wait; }
button.ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-weight: 500;
}
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}
.bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.45;
  max-width: 95%;
  white-space: pre-wrap;
}
.bubble.user { background: var(--user); align-self: flex-end; }
.bubble.bot { background: var(--bot); align-self: flex-start; }
.bubble.sys { color: var(--muted); font-size: 0.85rem; align-self: center; text-align: center; }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; min-height: 2.8rem; }
.error { color: #f87171; font-size: 0.9rem; margin-top: 0.75rem; }
footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
}
footer a { color: var(--accent); }