: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; }

/* Payment modal: Stripe's iframe sits inside our own chrome. */
#pay { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 0; border: 1px solid var(--line);
  border-radius: 14px; background: var(--bg); color: var(--fg); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
#pay::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.pay-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pay-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
#pay-close { background: none; color: var(--muted); font-size: 24px; line-height: 1; width: 44px; height: 44px; margin: -8px -10px -8px 0; padding: 0; }
#pay-close:hover { color: var(--fg); background: var(--user); }
#checkout { padding: 16px; min-height: 320px; }
/* Skeleton shows until Stripe mounts its iframe into the empty container. */
#checkout:empty::before { content: ""; display: block; height: 280px; border-radius: 10px;
  background: linear-gradient(90deg, var(--user) 25%, var(--line) 50%, var(--user) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { #checkout:empty::before { animation: none; } }
.pay-foot { margin: 0; padding: 10px 16px 14px; text-align: center; color: var(--muted); font-size: 12px; }
