/* ================================================================== chat */
.chat { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

.chat-scroll { flex: 1 1 auto; min-height: 0; padding: 16px 0 8px; overflow-anchor: none; }
.chat-list { display: flex; flex-direction: column; }

.chat-intro { padding: 26px 20px 18px; }
.chat-intro .badge {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 14px;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-muted);
}
.chat-intro .badge svg { width: 30px; height: 30px; }
.chat-intro h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.chat-intro p { color: var(--text-muted); font-size: 14.5px; margin-top: 6px; max-width: 620px; }

.load-more { display: flex; justify-content: center; padding: 10px 0 16px; }

.day-sep { display: flex; align-items: center; gap: 12px; padding: 14px 20px 6px; }
.day-sep::before, .day-sep::after { content: ""; height: 1px; background: var(--line); flex: 1 1 auto; }
.day-sep span { font-size: 11.5px; font-weight: 700; color: var(--text-faint); letter-spacing: .04em; }

/* -------------------------------------------------------------- mensagem */
.msg {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto;
  padding: 2px 16px 2px 12px;
  position: relative;
}
.msg:hover { background: color-mix(in srgb, var(--bg-void) 22%, transparent); }
.msg.first { margin-top: 14px; }
.msg.mentioned { background: color-mix(in srgb, var(--yellow) 8%, transparent); }
.msg.mentioned::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--yellow);
}
.msg.pending { opacity: .55; }
.msg.failed .msg-body { color: var(--red); }

.msg .gutter { grid-column: 1; display: flex; justify-content: center; padding-top: 3px; }
.msg .avatar { --size: 38px; cursor: pointer; transition: transform var(--fast); }
.msg .avatar:hover { transform: scale(1.05); }
.msg .stamp-side {
  font-size: 10.5px; color: var(--text-faint); opacity: 0;
  padding-top: 5px; text-align: right; width: 100%; padding-right: 6px;
  font-variant-numeric: tabular-nums;
}
.msg:hover .stamp-side { opacity: 1; }

.msg-main { grid-column: 2; min-width: 0; padding-bottom: 1px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 1px; }
.msg-head .author { font-weight: 700; font-size: 14.5px; color: var(--author, var(--text)); cursor: pointer; }
.msg-head .author:hover { text-decoration: underline; }
.msg-head .stamp { font-size: 11.5px; color: var(--text-faint); }
.msg-head .tag { font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-text); padding: 1px 5px; border-radius: 4px; }

.msg-body { font-size: 15px; line-height: 1.55; color: var(--text-soft); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-body .edited { font-size: 10.5px; color: var(--text-faint); margin-left: 4px; white-space: nowrap; }
.msg-body code {
  font-family: var(--mono); font-size: .87em;
  background: var(--bg-void); border: 1px solid var(--line);
  padding: .1em .35em; border-radius: 4px;
}
.msg-body pre {
  margin: 6px 0; padding: 11px 13px;
  background: var(--bg-void); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow-x: auto; white-space: pre;
}
.msg-body pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.5; }
.msg-body blockquote {
  margin: 4px 0; padding: 2px 0 2px 12px;
  border-left: 3px solid var(--line-strong); color: var(--text-muted);
}
.msg-body .mention {
  background: var(--accent-soft); color: var(--accent-text);
  padding: 0 3px; border-radius: 4px; font-weight: 600; cursor: pointer;
}
.msg-body .mention.me { background: color-mix(in srgb, var(--yellow) 22%, transparent); color: var(--yellow); }
.msg-body .spoiler {
  background: var(--bg-raised); color: transparent; border-radius: 4px; cursor: pointer;
  transition: color var(--fast), background var(--fast);
}
.msg-body .spoiler.revealed { background: var(--bg-hover); color: inherit; }
.msg-body .big-emoji { font-size: 2.6em; line-height: 1.15; }

.reply-line {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); margin-bottom: 3px;
  position: relative; padding-left: 2px;
}
.reply-line::before {
  content: ""; position: absolute; left: -30px; top: 50%; width: 26px; height: 10px;
  border-left: 2px solid var(--line-strong); border-top: 2px solid var(--line-strong);
  border-top-left-radius: 7px;
}
.reply-line .avatar { --size: 16px; }
.reply-line b { font-weight: 600; color: var(--text-soft); }
.reply-line .preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; cursor: pointer; }
.reply-line .preview:hover { color: var(--text); }

