/* Discord's message anatomy, Kavare's existing flat black/white/blue palette. */
:root{--chat-panel:#181818;--chat-hover:#202020;--chat-line:#353535;--chat-muted:#b3b3b3;--chat-blue:#0060ff;--chat-link:#8ab4ff}
body .chat-messages,body .dm-feed{direction:ltr!important;gap:0!important;padding:16px 0!important;scroll-padding-block:32px}
body .chat-row,body .message.chat-row.mine,body .message.chat-row:not(.mine),body .dm-bubble.chat-row{position:relative;direction:ltr!important;display:block!important;width:100%!important;max-width:100%!important;min-width:0!important;align-self:stretch!important;padding:8px 20px 8px 72px!important;margin:8px 0 0!important;box-sizing:border-box;background:transparent!important;border:0!important;border-radius:0!important;animation:none!important;text-align:left!important;overflow:visible!important}
body .chat-row:hover,body .chat-row:focus-within{background:var(--chat-hover)!important}
body .chat-row :is(.message-avatar,.reference-dm-avatar){position:absolute!important;inset:auto!important;left:20px!important;top:10px!important;width:40px!important;height:40px!important;min-height:40px!important;min-width:40px!important;border-radius:50%!important;overflow:visible}
body .chat-row :is(.message-content,.message-head,.reference-dm-identity){direction:ltr!important;text-align:left!important;max-width:100%!important;background:none!important;border:0!important;padding:0!important;box-shadow:none!important}
body .chat-row .message-head,body .chat-row .reference-dm-identity{justify-content:flex-start!important;gap:10px;margin:0 0 2px!important;min-height:24px}
body .chat-row :is(.message-author,.reference-dm-identity strong){color:#fff;font-size:15px}
body .chat-row :is(.message-text,.message-rich-text){text-align:left!important;unicode-bidi:plaintext;white-space:pre-wrap;font-size:15px!important;line-height:1.65!important;margin:0;overflow-wrap:anywhere;min-width:0}
body .chat-row time{font-size:11px!important;color:var(--chat-muted)!important;direction:ltr}
body .chat-row.chat-grouped{margin-top:0!important;padding-block:3px!important}
body .chat-row.chat-grouped :is(.message-avatar,.reference-dm-avatar,.message-head,.reference-dm-identity){display:none!important}
.chat-date-divider{display:flex;align-items:center;gap:12px;flex:none;color:var(--chat-muted);font-size:12px;font-weight:600;padding:16px 20px 4px;direction:rtl}
.chat-date-divider::before,.chat-date-divider::after{content:'';height:1px;background:var(--chat-line);flex:1}
body .chat-row.has-reply :is(.message-avatar,.reference-dm-avatar){top:36px!important}
body .chat-row .message-reply-reference{position:relative!important;display:flex!important;align-items:center!important;justify-content:flex-start!important;gap:7px!important;direction:ltr!important;width:fit-content!important;max-width:100%!important;min-width:0!important;min-height:24px!important;height:auto!important;margin:0 0 4px!important;padding:0!important;border:0!important;border-radius:0!important;background:none!important;box-shadow:none!important;color:var(--chat-muted)!important;text-align:left!important;font:inherit!important;cursor:pointer;overflow:visible!important}
body .chat-row .message-reply-reference::before{content:'';position:absolute;left:-34px;top:12px;width:27px;height:13px;border:solid #717171;border-width:2px 0 0 2px;border-top-left-radius:7px}
body .chat-row .message-reply-reference strong{font-size:12px;color:var(--chat-link);white-space:nowrap;flex:0 1 auto;max-width:45%;overflow:hidden;text-overflow:ellipsis}
body .chat-row .reply-excerpt{font-size:12px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;min-width:0}
.reply-mini-avatar{width:16px;height:16px;flex:0 0 16px;display:grid;place-items:center;background:#292929;border-radius:50%;font-size:10px;overflow:hidden}
.reply-mini-avatar img{width:100%;height:100%;object-fit:cover}
body .chat-row .message-reply-reference:hover{color:white!important}
body .chat-row .message-actions{position:absolute!important;inset:auto!important;right:16px!important;top:-18px!important;display:flex!important;gap:2px!important;margin:0!important;padding:3px!important;background:var(--chat-panel)!important;border:1px solid var(--chat-line)!important;border-radius:8px!important;box-shadow:0 4px 12px #0007;opacity:0;pointer-events:none;transition:opacity .12s;z-index:5}
body .chat-row:hover .message-actions,body .chat-row:focus-within .message-actions{opacity:1;pointer-events:auto}
body .chat-row .message-actions button{width:36px!important;height:36px!important;min-height:36px!important;border:0!important;border-radius:5px!important;padding:0!important;background:none!important;color:var(--chat-muted)!important;cursor:pointer}
body .chat-row .message-actions button:hover{background:var(--chat-hover)!important;color:#fff!important}
body .chat-row.reply-source-highlight{background:#0060ff24!important;box-shadow:inset 3px 0 #0060ff!important}
body form.chat-composer{position:relative!important;direction:ltr!important;display:flex!important;align-items:flex-end!important;flex-wrap:nowrap!important;gap:4px!important;min-height:60px!important;width:calc(100% - 32px)!important;max-width:none!important;margin:8px 16px 16px!important;padding:6px!important;box-sizing:border-box!important;background:var(--chat-panel)!important;border:1px solid var(--chat-line)!important;border-radius:10px!important;box-shadow:none!important;flex-shrink:0}
body form.chat-composer:focus-within{border-color:var(--chat-blue)!important}
body form.chat-composer textarea{order:0!important;flex:1 1 0!important;width:0!important;min-width:0!important;min-height:44px!important;max-height:128px!important;padding:10px 8px!important;border:0!important;border-radius:0!important;outline:0!important;background:none!important;box-shadow:none!important;color:#fff!important;font:inherit!important;font-size:15px!important;text-align:start!important;line-height:1.6;resize:none}
body form.chat-composer textarea::placeholder{color:var(--chat-muted)!important}
body form.chat-composer :is(.chat-icon,.chat-format-toggle,.dm-emoji-toggle,.chat-extras-button,[type=submit]){flex:0 0 40px!important;width:40px!important;height:44px!important;min-height:44px!important;min-width:0!important;padding:0!important;display:grid!important;place-items:center!important;margin:0!important;background:transparent!important;border:0!important;border-radius:6px!important;color:var(--chat-muted)!important;font-size:18px!important;cursor:pointer}
body form.chat-composer .chat-plus{background:#333!important;font-size:20px!important;order:-1!important}
body form.chat-composer :is(.chat-icon,.chat-format-toggle,.dm-emoji-toggle,.chat-extras-button):hover{background:var(--chat-hover)!important;color:white!important}
body form.chat-composer [type=submit]{background:var(--chat-blue)!important;color:#fff!important}
body form.chat-composer .chat-extras{position:relative;flex:0 0 40px}
body form.chat-composer :is(.attach-button,.dm-attach){display:none!important}
body form.chat-composer .chat-add-menu{position:absolute;bottom:calc(100% + 8px);left:0;width:240px;max-width:calc(100vw - 32px);padding:6px;border:1px solid var(--chat-line);border-radius:10px;background:#111;box-shadow:0 12px 32px #0009;z-index:125;direction:rtl}
body form.chat-composer .chat-add-menu[hidden]{display:none!important}
body form.chat-composer .chat-add-menu button{width:100%!important;display:flex!important;justify-content:flex-start;align-items:center;gap:12px;padding:10px!important;height:auto!important;min-height:44px!important;font-size:14px!important}
body form.chat-composer .chat-add-menu button:hover{background:var(--chat-blue)!important}
body .chat-reply-bar,body .reply-preview{display:flex;align-items:center;gap:10px;min-height:44px!important;margin:8px 16px -8px!important;width:calc(100% - 32px)!important;max-width:none!important;padding:8px 12px!important;box-sizing:border-box;background:#202020!important;color:var(--chat-muted);border:1px solid var(--chat-line)!important;border-bottom:0!important;border-radius:10px 10px 0 0!important;box-shadow:none!important;direction:rtl}
body .chat-reply-bar[hidden],body .reply-preview[hidden]{display:none!important}
body :is(.chat-reply-bar,.reply-preview):not([hidden])+form.chat-composer{border-radius:0 0 10px 10px!important;margin-top:8px!important}
body .chat-reply-bar strong{color:#fff}.chat-reply-bar>span{flex:none}.chat-reply-bar small{min-width:0;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body .chat-reply-bar button{width:44px;height:44px;min-height:44px;border:0;background:none;color:#ccc;cursor:pointer}
body .reply-preview .reply-mark{display:none}.reply-preview .reply-copy-body{display:flex;align-items:center;gap:12px}.reply-preview .reply-copy-heading{white-space:nowrap}
.chat-link-previews{display:grid;gap:8px;margin-top:8px;max-width:420px;min-width:0}
.chat-link-card{min-width:0;background:var(--chat-panel);border:1px solid var(--chat-line);border-left:4px solid var(--chat-blue);border-radius:5px;padding:12px;display:grid;gap:8px;direction:ltr;text-align:start;overflow-wrap:anywhere}
.chat-link-site{color:var(--chat-muted);font-size:12px}.chat-link-title{color:var(--chat-link)!important;font-size:16px;font-weight:700;text-decoration:none!important}.chat-link-title:hover{text-decoration:underline!important}
body .chat-link-description{font-size:13px!important;line-height:1.65!important;color:#e0e0e0;white-space:normal!important;margin:0!important;unicode-bidi:plaintext}
.chat-link-image{display:block;width:100%;aspect-ratio:16/9;max-height:260px;object-fit:contain;border-radius:4px;background:#101010}
body .chat-library{border-radius:10px!important;background:var(--chat-panel)!important;gap:8px!important;box-shadow:0 12px 36px #0009;direction:ltr!important;text-align:left!important}
body .chat-library .library-tabs{border-bottom:1px solid var(--chat-line);padding-bottom:8px}
body .chat-library .library-tabs button{background:none;border:0;border-radius:6px;min-height:40px;flex:0 1 auto;padding:8px 14px}
body .chat-library .library-tabs button[aria-selected=true]{background:#333;color:white}
body .chat-library .library-pane[data-chat-panel=emoji]{display:grid;grid-template-columns:44px minmax(0,1fr);grid-template-rows:auto minmax(80px,1fr) auto;gap:10px;overflow:hidden;min-height:0}
body .chat-library .library-pane>input{grid-column:1/-1;border-radius:6px;background:#111}
body .chat-library .library-categories{grid-column:1;grid-row:2;display:flex;flex-flow:column nowrap!important;gap:4px;margin:0;overflow-y:auto;max-height:290px}
body .chat-library .library-categories button{width:40px!important;min-height:40px!important;height:40px!important;padding:0!important;border:0;background:transparent;font-size:16px!important}
body .chat-library .library-categories button[aria-pressed=true]{background:var(--chat-blue)}
body .chat-library .library-emoji-grid{grid-column:2;grid-row:2;overflow-y:auto;align-content:start;max-height:290px;grid-template-columns:repeat(auto-fill,minmax(40px,1fr))!important;gap:2px}
body .chat-library .library-emoji-grid button{height:40px;min-height:40px;padding:2px;border-radius:5px;font-size:28px}
body .chat-library .library-more{grid-column:2;margin:0;min-height:36px;padding:4px}
.library-emoji-detail{display:flex;align-items:center;gap:10px;border-top:1px solid var(--chat-line);padding-top:8px;font-size:12px;color:var(--chat-muted)}.library-emoji-detail span:first-child{font-size:28px}
body .chat-row button:focus-visible,body .chat-composer button:focus-visible,body .message-reply-reference:focus-visible{outline:2px solid #8ab4ff!important;outline-offset:2px}
@media(max-width:640px){body .chat-row,body .message.chat-row.mine,body .message.chat-row:not(.mine),body .dm-bubble.chat-row{padding-left:56px!important;padding-right:12px!important}body .chat-row :is(.message-avatar,.reference-dm-avatar){left:12px!important;width:32px!important;height:32px!important;min-width:32px!important;min-height:32px!important}body form.chat-composer{width:calc(100% - 16px)!important;margin:8px 8px max(8px,env(safe-area-inset-bottom))!important;gap:2px!important}body form.chat-composer :is(.chat-gif-shortcut,.chat-sticker-shortcut){display:none!important}body form.chat-composer textarea{font-size:16px!important}body .chat-reply-bar,body .reply-preview{width:calc(100% - 16px)!important;margin-inline:8px!important}body .chat-row .message-actions{position:static!important;opacity:1;pointer-events:auto;background:transparent!important;box-shadow:none;border:0!important;width:fit-content;margin-top:4px!important}body .chat-row .message-actions button{width:44px!important;height:44px!important;min-height:44px!important}body .chat-row .message-reply-reference::before{left:-26px;width:20px}body .chat-library .library-emoji-grid button,body .chat-library .library-categories button{min-height:44px!important;height:44px!important}body .chat-reply-bar small{display:none}}
@media(prefers-reduced-motion:reduce){body .chat-row,body .message-actions{transition:none!important;animation:none!important}}
.chat-conversations-toggle,.chat-conversations-close{display:none}
.chat-compact-time{display:none;position:absolute;left:12px;top:6px;width:48px;text-align:center;font-size:10px!important;pointer-events:none}
body .chat-row.chat-grouped>.chat-compact-time{display:block;opacity:0}body .chat-row.chat-grouped:hover>.chat-compact-time,body .chat-row.chat-grouped:focus-within>.chat-compact-time{opacity:1}
body .chat-row.pinned{box-shadow:inset 3px 0 var(--chat-blue)!important}body .chat-row.pinned .message-head::after{content:'سنجاق‌شده';font-size:10px;color:var(--chat-link)}
body .reply-preview>.reply-copy>.reply-copy-body{display:flex!important;align-items:center;gap:12px;min-width:0}
body .reply-preview>.reply-copy>.reply-copy-body>small{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
body .chat-messages .empty-chat{margin-top:auto;align-items:flex-start!important;text-align:left!important;direction:ltr!important;padding:24px 20px!important;min-height:180px}
body .chat-messages .empty-chat>i{display:grid;place-items:center;width:64px;height:64px;border-radius:50%;background:#222;color:#fff;font-size:32px}
body .chat-messages .empty-chat h2{font-size:24px;margin:14px 0 6px}
@media(max-width:400px){body.community-page form.chat-composer .chat-format-toggle{display:none!important}}
@media(max-width:640px){body .chat-row .message-reply-reference{min-height:44px!important}body .chat-row.has-reply :is(.message-avatar,.reference-dm-avatar){top:56px!important}}
@media(max-width:900px){body.chat-dm-active .hub-content{padding:0!important;gap:0!important}body.chat-dm-active .hub-content>.hub-topbar{display:none!important}body.chat-dm-active .messages-panel{position:relative;display:block!important;height:100dvh!important;min-height:0!important;border:0!important;border-radius:0!important;overflow:hidden!important}body.chat-dm-active .messages-panel>.conversation-sidebar{display:none}body.chat-dm-active .messages-panel>.dm-room{height:100%!important;border:0!important;border-radius:0!important}body.chat-dm-active .chat-show-conversations>.conversation-sidebar{position:absolute;inset:0;z-index:25;display:block;background:#111;padding:12px!important}body.chat-dm-active .conversation-list{display:block!important}body.chat-dm-active .conversation-list>a{min-width:0!important}body .chat-conversations-toggle,body .chat-conversations-close{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;min-height:44px;background:#202020;color:white;border:1px solid #353535;border-radius:8px;cursor:pointer}body .chat-conversations-toggle{margin-inline-start:auto}}
