/* Chat ? bolhas, ack, sugest?o IA, composer */

.chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.chat-header {
  min-height: var(--panel-head-h);
  height: var(--panel-head-h);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.btn-back {
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  width: var(--control-h-lg);
  height: var(--control-h-lg);
  cursor: pointer;
  font-size: var(--fs-md);
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.btn-back:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-contact {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  padding: 0.15rem var(--space-2);
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
}

.chat-contact:hover { background: var(--surface-2); }

/* Avatar no header do chat (foto só aqui; painel Cliente sem foto duplicada) */
.chat-header-avatar {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--control-h-lg);
  height: var(--control-h-lg);
  min-width: var(--control-h-lg);
  min-height: var(--control-h-lg);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  overflow: visible;
  line-height: 0;
}
.chat-header-avatar .avatar,
.chat-header-avatar .avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  pointer-events: none;
}
.chat-header-avatar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chat-header .chat-contact {
  cursor: default;
  text-align: left;
  border: none;
  background: transparent;
  min-width: 0;
  flex: 1 1 auto;
}
.chat-header .btn-icon.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.chat-contact strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-sub {
  display: block;
  font-size: var(--fs-2xs);
  color: var(--muted);
  margin-top: 0.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

#btn-close-chat.btn-icon {
  opacity: 0.72;
}
#btn-close-chat.btn-icon:hover,
#btn-close-chat.btn-icon:focus-visible {
  opacity: 1;
}

#btn-toggle-crm-chat.btn-icon {
  display: inline-grid;
  place-items: center;
}

#btn-toggle-crm-chat .ico-user {
  transform: translateY(-1px);
}

/* Fechar/abrir chamado — ícone (phoneX / chat) no design system */
.btn-close-chamado,
.btn-open-chamado {
  color: var(--muted);
}

.btn-close-chamado {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-close-chamado:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, var(--danger-soft));
}

.btn-open-chamado {
  color: var(--ok);
  background: var(--ok-soft);
}

.btn-open-chamado:hover {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--ok-soft));
}

.btn-close-chamado .ico,
.btn-open-chamado .ico {
  color: currentColor;
}

.thread-search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.thread-search-bar .search-ico {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.thread-search-input {
  flex: 1;
  min-height: var(--control-h-md);
  padding: 0 var(--space-2);
  font-size: var(--fs-md);
  border: none;
  background: transparent;
  box-shadow: none;
}

.thread-search-input:focus {
  outline: none;
  box-shadow: none;
}

.msg-bubble.search-hidden {
  display: none;
}

.msg-bubble.search-hit {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ack-read) 35%, transparent);
}

.chat-thread {
  flex: 1;
  overflow: auto;
  /* Hover actions ficam para o centro da bolha — gutter lateral só precisa de respiro visual */
  padding: 0.65rem 1.15rem 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  /* background-color + image separados: kits não são apagados pelo shorthand */
  background-color: var(--thread-bg, var(--canvas));
  background-image: var(--chat-bg-image, none);
  /* cover/contain via schema do kit — sem tile lado a lado por padrão */
  background-repeat: var(--chat-bg-repeat, no-repeat);
  background-size: var(--chat-bg-size, cover);
  background-position: var(--chat-bg-position, center top);
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}

/* Camada de animação leve (CSS only) — transform/opacity, loop suave */
.chat-thread::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background: transparent;
  will-change: transform, opacity;
}

.chat-thread > * {
  position: relative;
  z-index: 1;
}

/* Galáxia: movimento celestial discreto */
html.kit-anim-celestial .chat-thread::after {
  opacity: 0.55;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 38% 62%, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 28%, rgba(200, 220, 255, 0.45), transparent 60%),
    radial-gradient(1px 1px at 88% 78%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1.4px 1.4px at 54% 44%, rgba(180, 160, 255, 0.4), transparent 60%);
  animation: kit-celestial 48s linear infinite;
}

/* Estrutura pronta (desligada até o kit habilitar) */
html.kit-anim-rain .chat-thread::after {
  opacity: 0.35;
  background-image: repeating-linear-gradient(
    185deg,
    transparent 0,
    transparent 10px,
    rgba(140, 180, 220, 0.18) 10px,
    rgba(140, 180, 220, 0.18) 12px
  );
  background-size: 18px 48px;
  animation: kit-rain 1.8s linear infinite;
}

html.kit-anim-leaves .chat-thread::after {
  opacity: 0.3;
  background-image:
    radial-gradient(ellipse 6px 3px at 20% 10%, rgba(80, 140, 60, 0.35), transparent 70%),
    radial-gradient(ellipse 5px 2.5px at 70% 40%, rgba(100, 150, 50, 0.3), transparent 70%);
  animation: kit-leaves 22s ease-in-out infinite;
}

html.kit-anim-birds .chat-thread::after {
  opacity: 0.25;
  background-image:
    radial-gradient(circle 2px at 15% 30%, rgba(40, 40, 50, 0.45), transparent 70%),
    radial-gradient(circle 1.5px at 60% 55%, rgba(40, 40, 50, 0.35), transparent 70%);
  animation: kit-birds 36s linear infinite;
}

@keyframes kit-celestial {
  0% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.45; }
  50% { transform: translate3d(-1.5%, 1%, 0) scale(1.03); opacity: 0.6; }
  100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.45; }
}

@keyframes kit-rain {
  0% { background-position: 0 0; }
  100% { background-position: 6px 48px; }
}

@keyframes kit-leaves {
  0% { transform: translate3d(0, -2%, 0) rotate(0deg); }
  50% { transform: translate3d(2%, 2%, 0) rotate(4deg); }
  100% { transform: translate3d(0, -2%, 0) rotate(0deg); }
}

