.chat {
  display: grid; grid-template-rows: auto auto 1fr auto auto; height: clamp(420px, calc(100vh - 300px), 820px); scroll-margin-top: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.chat-head h2 { font-size: 1.05rem; }
.chat-online { display: flex; align-items: center; }
.chat-online-face { margin-left: -8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface); position: relative; display: inline-flex; }
.chat-online-more { margin-left: 6px; font-size: .8rem; color: var(--text-2); }
.chat-offline { display: flex; align-items: center; gap: 8px; padding: 8px 18px; background: var(--warning-soft); font-size: .85rem; }
.chat-offline svg { width: 16px; height: 16px; flex: none; }
.chat-scroll { overflow-y: auto; padding: 12px 6px 4px; overscroll-behavior: contain; }
.chat-day { display: flex; align-items: center; gap: 12px; margin: 14px 12px 6px; color: var(--text-3); font-size: .75rem; font-weight: 600; }
.chat-day::before, .chat-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.chat-day span { text-transform: capitalize; }
.chat-start, .chat-older { text-align: center; color: var(--text-3); font-size: .8rem; padding: 8px; display: flex; justify-content: center; gap: 8px; }
.chat-empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 48px 24px; }

.chat-msg { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; padding: 2px 12px; border-radius: var(--r-sm); }
.chat-msg.has-author { margin-top: 10px; padding-top: 4px; }
.chat-msg:hover { background: var(--surface-2); }
.chat-msg-avatar { padding-top: 2px; }
.chat-msg-main { min-width: 0; }
.chat-msg-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: .9rem; }
.chat-msg-head time { color: var(--text-3); font-size: .75rem; }
.chat-msg.is-mine .chat-msg-head strong { color: var(--primary); }
.chat-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.5; }
.chat-msg-side { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .1s; }
.chat-msg:hover .chat-msg-side, .chat-msg:focus-within .chat-msg-side { opacity: 1; }
.chat-msg-time { color: var(--text-3); font-size: .72rem; }
.chat-msg-delete { width: 28px; height: 28px; }
.chat-msg-delete svg { width: 15px; height: 15px; }
.chat-msg-delete:hover { color: var(--danger); }
@media (hover: none) { .chat-msg-side { opacity: 1; } .chat-msg-time { display: none; } }

.chat-typing { min-height: 22px; padding: 0 18px; font-size: .8rem; color: var(--text-2); font-style: italic; }
.chat-composer { position: relative; display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-composer textarea { resize: none; min-height: 42px; max-height: 160px; border-radius: var(--r-md); background: var(--surface-2); border-color: transparent; }
.chat-composer textarea:focus { background: var(--surface); }
.chat-send { width: 42px; height: 42px; padding: 0; border-radius: var(--r-md); flex: none; }
/* Celular: o chat ocupa a tela entre a barra de cima e a de baixo */
@media (max-width: 860px) { .chat { height: calc(100dvh - 150px); min-height: 360px; border-radius: var(--r-md); scroll-margin-top: 70px; } }

.chat-staff { padding: 10px 12px; border-top: 1px solid var(--border); }

/* Emojis e @menções */
.chat-emoji-btn { width: 42px; height: 42px; flex: none; border-radius: var(--r-md); color: var(--text-2); }
.chat-emoji-btn svg { width: 22px; height: 22px; }
.chat-emoji-btn.is-on { color: var(--primary); background: var(--surface-2); }
.emoji-picker {
  position: absolute; left: 12px; bottom: calc(100% + 6px); z-index: 20; width: min(340px, calc(100% - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg, 0 18px 40px rgba(0,0,0,.18));
  padding: 8px; display: grid; gap: 6px;
}
.emoji-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding-bottom: 6px; overflow-x: auto; }
.emoji-tabs button { border: 0; background: none; font-size: 1.15rem; line-height: 1; padding: 6px 7px; border-radius: var(--r-sm); cursor: pointer; opacity: .6; }
.emoji-tabs button[aria-selected="true"] { opacity: 1; background: var(--surface-2); }
.emoji-group-label { margin: 0; font-size: .75rem; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 210px; overflow-y: auto; }
.emoji-grid button { border: 0; background: none; font-size: 1.4rem; line-height: 1; padding: 6px 0; border-radius: var(--r-sm); cursor: pointer; }
.emoji-grid button:hover, .emoji-grid button:focus-visible { background: var(--surface-2); }
.chat-mentions {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); z-index: 21; list-style: none; margin: 0; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg, 0 18px 40px rgba(0,0,0,.18));
  display: grid; gap: 2px; max-width: 360px;
}
.chat-mentions button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: var(--r-md); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.chat-mentions button.is-active, .chat-mentions button:hover { background: var(--surface-2); }
.chat-mention { color: var(--primary); font-weight: 600; text-decoration: none; border-radius: 4px; padding: 0 2px; background: color-mix(in srgb, var(--primary) 10%, transparent); }
.chat-mention:hover { text-decoration: underline; }
.chat-mention.is-me { color: #fff; background: var(--primary); }
.chat-msg.is-mentioned .chat-msg-main { box-shadow: inset 3px 0 0 var(--primary); padding-left: 8px; }
