:root { --bg:#f5f6f8; --panel:#fff; --line:#e5e7eb; --text:#1c1f24; --muted:#6b7280; --accent:#1f7a3a;
  --accent-soft:#e7f4ea; --mine:#e9f2ff; --danger:#c0362c; --code:#f0f1f3; }
@media (prefers-color-scheme: dark) { :root { --bg:#14161a; --panel:#1c1f25; --line:#2c3038; --text:#e6e8eb;
  --muted:#9aa1ab; --accent:#3fae62; --accent-soft:#1f3326; --mine:#1f2b3d; --danger:#ef6b5f; --code:#2a2e36; } }
* { box-sizing:border-box; }
html, body { height:100%; margin:0; }
body { font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif; background:var(--bg); color:var(--text); }
button, textarea { font:inherit; color:inherit; }
.app { display:flex; height:100%; }
.side { width:280px; flex:none; display:flex; flex-direction:column; background:var(--panel); border-right:1px solid var(--line); }
.side-head { padding:16px; display:flex; flex-direction:column; gap:12px; border-bottom:1px solid var(--line); }
.brand { font-weight:700; font-size:17px; } .brand span { color:var(--accent); }
.chats { flex:1; overflow-y:auto; padding:8px; }
.chat-item { display:block; width:100%; text-align:left; border:0; background:none; padding:10px 12px; border-radius:8px;
  cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.chat-row { position:relative; display:flex; align-items:center; border-radius:8px; }
.chat-row:hover { background:var(--bg); } .chat-row.active { background:var(--accent-soft); }
.chat-row.active .chat-item { font-weight:600; }
.chat-row.dragging { opacity:.45; }
.chat-item { flex:1; min-width:0; }
.chat-row .more { flex:none; border:0; background:none; cursor:pointer; color:var(--muted); font-size:18px; line-height:1;
  padding:6px 8px; margin-right:4px; border-radius:6px; visibility:hidden; }
.chat-row:hover .more, .chat-row .more:focus-visible, .chat-row:has(.menu) .more { visibility:visible; }
.chat-row .more:hover { background:var(--line); color:var(--text); }
.menu { position:absolute; right:6px; top:calc(100% - 2px); z-index:7; min-width:170px; padding:4px; background:var(--panel);
  border:1px solid var(--line); border-radius:10px; box-shadow:0 6px 20px rgba(0,0,0,.14); }
.menu-item { display:block; width:100%; text-align:left; border:0; background:none; padding:8px 10px; border-radius:6px;
  cursor:pointer; font-size:14px; }
.menu-item:hover, .menu-item:focus-visible { background:var(--bg); outline:none; }
.menu-item.danger { color:var(--danger); }
@media (hover: none) { .chat-row .more { visibility:visible; } }
.side-foot { padding:12px 16px; border-top:1px solid var(--line); color:var(--muted); font-size:13px; }
.empty-list { color:var(--muted); padding:12px; font-size:14px; }
.main { flex:1; display:flex; flex-direction:column; min-width:0; }
.top { display:flex; align-items:center; gap:8px; padding:12px 20px; background:var(--panel); border-bottom:1px solid var(--line); }
.top h1 { font-size:16px; margin:0; flex:1; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.btn { border:1px solid var(--line); background:var(--panel); border-radius:8px; padding:9px 14px; cursor:pointer; }
.btn.primary { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }
.btn:disabled { opacity:.55; cursor:default; }
.icon { border:0; background:none; cursor:pointer; font-size:17px; padding:6px 8px; border-radius:6px; color:var(--muted); }
.icon:hover { background:var(--bg); } .icon.danger:hover { color:var(--danger); }
.only-mobile { display:none; }
.messages { flex:1; overflow-y:auto; padding:20px; display:flex; flex-direction:column; gap:12px; }
.msg { max-width:760px; padding:10px 14px; border-radius:12px; overflow-wrap:anywhere; }
.msg.user { align-self:flex-end; background:var(--mine); white-space:pre-wrap; }
.msg.assistant { align-self:flex-start; background:var(--panel); border:1px solid var(--line); }
.msg.note { align-self:center; background:none; color:var(--muted); font-size:14px; text-align:center; }
.msg.error { align-self:flex-start; color:var(--danger); background:none; border:1px dashed var(--danger); }
.msg p { margin:0 0 8px; } .msg p:last-child { margin-bottom:0; }
.msg ul, .msg ol { margin:4px 0 8px; padding-left:22px; }
.msg code { background:var(--code); padding:1px 5px; border-radius:4px; font-size:13px; }
.msg pre { background:var(--code); padding:10px; border-radius:8px; overflow-x:auto; white-space:pre; }
.msg pre code { background:none; padding:0; }
.msg a { color:var(--accent); }
.typing { color:var(--muted); font-style:italic; }
.welcome { margin:auto; max-width:520px; text-align:center; color:var(--muted); }
.welcome h2 { color:var(--text); font-size:20px; }
.composer { display:flex; flex-wrap:wrap; align-items:flex-end; gap:10px; padding:12px 20px 16px; background:var(--panel); border-top:1px solid var(--line); }
.composer textarea { flex:1; resize:none; max-height:200px; overflow-y:hidden; padding:10px 12px; border:1px solid var(--line);
  border-radius:10px; background:var(--bg); outline:none; }
.composer textarea:focus { border-color:var(--accent); }
.overlay { position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:5; }
@media (max-width: 760px) {
  .side { position:fixed; z-index:6; inset:0 auto 0 0; width:84%; max-width:320px; transform:translateX(-100%); transition:transform .2s; }
  .side.open { transform:none; }
  .only-mobile { display:inline-block; }
  .messages { padding:14px 16px; } .composer { padding:10px 16px 14px; } .top { padding:10px 16px; }
  .composer .btn { padding:9px 12px; }
}
.msg.streaming > p:last-child::after, .msg.streaming > :is(ul,ol):last-child > li:last-child::after,
.msg.streaming > pre:last-child > code::after { content:"▍"; color:var(--muted); animation:blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity:0; } }
.attachments { flex-basis:100%; display:flex; flex-wrap:wrap; gap:8px; }
  border-radius:8px; background:var(--bg); font-size:13px; }
.composer .attach { align-self:center; font-size:19px; }
.files { display:flex; flex-wrap:wrap; align-items:flex-start; gap:8px; margin-top:8px; white-space:normal; }
.files:first-child { margin-top:0; }
.files img { display:block; max-width:220px; max-height:160px; border-radius:8px; border:1px solid var(--line); }
.files a.file { display:inline-block; padding:6px 10px; border-radius:8px; background:var(--panel); border:1px solid var(--line);
  text-decoration:none; font-size:13px; }
.main.drop { outline:2px dashed var(--accent); outline-offset:-6px; }
.room-wrap { padding:8px 8px 0; }
.room-item { display:flex; align-items:center; justify-content:space-between; width:100%; border:0; background:none;
  padding:10px 12px; border-radius:8px; cursor:pointer; text-align:left; font-weight:600; }
.room-item:hover { background:var(--bg); } .room-item.active { background:var(--accent-soft); }
.badge { min-width:20px; padding:1px 6px; border-radius:10px; background:var(--accent); color:#fff; font-size:12px;
  text-align:center; font-weight:700; }
.list-label { padding:12px 20px 0; color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
.msg.room { position:relative; }
.msg.other { align-self:flex-start; background:var(--panel); border:1px solid var(--line); white-space:pre-wrap; }
.msg.room .author { font-size:12px; color:var(--muted); margin-bottom:2px; white-space:normal; }
.msg.room.assistant .author { color:var(--accent); font-weight:600; }
.msg.room .del { position:absolute; top:4px; right:6px; border:0; background:none; color:var(--muted); cursor:pointer;
  font-size:15px; visibility:hidden; }
.msg.room:hover .del, .msg.room .del:focus-visible { visibility:visible; }
.msg.room.user .author, .msg.room.other .author { padding-right:16px; }
@media (hover: none) { .msg.room .del { visibility:visible; } }

.attachments .cards { display:flex; flex-wrap:wrap; gap:10px; }
.card { position:relative; width:132px; border:1px solid var(--line); border-radius:12px; background:var(--panel);
  overflow:hidden; }
.card .thumb { position:relative; height:104px; display:flex; align-items:center; justify-content:center;
  background:var(--bg); border-bottom:1px solid var(--line); }
.card .thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.card .thumb.icon { font-size:40px; }
.card .busy { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:12px;
  color:var(--text); background:rgba(255,255,255,.65); }
.card .name { padding:5px 8px; font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.card .remove { position:absolute; top:5px; right:5px; width:22px; height:22px; border-radius:50%; border:0; cursor:pointer;
  background:rgba(0,0,0,.55); color:#fff; font-size:14px; line-height:22px; padding:0; }
.card.failed { border-color:var(--danger); } .card.failed .name { color:var(--danger); }
.attach-error { flex-basis:100%; color:var(--danger); font-size:13px; margin-top:6px; }