@keyframes kit-birds {
  0% { transform: translate3d(-4%, 0, 0); }
  100% { transform: translate3d(6%, -2%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  html.kit-anim-celestial .chat-thread::after,
  html.kit-anim-rain .chat-thread::after,
  html.kit-anim-leaves .chat-thread::after,
  html.kit-anim-birds .chat-thread::after {
    animation: none !important;
    opacity: 0.2;
  }
}

/* Chat largo (CRM fechado): um pouco mais de ar nas bordas */
.atendimento-grid.crm-collapsed .chat-thread {
  padding-left: 1.75rem;
  padding-right: 1.75rem;
}

/* CRM aberto: painel estreito — colar bolhas nas bordas úteis */
.atendimento-grid:not(.crm-collapsed) .chat-thread {
  padding-left: 0.7rem;
  padding-right: 0.7rem;
}

.atendimento-grid:not(.crm-collapsed) .msg-wrap {
  max-width: min(88%, 560px);
}

.chat-body {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.chat-empty {
  color: var(--muted);
  text-align: center;
  margin: auto;
  font-size: var(--fs-sm);
}

.msg-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: min(80%, 560px);
  margin-bottom: 0.12rem;
}

.msg-wrap.in { align-self: flex-start; }
.msg-wrap.out { align-self: flex-end; }

.msg-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
}

.msg-wrap.in .msg-row { flex-direction: row; }
.msg-wrap.out .msg-row { flex-direction: row; justify-content: flex-end; }

.msg-wrap.is-react-open,
.msg-wrap:has(.msg-inline-react:not(.hidden)) {
  z-index: 24;
}

.msg-row .msg-bubble.has-media-audio {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 100%;
}

/* Bolhas Calm Clinic — cantos 10px, sombra suave, sem cauda agressiva */
.msg-bubble {
  position: relative;
  max-width: 100%;
  width: fit-content;
  min-width: 0;
  border-radius: var(--radius-bubble);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  padding: 0.55rem 2.2rem 0.4rem 0.7rem;
}

.msg-bubble.in {
  background: var(--bubble-in, var(--surface));
  border-top-left-radius: var(--radius-sm);
  padding: 0.55rem 2.2rem 0.4rem 0.7rem;
}

.msg-bubble.in .msg-text {
  padding-right: 0.35rem;
}

.msg-bubble.in::before {
  content: none;
}

.msg-bubble.out {
  background: var(--bubble-out, #E8F3EF);
  border-color: color-mix(in srgb, var(--brand, var(--accent)) 12%, var(--line));
  border-top-right-radius: var(--radius-sm);
}

.msg-bubble.out::before {
  content: none;
}

.msg-text {
  font-size: var(--fs-md, 0.875rem);
  font-weight: var(--fw-normal, 400);
  line-height: var(--lh-body, 1.45);
  white-space: pre-wrap;
  color: var(--ink);
}

.msg-sender-label {
  display: block;
  margin-top: 0.28rem;
  color: color-mix(in srgb, var(--brand, var(--accent)) 72%, var(--muted));
  font-size: 0.62rem;
  font-weight: var(--fw-semibold, 600);
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: right;
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  margin-top: 0.12rem;
  margin-left: auto;
  padding-top: 0.08rem;
  font-size: 0.6875rem;
  line-height: 0.9375rem;
  color: var(--muted);
  float: right;
  clear: both;
  position: relative;
  top: 0.28rem;
  margin-bottom: -0.12rem;
  margin-right: -0.05rem;
}

.msg-meta.inbound { justify-content: flex-end; }

.msg-meta time { font-variant-numeric: tabular-nums; }

.msg-ack {
  font-size: 0.58rem;
  line-height: 1;
  letter-spacing: -0.12em;
  font-weight: 500;
  margin-left: 0.04rem;
}

.msg-ack.ack-enviado { color: #8c98a4 !important; }

.msg-ack.ack-lido {
  color: #28d8ff !important;
  font-weight: 800;
  text-shadow: 0 0 5px rgba(40, 216, 255, 0.45);
}

html.dark .msg-ack.ack-lido {
  color: #28d8ff !important;
}

.msg-ack.ack-pendente {
  color: var(--warn);
  animation: spin-pendente 1.2s linear infinite;
  display: inline-block;
}

.msg-ack.ack-falha {
  color: var(--danger);
  font-weight: 800;
}

@keyframes spin-pendente {
  to { transform: rotate(360deg); }
}

.chat-footer {
  border-top: 1px solid var(--line);
  background-color: var(--surface);
  background-image: var(--composer-bg-image, none);
  background-size: var(--composer-bg-size, cover);
  background-position: var(--composer-bg-position, center);
  background-repeat: var(--composer-bg-repeat, no-repeat);
  padding: 0.5rem 0.75rem 0.65rem;
  flex-shrink: 0;
}

.sugestao-ia-bar.copilot-suggest-wrap {
  margin-bottom: 0.35rem;
  width: 100%;
  font-size: 12px;
  padding: 0;
  background: transparent;
  border: 0;
}

.copilot-suggest-wrap .dc-bar-inner {
  --copilot-radius: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  grid-template-rows: auto auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--copilot-radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.copilot-suggest-wrap .dc-bar-head {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: auto auto;
  align-items: start;
  justify-items: stretch;
  gap: 4px;
  width: max-content;
  min-width: 0;
  padding: 5px 6px 5px 5px;
  background: var(--surface-soft);
  border-left: 1px solid var(--line);
}

.copilot-suggest-wrap .dc-bar-confidence {
  color: var(--muted);
  font-size: 10px;
  font-weight: var(--fw-medium, 500);
  white-space: nowrap;
}

.copilot-suggest-wrap .dc-bar-head-actions {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.copilot-suggest-wrap .dc-head-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm, 8px);
  width: 22px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.copilot-suggest-wrap .dc-head-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.copilot-suggest-wrap .dc-bar-body {
  display: contents;
}

.copilot-suggest-wrap .dc-chip {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  border: 0;
  background: var(--surface);
  text-align: left;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--ink);
  overflow: hidden;
  font: inherit;
  font-size: 12px;
}

.copilot-suggest-wrap .dc-chip-title {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: var(--fs-2xs, 11px);
  font-weight: var(--fw-semibold, 600);
  line-height: 1.2;
}

.copilot-suggest-wrap .dc-chip-text {
  display: block;
  min-height: 0;
  max-height: calc(1.35em * 2);
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--ink);
  line-height: 1.35;
  white-space: pre-line;
  word-break: break-word;
  scrollbar-width: thin;
}

.copilot-suggest-wrap .dc-chip:hover {
  background: var(--surface-2);
}

.copilot-suggest-wrap .dc-chip.is-idle {
  color: var(--muted);
  font-style: italic;
  cursor: default;
}

.copilot-suggest-wrap .dc-chip.is-idle .dc-chip-text,
.copilot-suggest-wrap .dc-chip.is-loading .dc-chip-text {
  color: var(--muted);
}

.copilot-suggest-wrap .dc-bar-actions {
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  padding: 2px 0 0;
  border-top: 1px solid var(--line);
}

.copilot-suggest-wrap .dc-icon-btn {
  width: 30px;
  height: 30px;
  min-height: 0;
  flex: 0 0 auto;
  border: 0;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 8px);
}

.copilot-suggest-wrap .dc-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.copilot-suggest-wrap .dc-chip.is-loading {
  color: var(--muted);
  font-style: italic;
}

.copilot-suggest-wrap .dc-icon-btn:hover {
  background: var(--accent-soft);
}

.copilot-suggest-wrap .dc-icon-btn.positive:hover {
  color: var(--accent);
}

.copilot-suggest-wrap .dc-icon-btn.negative:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.copilot-suggest-wrap .dc-icon-btn.active.positive {
  background: var(--accent-soft);
  color: var(--accent);
}

.copilot-suggest-wrap .dc-icon-btn.active.negative {
  background: var(--danger-soft);
  color: var(--danger);
}

.copilot-suggest-wrap .dc-feedback-form {
  grid-column: 1 / -1;
  grid-row: 3;
  border-top: 1px solid var(--line);
  padding: 6px 8px;
  background: var(--surface-2);
  display: grid;
  gap: 6px;
}

.copilot-suggest-wrap .dc-feedback-form.hidden {
  display: none !important;
}

.copilot-suggest-wrap .dc-feedback-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.copilot-suggest-wrap .dc-feedback-textarea {
  width: 100%;
  min-height: 48px;
  box-sizing: border-box;
  font-size: 12px;
  resize: vertical;
}

.copilot-suggest-wrap .dc-feedback-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.copilot-suggest-wrap .dc-hint {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

html.dark .copilot-suggest-wrap .dc-bar-inner,
html.dark .copilot-suggest-wrap .dc-chip,
html.dark .copilot-suggest-wrap .dc-icon-btn,
html.dark .copilot-suggest-wrap .dc-head-btn {
  background: var(--panel-2);
  color: var(--ink);
}

html.dark .copilot-suggest-wrap .dc-bar-head {
  background: var(--surface-soft);
}

.composer-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.panel-chat-body {
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-placeholder-wrap {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

@media (max-width: 960px) {
  .chat-thread,
  .atendimento-grid.crm-collapsed .chat-thread,
  .atendimento-grid:not(.crm-collapsed) .chat-thread {
    padding: 0.55rem 0.85rem 0.85rem 0.85rem;
  }

  .msg-wrap,
  .atendimento-grid:not(.crm-collapsed) .msg-wrap {
    max-width: min(88%, 100%);
  }
}

@media (max-width: 768px) {
  .chat-thread,
  .atendimento-grid.crm-collapsed .chat-thread,
  .atendimento-grid:not(.crm-collapsed) .chat-thread {
    padding: 0.5rem 1rem 0.85rem 1rem;
  }

  .btn-back.mobile-only { display: inline-flex; align-items: center; justify-content: center; }

  .chat-body {
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .chat-thread-rail:not(.hidden) {
    display: flex;
  }

  .chat-body:has(.chat-thread-rail:not(.hidden)) .chat-thread {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .msg-wrap,
  .atendimento-grid:not(.crm-collapsed) .msg-wrap {
    max-width: 90%;
  }
}

@media (min-width: 769px) {
  .btn-back.mobile-only { display: none; }
}

/* Composer avan?ado */
.composer-shell { position: relative; }

.composer-glow {
  border-radius: calc(var(--radius) + 2px);
  padding: 2px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, transparent), color-mix(in srgb, var(--primary) 25%, transparent), color-mix(in srgb, var(--accent) 20%, transparent));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
  transition: box-shadow 0.25s, background 0.25s;
}

.composer-glow.focused {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--primary) 40%, transparent), color-mix(in srgb, var(--accent) 45%, transparent));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
    0 0 18px color-mix(in srgb, var(--accent) 22%, transparent),
    0 0 36px color-mix(in srgb, var(--accent) 10%, transparent);
}

.composer-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  /* herda o arredondamento do .composer-glow (anel externo) */
  /* Menus de respostas rápidas abrem acima do compositor. */
  overflow: visible;
}

