:root { --bg:#f0f2f5; --card:#fff; --text:#1c1e21; --muted:#65676b; --line:#dfe2e6; --accent:#2563eb; --soft:#eef3ff; --danger:#c0392b; }
@media (prefers-color-scheme: dark) {
  :root { --bg:#18191a; --card:#242526; --text:#e4e6eb; --muted:#9a9da3; --line:#3a3b3c; --accent:#5b8def; --soft:#27324a; --danger:#e06b5e; }
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; background:var(--bg); color:var(--text); font-family:system-ui,"Segoe UI",Tahoma,sans-serif; }

.btn { padding:8px 14px; border:0; border-radius:8px; font:inherit; cursor:pointer; background:var(--line); color:var(--text); }
.btn:disabled { opacity:.6; cursor:wait; }
.btn.primary { background:var(--accent); color:#fff; }
.btn.link { background:none; color:var(--accent); padding:6px 8px; }
.btn.danger { background:none; color:var(--danger); padding:4px 8px; font-size:.85rem; }
input[type=text], input[type=password], textarea, select { width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:8px; background:var(--card); color:var(--text); font:inherit; }
.muted { color:var(--muted); font-size:.85rem; }
.err { color:var(--danger); font-size:.85rem; margin:0; min-height:1.2em; }

.topbar { position:sticky; top:0; z-index:5; display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; padding:10px 16px; background:var(--card); border-bottom:1px solid var(--line); }
.topbar h1 { margin:0; font-size:1.1rem; }
main { max-width:720px; margin:0 auto; padding:16px; }

.login { position:fixed; inset:0; background:var(--bg); display:grid; place-items:center; padding:16px; z-index:10; }
.login form { background:var(--card); padding:28px; border-radius:14px; width:100%; max-width:360px; display:grid; gap:12px; border:1px solid var(--line); }
.login h1 { margin:0; font-size:1.3rem; }

.composer { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:12px; display:flex; gap:10px; align-items:center; margin-bottom:12px; }
.avatar { width:38px; height:38px; border-radius:50%; background:var(--accent); color:#fff; display:grid; place-items:center; font-weight:700; flex:none; }
.avatar.sm { width:30px; height:30px; font-size:.85rem; }
.composer button { flex:1; text-align:right; background:var(--bg); border:0; border-radius:20px; padding:10px 14px; color:var(--muted); font:inherit; cursor:pointer; }
.filterbar { display:flex; gap:8px; align-items:center; margin-bottom:16px; }
.filterbar label { flex:none; }
.filterbar select { max-width:260px; }

.post { background:var(--card); border:1px solid var(--line); border-radius:10px; margin-bottom:10px; }
.post-head { display:flex; gap:8px; align-items:center; padding:8px 12px 0; }
.post-head .who { font-size:.9rem; min-width:0; }
.post-head .who .muted { font-size:.78rem; }
.post-head .btn.danger { margin-inline-start:auto; }
.post-body { padding:4px 12px 6px; }
.post-body h2 { margin:2px 0; font-size:1rem; }
.post-body p { margin:2px 0; font-size:.9rem; white-space:pre-wrap; overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.post-body p.full { display:block; overflow:visible; }
.actions { display:flex; gap:2px; flex-wrap:wrap; padding:2px 6px; border-top:1px solid var(--line); }
.actions .btn.link { font-size:.85rem; padding:5px 8px; }
.actions .btn.link:last-child { margin-inline-start:auto; }

.viewer { border-top:1px solid var(--line); }
.viewer:empty { display:none; }
.viewer iframe { width:100%; height:min(480px, 65vh); border:0; background:#fff; display:block; }
.viewer img { max-width:100%; max-height:65vh; display:block; margin:8px auto; }
.viewer .loading { padding:12px; text-align:center; }

.comments { padding:8px 12px 10px; display:grid; gap:8px; border-top:1px solid var(--line); }
.comments-list { display:grid; gap:8px; }
.comments-list:empty { display:none; }
.comment { display:flex; gap:8px; }
.bubble { background:var(--bg); border-radius:14px; padding:8px 12px; flex:1; min-width:0; }
.bubble p { margin:2px 0; white-space:pre-wrap; overflow-wrap:anywhere; }
.attach { margin-top:6px; padding:6px 8px; border:1px dashed var(--accent); border-radius:8px; background:var(--soft); display:flex; gap:6px; flex-wrap:wrap; align-items:center; font-size:.85rem; overflow-wrap:anywhere; }
.cform { display:grid; gap:6px; position:relative; }
.mention-list { position:absolute; inset-inline:0; z-index:7; max-height:220px; overflow:auto; margin-top:2px; background:var(--card); border:1px solid var(--line); border-radius:10px; box-shadow:0 6px 18px rgba(0,0,0,.18); }
.mention-item { padding:8px 12px; cursor:pointer; }
.mention-item.active, .mention-item:hover { background:var(--soft); }
.mention { color:var(--accent); font-weight:600; background:var(--soft); border-radius:4px; padding:0 3px; }
.mention.me { outline:1px solid var(--accent); }
.cform textarea { resize:none; min-height:38px; max-height:160px; }
.cform .row { display:flex; gap:8px; align-items:center; }
.cform .row .btn { padding:6px 12px; font-size:.85rem; }
.cform .picked { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cform .row .btn.primary { margin-inline-start:auto; }
.empty { text-align:center; padding:40px 0; color:var(--muted); }

dialog { border:1px solid var(--line); border-radius:14px; background:var(--card); color:var(--text); width:min(460px, 92vw); padding:20px; }
dialog::backdrop { background:rgba(0,0,0,.45); }
dialog form { display:grid; gap:12px; }
dialog h2, dialog p { margin:0; }
dialog label { display:grid; gap:4px; font-size:.9rem; }
.dialog-actions { display:flex; gap:8px; }
.toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#222; color:#fff; padding:10px 16px; border-radius:10px; z-index:20; max-width:90vw; }
