:root{--accent:#d97757;--bg:#ffffff;--panel:#f7f7f5;--line:#ececec;--text:#1a1a1a;--muted:#8a8a82}
*{box-sizing:border-box}
body{margin:0;font-family:-apple-system,Segoe UI,Roboto,Arial,sans-serif;color:var(--text);background:var(--bg)}
.hidden{display:none!important}
.login{height:100dvh;display:flex;align-items:center;justify-content:center}
.login form{display:flex;flex-direction:column;gap:12px;width:280px}
.login h1{text-align:center;color:var(--accent)}
.login input,.login button{padding:12px;border-radius:8px;border:1px solid var(--line);font-size:16px}
.login button{background:var(--accent);color:#fff;border:0;cursor:pointer}
.err{color:#c0392b;font-size:13px;min-height:16px}
.app{display:flex;height:100dvh}
.sidebar{width:260px;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;padding:10px;gap:8px}
.project{padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;font:inherit;font-size:13px;color:var(--text);cursor:pointer}
.new-thread{padding:10px;border:1px solid var(--line);border-radius:8px;background:#fff;cursor:pointer}
.threads{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;gap:4px}
.thread{flex:0 0 auto;display:flex;align-items:center;gap:4px;padding:9px;border-radius:7px;cursor:pointer}
.thread:hover{background:#efe7e2}
.thread.active{background:#efe7e2}
.thread-title{flex:1;min-width:0;font-size:14px;color:#444;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.thread.active .thread-title{color:#000}
.thread-del{flex:0 0 auto;border:0;background:none;color:var(--muted);cursor:pointer;font-size:13px;line-height:1;padding:2px 5px;border-radius:4px;opacity:0;transition:opacity .15s}
.thread:hover .thread-del{opacity:.7}
.thread-del:hover{opacity:1;color:#c0392b;background:#00000010}
.main{flex:1;display:flex;flex-direction:column;min-width:0}
.topbar{display:flex;align-items:center;gap:10px;padding:10px 14px;border-bottom:1px solid var(--line);font-weight:600}
.burger{display:none;border:0;background:none;font-size:20px;cursor:pointer}
.messages{flex:1;overflow:auto;padding:16px;display:flex;flex-direction:column;gap:10px}
.msg{max-width:760px;width:fit-content;padding:10px 14px;border-radius:12px;line-height:1.5}
.msg.user{align-self:flex-end;background:var(--accent);color:#fff;white-space:pre-wrap}
.msg.bot{align-self:flex-start;background:var(--panel)}
.msg.bot pre{background:#0d1117;color:#e6edf3;padding:10px;border-radius:8px;overflow:auto}
.msg.bot p:first-child{margin-top:0}
.msg.bot p:last-child{margin-bottom:0}
.tool{align-self:flex-start;font-size:12px;color:var(--muted)}
.composer{display:flex;gap:8px;padding:10px;border-top:1px solid var(--line)}
.composer textarea{flex:1;resize:none;padding:10px 12px;border:1px solid var(--line);border-radius:10px;font:inherit;max-height:160px}
.composer button{width:46px;border:0;border-radius:10px;background:var(--accent);color:#fff;font-size:16px;cursor:pointer}
@media(max-width:720px){
  .sidebar{position:fixed;z-index:10;height:100dvh;transform:translateX(-100%);transition:transform .2s}
  .sidebar.open{transform:none}
  .burger{display:block}
  .thread-del{opacity:.55}
}