.composer-field-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

.composer-input {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  padding: 7px var(--space-2);
  font: inherit;
  font-size: 0.875rem;
  line-height: 22px;
  min-height: var(--control-h-lg);
  max-height: 82px;
  overflow-y: hidden;
  color: var(--ink);
}

.composer-input:focus { outline: none; }

.composer-btn {
  box-sizing: border-box;
  width: var(--control-h-md);
  height: var(--control-h-md);
  min-width: var(--control-h-md);
  min-height: var(--control-h-md);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft, var(--muted));
  cursor: pointer;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  line-height: 0;
  overflow: visible;
  padding: 0;
}

.composer-btn:hover {
  background: var(--surface-muted, var(--surface-2));
  color: var(--ink);
}
.composer-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.composer-btn.is-recording { color: var(--danger, #c0392b); background: color-mix(in srgb, var(--danger, #c0392b) 12%, transparent); animation: composer-dictate-pulse 1.2s ease-in-out infinite; }
@keyframes composer-dictate-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--danger, #c0392b) 12%, transparent); } }

.composer-attach .ico {
  color: var(--ink);
  stroke-width: 2;
}

.composer-send {
  background: var(--brand, var(--ack-read));
  color: #fff;
  box-shadow: none;
}
.composer-send:hover {
  background: var(--brand-hover, var(--primary-hover));
  color: #fff;
}

.composer-send .ico,
.composer-send .ico-send {
  color: #fff;
}

.composer-send:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--muted) 70%, var(--surface-2));
  box-shadow: none;
}

