/* Mobile first. One column, full height; wider screens just get a centred column. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --line: #dfe2e7;
  --accent: #1f5fd1;
  --accent-text: #ffffff;
  --user: #dce8ff;
  --alert: #fff6d9;
  --alert-line: #e6c65a;
  --error: #b3261e;
  --long: #0f7a3d;
  --short: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1b1e25;
    --text: #eceef2;
    --muted: #9aa2af;
    --line: #2c313b;
    --accent: #6ea0ff;
    --accent-text: #0b1220;
    --user: #233a66;
    --alert: #3a3216;
    --alert-line: #8a7426;
    --error: #ff8a80;
    --long: #5fd08f;
    --short: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Arial, sans-serif; }
#app { max-width: 720px; margin: 0 auto; height: 100%; }
.screen { padding: 20px 16px; }
.screen.center { min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.85rem; }
.error { color: var(--error); margin: 8px 0 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
label { font-weight: 600; }
input[type="email"], input[type="text"], textarea { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
input[type="range"] { width: 100%; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 12px 16px; min-height: 44px; }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { background: none; color: var(--accent); padding: 8px; min-height: 44px; }
button:disabled { opacity: 0.55; cursor: default; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.symbols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.symbols label, .toggle { font-weight: 400; display: flex; align-items: center; gap: 8px; min-height: 40px; }
.symbols h3 { grid-column: 1 / -1; font-size: 0.9rem; color: var(--muted); margin: 8px 0 0; }

/* chat */
.screen.chat { padding: 0; height: 100%; display: flex; flex-direction: column; }
.chat-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: max(10px, env(safe-area-inset-top)); }
.status { display: inline-block; margin-inline-start: 8px; font-size: 0.8rem; color: var(--muted); }
.header-actions { display: flex; }
.messages { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 86%; padding: 10px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); background: var(--surface); align-self: flex-end; }
.bubble.user { background: var(--user); border-color: transparent; align-self: flex-start; }
.bubble.alert { background: var(--alert); border-color: var(--alert-line); max-width: 94%; }
.bubble.pending { opacity: 0.7; font-style: italic; }
.bubble.failed { border-color: var(--error); }
.alert-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-weight: 700; margin-bottom: 6px; }
.tag { font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; }
.tag.long { color: var(--long); }
.tag.short { color: var(--short); }
.time { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.retry { margin-top: 6px; }
.banner { margin: 0; padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.composer { display: flex; gap: 8px; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.composer textarea { resize: none; max-height: 140px; }
.empty { margin: auto; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }
