/* S090-089d — Chat del hub cliente (estilo mensajería pro).
   Se carga DESPUÉS de mc-hub.css: sobrescribe solo el bloque de chat del hub.
   Tokens del tenant: --tenant-primary / --sys-*; sin colores de marca fijos. */

#mc-client-hub-dialog .mc-hub-chat {
  --mc-chat-gutter: max(14px, calc((100% - 880px) / 2));
  --mc-chat-in: var(--sys-surface);
  --mc-chat-out: color-mix(in srgb, var(--tenant-primary) 17%, var(--sys-surface));
  --mc-chat-out-ink: var(--sys-text);
  --mc-chat-meta: color-mix(in srgb, var(--sys-text) 52%, transparent);
  position: relative;
  border-top: 0;
  /* Fondo con textura apenas perceptible (puntos del tono del tenant) */
  background-color: color-mix(in srgb, var(--tenant-primary) 3.5%, var(--sys-surface-2));
  background-image: radial-gradient(color-mix(in srgb, var(--tenant-primary) 9%, transparent) 1px, transparent 1.4px);
  background-size: 22px 22px;
}
.dark #mc-client-hub-dialog .mc-hub-chat,
[data-theme="dark"] #mc-client-hub-dialog .mc-hub-chat {
  --mc-chat-out: color-mix(in srgb, var(--tenant-primary) 30%, var(--sys-surface));
  --mc-chat-meta: color-mix(in srgb, var(--sys-text) 58%, transparent);
}

/* El pane llena el main sin márgenes negativos (dejaban ~48 px muertos bajo el composer). */
#mc-client-hub-dialog .mc-hub-main:has(> [data-mc-hub-pane="chat"].is-active) { padding: 0; }
#mc-client-hub-dialog .mc-hub-pane[data-mc-hub-pane="chat"].is-active {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  margin: 0;
}

/* ——— Barra del hilo: presencia / escribiendo + opciones ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 0 calc(var(--mc-chat-gutter) - 6px) 0 var(--mc-chat-gutter);
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--sys-surface) 94%, transparent);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-presence {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-presence.is-online::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sys-ok, #22a06b);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-presence.is-typing { color: var(--tenant-primary); font-weight: 600; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-wrap { position: relative; flex: 0 0 auto; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more { width: 36px; min-width: 36px; height: 36px; min-height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; box-shadow: none; color: var(--muted); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more:hover,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more[aria-expanded="true"] { color: var(--sys-text); background: color-mix(in srgb, var(--sys-text) 7%, transparent); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more .nav-ico { width: 18px; height: 18px; }
/* Clase propia: closeChatMsgMenu() elimina del DOM todo `.chat-msg-menu`. */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 8;
  min-width: 200px;
  padding: 5px;
  display: grid;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--sys-surface);
  box-shadow: var(--elev-2);
  animation: mc-chat-menu-in 130ms cubic-bezier(0.23, 1, 0.32, 1) both;
  transform-origin: 100% 0;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sys-err);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu button:hover,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu button:focus-visible { background: color-mix(in srgb, var(--sys-text) 7%, transparent); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu[hidden] { display: none; }

/* ——— Escribiendo… (burbuja de tres puntos, como la app) ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing {
  position: absolute;
  left: var(--mc-chat-gutter);
  bottom: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 13px;
  border-radius: 16px 16px 16px 5px;
  background: var(--mc-chat-in);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--sys-text) 10%, transparent);
  animation: mc-chat-pop 170ms cubic-bezier(0.23, 1, 0.32, 1) both;
  transform-origin: 0 100%;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing[hidden] { display: none; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-stage:has(.mc-hub-chat-typing:not([hidden])) .mc-hub-chat-msg-list { padding-bottom: 54px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: mc-chat-typing 1.1s ease-in-out infinite;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing i:nth-child(2) { animation-delay: 0.15s; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mc-chat-typing {
  0%, 60%, 100% { opacity: 0.35; transform: none; }
  30% { opacity: 1; transform: translateY(-2px); }
}

#mc-client-hub-dialog .mc-hub-chat-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

/* ——— Lista ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-msg-list {
  flex: 1 1 auto;
  gap: 2px;
  padding: 14px var(--mc-chat-gutter) 12px;
  overscroll-behavior: contain;
  scroll-padding-bottom: 12px;
  scrollbar-gutter: stable;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-run-start { margin-top: 9px !important; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item:first-child { margin-top: 0 !important; }

/* ——— Burbujas ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: min(70%, 540px);
  min-width: 76px;
  padding: 7px 11px 5px;
  border: 0;
  border-radius: 16px;
  background: var(--mc-chat-in);
  color: var(--sys-text);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--sys-text) 8%, transparent), 0 1px 3px color-mix(in srgb, var(--sys-text) 6%, transparent);
}
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-mine {
  margin-left: auto;
  background: var(--mc-chat-out);
  color: var(--mc-chat-out-ink);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-run-start:not(.is-mine) .chat-bubble { border-top-left-radius: 5px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-run-start.is-mine .chat-bubble { border-top-right-radius: 5px; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble-body {
  order: 1;
  font-size: 0.9rem;
  line-height: 1.44;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  /* hueco para la hora cuando el texto es corto: queda en la misma línea */
  padding-right: 4px;
}