.composer-send:not(:disabled):hover {
  background: color-mix(in srgb, var(--ack-read) 88%, #000);
}

.attach-menu,
.slash-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 30;
  min-width: 160px;
}

.attach-menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.attach-menu button {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}

.attach-menu button .ico {
  flex-shrink: 0;
  color: var(--muted);
}

.attach-menu button:hover:not(:disabled) .ico {
  color: var(--accent);
}

.attach-menu button:hover:not(:disabled) { background: var(--surface-2); }

.attach-menu button:disabled { opacity: 0.4; cursor: not-allowed; }

.slash-menu { width: min(320px, 90vw); }

.assisted-budget-text-review {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 70;
  width: min(30rem, calc(100% - 2 * var(--space-3)));
  max-height: min(70vh, 34rem);
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, #d9a514 58%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, #fff4bf 34%, var(--surface));
  box-shadow: var(--shadow-lg, var(--shadow));
  color: var(--ink);
}
.assisted-budget-text-review > header,
.assisted-budget-text-review > header > div,
.assisted-budget-text-review li > span {
  display: flex;
}
.assisted-budget-text-review > header {
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.assisted-budget-text-review > header > div,
.assisted-budget-text-review li > span {
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.assisted-budget-text-review header span,
.assisted-budget-text-review small,
.assisted-budget-text-review > p {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.assisted-budget-text-review > p {
  margin: var(--space-2) 0;
  line-height: 1.45;
}
.assisted-budget-text-review ul {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.assisted-budget-text-review li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #d9a514 10%, var(--surface));
}
@media (max-width: 600px) {
  .assisted-budget-text-review {
    top: var(--space-2);
    right: var(--space-2);
    width: calc(100% - 2 * var(--space-2));
    max-height: 76vh;
  }
}

.slash-item {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.slash-item.active,
.slash-item:hover { background: var(--accent-soft); }

.slash-item strong { color: var(--accent); min-width: 72px; }

.slash-item span { color: var(--muted); font-size: 0.78rem; }

.audio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.audio-ico {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.audio-ico:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.audio-ico:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.audio-ico-primary {
  background: color-mix(in srgb, var(--ok) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}

.audio-ico-primary .ico {
  color: var(--ok);
}

.audio-ico-send:not(:disabled) {
  background: var(--ack-read);
  border-color: transparent;
}

.audio-ico-send:not(:disabled) .ico {
  color: #fff;
}

#audio-transcribe {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.audio-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem;
  background: var(--surface-2);
}

.audio-wave {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 24px;
  margin-bottom: 0.35rem;
}

.audio-wave span {
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite alternate;
}

.audio-wave span:nth-child(2) { animation-delay: 0.1s; height: 16px; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; height: 12px; }
.audio-wave span:nth-child(4) { animation-delay: 0.3s; height: 18px; }

@keyframes wave {
  from { height: 6px; opacity: 0.5; }
  to { height: 22px; opacity: 1; }
}

.audio-timer {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.audio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.transcribe-box {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
}

.transcribe-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.transcribe-box .btn-accent {
  margin-top: 0.35rem;
}

#audio-transcribe.btn-accent:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mensagens — menu, seleção, citação, reações */
.msg-bubble {
  overflow: visible;
}

.msg-bubble.has-select {
  padding-left: 1.65rem;
}

.msg-bubble.important {
  box-shadow: var(--shadow-sm), inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent);
}

.msg-bubble.selected {
  outline: 2px solid var(--brand, var(--accent));
  outline-offset: 1px;
}

.msg-text {
  padding-right: 0.35rem;
}

/* Ações externas (reagir / encaminhar) — fora da bolha, centralizadas verticalmente */
.msg-hover-actions {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  min-width: 2.5rem;
  position: relative;
  z-index: 5;
}

@media (min-width: 769px) {
  .msg-wrap:hover .msg-hover-actions,
  .msg-wrap:focus-within .msg-hover-actions,
  .msg-wrap:has(.msg-menu-btn[aria-expanded="true"]) .msg-hover-actions,
  .msg-wrap:has(.msg-inline-react:not(.hidden)) .msg-hover-actions,
  .chat-thread.select-mode-active .msg-hover-actions {
    opacity: 1;
    pointer-events: auto;
  }

  .msg-bubble:hover .msg-menu-btn,
  .msg-bubble:focus-within .msg-menu-btn,
  .msg-bubble.has-select .msg-menu-btn,
  .msg-menu-btn[aria-expanded="true"] {
    opacity: 0.75;
  }
}

@media (max-width: 768px) {
  .msg-hover-actions {
    display: none !important;
  }

  .msg-menu-btn {
    display: inline-flex !important;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    opacity: 0.72;
  }

  .msg-wrap.is-mobile-actions {
    /* A rail de avatares e o WebView podem criar camadas próprias; o toolbar
       precisa ficar acima delas enquanto a ação da mensagem está aberta. */
    z-index: 2147483000 !important;
    isolation: isolate;
  }

  .msg-wrap.is-mobile-actions .msg-inline-react:not(.hidden) {
    display: flex;
    position: fixed !important;
    z-index: 2147483001 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  }
}

.msg-wrap:has(.msg-menu-btn[aria-expanded="true"]) {
  z-index: 520;
}

.msg-bubble:has(.msg-menu-btn[aria-expanded="true"]) {
  z-index: 521;
}

.msg-select-wrap {
  position: absolute;
  left: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  z-index: 2;
}

.msg-select {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Menu de ações — canto superior direito da bolha */
.msg-menu-btn {
  position: absolute;
  top: 0.2rem;
  right: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  line-height: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  color: var(--muted);
  cursor: pointer;
  opacity: 0.66;
  z-index: 4;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.msg-menu-btn .ico {
  display: block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  pointer-events: none;
}

.msg-forward-btn,
.msg-react-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 26px; /* ui-icon-btn --sm */
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  line-height: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, transform 0.1s;
}

.msg-forward-btn .ico,
.msg-react-btn .ico {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.msg-forward-btn .ico {
  width: 20px;
  height: 20px;
}

.msg-react-btn .ico {
  width: 22px;
  height: 22px;
}

.msg-menu-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  opacity: 1;
}

.msg-document-caption {
  margin-top: 0.25rem;
}

.msg-document-caption > summary {
  color: var(--accent);
  cursor: pointer;
  font-size: var(--fs-2xs, 0.75rem);
  font-weight: 600;
}

.msg-document-caption[open] > summary {
  margin-bottom: 0.25rem;
}

.msg-forward-btn:hover,
.msg-react-btn:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--accent);
  opacity: 1;
}

.msg-react-btn.active,
.msg-react-btn:hover .ico {
  color: var(--accent);
}

.msg-forward-btn:hover {
  transform: scale(1.05);
}

.msg-menu {
  display: none !important;
}

.msg-context-menu {
  position: fixed;
  z-index: 12000;
  min-width: 190px;
  max-width: min(92vw, 260px);
  max-height: min(70vh, 360px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  padding: 0.25rem;
}

.msg-context-menu.hidden {
  display: none;
}

.msg-context-menu .msg-menu-item {
  width: 100%;
}

.quick-reaction-bar {
  position: fixed;
  z-index: 200;
  display: flex;
  gap: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 0.25rem 0.5rem;
}

.quick-reaction-bar.hidden {
  display: none;
}

.quick-reaction-btn {
  border: none;
  background: transparent;
  font-size: 1.875rem;
  padding: 0.375rem;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}

.quick-reaction-btn:hover {
  transform: scale(1.2);
  background: var(--surface-2);
}

.quick-reaction-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--muted);
}

.quick-reaction-more .ico {
  width: 27px;
  height: 27px;
}

.reaction-emoji-panel {
  position: fixed;
  z-index: 200;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 16px));
  min-width: 0;
  max-height: min(360px, calc(100vh - 16px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.reaction-emoji-panel.hidden {
  display: none;
}

.reaction-emoji-tabs {
  display: flex;
  gap: 0.12rem;
  padding: 0.35rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  flex-shrink: 0;
}

.reaction-emoji-tab {
  border: none;
  background: transparent;
  font-size: 1.725rem;
  line-height: 1;
  padding: 0.3rem 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.55;
  flex-shrink: 0;
}

.reaction-emoji-tab:hover {
  background: var(--surface-2);
  opacity: 0.85;
}

.reaction-emoji-tab.active {
  background: var(--accent-soft);
  opacity: 1;
}

.reaction-emoji-grid-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem;
  flex: 1;
  min-height: 0;
}

.reaction-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.08rem;
  min-width: 0;
  overflow-x: hidden;
}

.reaction-emoji-btn {
  border: none;
  background: transparent;
  font-size: 1.7rem;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 8px;
  cursor: pointer;
  aspect-ratio: 1;
}

.reaction-emoji-btn:hover {
  background: var(--accent-soft);
  transform: scale(1.04);
}

.msg-quote,
.composer-reply-quote {
  margin: 0 0 0.35rem;
  padding: 0.35rem 0.45rem;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-bubble);
  background: color-mix(in srgb, var(--ink) 4%, var(--surface-2));
  font-size: 0.72rem;
  line-height: 1.35;
}

.msg-quote[data-quote-id] {
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.msg-quote[data-quote-id]:hover,
.msg-quote[data-quote-id]:focus-visible {
  border-left-color: color-mix(in srgb, var(--accent) 75%, white);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
  outline: none;
}

.msg-wrap.is-quote-target .msg-bubble {
  animation: quote-target-pulse 1.05s ease-in-out 2;
}

@keyframes quote-target-pulse {
  0%, 100% { box-shadow: none; }
  45% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 38%, transparent); }
}

