/* Chat de ayuda: botón flotante abajo a la derecha y panel encima. Usa los colores de la app (claro y oscuro). */
.chat-btn {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.chat-btn:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}
.chat {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: min(380px, calc(100vw - 36px));
  height: min(560px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.chat[hidden] {
  display: none;
}
.chat-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.chat-x {
  background: none;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.chat-x:hover {
  color: var(--ink);
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}
.chat-m {
  max-width: 88%;
  padding: 8px 11px;
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.4;
}
.chat-m.yo {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
}
.chat-m.bot {
  align-self: flex-start;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.chat-m.espera {
  color: var(--muted);
  font-style: italic;
}
.chat-m.error {
  color: var(--bad);
  background: var(--bad-soft);
  border-color: var(--bad);
}
.chat-ir {
  display: block;
  margin-top: 8px;
}
.chat-f {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat-f input {
  flex: 1;
  min-width: 0;
}
@media (max-width: 700px) {
  .chat {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
  }
  body.chat-abierto .chat-btn {
    display: none; /* en el móvil el panel ocupa toda la pantalla; se cierra con la ✕ */
  }
}