/* Hora + estado: abajo a la derecha, dentro de la burbuja */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble-meta {
  order: 2;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 1px 0 0;
  padding: 0;
  font-size: 0.68rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--mc-chat-meta);
}
#mc-client-hub-dialog .mc-hub-chat .chat-bubble-meta > span:not(.chat-read-receipt) { display: none; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble-meta time { color: inherit; }
#mc-client-hub-dialog .mc-hub-chat .chat-read-receipt {
  display: inline-flex;
  align-items: center;
  letter-spacing: 0;
  color: var(--mc-chat-meta);
}
#mc-client-hub-dialog .mc-hub-chat .chat-read-receipt.is-read { color: color-mix(in srgb, var(--tenant-primary) 86%, var(--sys-text)); }
.dark #mc-client-hub-dialog .mc-hub-chat .chat-read-receipt.is-read,
[data-theme="dark"] #mc-client-hub-dialog .mc-hub-chat .chat-read-receipt.is-read { color: color-mix(in srgb, var(--tenant-primary) 70%, #fff); }
#mc-client-hub-dialog .mc-hub-chat .mc-chat-tick {
  width: 16px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#mc-client-hub-dialog .mc-hub-chat .chat-read-receipt.is-sending .mc-chat-tick { width: 12px; height: 12px; }