html.dark .msg-quote,
html.dark .composer-reply-quote {
  background: color-mix(in srgb, var(--ink) 8%, var(--surface-2));
}

.msg-quote.has-media { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
.msg-quote-content { min-width: 0; display: block; flex: 1; }
.msg-quote-media-label { display: block; color: var(--muted); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-quote-thumb { flex: 0 0 auto; width: 3rem; height: 3rem; border-radius: 0.45rem; object-fit: cover; background: var(--surface-2); }

.msg-quote-author,
.composer-reply-author {
  display: block;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.1rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.msg-quote-text,
.composer-reply-text {
  display: block;
  color: var(--muted);
  overflow: hidden;
  margin-bottom: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
}

.msg-quote-lazy {
  display: inline-flex;
  align-items: center;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}

.msg-quote-lazy:hover:not(:disabled) {
  border-style: solid;
}

.msg-quote-lazy.is-loading {
  opacity: 0.65;
  cursor: progress;
}

.composer-reply-inner { flex: 1; min-width: 0; }

.composer-reply-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.2rem;
}

.composer-reply-close {
  flex-shrink: 0;
}

.reaction-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.reaction-grid-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 1.25rem;
  cursor: pointer;
}

.reaction-grid-btn:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.audio-wave.paused span {
  animation-play-state: paused;
  opacity: 0.35;
}

.attach-menu button[data-attach="rapidas"] .ico {
  color: var(--accent);
}

.msg-menu-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: none;
  background: transparent;
  padding: 0.45rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink);
  text-align: left;
}

