.chat-layout { display:grid; grid-template-columns:minmax(11rem,15rem) minmax(0,1fr); gap:1rem; align-items:start }
.chat-layout.chat-direct { grid-template-columns:minmax(0,1fr) }
.chat-layout [hidden] { display:none !important }
.chat-sidebar,.chat-room { min-width:0; display:grid; gap:.85rem }
.chat-sidebar h2,.chat-room h2 { margin:0; overflow-wrap:anywhere }
.chat-sidebar h2,.chat-room h2 { font-size:1.1rem }
.chat-room-list { display:grid; gap:.4rem; list-style:none; padding:0; margin:0; max-height:24rem; overflow:auto }
.chat-room-list button { min-height:44px; width:100%; text-align:left; border-radius:8px; padding:.5rem .65rem; display:grid; gap:.2rem; white-space:normal; overflow-wrap:anywhere }
.chat-room-list [aria-current="true"] { background:var(--surface-2,var(--soft)); border-color:var(--action,var(--blue)); color:var(--ink) }
.chat-room-list small { font-weight:600 }
.chat-log { display:grid; align-content:start; gap:.6rem; min-height:14rem; height:clamp(14rem,46vh,29rem); overflow:auto; scrollbar-gutter:stable; border:1px solid var(--line); border-radius:10px; padding:.8rem }
.chat-message { justify-self:start; max-width:85%; border-radius:9px; background:var(--surface-2,var(--soft)); padding:.6rem .75rem; overflow-wrap:anywhere }
.chat-message-own { justify-self:end; background:var(--gold-soft,var(--soft)) }
.chat-message:focus { outline:2px solid var(--action,var(--blue)); outline-offset:2px }
.chat-message p,.chat-pending p { white-space:pre-wrap; overflow-wrap:anywhere; margin:.3rem 0 0 }
.chat-reply-quote { display:grid; gap:.15rem; margin-top:.4rem; padding:.35rem .5rem; border-inline-start:3px solid var(--action,var(--blue)); border-radius:4px; background:var(--surface); color:inherit; text-decoration:none; overflow-wrap:anywhere }
.chat-reply-quote:hover .chat-reply-label { text-decoration:underline }
.chat-reply-label { font-size:.8rem; font-weight:600 }
.chat-reply-excerpt { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden }
.chat-message-meta { display:flex; gap:.45rem .75rem; align-items:baseline; flex-wrap:wrap; font-size:.8rem }
.chat-message-meta time { color:var(--muted) }
.chat-controls,.chat-compose,.chat-bindings { display:grid; min-width:0; gap:.65rem }
.chat-compose textarea,.chat-compose input,.chat-controls select,.chat-bindings input,.chat-bindings select { display:block; width:100%; max-width:100%; margin-top:.3rem }
.chat-compose textarea { resize:vertical; min-height:4.2rem }
.chat-compose button,.chat-controls button,.chat-pending button { min-height:44px }
.chat-actions { display:flex; gap:.5rem; align-items:center; flex-wrap:wrap }
.chat-attachment { display:inline-flex; min-height:44px; align-items:center; max-width:100%; overflow-wrap:anywhere; text-align:left }
.chat-message-image { display:flex; align-items:center; justify-content:center; width:14rem; max-width:100%; height:10rem; margin:.4rem 0; padding:0; border:1px solid var(--line); border-radius:6px; overflow:hidden; background:var(--surface); color:var(--ink); cursor:zoom-in }
.chat-message-image img { display:block; width:100%; height:100%; object-fit:contain }
.dialog.chat-image-dialog { width:min(100% - 24px, 960px) }
.chat-large-image { display:block; max-width:100%; max-height:calc(100dvh - 8rem); margin:0 auto; object-fit:contain }
.chat-preview { display:block; width:auto; max-width:100%; max-height:18rem; object-fit:contain; border-radius:6px }
.chat-draft-attachment { display:grid; gap:.4rem; justify-items:start; min-width:0; padding:.6rem; border:1px solid var(--line); border-radius:8px }
.chat-draft-attachment span { overflow-wrap:anywhere }
.chat-pending { border-top:1px solid var(--line); padding-top:.65rem }
.chat-bindings { margin-top:.8rem }
.chat-error { color:var(--danger,#ad2828) }
@media (max-width:720px) {
  .chat-layout { grid-template-columns:minmax(0,1fr) }
  .chat-room-list { max-height:10.5rem }
  .chat-message { max-width:94% }
}
