:root {
  --fondo: #0b1220;
  --panel: #111a2e;
  --borde: #22304d;
  --texto: #dbe7ff;
  --tenue: #8fa6c9;
  --acento: #3aa0ff;
  --acento-2: #7fd4ff;
  --yo: #1d4f8f;
  --error: #ff7b7b;
  --ok: #4ade80;
  --sup: env(safe-area-inset-top, 0px);
  --inf: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--acento-2); outline-offset: 2px; }

.vista { min-height: 100%; }
.centrada { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: calc(24px + var(--sup)) 16px calc(24px + var(--inf)); text-align: center; }
.tenue { color: var(--tenue); margin: 0; }
.marca { margin: 0; font-weight: 600; letter-spacing: .3em; }
.marca.pequena { font-size: 1.2rem; letter-spacing: .1em; }
.nucleo { width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, var(--acento-2) 0%, #1f7bd6 45%, var(--fondo) 72%);
  box-shadow: 0 0 40px #1f7bd6aa; animation: latido 3s ease-in-out infinite; }
@keyframes latido { 50% { transform: scale(1.06); box-shadow: 0 0 60px #1f7bd6; } }
@media (prefers-reduced-motion: reduce) { .nucleo { animation: none; } }

.tarjeta { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--borde);
  border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.tarjeta p { margin: 0; line-height: 1.45; }
.boton { width: 100%; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--borde); background: #182544;
  font-weight: 600; }
.boton.principal { background: var(--acento); border-color: var(--acento); color: #04111f; }
.boton.peligro { background: transparent; border-color: #6b2a2a; color: var(--error); margin-top: 8px; }
.enlace { background: none; border: none; color: var(--acento-2); padding: 6px; text-decoration: underline; }
.formulario { display: flex; flex-direction: column; gap: 8px; }
.formulario label { color: var(--tenue); font-size: .9rem; }
input, textarea { font: inherit; font-size: 16px; color: var(--texto); background: #0d1628; border: 1px solid var(--borde);
  border-radius: 10px; padding: 12px; width: 100%; }
.error { color: var(--error); min-height: 1.2em; margin: 0; font-size: .95rem; }

/* Chat */
#vista-chat { display: flex; flex-direction: column; height: 100dvh; }
.cabecera { display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--sup)) 16px 10px; border-bottom: 1px solid var(--borde); background: var(--fondo); }
.titulo { font-weight: 600; letter-spacing: .25em; display: flex; align-items: center; gap: 10px; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.punto.desconectado { background: var(--error); box-shadow: 0 0 8px var(--error); }
.icono { background: none; border: none; font-size: 1.3rem; padding: 6px 8px; color: var(--tenue); }
.mensajes { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; }
.msg { max-width: 85%; padding: 10px 13px; border-radius: 16px; line-height: 1.45; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--yo); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--borde);
  border-bottom-left-radius: 5px; }
.msg.sistema { align-self: center; background: none; color: var(--tenue); font-size: .85rem; }
.msg a { color: var(--acento-2); }
.meta { display: block; margin-top: 4px; font-size: .72rem; color: var(--tenue); }
.msg.user .meta { color: #b8cdee; text-align: right; }
.herramienta { align-self: flex-start; font-size: .85rem; color: var(--tenue); padding: 0 6px; }
.escribiendo::after { content: "▍"; animation: parpadeo 1s steps(1) infinite; }
@keyframes parpadeo { 50% { opacity: 0; } }
.confirmacion { align-self: flex-start; max-width: 85%; background: #1a2440; border: 1px solid #3b5ea8;
  border-radius: 14px; padding: 12px; white-space: pre-wrap; }
.confirmacion .botones { display: flex; gap: 8px; margin-top: 10px; }
.confirmacion .boton { padding: 9px; }
.compositor { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px calc(10px + var(--inf));
  border-top: 1px solid var(--borde); background: var(--fondo); }
.compositor textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.microfono, .enviar { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--borde);
  background: #182544; font-size: 1.15rem; }
.enviar { background: var(--acento); border-color: var(--acento); color: #04111f; }

/* Ajustes */
.panel { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; justify-content: center;
  z-index: 10; }
.hoja { width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto; background: var(--panel);
  border-radius: 18px 18px 0 0; padding: 16px 18px calc(18px + var(--inf)); }
.hoja-cabecera { display: flex; justify-content: space-between; align-items: center; }
.hoja h2 { margin: 0; font-size: 1.15rem; }
.hoja h3 { font-size: .95rem; color: var(--tenue); margin: 18px 0 8px; }
.lista { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lista li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #0d1628;
  border: 1px solid var(--borde); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.lista li small { display: block; color: var(--tenue); }
.lista li button { background: none; border: 1px solid #6b2a2a; color: var(--error); border-radius: 8px;
  padding: 6px 10px; font-size: .85rem; flex: none; }
@media (min-width: 700px) { .panel { align-items: center; } .hoja { border-radius: 18px; } }

/* Modo voz */
.panel-voz { position: fixed; inset: 0; z-index: 20; background: radial-gradient(circle at 50% 40%, #13213d 0%, var(--fondo) 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(56px + var(--sup)) 20px calc(24px + var(--inf)); text-align: center; }
.cerrar-voz { position: absolute; top: calc(10px + var(--sup)); right: 12px; font-size: 1.5rem; }
.voz-estado { margin: 0; letter-spacing: .2em; text-transform: uppercase; color: var(--acento-2); font-size: .9rem; }
.orbe { position: relative; width: 190px; height: 190px; border-radius: 50%; border: none; padding: 0;
  -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent;
  background: radial-gradient(circle, var(--acento-2) 0%, #1f7bd6 48%, #0b1220 74%);
  filter: drop-shadow(0 0 22px #1f7bd6aa); transition: transform .12s ease-out, filter .2s; }
.orbe span { position: absolute; inset: -14px; border-radius: 50%; border: 2px solid #7fd4ff66; opacity: 0;
  transition: transform .08s linear, opacity .2s; }
.orbe.escuchando span { opacity: 1; }
.orbe.pensando { animation: pensar 1.4s ease-in-out infinite; }
.orbe.hablando { filter: drop-shadow(0 0 40px #3aa0ff); }
@keyframes pensar { 50% { filter: hue-rotate(40deg) brightness(1.25); transform: scale(.96); } }
@media (prefers-reduced-motion: reduce) { .orbe.pensando { animation: none; } }
.voz-tu { margin: 0; min-height: 1.4em; font-size: 1.15rem; max-width: 34em; color: #cfe0ff; }
.voz-tu.provisional { color: var(--tenue); font-style: italic; }
.voz-jarvis { min-height: 3em; max-width: 34em; max-height: 30dvh; overflow-y: auto; color: var(--texto);
  line-height: 1.5; white-space: pre-wrap; }
.voz-jarvis .herramienta { display: block; margin-bottom: 6px; }
.voz-pista { font-size: .85rem; max-width: 30em; }