.msg-menu-item:hover { background: var(--surface-2); }

.msg-menu-item.danger { color: var(--danger); }

.msg-menu-item .ico { flex-shrink: 0; color: var(--muted); }

.msg-info-dl {
  margin: 0;
  font-size: 0.82rem;
}

.msg-info-dl dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  margin-top: 0.5rem;
}

.msg-info-dl dd { margin: 0.15rem 0 0; }

.crm-ads-origem summary {
  cursor: pointer;
  list-style: none;
}
.crm-ads-origem summary::-webkit-details-marker { display: none; }
.crm-ads-summary-head h3 { display: inline; margin: 0; font-size: inherit; }

.attach-preview {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.attach-preview.hidden { display: none; }
.attach-preview-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  margin-bottom: 0.5rem;
}
.attach-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}
.attach-preview-doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.attach-preview-caption-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.attach-preview-caption-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.attach-preview-caption-wrap .attach-preview-caption {
  width: 100%;
  padding-left: 2.55rem;
}
.attach-caption-quick {
  position: absolute;
  left: 0.35rem;
  z-index: 2;
  width: 1.85rem;
  height: 1.85rem;
  color: var(--accent);
}
.attach-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chat-thread.select-mode-active {
  padding-bottom: 5.5rem;
}

.select-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0.85rem 1.35rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 2px solid var(--accent);
  border-radius: 14px;
  font-size: 0.92rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  position: absolute;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  min-width: min(92vw, 420px);
}

.select-bar .btn { font-weight: 600; }
.select-bar #btn-forward {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.select-count { font-weight: 700; color: var(--accent); margin-right: 0.25rem; }

/* Cores do WhatsApp — tokens independentes (--wa-*), não alias de --bubble-out */
html.whatsapp-colors .msg-bubble.out {
  background: var(--wa-out);
  color: var(--wa-out-text);
  border-color: var(--wa-out-border);
}
html.whatsapp-colors .msg-bubble.in {
  background: var(--wa-in);
  color: var(--wa-in-text);
  border-color: var(--wa-in-border);
}

html.whatsapp-colors .msg-bubble.out .msg-text,
html.whatsapp-colors .msg-bubble.out .msg-sender-label {
  color: var(--wa-out-text);
}
html.whatsapp-colors .msg-bubble.in .msg-text,
html.whatsapp-colors .msg-bubble.in .msg-sender-label {
  color: var(--wa-in-text);
}

html.whatsapp-colors .msg-bubble.out .msg-meta,
html.whatsapp-colors .msg-bubble.out .msg-meta time {
  color: var(--wa-out-meta);
}
html.whatsapp-colors .msg-bubble.in .msg-meta,
html.whatsapp-colors .msg-bubble.in .msg-meta time {
  color: var(--wa-in-meta);
}

/* Caudas / cantos no estilo WA (sem depender de !important) */
html.whatsapp-colors .msg-bubble.out {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-bubble);
}
html.whatsapp-colors .msg-bubble.in {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-bubble);
}
html.whatsapp-colors .msg-bubble.out::before,
html.whatsapp-colors .msg-bubble.in::before {
  content: none;
}

/* Áudio / scrubber */
html.whatsapp-colors .msg-bubble .msg-audio-bars-fg .msg-audio-bar,
html.whatsapp-colors .msg-bubble .msg-audio-scrubber {
  background: var(--wa-audio);
}
html.whatsapp-colors .msg-bubble.out .msg-ack.ack-lido {
  color: #28d8ff !important;
}

/* Texturas via Kits — camadas extras (base já definida nos seletores principais) */
.rail-head {
  background-color: var(--surface);
  background-image: var(--topbar-bg-image, none);
  background-size: var(--topbar-bg-size, cover);
  background-position: var(--topbar-bg-position, center);
  background-repeat: var(--topbar-bg-repeat, no-repeat);
}


.msg-wrap .msg-reaction-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  position: relative;
  left: auto;
  bottom: auto;
  transform: translateY(-0.35rem);
  margin-top: -0.2rem;
  margin-left: 0.65rem;
  padding: 0.1rem 0.38rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.82rem;
  cursor: pointer;
  line-height: 1.2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  z-index: 6;
}

.msg-wrap.out .msg-reaction-chip {
  align-self: flex-end;
  margin-left: 0;
  margin-right: 0.65rem;
}

.msg-system {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.55rem 0;
  gap: 0.12rem;
  width: 100%;
}

.msg-system-pill {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  max-width: min(92%, 420px);
  text-align: center;
}

.msg-system-time {
  font-size: 0.62rem;
  color: var(--muted);
  opacity: 0.8;
}

.thread-older-loader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  user-select: none;
}