/* ------------------------------------------------------------- anexos */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-image {
  max-width: min(440px, 100%); border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-void); cursor: zoom-in;
  transition: border-color var(--fast);
}
.att-image:hover { border-color: var(--line-strong); }
.att-image img { width: 100%; height: auto; }
.att-video { max-width: min(440px, 100%); border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); }
.att-video video { width: 100%; }
.att-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 11px; border-radius: var(--r-md);
  background: var(--bg-raised); border: 1px solid var(--line);
  transition: border-color var(--fast);
}
.att-file:hover { border-color: var(--accent-line); }
.att-file .ico { width: 32px; height: 32px; display: grid; place-items: center; color: var(--accent-text); flex: none; }
.att-file .meta { min-width: 0; }
.att-file .meta b { display: block; font-size: 13.5px; font-weight: 600; color: var(--accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.att-file .meta span { font-size: 11.5px; color: var(--text-faint); }

/* ------------------------------------------------------------- reações */
.reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px;
  height: 25px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--bg-hover); border: 1px solid transparent;
  font-size: 13px; color: var(--text-soft);
  transition: background var(--fast), border-color var(--fast);
}
.reaction:hover { border-color: var(--line-strong); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.reaction .n { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------- ações rápidas */
.msg-actions {
  position: absolute; top: -14px; right: 16px;
  display: none; gap: 1px; padding: 2px;
  background: var(--bg-raised); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); z-index: 5;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 28px; height: 28px; border-radius: var(--r-sm); }
.msg-actions .icon-btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------- composição */
.composer-wrap { flex: none; padding: 0 16px 20px; }

.composer-context {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: 13px; color: var(--text-muted);
  background: var(--bg-raised); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.composer-context b { color: var(--text-soft); }
.composer-context .spacer { flex: 1 1 auto; }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 6px 8px 6px 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.composer-context + .composer { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  flex: 1 1 auto; min-width: 0;
  background: none; border: 0; resize: none;
  padding: 10px 4px; max-height: 220px; line-height: 1.5;
  font-size: 15px;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:focus-visible { outline: none; }
.composer .icon-btn { width: 36px; height: 36px; margin-bottom: 1px; }

.composer-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; background: var(--bg-raised);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-md) var(--r-md) 0 0; }
.pending-file {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px;
  background: var(--bg-void); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 12.5px;
  max-width: 240px;
}
.pending-file img { width: 34px; height: 34px; border-radius: 4px; object-fit: cover; flex: none; }
.pending-file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-file .bar { width: 46px; height: 4px; border-radius: 3px; background: var(--bg-input); overflow: hidden; flex: none; }
.pending-file .bar i { display: block; height: 100%; background: var(--accent); transition: width .18s linear; }

.composer-foot { display: flex; align-items: center; gap: 10px; min-height: 22px; padding: 5px 6px 0; font-size: 12px; color: var(--text-faint); }
.typing { display: flex; align-items: center; gap: 6px; }
.typing .dots { display: inline-flex; gap: 3px; }
.typing .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-muted); animation: typing-bounce 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .16s; }
.typing .dots i:nth-child(3) { animation-delay: .32s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.composer-foot .counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.composer-foot .counter.warn { color: var(--yellow); }

.drop-veil {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, rgba(0,0,0,.55));
  backdrop-filter: blur(3px);
  border: 2px dashed var(--accent); border-radius: var(--r-lg);
  font-weight: 700; color: var(--text); pointer-events: none;
  animation: fade-in .12s var(--ease);
}

/* -------------------------------------------------------------- lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .86); backdrop-filter: blur(6px);
  animation: fade-in .16s var(--ease); cursor: zoom-out;
}
.lightbox img, .lightbox video { max-width: 92vw; max-height: 86vh; border-radius: var(--r-md); box-shadow: var(--shadow-lg); }
.lightbox .bar { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }

/* ------------------------------------------------------------- compacto */
:root[data-compact="true"] .msg { padding-top: 1px; padding-bottom: 1px; }
:root[data-compact="true"] .msg.first { margin-top: 8px; }
:root[data-compact="true"] .msg-body { font-size: 14px; line-height: 1.45; }
:root[data-compact="true"] .msg .avatar { --size: 30px; }
:root[data-compact="true"] .msg { grid-template-columns: 38px minmax(0, 1fr) auto; }
