:root {
  --bg: #f7f7f8; --surface: #ffffff; --text: #1f2328; --muted: #6b7280; --border: #e5e7eb;
  --accent: #4f46e5; --accent-text: #ffffff; --user: #eef2ff; --code: #f3f4f6; --error: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111318; --surface: #1a1d24; --text: #e6e8eb; --muted: #9aa1ab; --border: #2b2f38;
    --accent: #818cf8; --accent-text: #0b0d12; --user: #252a3a; --code: #0d0f14; --error: #f87171; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; font-weight: 400; } .error { color: var(--error); min-height: 1.2em; margin: 0; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); font-weight: 500; padding: 6px 12px; }
input, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: grid; gap: 12px; text-align: center; }
.card img { margin: 0 auto; } .card h1 { margin: 0; font-size: 22px; } .card p { margin: 0; }

.app { height: 100%; display: flex; flex-direction: column; max-width: 820px; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.actions { display: flex; gap: 8px; }
main { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; text-align: center; max-width: 440px; } .empty h2 { margin: 0 0 6px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); padding: 8px 14px; border-radius: 16px 16px 4px 16px; max-width: 85%; white-space: pre-wrap; }
.msg.assistant p { margin: 0 0 .6em; } .msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant pre { background: var(--code); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 14px; }
.msg.assistant code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: var(--code); padding: 1px 4px; border-radius: 4px; }
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 .6em; padding-left: 1.4em; }
.msg.err { color: var(--error); }
.status { color: var(--muted); font-size: 14px; font-style: italic; }
.composer { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.composer textarea { resize: none; max-height: 200px; }