.thread-older-btn {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.thread-older-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.thread-older-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.thread-older-sentinel {
  width: 100%;
  height: 1px;
  flex-shrink: 0;
  pointer-events: none;
}

.thread-older-loader.is-loading .thread-older-spinner {
  animation: thread-spin 0.8s linear infinite;
}

.thread-older-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
}

@keyframes thread-spin {
  to { transform: rotate(360deg); }
}

.skeleton-msg {
  display: flex;
  width: 100%;
  padding: 0.15rem 0.5rem;
}

.skeleton-msg.out {
  justify-content: flex-end;
}

.skeleton-bubble {
  height: 2.4rem;
  width: min(58%, 200px);
  border-radius: var(--radius-bubble);
}

.conv-skeleton {
  display: flex;
  gap: 0.65rem;
  padding: 0.65rem 0.55rem;
  pointer-events: none;
}

.skeleton-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-line {
  flex: 1;
  height: 2.6rem;
  border-radius: 8px;
}

/* Rail fixo ao lado do thread (mobile) — não rola com as mensagens */
.chat-thread-rail {
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 0;
  width: var(--thread-rail-w);
  min-width: var(--thread-rail-w);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 0.35rem 0.4rem 0.35rem 0.75rem;
  box-sizing: border-box;
  align-items: center;
  gap: 0.35rem;
}

.chat-thread-rail::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.chat-thread-rail .conv-rail-item {
  width: 36px;
  max-width: 36px;
  padding: 0.1rem 0;
}

.chat-thread-rail .conv-rail-item .avatar-sm {
  width: 36px;
  height: 36px;
}

.chat-thread-rail .conv-rail-item .avatar-iniciais {
  font-size: 0.7rem;
}

.chat-thread-rail.hidden {
  display: none;
}

.msg-reaction-chip.is-pending {
  opacity: 0.72;
  transform: scale(0.96);
  transition: opacity 0.15s, transform 0.15s;
}

.msg-inline-react {
  position: absolute;
  left: 50%;
  right: auto;
  top: -2.75rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.12rem;
  padding: 0.22rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 12002;
  isolation: isolate;
  width: max-content;
  max-width: calc(100vw - 2rem);
  pointer-events: auto;
}

.msg-inline-react.hidden { display: none; }

/* Toolbar móvel portalizada no body: não pode ser recortada pelo thread nem
   competir com a rail de avatares em outro contexto de empilhamento. */
.msg-inline-react.crm-msg-react-portal {
  position: fixed !important;
  z-index: 2147483001 !important;
  isolation: isolate;
}

.msg-inline-react-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.225rem 0.3rem;
  min-width: 2rem;
  min-height: 2rem;
  border-radius: 6px;
}

.msg-inline-react-btn:hover {
  background: var(--accent-soft);
}

.msg-wrap .msg-reaction-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
}

.composer-reply {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.thread-day-sep {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0.75rem 0 0.55rem;
  flex-shrink: 0;
}

.thread-day-sep-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 90%, var(--ink) 2%);
  border-radius: 6px;
  padding: 0.25rem 0.75rem;
  box-shadow:
    0 0 1px 1px rgba(0, 0, 0, 0.06),
    0 1px 0 0 rgba(0, 0, 0, 0.05);
  text-transform: capitalize;
}

.msg-wrap:has(.msg-bubble.has-media-img) {
  width: fit-content;
  max-width: min(80%, 560px);
}

.msg-wrap:has(.msg-bubble.has-media-audio) {
  width: min(336px, 80%);
  max-width: 80%;
}

.msg-bubble.has-media-img {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  max-width: min(300px, 82vw);
  padding: 0.35rem 0.45rem 0.28rem;
  box-sizing: border-box;
  overflow: clip;
}

.msg-bubble.has-media-img .msg-media {
  width: auto;
  max-width: min(268px, calc(82vw - 3rem));
  margin: 0 0 0.12rem;
  line-height: 0;
}

.msg-bubble.has-media-img .msg-media a {
  display: block;
  max-width: 100%;
  line-height: 0;
}

