:root{--bg:#0f172a;--panel:#1f2937;--me:#2563eb;--bot:#334155;--text:#f1f5f9;--muted:#94a3b8;--accent:#f59e0b}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{display:flex;flex-direction:column;background:var(--bg);color:var(--text);font:16px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
header{display:flex;justify-content:space-between;align-items:center;padding:calc(10px + env(safe-area-inset-top)) 14px 10px;background:var(--panel);box-shadow:0 1px 0 #0003}
.brand{display:flex;gap:10px;align-items:center}
.avatar{font-size:28px;background:var(--accent);border-radius:50%;width:42px;height:42px;display:grid;place-items:center}
h1{font-size:18px;margin:0}
small{color:var(--muted)}
.actions button,#composer button,dialog button{background:var(--bot);color:var(--text);border:0;border-radius:10px;padding:8px 12px;font-size:15px;cursor:pointer}
main{flex:1;overflow-y:auto;padding:16px 12px;display:flex;flex-direction:column;gap:8px}
.msg{max-width:min(80%,640px);padding:9px 13px;border-radius:16px;white-space:pre-wrap;word-wrap:break-word}
.msg.user{align-self:flex-end;background:var(--me);border-bottom-right-radius:4px}
.msg.assistant{align-self:flex-start;background:var(--bot);border-bottom-left-radius:4px}
.msg.error{align-self:center;background:#7f1d1d;font-size:14px}
.typing::after{content:"▍";animation:blink 1s infinite}
@keyframes blink{50%{opacity:0}}
.empty{margin:auto;text-align:center;color:var(--muted)}
#composer{display:flex;gap:8px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));background:var(--panel)}
#input{flex:1;resize:none;max-height:140px;background:var(--bg);color:var(--text);border:1px solid #334155;border-radius:14px;padding:10px 12px;font:inherit}
#composer button{background:var(--me);font-size:18px;width:46px}
#composer button:disabled{opacity:.5}
dialog{background:var(--panel);color:var(--text);border:0;border-radius:16px;width:min(92vw,420px)}
dialog::backdrop{background:#0008}
dialog label{display:block;margin:10px 0}
dialog input{width:100%;margin-top:4px;padding:8px;border-radius:8px;border:1px solid #334155;background:var(--bg);color:var(--text);font:inherit}
.row{display:flex;justify-content:space-between;gap:8px;margin-top:12px}
.danger{background:#991b1b!important}
.hint{color:var(--muted);font-size:13px}
dialog h3{font-size:15px;margin:16px 0 6px;color:var(--muted)}
.facts{list-style:none;padding:0;margin:0;max-height:40vh;overflow-y:auto}
.facts li{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;border-radius:8px;background:var(--bg);margin-bottom:6px}
.facts li small{color:var(--muted);font-size:11px;margin-left:6px}
.facts li button{background:transparent!important;padding:2px 8px!important;font-size:16px!important}
.facts .none{color:var(--muted);background:transparent}
.row.add input{flex:1;margin:0}
.summary{white-space:pre-wrap;font-size:14px;background:var(--bg);padding:8px;border-radius:8px;min-height:1.5em}
