*{box-sizing:border-box}
html,body{margin:0;height:100%;background:#0f172a;color:#e2e8f0;font:16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
button{font:inherit;cursor:pointer;border:0}
.hidden{display:none!important}
.login{height:100%;display:grid;place-items:center;padding:24px}
.login form{display:flex;flex-direction:column;gap:12px;width:min(320px,100%);text-align:center;align-items:center}
.login h1{margin:0 0 8px;font-size:22px}
.login input,.login button{width:100%;padding:12px 14px;border-radius:12px;font-size:16px}
.login input{background:#1e293b;border:1px solid #334155;color:inherit}
.login button{background:#22d3ee;color:#0f172a;font-weight:600}
.err{color:#f87171;min-height:1.2em;margin:0}
.app{height:100%;height:100dvh;display:flex;flex-direction:column}
header{display:flex;justify-content:space-between;align-items:center;padding:calc(10px + env(safe-area-inset-top)) 14px 10px;border-bottom:1px solid #1e293b}
.hbtns{display:flex;gap:6px}
.icon{background:#1e293b;color:inherit;width:38px;height:38px;border-radius:10px;opacity:.55}
.icon.on,#clearBtn{opacity:1}
main{flex:1;overflow-y:auto;padding:16px 12px;display:flex;flex-direction:column;gap:10px}
.hint{margin:auto;color:#64748b;text-align:center;padding:0 20px}
.msg{max-width:85%;padding:10px 14px;border-radius:16px;white-space:pre-wrap;word-wrap:break-word}
.msg.user{align-self:flex-end;background:#0e7490;border-bottom-right-radius:4px}
.msg.assistant{align-self:flex-start;background:#1e293b;border-bottom-left-radius:4px}
.msg.assistant.typing::after{content:"▍";animation:blink 1s infinite}
.msg.error{align-self:center;background:#7f1d1d;font-size:14px}
.msg .say{display:block;margin-top:6px;background:none;color:#94a3b8;font-size:13px;padding:0}
@keyframes blink{50%{opacity:0}}
footer{display:flex;gap:8px;align-items:flex-end;padding:10px 10px calc(10px + env(safe-area-inset-bottom));border-top:1px solid #1e293b}
textarea{flex:1;resize:none;max-height:140px;padding:11px 14px;border-radius:20px;background:#1e293b;border:1px solid #334155;color:inherit;font:inherit}
.mic,.send{width:46px;height:46px;border-radius:50%;flex:none;font-size:20px}
.mic{background:#1e293b;color:inherit}
.mic.rec{background:#dc2626;animation:pulse 1.2s infinite}
.mic.busy{opacity:.5}
.send{background:#22d3ee;color:#0f172a}
.send.stop{background:#f59e0b}
@keyframes pulse{0%{box-shadow:0 0 0 0 #dc262699}70%{box-shadow:0 0 0 12px #dc262600}}