.msg-bubble.has-media-img .msg-media-deferred {
  min-height: 120px;
  background: color-mix(in srgb, var(--surface-2, #e8eef0) 80%, transparent);
  border-radius: 6px;
}

.msg-bubble.has-media-img .msg-media-img {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(420px, 70vh);
  border-radius: 6px;
  display: block;
  object-fit: contain;
  vertical-align: bottom;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.msg-bubble.has-media-img .msg-media-img.is-loaded {
  opacity: 1;
}

.msg-bubble.has-media-img .msg-media-img.is-loading {
  opacity: 0;
}

.msg-bubble.has-media-img .msg-text {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding-right: 0.1rem;
}

.msg-bubble.has-media-img .msg-meta {
  float: right;
  margin-top: 0.2rem;
}

.msg-bubble.has-media-audio {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  min-width: 260px;
  min-height: 4.2rem;
  max-width: none;
  padding: 0.35rem calc(0.45rem + 10px) 1.05rem 0.4rem;
  overflow: visible;
  box-sizing: border-box;
}

.msg-bubble.has-media-audio .msg-media {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 100%;
  width: 100%;
  min-height: 2.75rem;
  margin-bottom: 0;
}

.msg-bubble.has-media-audio .msg-meta {
  position: absolute;
  right: calc(0.45rem + 10px);
  bottom: 0.24rem;
  margin: 0;
  float: none;
  top: auto;
  z-index: 2;
  font-size: 0.58rem;
  line-height: 0.85rem;
  gap: 0.1rem;
}

.msg-audio-player {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding-bottom: 0.9rem;
  border: none;
  border-radius: 0;
  background: transparent;
  box-sizing: border-box;
  overflow: hidden;
}

.msg-audio-main {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  align-self: center;
}

.msg-audio-player.is-loading {
  opacity: 0.75;
}

.msg-audio-player.is-loading .msg-audio-wave {
  cursor: progress;
  opacity: 0.65;
}

.msg-audio-player.is-loading .msg-audio-speed {
  opacity: 0.55;
  pointer-events: none;
}

.msg-audio-player.is-error .msg-audio-wave {
  opacity: 0.5;
}

.msg-audio-player audio.msg-audio {
  display: none;
}

.msg-audio-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  justify-content: center;
  padding-bottom: 0.1rem;
}

.msg-audio-wave {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 20px;
  cursor: pointer;
  display: block;
  overflow: hidden;
  touch-action: none;
  box-sizing: border-box;
  isolation: isolate;
  /* Track compartilhada: barras e scrubber usam o mesmo inset */
  --audio-track-inset: 4px;
}

.msg-audio-wave.is-scrubbing {
  cursor: grabbing;
}

.msg-audio-wave:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.msg-audio-bars {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--audio-track-inset, 4px);
  right: var(--audio-track-inset, 4px);
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(var(--audio-bar-count, 1), 3px);
  column-gap: var(--audio-bar-gap, 2px);
  align-items: center;
  justify-content: stretch;
  width: auto;
  height: 100%;
  max-width: none;
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
}

.msg-audio-bar {
  display: block;
  width: 3px;
  min-width: 3px;
  max-width: 3px;
  height: var(--h, 40%);
  min-height: 3px;
  border-radius: 1.5px;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  justify-self: center;
}

.msg-audio-bars-fg .msg-audio-bar {
  background: var(--accent);
}

.msg-audio-bars-fg {
  z-index: 1;
  clip-path: inset(0 100% 0 0);
}

.msg-audio-scrubber {
  position: absolute;
  top: 50%;
  left: var(--audio-track-inset, 4px);
  width: 8px;
  height: 8px;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
  pointer-events: auto;
  z-index: 2;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
}

.msg-audio-scrubber.is-dragging {
  cursor: grabbing;
}

.msg-audio-footer {
  position: absolute;
  left: calc(32px + 0.35rem);
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 0.95rem;
  padding-right: 0;
  flex: 0 0 auto;
}

.msg-audio-dur {
  font-size: 0.6875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.msg-audio-play {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.msg-audio-play .ico,
.msg-audio-play .msg-audio-spinner {
  display: block;
  margin: 0;
  pointer-events: none;
}

.msg-audio-play:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.msg-audio-play:disabled {
  cursor: progress;
}

.msg-audio-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: msg-audio-spin 0.8s linear infinite;
}

.msg-audio-status {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes msg-audio-spin {
  to { transform: rotate(360deg); }
}

.msg-audio-speed {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  padding: 0.05rem 0.25rem;
  font: inherit;
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.85;
}

.msg-audio-speed:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.msg-bubble.has-media:not(.has-media-img):not(.has-media-audio) {
  width: fit-content;
  max-width: min(300px, 92%);
}

.msg-media-lazy {
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.msg-media-lazy:hover:not(:disabled) {
  border-style: solid;
}

.msg-media-lazy.is-loading {
  opacity: 0.65;
  cursor: progress;
}

.msg-media {
  margin-bottom: 0.35rem;
  max-width: min(280px, 100%);
}

.msg-bubble.has-media .msg-media {
  margin-bottom: 0.15rem;
}

.msg-media-img {
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(420px, 70vh);
  border-radius: 8px;
  display: block;
  object-fit: contain;
}

.msg-media audio {
  width: 100%;
  min-width: 200px;
  height: 36px;
}

.msg-media-doc {
  display: inline-block;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.msg-text-muted {
  font-size: 0.8rem;
  opacity: 0.75;
  font-style: italic;
}



.msg-media-unavailable {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-md, 8px);
  background: color-mix(in srgb, var(--muted, #94a3b8) 14%, transparent);
  color: var(--muted, #64748b);
  font-size: var(--fs-sm, 0.82rem);
  font-style: italic;
  border: 1px dashed color-mix(in srgb, var(--line, #cbd5e1) 80%, transparent);
}
.copilot-suggest-wrap .dc-bar-head {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  padding: 0.35rem;
}

.copilot-suggest-wrap .dc-bar-action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, minmax(28px, 1fr));
  gap: 4px;
  width: 100%;
}

.copilot-suggest-wrap .dc-bar-action-grid .dc-icon-btn {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.copilot-suggest-wrap .dc-bar-action-grid .dc-icon-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.copilot-suggest-wrap .dc-bar-inner {
  transform-origin: bottom center;
  transition: opacity 0.22s ease, transform 0.28s ease, max-height 0.28s ease;
  max-height: 220px;
  overflow: hidden;
}

.copilot-suggest-wrap.is-paused {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.copilot-suggest-wrap.is-paused .dc-bar-inner {
  opacity: 0;
  transform: scale(0.92) translateY(12px);
  max-height: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
}

.chat-panel.chat-panel-copilot-host {
  position: relative;
}

.dc-resume-btn {
  position: absolute;
  right: 0.85rem;
  bottom: 5.4rem;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.85rem;
  height: 2.85rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: dc-resume-in 0.28s ease;
}

.dc-resume-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

@keyframes dc-resume-in {
  from { opacity: 0; transform: scale(0.75); }
  to { opacity: 1; transform: scale(1); }
}

@media (max-width: 560px) {
  .copilot-suggest-wrap .dc-bar-head { width: 106px; }
  .copilot-suggest-wrap .dc-bar-action-grid .dc-icon-btn { height: 28px; }
  .dc-resume-btn { bottom: 5.8rem; right: 0.7rem; }
}
