/* D189: regras de conversa reunidas; o layout do workspace continua em style.css. */
:root { --chat-content: 900px; --chat-radius: 10px; --chat-gap: 12px; }
.studio-conversations { display: flex; flex: 1; min-height: 0; min-width: 0; background: var(--bg); }
.studio-conversations[hidden],.direct-status:empty { display: none; }
.direct-main { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.direct-main > .page-head { flex: none; background: var(--bg); border-bottom: 1px solid var(--border); padding: 10px 16px; }
.direct-peer-avatar { flex: none; display: flex; }
.direct-peer-avatar:empty { display: none; }
.direct-peer-avatar .avatar { width: 36px; height: 36px; }
.direct-status { flex: none; color: var(--muted); padding: 8px 22px; margin: 0; font-size: 12px; overflow-wrap: anywhere; background: var(--surface); border-bottom: 1px solid var(--border); }
.direct-retry { flex: none; align-self: flex-start; margin: 6px 22px; }
.direct-main .direct-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 20px; gap: 0; scroll-padding-bottom: 16px; }
.chat-list > * { flex-shrink: 0; }
.direct-main .direct-messages > * { min-width: 0; }
.direct-day { display: flex; align-items: center; gap: 12px; margin: 14px 0 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.direct-day::before,.direct-day::after { content: ''; height: 1px; background: var(--border); flex: 1; }
.direct-message { position: relative; margin: 12px -8px 0; padding: 2px 40px 2px 60px; min-height:44px; border-radius:0; }
.direct-message:hover { background: var(--hover-soft); }
.direct-message.mine { background: transparent; }
.direct-message.mine:hover { background: var(--hover-soft); }
.direct-message.cont { margin-top: 0; padding-top: 1px; padding-bottom: 1px; min-height:0; }
.direct-message.cont .direct-message-head { display: none; }
.direct-message.cont::before { content: attr(data-time); position: absolute; left: 4px; top: 7px; width: 40px; font-size: 10px; color: var(--muted); opacity: 0; text-align: center; }
.direct-message.cont:hover::before { opacity: 1; }
.direct-message-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin-bottom: 1px; }
.direct-message-head strong { font-size: 14px; font-weight: 600; }
.direct-message-head > .avatar { position: absolute; left: 8px; top: 3px; width: 40px; height: 40px; }
.direct-message-head time { font-size: 11px; color: var(--muted); }
.direct-message.mine .direct-message-head strong { color: var(--text); }
.direct-message-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; padding: 0; }
.direct-message-menu { position: absolute; right: 5px; top: 5px; min-width: 28px; min-height: 28px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text); cursor: pointer; opacity: 0; }
.direct-message:hover .direct-message-menu,.direct-message:focus-within .direct-message-menu { opacity: 1; }
.direct-message-state { display: block; font-size: 11px; color: var(--muted); }
.direct-reply-draft { display:flex; flex:none; align-items:center; gap:8px; margin:8px 12px -4px; padding:6px 10px; border-left:3px solid var(--accent); border-radius:5px; background:var(--surface-2); font-size:12px; }
.direct-reply-draft[hidden] { display:none; }
.direct-reply-draft span { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.direct-reply-draft button { flex:none; min-width:28px; min-height:28px; }
.direct-reply-quote { display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; border:0; border-left:2px solid var(--accent); border-radius:0; padding:2px 8px; margin:0 0 4px; background:transparent; color:var(--muted); text-align:left; font-size:12px; cursor:pointer; }
.direct-reply-quote:hover,.direct-reply-quote:focus-visible { color:var(--text); background:var(--hover-soft); }
.direct-message:has(.direct-reply-quote) .direct-message-head > .avatar { top:30px; }
.direct-message.reply-highlight { background:color-mix(in srgb,var(--accent) 18%,transparent); }
.direct-message.pending:not(.failed) .direct-message-text,.direct-message.pending:not(.failed) .direct-message-head { opacity: .55; }
.direct-message.failed { background: color-mix(in srgb,var(--danger) 7%,transparent); }
.direct-message.deleted .direct-message-text { color: var(--muted); font-style: italic; }
.direct-change { width: min(520px,calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg); color: var(--text); }
.direct-change::backdrop { background: #0008; }
.direct-change h2 { margin: 0 0 16px; font-size: 19px; }
.direct-change textarea { box-sizing: border-box; width: 100%; min-height: 120px; padding: 12px; resize: vertical; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; }
.direct-change footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.direct-main textarea { resize: none; flex: 1; min-width: 0; color: var(--text); font: inherit; }
.direct-main > .composer,#gform,#card-form { margin: 12px 18px 18px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); align-items: flex-end; gap: 10px; }
.direct-main > .composer { box-sizing: border-box; flex: none; width: calc(100% - 24px); margin: 10px 12px 12px; }
.direct-main > .composer textarea { max-height: 160px; overflow-y: auto; }
/* O campo mantém a mesma superfície ao passar o mouse e ao digitar. */
.composer:focus-within { box-shadow: none; }
.direct-main .composer textarea,#gform input,#card-form input { padding: 7px 4px; border: 0; background: transparent; font-size: 14px; line-height: 1.5; }
.direct-main .composer textarea:focus,#gform input:focus,#card-form input:focus { border: 0; outline: none; }
.direct-main .composer .send,#gform .send,#card-form .send { border-radius: 9px; width: 34px; height: 34px; }
.detail-discussion #card-form { margin: 8px 0; }
.chat-list .msg { border-radius:0; padding-top:2px; padding-bottom:2px; margin-top:12px; gap:12px; min-height:44px; }
.chat-list .msg > .avatar { width:40px; height:40px; }
.chat-list .msg.cont { padding-top:1px; padding-bottom:1px; margin-top:0; min-height:0; }
.chat-list .msg.cont .body { padding-left:52px; }
.chat-list .msg.mine .head .name { color:var(--text); }
.chat-list .msg .text { font-size: 15px; line-height: 1.5; }
.chat-list .msg .head .name { font-size: 14px; }
.chat-list .msg .head .time { font-size: 11px; }
.chat-list .msg .acts button { border-radius: 6px; }
.direct-search { display: block; padding: 12px 12px 6px; }
.direct-search input { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 13px; }
.studio-people-list { padding: 8px; }
.direct-sidebar-title { display:flex; align-items:center; gap:8px; min-width:0; }
.direct-sidebar-title .head-title { flex:1; }
.direct-sidebar-title .head-title b { color:var(--muted); font-size:12px; font-weight:600; letter-spacing:.03em; }
.direct-sidebar-title .head-desc { display:none; }
.direct-sidebar-new { flex:none; width:28px; height:28px; padding:0; border:0; border-radius:6px; background:transparent; color:var(--muted); font-size:22px; line-height:1; }
.direct-sidebar-new:hover { color:var(--text); background:var(--surface-3); }
.studio-person { min-height:44px; height:44px; box-sizing:border-box; padding:6px 8px; margin-bottom:2px; border-radius:7px; gap:10px; color:var(--muted); }
.studio-person:hover { background:color-mix(in srgb,var(--accent) 7%,var(--surface)); color:var(--text); }
.studio-person.on { background:linear-gradient(100deg,color-mix(in srgb,var(--accent) 15%,var(--surface)),color-mix(in srgb,var(--accent) 27%,var(--surface))); box-shadow:none; color:var(--text); }
.studio-person.unread { color:var(--text); }
.studio-person .avatar,.studio-person .direct-group-avatar { width:32px; height:32px; flex:0 0 32px; border-radius:50%; }
.studio-person-name { justify-content:center; overflow:hidden; }
.studio-person-name strong { color:inherit; font-size:14px; font-weight:500; line-height:1.4; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.studio-person.on .studio-person-name strong,.studio-person.unread .studio-person-name strong { font-weight:650; }
.studio-person-name small { font-size: 12px; line-height: 1.45; }
.studio-person-time { align-self: flex-start; color: var(--muted); font-size: 10px; white-space: nowrap; }
.studio-person .badge { flex: none; }
.direct-filters { gap: 6px; border-bottom: 0; padding-bottom: 8px; }
.direct-filters button { padding: 6px 10px; border: 0; border-radius: 7px; }
.direct-filters button[aria-pressed=true] { background: var(--surface-3); }
.direct-unread { position: absolute; right: 8px; top: 12px; border-radius: 12px; padding: 2px 6px; background: var(--accent); color: var(--on-accent); font-size: 11px; }
/* O mesmo chat acompanha a sala e a aba de chamada; não cria outra conversa. */
.gbody { position: relative; }
.gbody > #chat { width: clamp(280px,28vw,360px); }
.gbody > #chat:not([hidden]) { display: flex; }
body #gbody:has(> #chat:not([hidden])) > #rail-tools { display: none; }
#chat > header,#chat > .composer { flex: none; }
#chat .chat-list { min-height: 0; }
#chat .msg .body { min-width: 0; }
#chat .composer { gap: 8px; margin: 10px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); }
#chat .composer input { min-width: 0; background: transparent; border: 0; }
#call-chat-button { position: relative; flex: none; }
#call-chat-unread { position: absolute; right: -5px; top: -6px; font-size: 9px; padding: 1px 4px; }
@media(max-width:1000px) {
  .gbody > #chat { position: absolute; inset: 0 0 0 auto; z-index: 6; width: min(360px,100%); box-shadow: -8px 0 24px #0003; }
}
@media(max-width:760px) {
  .direct-main > .page-head { padding: 10px 12px; }
  .direct-main .direct-messages { padding: 8px; }
  .direct-main > .composer,#gform,#card-form { margin: 8px; }
  .direct-main > .composer { width: calc(100% - 16px); }
  .direct-message { padding-right: 32px; }
  .direct-new kbd,.studio-person-time { display: none; }
}
@media(hover:none) { .direct-message-menu { opacity: 1; } }
.direct-image { display:block; box-sizing:border-box; min-height:0; max-width:100%; padding:0; margin:8px 0 2px; overflow:hidden; border:0; border-radius:0; background:#09090d; cursor:zoom-in; }
.direct-image img { display:block; width:100%; height:100%; object-fit:contain; }
.direct-image video { display:block; width:100%; height:100%; object-fit:contain; }
.direct-image:has(video) { cursor:default; }
.direct-image-draft { flex:none; display:flex; align-items:center; gap:12px; width:min(900px,calc(100% - 40px)); margin:8px auto 0; padding:8px 12px; border:1px solid var(--border); border-radius:10px; }
.direct-image-draft[hidden] { display:none; }
.direct-image-draft img { width:72px; height:56px; object-fit:contain; border-radius:6px; }
.direct-image-draft video { width:120px; max-height:80px; }
.direct-image-draft span { flex:1; font-size:13px; }
.direct-image-draft button { font-size:12px; }
.direct-image-viewer { max-width:94vw; max-height:94vh; padding:12px; }
.direct-image-viewer img { display:block; max-width:88vw; max-height:80vh; object-fit:contain; margin-top:10px; }
.direct-attach { flex:none; font-size:24px; }
.channels,.chat-list { scrollbar-width:none; }
.channels::-webkit-scrollbar,.chat-list::-webkit-scrollbar { display:none; }
.gtab.tab-dragging { opacity:.45; }
.gif-library { width:min(560px,90vw); max-height:80vh; overflow:auto; padding:20px; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); }
.gif-library header { display:flex; justify-content:space-between; align-items:center; }
.gif-library p { font-size:13px; color:var(--muted); }
.gif-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:16px 0; }
.gif-grid img { width:100%; height:100px; object-fit:contain; }
.gif-grid > div > button:first-child { display:block; width:100%; padding:0; }
.gif-save { display:block; margin-bottom:8px; }
.gif-library-button { flex:none; font-size:11px; font-weight:700; }
.chat-media-status { flex:none; font-size:12px; padding:0 12px; color:var(--muted); }
.chat-media-status:empty { display:none; }
/* Texto formatado igual em canais, chamadas e privado; conteúdo continua sendo texto no envio. */
.chat-rich { white-space:normal; }
.chat-list .msg .text.chat-rich,.direct-message-text.chat-rich { white-space:normal; }
.chat-rich p { white-space:pre-wrap; margin:0 0 8px; }
.chat-rich > :last-child { margin-bottom:0; }
.chat-rich h3,.chat-rich h4,.chat-rich h5 { margin:12px 0 4px; line-height:1.35; }
.chat-rich h3 { font-size:1.35em; }.chat-rich h4 { font-size:1.15em; }.chat-rich h5 { font-size:1em; }
.chat-rich > :first-child { margin-top:0; }
.chat-rich ul,.chat-rich ol { margin:4px 0 8px; padding-left:24px; }
.chat-rich li { padding:1px 0; white-space:pre-wrap; }
.chat-rich blockquote { margin:6px 0; border-left:3px solid var(--border-strong); padding:2px 12px; color:var(--muted); white-space:pre-wrap; }
.chat-rich code { font: .9em ui-monospace,Consolas,monospace; padding:2px 4px; background:var(--surface-2); border-radius:4px; }
.chat-rich pre { max-width:100%; overflow:auto; white-space:pre; margin:8px 0; padding:10px 12px; border:1px solid var(--border); background:var(--surface-2); border-radius:5px; }
.chat-rich pre code { padding:0; background:transparent; border-radius:0; }
.chat-rich .code-add { color:#8fcca9; }.chat-rich .code-remove { color:#e99b9b; }
.composer textarea.chat-compose { box-sizing:border-box; flex:1; min-width:0; width:100%; min-height:34px; max-height:160px; resize:none; overflow-y:auto; border:0; background:transparent; color:var(--text); font:inherit; font-size:14px; line-height:1.5; padding:6px 4px; }
.composer textarea.chat-compose:focus { outline:none; border:0; }
#gchat > .page-head { background:var(--bg); }
.channel-chat-dialog .msg .body { min-width:0; }

#studio-people > .page-head { padding:10px 12px 4px; gap:0; min-height:0; }
#studio-people .direct-archive-back { margin-top:6px; font-size:11px; }
#studio-people .inbox-status:empty { display:none; }