/* Mensaje en vuelo */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-pending .chat-bubble { opacity: 0.82; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-upload .chat-bubble-body { color: var(--muted); font-size: 0.84rem; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-pending { animation: mc-chat-pop 170ms cubic-bezier(0.23, 1, 0.32, 1) both; transform-origin: 100% 100%; }
@keyframes mc-chat-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* Mensaje borrado / sistema */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-deleted {
  background: color-mix(in srgb, var(--mc-chat-in) 70%, transparent);
  box-shadow: none;
  border: 1px dashed var(--hairline);
}
#mc-client-hub-dialog .mc-hub-chat .chat-msg-deleted { color: var(--muted); font-style: italic; font-size: 0.84rem; }
#mc-client-hub-dialog .mc-hub-chat .chat-msg-system span {
  background: color-mix(in srgb, var(--sys-surface) 88%, transparent);
  border: 1px solid var(--hairline);
}

/* ——— Respuesta citada ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-reply-quote {
  border: 0 !important;
  border-left: 3px solid var(--tenant-primary) !important;
  margin: 0 0 5px !important;
  padding: 4px 8px !important;
  border-radius: 7px;
  background: color-mix(in srgb, var(--sys-text) 6%, transparent);
  font-size: 0.8rem !important;
  line-height: 1.3;
  opacity: 1 !important;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
#mc-client-hub-dialog .mc-hub-chat .chat-reply-quote strong { color: var(--tenant-primary); font-weight: 650; }

/* ——— Menú del mensaje (chevron al pasar el cursor; visible en táctil) ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 26px;
  height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, transparent, color-mix(in srgb, var(--mc-chat-in) 94%, transparent) 38%);
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 140ms ease;
}
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-mine .chat-msg-menu-btn {
  background: linear-gradient(135deg, transparent, color-mix(in srgb, var(--mc-chat-out) 96%, transparent) 38%);
}
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu-btn .nav-ico { width: 18px; height: 18px; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble:hover .chat-msg-menu-btn,
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu-btn:focus-visible,
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu-btn[aria-expanded="true"] { opacity: 1; }
@media (hover: none) {
  #mc-client-hub-dialog .mc-hub-chat .chat-msg-menu-btn { opacity: 0.7; width: 32px; height: 32px; }
}
#mc-client-hub-dialog .mc-hub-chat .chat-bubble-meta { position: static; }
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu {
  position: absolute;
  top: 28px;
  right: 2px;
  bottom: auto;
  z-index: 6;
  min-width: 176px;
  padding: 5px;
  display: grid;
  gap: 1px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--sys-surface);
  box-shadow: var(--elev-2);
  animation: mc-chat-menu-in 130ms cubic-bezier(0.23, 1, 0.32, 1) both;
  transform-origin: 100% 0;
}
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu.is-up {
  top: auto;
  bottom: 28px;
  transform-origin: 100% 100%;
}
@keyframes mc-chat-menu-in {
  from { opacity: 0; transform: scale(0.96) translateY(-3px); }
  to { opacity: 1; transform: none; }
}
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sys-text);
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu button:hover,
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu button:focus-visible { background: color-mix(in srgb, var(--sys-text) 7%, transparent); }
#mc-client-hub-dialog .mc-hub-chat .chat-msg-menu button.danger { color: var(--sys-err); }

/* ——— Foto / video ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media { padding: 3px 3px 4px; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media .chat-bubble-body { padding-right: 0; }
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble { gap: 0; position: relative; }
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble > span { display: none; }
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble img,
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble video {
  display: block;
  width: min(340px, calc(100vw - 150px));
  max-width: 100%;
  height: auto;
  max-height: 340px;
  min-height: 90px;
  margin: 0;
  border-radius: 13px;
  object-fit: cover;
  background: color-mix(in srgb, var(--sys-text) 8%, transparent);
}
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble img { cursor: zoom-in; }
#mc-client-hub-dialog .mc-hub-chat .chat-media-bubble img:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }
/* Hora sobre la foto (sin pie vacío) */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media .chat-bubble-meta {
  position: absolute;
  z-index: 2;
  right: 9px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(14, 18, 16, 0.58);
  color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media .chat-read-receipt,
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media .chat-read-receipt.is-read { color: rgba(255, 255, 255, 0.94); }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media .chat-msg-menu-btn { top: 9px; right: 9px; z-index: 3; color: #fff; background: rgba(14, 18, 16, 0.5); border-radius: 999px; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media > .chat-msg-menu { top: 40px; right: 6px; }
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-media:has(.chat-reply-quote) .chat-reply-quote { margin: 4px 4px 5px !important; }

/* ——— Archivo ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-file-bubble a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 12px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--sys-text) 6%, transparent);
  color: var(--sys-text);
  font-size: 0.86rem;
  font-weight: 560;
  text-decoration: none;
  overflow-wrap: anywhere;
}
#mc-client-hub-dialog .mc-hub-chat .chat-file-bubble a:hover { background: color-mix(in srgb, var(--tenant-primary) 12%, transparent); }
#mc-client-hub-dialog .mc-hub-chat .chat-file-bubble a:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }

/* ——— Nota de voz ——— */
#mc-client-hub-dialog .mc-hub-chat .chat-bubble.is-audio { min-width: min(268px, 100%); }
#mc-client-hub-dialog .mc-hub-chat .chat-audio-bubble > span { font-size: 0.76rem; color: var(--muted); }
#mc-client-hub-dialog .mc-hub-chat .chat-audio-bubble audio:not([hidden]) { width: min(260px, 100%); height: 38px; }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-ui {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--tenant-primary);
  color: var(--on-primary, #fff);
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio-btn:active { transform: scale(0.94); }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-btn:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-btn svg { width: 20px; height: 20px; }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-body { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 26px;
  cursor: pointer;
  touch-action: none;
  border-radius: 6px;
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio-wave:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-wave i {
  flex: 1 1 0;
  min-width: 2px;
  max-width: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--sys-text) 24%, transparent);
  transition: background-color 120ms linear;
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio-wave i.on { background: var(--tenant-primary); }
#mc-client-hub-dialog .mc-hub-chat .mc-audio-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--mc-chat-meta);
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio-rate {
  min-width: 34px;
  height: 20px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sys-text) 9%, transparent);
  color: inherit;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
#mc-client-hub-dialog .mc-hub-chat .mc-audio.is-error .mc-audio-btn { opacity: 0.4; cursor: not-allowed; }

/* ——— Separador de día ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-day { margin: 14px 0 6px !important; top: 6px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-day span {
  padding: 4px 12px;
  border: 0;
  background: color-mix(in srgb, var(--sys-surface) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--sys-text) 8%, transparent);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}

/* ——— Vacío / carga ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-empty {
  padding: 28px 24px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--sys-surface) 86%, transparent);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--sys-text) 7%, transparent);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-empty .nav-ico { width: 30px; height: 30px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-skel {
  display: grid;
  gap: 8px;
  padding: 6px 0;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-skel .mc-hub-skel {
  display: block;
  height: 38px;
  width: min(56%, 360px);
  border-radius: 16px;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-skel .mc-hub-skel.is-mine { margin-left: auto; width: min(44%, 300px); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-skel .mc-hub-skel.is-short { width: min(30%, 190px); }

/* ——— Ir al último mensaje ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump {
  position: absolute;
  right: calc(var(--mc-chat-gutter) - 4px);
  bottom: 12px;
  z-index: 4;
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--sys-surface);
  color: var(--sys-text);
  box-shadow: var(--elev-2);
  cursor: pointer;
  animation: mc-chat-menu-in 150ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump[hidden] { display: none; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump .nav-ico { width: 22px; height: 22px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump:active { transform: scale(0.94); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump-n {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--tenant-primary);
  color: var(--on-primary, #fff);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump-n[hidden] { display: none; }

/* ——— Responder (barra sobre el composer) ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-reply {
  margin: 0 var(--mc-chat-gutter);
  padding: 8px 6px 8px 12px;
  border: 0;
  border-left: 3px solid var(--tenant-primary);
  border-radius: 12px 12px 0 0;
  background: var(--sys-surface);
  box-shadow: 0 -1px 3px color-mix(in srgb, var(--sys-text) 6%, transparent);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-reply .ghost { min-width: 36px; min-height: 36px; }

/* ——— Composer ——— */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.chat-composer--rich {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto;
  align-items: end;
  gap: 8px;
  padding: 10px var(--mc-chat-gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--sys-surface) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-wrap { grid-column: 1; grid-row: 1; height: 44px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer textarea {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  min-height: 44px;
  height: auto;
  max-height: 132px;
  margin: 0;
  padding: 11px 50px 11px 16px;
  border: 1px solid var(--hairline);
  border-radius: 22px;
  background: var(--sys-surface-2);
  color: var(--sys-text);
  font-size: 0.92rem;
  line-height: 1.3;
  resize: none;
  box-sizing: border-box;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer textarea::placeholder { color: var(--muted); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer textarea:focus {
  outline: 0;
  border-color: color-mix(in srgb, var(--tenant-primary) 60%, var(--hairline));
  background: var(--sys-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tenant-primary) 16%, transparent);
}
/* Cámara dentro del campo, a la derecha */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-camera-btn {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: end;
  z-index: 1;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0 2px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-camera-btn:hover { color: var(--sys-text); background: transparent; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-mic-btn,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  border-radius: 50%;
  flex: 0 0 44px;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-mic-btn {
  border: 0;
  background: color-mix(in srgb, var(--sys-text) 7%, transparent);
  color: var(--sys-text);
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn:hover,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-mic-btn:hover { background: color-mix(in srgb, var(--tenant-primary) 14%, transparent); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--tenant-primary) 18%, transparent); color: var(--tenant-primary); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn .nav-ico { transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn[aria-expanded="true"] .nav-ico { transform: rotate(45deg); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-mic-btn,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn { grid-column: 3; grid-row: 1; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn {
  border: 0;
  background: var(--tenant-primary);
  color: var(--on-primary, #fff);
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--tenant-primary) 70%, transparent);
  transition: transform 130ms ease, opacity 130ms ease;
}
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn:active { transform: scale(0.93); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn:disabled { opacity: 0.45; box-shadow: none; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.has-text .chat-send-btn { animation: mc-chat-pop 150ms cubic-bezier(0.23, 1, 0.32, 1) both; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn .nav-ico { width: 20px; height: 20px; }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-attach-btn:focus-visible,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-mic-btn:focus-visible,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-camera-btn:focus-visible,
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer .chat-send-btn:focus-visible { outline: 2px solid var(--tenant-primary); outline-offset: 2px; }

/* Menú adjuntar */
#mc-client-hub-dialog .mc-hub-chat .chat-attach-menu {
  left: 0;
  bottom: calc(100% + 10px);
  min-width: 212px;
  padding: 5px;
  border-radius: 14px;
  background: var(--sys-surface);
  box-shadow: var(--elev-2);
  transform-origin: 0 100%;
  animation: mc-chat-menu-in 140ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
#mc-client-hub-dialog .mc-hub-chat .chat-attach-menu[hidden] { display: none; }
#mc-client-hub-dialog .mc-hub-chat .chat-attach-item { min-height: 44px; border-radius: 9px; }

/* Grabando: barra completa */
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.is-recording { grid-template-columns: minmax(0, 1fr); }
#mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.is-recording .chat-rec-ui {
  grid-column: 1;
  grid-row: 1;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 6px;
  border-radius: 22px;
  background: var(--sys-surface-2);
}
#mc-client-hub-dialog .mc-hub-chat .chat-rec-ui .icon-btn { min-width: 44px; min-height: 44px; border-radius: 50%; }
#mc-client-hub-dialog .mc-hub-chat .chat-rec-ui .chat-rec-wave { flex: 1 1 auto; min-width: 0; height: 32px; }

/* ——— Visor de foto (dentro del dialog: top-layer) ——— */
.mc-hub-lightbox {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
  padding: 8px 16px 20px;
  background: rgba(8, 12, 10, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: mc-lightbox-in 180ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes mc-lightbox-in { from { opacity: 0; } to { opacity: 1; } }
.mc-hub-lightbox-bar {
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.mc-hub-lightbox-bar .mc-hub-lightbox-dl {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  font-size: 0.84rem;
  text-decoration: none;
  background: transparent;
}
.mc-hub-lightbox-bar .mc-hub-lightbox-close {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.mc-hub-lightbox-bar a:focus-visible,
.mc-hub-lightbox-bar button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Sin upscale: una foto pequeña se ve a su tamaño real, no pixelada a pantalla completa. */
.mc-hub-lightbox .mc-hub-lightbox-img {
  width: auto;
  height: auto;
  max-width: min(100%, 1100px);
  max-height: 100%;
  min-height: 0;
  align-self: center;
  object-fit: contain;
  border-radius: 10px;
}

/* ——— Celular ——— */
@media (max-width: 760px) {
  #mc-client-hub-dialog .mc-hub-chat { --mc-chat-gutter: 12px; }
  #mc-client-hub-dialog .mc-hub-chat .chat-bubble { max-width: 86%; }
  #mc-client-hub-dialog .mc-hub-chat .chat-bubble-body { font-size: 0.94rem; }
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer textarea { font-size: 16px; } /* evita el zoom de iOS */
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.chat-composer--rich { padding-top: 8px; gap: 6px; }
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump { right: 12px; }
  #mc-client-hub-dialog .mc-hub-chat .chat-media-bubble img,
  #mc-client-hub-dialog .mc-hub-chat .chat-media-bubble video { width: min(340px, calc(100vw - 96px)); max-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-item.is-pending,
  #mc-client-hub-dialog .mc-hub-chat .chat-msg-menu,
  #mc-client-hub-dialog .mc-hub-chat .chat-attach-menu,
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-jump,
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing,
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-typing i,
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-more-menu,
  #mc-client-hub-dialog .mc-hub-chat .mc-hub-chat-composer.has-text .chat-send-btn,
  .mc-hub-lightbox { animation: none; }
  #mc-client-hub-dialog .mc-hub-chat .chat-attach-btn .nav-ico,
  #mc-client-hub-dialog .mc-hub-chat .mc-audio-wave i { transition: none; }
}
