:root {
  --bg: #ffffff; --fg: #1f2328; --muted: #656d76; --line: #d8dee4;
  --user: #f0f3f6; --accent: #10a37f; --accent-fg: #ffffff; --err: #cf222e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #212121; --fg: #ececec; --muted: #a0a0a0; --line: #3a3a3a; --user: #2f2f2f; --accent: #10a37f; --err: #ff7b72; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
input, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brand b { font-weight: 700; }

header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.badge { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
#buy { display: flex; align-items: center; gap: 6px; }
#amount { width: 90px; }
.email { color: var(--muted); font-size: 14px; }
#note { margin: 0; padding: 0 16px; color: var(--muted); font-size: 14px; }
#note:not(:empty) { padding: 8px 16px; }

#log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 780px; margin: 0 auto; }
.msg { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--user); border-radius: 18px; padding: 8px 14px; max-width: 80%; }
.msg.pending { color: var(--muted); }
.msg.error { color: var(--err); }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; }

#chat { display: flex; gap: 8px; width: 100%; max-width: 780px; margin: 0 auto; padding: 12px 16px 20px; }
#msg { flex: 1; resize: none; min-height: 44px; max-height: 200px; }

body.login { align-items: center; justify-content: center; padding: 16px; }
.card { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; }
.card .brand { font-size: 22px; font-weight: 400; margin: 0 0 6px; }
.demo { color: var(--muted); margin: 0; font-size: 14px; }
.error { color: var(--err); margin: 0; }
