.agente {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 900;
}

.agente__boton {
  position: relative;
  width: 60px; height: 60px; padding: 0;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--acento);
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0,0,0,.5), 0 0 0 0 var(--acento-40);
  transition: transform var(--rapido) var(--suave),
              box-shadow var(--medio) var(--suave);
}
.agente__boton:hover { transform: translateY(-3px) scale(1.04); }
.agente__boton:focus-visible { outline: 2px solid var(--tinta); outline-offset: 4px; }

.agente__boton::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid var(--acento);
  animation: agente-anillo 2.8s var(--suave) infinite;
  pointer-events: none;
}
@keyframes agente-anillo {
  0%   { transform: scale(1);    opacity: .7; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
.agente.abierto .agente__boton::before { animation: none; }

.agente__etq { display: none; }
.agente__icono { font-size: 0; width: 22px; height: 6px; position: relative; }

.agente__icono::before,
.agente__icono::after {
  content: ''; position: absolute; top: 0; left: 0;
  background: var(--sobre-acento, #0A0A0C);
  transition: width var(--medio) var(--elastico),
              height var(--medio) var(--elastico),
              border-radius var(--medio) var(--suave),
              box-shadow var(--rapido) var(--suave),
              transform var(--medio) var(--elastico),
              opacity var(--rapido) var(--suave);
}

.agente__icono::before {
  width: 6px; height: 6px; border-radius: 50%;
  box-shadow: 8px 0 0 var(--sobre-acento, #0A0A0C), 16px 0 0 var(--sobre-acento, #0A0A0C);
}
.agente__icono::after { width: 6px; height: 6px; border-radius: 50%; opacity: 0; }

.agente.abierto .agente__icono::before {
  width: 20px; height: 2px; border-radius: 2px; box-shadow: none;
  transform: translate(1px, 2px) rotate(45deg);
}
.agente.abierto .agente__icono::after {
  width: 20px; height: 2px; border-radius: 2px; opacity: 1;
  transform: translate(1px, 2px) rotate(-45deg);
}

@media (pointer: fine) {
  .agente__boton::after {
    content: 'Pregúntame';
    position: absolute; right: calc(100% + .7rem); top: 50%;
    transform: translateY(-50%) translateX(6px);
    white-space: nowrap; padding: .45rem .8rem; border-radius: var(--radio-pill);
    background: var(--fondo-alto); color: var(--tinta);
    border: 1px solid var(--cristal-borde);
    font-family: var(--tipo-texto); font-size: var(--texto-s); font-weight: 500;
    opacity: 0; pointer-events: none;
    transition: opacity var(--rapido) var(--suave), transform var(--rapido) var(--suave);
  }
  .agente__boton:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
  .agente.abierto .agente__boton::after { display: none; }
}

.agente__panel {
  position: absolute; right: 0; bottom: calc(60px + .9rem);
  width: min(370px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  display: flex; flex-direction: column;
  transform-origin: bottom right;
  animation: agente-brota .42s var(--suave);
}

.agente__panel[hidden] { display: none; }

@keyframes agente-brota {
  from { opacity: 0; transform: scale(.28) translate(18px, 26px); }
  to   { opacity: 1; transform: scale(1) translate(0, 0); }
}

.agente__cab {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--linea-tenue);
}
.agente__cab b { display: block; font-family: var(--tipo-display); font-size: .95rem; color: var(--tinta); }
.agente__cab small { font-family: var(--tipo-mono); font-size: .64rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--acento-texto); }
.agente__cerrar { background: none; border: none; color: var(--tinta-tenue); font-size: 1rem;
  cursor: pointer; padding: .3rem; }
.agente__cerrar:hover { color: var(--tinta); }

.agente__mensajes { flex: 1; overflow-y: auto; padding: 1.1rem 1.2rem;
  display: flex; flex-direction: column; gap: .9rem; }

.agente__msg {
  max-width: 88%;
  transform-origin: bottom right;
  animation: agente-sale .42s var(--elastico) backwards;
}

@keyframes agente-sale {
  from { opacity: 0; transform: scale(.6) translate(26px, 20px); }
  to   { opacity: 1; transform: scale(1) translate(0, 0); }
}

.agente__msg p {
  padding: .7rem .95rem; border-radius: 16px;
  font-size: .88rem; line-height: 1.55; margin: 0;
}
.agente__msg a { color: var(--acento-texto); text-decoration: underline; }
.agente__msg--agente { align-self: flex-start; }
.agente__msg--agente p { background: rgba(255,255,255,.06); color: var(--tinta-suave);
  border-bottom-left-radius: 5px; }
.agente__msg--yo { align-self: flex-end; }
.agente__msg--yo p { background: var(--acento); color: var(--sobre-acento, #0A0A0C);
  font-weight: 500; border-bottom-right-radius: 5px; }

.agente__sugerencias { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.agente__sug {
  padding: .4rem .8rem; border-radius: var(--radio-pill);
  border: 1px solid var(--cristal-borde); background: rgba(255,255,255,.04);
  color: var(--tinta-suave); font-family: var(--tipo-texto); font-size: .78rem; cursor: pointer;
  transition: background var(--rapido) var(--suave), color var(--rapido) var(--suave),
              border-color var(--rapido) var(--suave);
}
.agente__sug:hover { background: var(--acento-15); border-color: var(--acento-40); color: var(--tinta); }

.agente__puntos { display: inline-flex; gap: 4px; }
.agente__puntos i { width: 6px; height: 6px; border-radius: 50%; background: var(--tinta-tenue);
  animation: agente-late 1.2s ease-in-out infinite; }
.agente__puntos i:nth-child(2) { animation-delay: .15s; }
.agente__puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes agente-late { 0%,60%,100% { opacity: .3; } 30% { opacity: 1; } }

.agente__forma { display: flex; gap: .5rem; padding: .9rem 1rem;
  border-top: 1px solid var(--linea-tenue); }
.agente__campo {
  flex: 1; min-height: 44px; padding: .6rem .9rem;
  border-radius: var(--radio-pill); border: 1px solid var(--cristal-borde);
  background: rgba(255,255,255,.04); color: var(--tinta);
  font-family: var(--tipo-texto); font-size: .88rem;
}
.agente__campo::placeholder { color: var(--tinta-tenue); }
.agente__campo:focus { outline: none; border-color: var(--acento); }
.agente__enviar {
  width: 44px; height: 44px; flex: none; border: none; border-radius: 50%;
  background: var(--acento); color: var(--sobre-acento, #0A0A0C);
  font-size: 1.1rem; cursor: pointer;
  transition: transform var(--rapido) var(--suave);
}
.agente__enviar:hover { transform: scale(1.06); }
.agente__enviar:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }

@media (max-width: 520px) {
  .agente { right: 1rem; bottom: 1rem; left: 1rem; }
  .agente__panel { width: 100%; height: min(68vh, 500px); bottom: calc(60px + .8rem); }
}

@media (prefers-reduced-motion: reduce) {
  .agente__panel, .agente__msg { animation: none; }
  .agente__boton::before { animation: none; }
}

.agente__resumen {
  display: block; margin: .7rem 0; padding: .7rem .9rem;
  border-radius: 10px; border-left: 3px solid var(--acento);
  background: rgba(255,255,255,.05);
  font-family: var(--tipo-mono); font-size: .72rem; line-height: 1.6;
  color: var(--tinta-suave);
}
.agente__resumen::before {
  content: attr(data-nivel);
  display: inline-block; margin-bottom: .4rem; padding: .12rem .5rem;
  border-radius: var(--radio-pill); background: var(--acento);
  color: var(--sobre-acento, #0A0A0C); font-weight: 600; font-size: .62rem; letter-spacing: .08em;
}
.agente__resumen[data-nivel="TIBIO"]::before { background: var(--tinta-tenue); color: var(--fondo); }
.agente__resumen[data-nivel="FRÍO"]::before  { background: var(--linea); color: var(--tinta-suave); }
