/* Jarvis — estilos
   HUD oscuro, cian y azul. Primero el celular (iPhone), luego escritorio.
   Sin fuentes externas: usamos las del sistema (SF Pro / SF Mono en Apple). */

:root {
  --fondo: #02070d;
  --fondo-2: #051422;
  --panel: rgba(5, 22, 36, 0.72);
  --cian: #62e6ff;
  --cian-2: #19c8ff;
  --azul: #1c6dff;
  --hielo: #e4f9ff;
  --tenue: #8db3c6;
  --linea: rgba(98, 230, 255, 0.18);
  --linea-fuerte: rgba(98, 230, 255, 0.48);
  --ambar: #ffc15e;
  --rojo: #ff6b7d;
  --sans: system-ui, -apple-system, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --suave: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  height: 100%;
  background: var(--fondo);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--fondo);
  color: var(--hielo);
  font: 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--cian); outline-offset: 3px; }

.oculto {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* ---------- Fondo: brillo central, rejilla y líneas de escaneo ---------- */
.fondo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 42% at 50% 34%, rgba(20, 118, 190, 0.30), transparent 70%),
    radial-gradient(90% 50% at 50% 118%, rgba(28, 109, 255, 0.22), transparent 70%),
    linear-gradient(180deg, #03101b 0%, var(--fondo) 55%, #01040a 100%);
}
.fondo::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(98, 230, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 230, 255, 0.06) 1px, transparent 1px);
  background-size: 34px 34px;
  background-position: center center;
  -webkit-mask-image: radial-gradient(70% 55% at 50% 38%, #000 10%, transparent 80%);
  mask-image: radial-gradient(70% 55% at 50% 38%, #000 10%, transparent 80%);
}
.fondo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 4px);
}

/* Esquinas del HUD */
.marco {
  position: fixed;
  z-index: 1;
  pointer-events: none;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  right: calc(env(safe-area-inset-right, 0px) + 6px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
  left: calc(env(safe-area-inset-left, 0px) + 6px);
}
.marco i {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 0 solid var(--linea-fuerte);
  opacity: 0.55;
}
.marco i:nth-child(1) { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.marco i:nth-child(2) { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.marco i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.marco i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }

/* ---------- Estructura de la app ---------- */
.app {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
  animation: encender 0.7s var(--suave) both;
}

.barra {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 8px 14px 4px 20px;
}
.marca { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.marca-nombre {
  font-size: 15px;
  font-weight: 300;
  letter-spacing: 0.46em;
  color: var(--hielo);
  text-shadow: 0 0 14px rgba(98, 230, 255, 0.55);
}
.marca-estado {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tenue);
}
.punto {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ambar);
  box-shadow: 0 0 8px var(--ambar);
  animation: titilar 1.4s ease-in-out infinite;
}
.marca-estado[data-conexion="en-linea"] .punto { background: var(--cian); box-shadow: 0 0 10px var(--cian); animation: none; }
.marca-estado[data-conexion="en-linea"] { color: var(--cian); }
.marca-estado[data-conexion="caida"] .punto { background: var(--rojo); box-shadow: 0 0 10px var(--rojo); }
.marca-estado[data-conexion="caida"] { color: #ffb3bd; }

.barra-botones { display: flex; gap: 8px; }

/* Botón con icono (mínimo 48 px para el dedo) */
.btn-icono {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--linea);
  border-radius: 14px;
  background: rgba(6, 26, 42, 0.62);
  color: var(--cian);
  box-shadow: inset 0 0 14px rgba(98, 230, 255, 0.06);
  transition: border-color 0.2s, background 0.2s, transform 0.15s, color 0.2s;
  touch-action: manipulation;
}
.btn-icono:active { transform: scale(0.94); }
.btn-icono:disabled { opacity: 0.35; }
@media (hover: hover) {
  .btn-icono:not(:disabled):hover { border-color: var(--linea-fuerte); background: rgba(12, 46, 70, 0.7); }
}

.centro {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Zona del reactor ---------- */
.zona-reactor {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 16px 8px;
}
body.vacio .zona-reactor { flex: 1; justify-content: center; }

/* Mira: dos líneas finas que salen del reactor (adorno) */
.mira {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--linea) 18%, transparent 38%, transparent 62%, var(--linea) 82%, transparent);
  opacity: 0;
  transition: opacity 0.5s;
}
body.vacio .mira { opacity: 1; top: calc(50% - 44px); }

.reactor {
  --tam: min(40vw, 23dvh, 210px);
  position: relative;
  flex: none;
  width: var(--tam);
  height: var(--tam);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--cian);
  touch-action: manipulation;
  transition: width 0.6s var(--suave), height 0.6s var(--suave), color 0.4s, transform 0.15s;
}
body.vacio .reactor { --tam: min(76vw, 44dvh, 400px); }
.reactor:active { transform: scale(0.97); }
.reactor:focus-visible { outline-offset: 6px; }

.reactor-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 7px rgba(98, 230, 255, 0.5));
}

/* Todas las piezas giran sobre su propio centro */
.r-gira, .r-nucleo, .entra { transform-box: fill-box; transform-origin: 50% 50%; }
.r-marcas { animation: girar 90s linear infinite; }
.r-segmentos { animation: girar 34s linear infinite reverse; }
.r-escaner { animation: girar 9s linear infinite; }
.r-bobinas { animation: girar 70s linear infinite; }
.r-nucleo { animation: respirar 4.2s ease-in-out infinite; }
.r-halo { opacity: 0.8; transition: opacity 0.5s; }
.r-escaner-arco { transition: stroke 0.4s; }

/* Entrada al cargar: cada anillo aparece con un pequeño retraso */
.entra { animation: aparecer-anillo 0.9s var(--suave) both; }
.e1 { animation-delay: 0.05s; }
.e2 { animation-delay: 0.15s; }
.e3 { animation-delay: 0.25s; }
.e4 { animation-delay: 0.35s; }
.e5 { animation-delay: 0.45s; }

/* Barras de voz alrededor del núcleo */
.r-barras rect {
  fill: currentColor;
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: scaleY(0.18);
  opacity: 0.22;
  transition: opacity 0.35s;
}
.r-barras g:nth-child(8n+1) rect { animation-delay: -0.05s; }
.r-barras g:nth-child(8n+2) rect { animation-delay: -0.42s; }
.r-barras g:nth-child(8n+3) rect { animation-delay: -0.19s; }
.r-barras g:nth-child(8n+4) rect { animation-delay: -0.66s; }
.r-barras g:nth-child(8n+5) rect { animation-delay: -0.31s; }
.r-barras g:nth-child(8n+6) rect { animation-delay: -0.08s; }
.r-barras g:nth-child(8n+7) rect { animation-delay: -0.53s; }
.r-barras g:nth-child(8n+8) rect { animation-delay: -0.24s; }

/* Ondas para "escuchando" */
.onda {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 2px solid currentColor;
  box-shadow: 0 0 22px rgba(98, 230, 255, 0.35), inset 0 0 22px rgba(98, 230, 255, 0.2);
  opacity: 0;
  pointer-events: none;
}

/* ----- Estados del reactor ----- */
body[data-estado="escuchando"] .reactor { color: #9ef1ff; }
body[data-estado="escuchando"] .onda { animation: onda 2.1s cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
body[data-estado="escuchando"] .onda:nth-child(2) { animation-delay: 0.7s; }
body[data-estado="escuchando"] .onda:nth-child(3) { animation-delay: 1.4s; }
body[data-estado="escuchando"] .r-nucleo { animation-duration: 1.5s; }
body[data-estado="escuchando"] .r-marcas { animation-duration: 24s; }
body[data-estado="escuchando"] .r-halo { opacity: 1; }
body[data-estado="escuchando"] .r-barras rect { opacity: 0.55; animation: escucha 1.6s ease-in-out infinite; }

body[data-estado="pensando"] .r-segmentos { animation-duration: 1.7s; }
body[data-estado="pensando"] .r-escaner { animation-duration: 0.8s; }
body[data-estado="pensando"] .r-bobinas { animation-duration: 6s; }
body[data-estado="pensando"] .r-marcas { animation-duration: 14s; }
body[data-estado="pensando"] .r-nucleo { animation: parpadeo 1.1s ease-in-out infinite; }
body[data-estado="pensando"] .reactor { color: #7fc8ff; }

body[data-estado="hablando"] .r-barras rect { opacity: 0.95; animation: ecualizador 0.62s ease-in-out infinite alternate; }
body[data-estado="hablando"] .r-barras g:nth-child(3n) rect { animation-duration: 0.47s; }
body[data-estado="hablando"] .r-barras g:nth-child(3n+1) rect { animation-duration: 0.81s; }
body[data-estado="hablando"] .r-nucleo { animation: latido 0.46s ease-in-out infinite alternate; }
body[data-estado="hablando"] .r-halo { opacity: 1; }
body[data-estado="hablando"] .onda { animation: onda-voz 1.3s ease-out infinite; }
body[data-estado="hablando"] .onda:nth-child(2) { animation-delay: 0.43s; }
body[data-estado="hablando"] .onda:nth-child(3) { animation-delay: 0.86s; }

body[data-estado="error"] .reactor { color: var(--rojo); }
body[data-estado="error"] .reactor-svg { filter: drop-shadow(0 0 8px rgba(255, 107, 125, 0.6)); }

/* Trabajando en algo largo: el escáner se pone ámbar y sigue girando */
body.trabajando .r-escaner-arco { stroke: var(--ambar); }
body.trabajando .r-escaner { animation-duration: 2.2s; }

/* Texto debajo del reactor */
.estado {
  margin: 12px 0 0;
  font: 600 12px/1.2 var(--mono);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  text-align: center;
  color: var(--cian);
  text-shadow: 0 0 12px rgba(98, 230, 255, 0.45);
}
body.trabajando[data-estado="reposo"] .estado { color: var(--ambar); text-shadow: 0 0 12px rgba(255, 193, 94, 0.4); }
body[data-estado="error"] .estado { color: var(--rojo); text-shadow: none; }

.oyendo {
  margin: 8px 0 0;
  max-width: 30ch;
  text-align: center;
  font-size: 19px;
  font-weight: 300;
  line-height: 1.3;
  color: var(--hielo);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.oyendo:empty { display: none; }
body.vacio .oyendo { font-size: clamp(22px, 6.6vw, 30px); font-weight: 200; }
.oyendo.aviso { color: var(--ambar); font-size: 17px; font-weight: 500; }

.btn-callar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-top: 10px;
  padding: 0 24px;
  border: 1px solid rgba(255, 107, 125, 0.6);
  border-radius: 999px;
  background: rgba(70, 10, 22, 0.6);
  color: #ffd9de;
  font-weight: 600;
  letter-spacing: 0.04em;
  animation: aparecer 0.25s ease-out both;
  touch-action: manipulation;
}
.btn-callar:active { transform: scale(0.96); }

/* ---------- Conversación ---------- */
.zona-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.vacio .zona-chat { flex: none; }

.chat {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 14px 16px 10px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  mask-image: linear-gradient(180deg, transparent 0, #000 22px);
}
body.vacio .chat { display: none; }

.msg {
  max-width: 86%;
  animation: aparecer 0.35s var(--suave) both;
}
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.msg-yo {
  align-self: flex-end;
  padding: 10px 14px;
  border: 1px solid rgba(98, 230, 255, 0.34);
  border-radius: 18px 18px 5px 18px;
  background: linear-gradient(135deg, rgba(28, 109, 255, 0.34), rgba(25, 200, 255, 0.18));
  color: var(--hielo);
}

.msg-jarvis {
  align-self: flex-start;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--cian);
  font-size: 18px;
  line-height: 1.42;
  color: #f2fcff;
}
.msg-jarvis::before {
  content: "JARVIS";
  display: block;
  margin-bottom: 2px;
  font: 700 10px/1.6 var(--mono);
  letter-spacing: 0.24em;
  color: var(--cian);
  opacity: 0.85;
}

.msg-aviso, .msg-error {
  align-self: center;
  max-width: 92%;
  padding: 8px 14px;
  border-radius: 12px;
  text-align: center;
  font-size: 16px;
}
.msg-aviso { color: var(--ambar); border: 1px dashed rgba(255, 193, 94, 0.45); background: rgba(40, 26, 4, 0.35); }
.msg-error { color: #ffd0d6; border: 1px solid rgba(255, 107, 125, 0.5); background: rgba(60, 8, 18, 0.45); }

.msg-trabajando { color: var(--ambar); border-left-color: var(--ambar); }
.msg-trabajando::before { color: var(--ambar); }
.puntos { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.puntos i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: brinco 1.2s ease-in-out infinite; }
.puntos i:nth-child(2) { animation-delay: 0.15s; }
.puntos i:nth-child(3) { animation-delay: 0.3s; }

.msg-foto {
  display: block;
  width: auto;
  height: auto;
  max-width: min(170px, 100%);
  max-height: 170px;
  margin: 0 0 8px auto;
  border-radius: 12px;
  border: 1px solid var(--linea-fuerte);
}
.msg-etiqueta {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 8px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 999px;
  font: 700 10px/1.6 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cian);
}

/* ---------- Caja para escribir ---------- */
.compositor {
  flex: none;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
}
.fila {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--linea);
  border-radius: 20px;
  background: rgba(3, 16, 27, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.fila:focus-within { border-color: var(--linea-fuerte); box-shadow: 0 0 0 3px rgba(98, 230, 255, 0.08), 0 0 24px rgba(98, 230, 255, 0.12); }
.fila .btn-icono { border-radius: 15px; }

.campo-texto {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 8px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--hielo);
  font-size: 17px;
}
.campo-texto::placeholder { color: rgba(141, 179, 198, 0.75); }

.btn-enviar:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, var(--cian-2), var(--azul));
  color: #001421;
  box-shadow: 0 0 18px rgba(25, 200, 255, 0.45);
}
.btn-camara.con-foto { border-color: var(--linea-fuerte); background: rgba(25, 200, 255, 0.18); }

.adjunto {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 16px;
  background: rgba(6, 30, 48, 0.8);
  animation: aparecer 0.3s var(--suave) both;
}
.adjunto-vista canvas {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 10px;
}
.adjunto-texto { flex: 1; font-size: 16px; color: var(--cian); }
.btn-chico { width: 48px; height: 48px; }

/* ---------- Panel de memoria ---------- */
.panel {
  width: 100%;
  max-width: 100%;
  max-height: min(86dvh, 760px);
  margin: auto 0 0;
  padding: 0;
  border: 1px solid var(--linea-fuerte);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, rgba(6, 26, 42, 0.98), rgba(2, 10, 18, 0.99));
  color: var(--hielo);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.panel[open] { display: flex; animation: subir 0.35s var(--suave) both; }
.panel::backdrop { background: rgba(0, 5, 10, 0.62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.panel-caja {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: inherit;
}
.panel-cabeza {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 4px 22px;
}
.panel h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(98, 230, 255, 0.5);
}
.panel-ayuda { margin: 0; padding: 0 22px 6px; color: var(--tenue); font-size: 15px; }
.panel-cuerpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 16px calc(22px + env(safe-area-inset-bottom, 0px)) 22px;
}
.panel h3 {
  margin: 18px 0 8px;
  font: 700 11px/1.4 var(--mono);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cian);
}
.lista-memoria { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.lista-memoria li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--linea);
  border-radius: 14px;
  background: rgba(8, 30, 48, 0.5);
  animation: aparecer 0.3s var(--suave) both;
}
.lista-memoria p { flex: 1; margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.btn-borrar { color: var(--tenue); }
.btn-icono.btn-borrar.confirmar,
.btn-icono.btn-borrar.confirmar:not(:disabled):hover {
  width: auto;
  padding: 0 14px;
  border-color: rgba(255, 107, 125, 0.7);
  background: rgba(80, 12, 24, 0.65);
  color: #ffd9de;
  font-weight: 700;
  font-size: 15px;
}
.nota-panel { margin: 6px 0; color: var(--tenue); font-size: 15px; }
.nota-panel.error { color: #ffc2ca; }
.btn-texto {
  min-height: 48px;
  margin-top: 8px;
  padding: 0 18px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 14px;
  background: rgba(6, 30, 48, 0.7);
  color: var(--cian);
  font-weight: 600;
}

/* ---------- Panel de misiones ---------- */
/* Mismo cajón que la memoria. Cada misión es una tarjeta con una barrita de color según su estado. */
.panel-acciones { display: flex; gap: 8px; }
.misiones-estado {
  margin: 0;
  padding: 2px 22px 8px;
  color: var(--cian);
  font: 500 13px/1.45 var(--mono);
  letter-spacing: 0.02em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.misiones-estado:empty { display: none; }

.mision {
  --acento: var(--tenue);
  position: relative;
  margin: 12px 0 0;
  padding: 14px 14px 12px 16px;
  border: 1px solid var(--linea);
  border-radius: 16px;
  background: rgba(8, 30, 48, 0.5);
  animation: aparecer 0.3s var(--suave) both;
}
.mision::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 3px;
  background: var(--acento);
  box-shadow: 0 0 10px var(--acento);
}
.mision[data-estado="corriendo"],
.mision[data-estado="revisar"] { --acento: var(--ambar); }
.mision[data-estado="lista"] { --acento: var(--cian); }
.mision[data-estado="faltan_fotos"],
.mision[data-estado="no_encontrado"],
.mision[data-estado="bloqueada"],
.mision[data-estado="fallo"],
.mision[data-estado="interrumpida"] { --acento: var(--rojo); }
.mision[data-estado="corriendo"] { border-color: rgba(255, 193, 94, 0.32); }

.mision-cabeza { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mision-nombres { min-width: 0; }
.panel .mision-negocio {
  margin: 0;
  font: 600 17px/1.3 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  color: var(--hielo);
  overflow-wrap: anywhere;
}
.mision-tipo {
  display: block;
  margin-top: 3px;
  font: 700 10.5px/1.5 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--tenue);
}
.mision-chip {
  flex: none;
  max-width: 50%;
  padding: 3px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--acento);
  font: 700 11px/1.35 var(--mono);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}
.mision-paso {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--acento);
  font: 500 13px/1.45 var(--mono);
}
.mision[data-estado="lista"] .mision-paso,
.mision[data-estado="cancelada"] .mision-paso,
.mision[data-estado="otro"] .mision-paso { color: var(--tenue); }
.mision-latido {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ambar);
  box-shadow: 0 0 8px var(--ambar);
  animation: titilar 1.2s ease-in-out infinite;
}
.mision-razon { margin: 8px 0 0; color: #ffc2ca; font-size: 15px; overflow-wrap: anywhere; }
.mision-resumen { margin: 8px 0 0; color: #f2fcff; font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.mision-nota { margin: 10px 0 0; color: var(--tenue); font-size: 14px; overflow-wrap: anywhere; }

.mision-bloque {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--linea);
  border-radius: 12px;
  background: rgba(4, 18, 30, 0.6);
}
.mision-bloque-titulo {
  margin: 0 0 6px;
  font: 700 11px/1.5 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cian);
}
.mision-importante { border-color: rgba(255, 193, 94, 0.5); background: rgba(40, 26, 4, 0.4); }
.mision-importante .mision-bloque-titulo { color: var(--ambar); }
.mision-problemas { border-color: rgba(255, 107, 125, 0.5); background: rgba(60, 8, 18, 0.4); }
.mision-problemas .mision-bloque-titulo { color: #ffb3bd; }
.mision-problemas .mision-lista li::marker { color: #ffb3bd; }
.mision-lista {
  margin: 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 15px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.mision-lista li::marker { color: var(--acento); }

.mision-plegable { margin-top: 8px; border-top: 1px solid var(--linea); }
.mision-plegable summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--cian);
  font: 600 12px/1.3 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}
.mision-plegable summary::-webkit-details-marker { display: none; }
.mision-plegable summary::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin: 0 2px 0 1px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s;
}
.mision-plegable[open] summary::before { transform: rotate(45deg); }
.mision-plegable > :not(summary) { margin-bottom: 8px; }
.mision-reporte {
  margin: 0;
  max-height: 50dvh;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.45;
}

/* Capturas: portada de escritorio (16:10) y de celular (390x844), a la misma altura */
.mision-capturas { margin-top: 12px; }
.capturas-fila { display: flex; gap: 10px; align-items: flex-start; }
.captura {
  position: relative;
  flex: none;
  height: clamp(120px, 36vw, 190px);
  padding: 0;
  border: 1px solid var(--linea-fuerte);
  border-radius: 10px;
  overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(98, 230, 255, 0.05) 0 6px, transparent 6px 12px),
    rgba(4, 18, 30, 0.9);
  touch-action: manipulation;
  transition: border-color 0.2s, transform 0.15s;
}
.captura:active { transform: scale(0.97); }
.captura-escritorio { aspect-ratio: 16 / 10; }
.captura-movil { aspect-ratio: 390 / 844; }
.captura-img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.captura-vista {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(2, 7, 13, 0.8);
  color: var(--cian);
  font: 700 10px/1.6 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
/* La portada del celular es angosta: su etiqueta va centrada y más apretada */
.captura-movil .captura-vista { left: 3px; right: 3px; padding: 1px 2px; letter-spacing: 0.03em; text-align: center; }
.captura.cargando::after,
.captura.fallo::after {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  font: 600 11px/1.3 var(--mono);
  text-align: center;
  color: var(--tenue);
}
.captura.cargando::after { content: "Cargando…"; animation: titilar 1.2s ease-in-out infinite; }
.captura.fallo::after { content: "No cargó"; color: #ffc2ca; }
.captura-movil.cargando::after { content: "…"; }
.captura-movil.fallo::after { content: "×"; font-size: 16px; }
@media (hover: hover) {
  .captura:hover { border-color: var(--cian); }
}

.mision-borrador { border-color: var(--linea-fuerte); background: rgba(6, 30, 48, 0.6); }
.mision-borrador .mision-bloque-titulo { color: var(--ambar); }
.mision-borrador-texto {
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.45;
}
.mision-zip { margin: 12px 0 0; }
.mision-zip .mision-plegable { margin-top: 2px; border-top: 0; }
.mision-zip-etiqueta {
  margin: 0;
  font: 700 11px/1.5 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--cian);
}
.mision-ruta {
  font: 500 13px/1.4 var(--mono);
  color: var(--hielo);
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}
.btn-ver-capturas { margin-top: 0; }
/* Cancelar: un enlace chico (no un botón rojo grande que tape lo importante); pide dos toques */
.panel .btn-cancelar-mision {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 2px;
  border: 0;
  background: none;
  box-shadow: none;
  color: #ffc2ca;
  font: 600 13px/1.3 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.panel .btn-cancelar-mision.confirmar { color: #ff8595; font-weight: 700; }

/* Punto en el cohete: terminó una misión y todavía no abre el panel */
#btn-misiones { position: relative; }
#btn-misiones.con-novedad::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ambar);
  box-shadow: 0 0 8px var(--ambar);
}
.btn-texto:disabled { opacity: 0.5; }

/* Visor de una captura completa: tapa el panel; la imagen se desplaza (y se acerca al tocarla) */
.visor {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #04121e, #02080e);
  animation: aparecer 0.25s var(--suave) both;
}
.visor-cabeza {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 4px 22px;
}
.visor-titulo {
  margin: 0;
  min-width: 0;
  font: 600 12px/1.4 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cian);
  overflow-wrap: anywhere;
}
.visor-nota { margin: 0; padding: 0 22px 8px; color: var(--tenue); font-size: 14px; }
.visor-cuerpo {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
}
.visor-img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--linea);
  border-radius: 10px;
  cursor: zoom-in;
}
.visor-cuerpo.zoom .visor-img { width: 250%; max-width: none; cursor: zoom-out; }

/* ---------- Pantalla sin enlace ---------- */
.pantalla-enlace {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 24px);
  text-align: center;
  overflow-y: auto;
  animation: encender 0.7s var(--suave) both;
}
.mini-reactor { position: relative; width: 150px; height: 150px; margin-bottom: 10px; }
.mini-reactor i { position: absolute; border-radius: 50%; }
.mini-reactor i:nth-child(1) { inset: 0; border: 1px solid var(--linea-fuerte); }
.mini-reactor i:nth-child(2) {
  inset: 16px;
  border: 6px dashed rgba(98, 230, 255, 0.35);
  animation: girar 24s linear infinite;
}
.mini-reactor i:nth-child(3) {
  inset: 44px;
  background: radial-gradient(circle, #ffffff 0 16%, #8eefff 36%, rgba(28, 109, 255, 0) 72%);
  animation: respirar 4s ease-in-out infinite;
  opacity: 0.8;
}
.enlace-titulo {
  margin: 0;
  font-size: 30px;
  font-weight: 200;
  letter-spacing: 0.02em;
}
.enlace-msg { margin: 0; max-width: 22ch; font-size: 20px; font-weight: 300; line-height: 1.35; }
.enlace-pegar { width: min(360px, 100%); margin-top: 14px; }
.enlace-pegar summary {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  color: var(--cian);
  cursor: pointer;
  list-style: none;
}
.enlace-pegar summary::-webkit-details-marker { display: none; }
.form-enlace { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.form-enlace input {
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 14px;
  background: rgba(4, 18, 30, 0.85);
  color: var(--hielo);
  font-size: 16px;
  outline: none;
}
.form-enlace input:focus { box-shadow: 0 0 0 3px rgba(98, 230, 255, 0.15); }
.btn-principal {
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cian-2), var(--azul));
  color: #001421;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 0 22px rgba(25, 200, 255, 0.4);
}
.enlace-error { margin: 0; color: #ffc2ca; font-size: 15px; }

/* ---------- Pantallas grandes (compu / iPad acostado) ---------- */
@media (min-width: 900px) and (min-height: 560px) {
  .barra { padding: 14px 28px 6px 32px; }
  .centro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 470px);
    grid-template-rows: minmax(0, 1fr);
    gap: 0 32px;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 28px 24px;
  }
  .zona-reactor, body.vacio .zona-reactor { justify-content: center; }
  .reactor, body.vacio .reactor { --tam: min(40vw, 58dvh, 500px); }
  .mira, body.vacio .mira { opacity: 1; top: calc(50% - 50px); }
  .zona-chat, body.vacio .zona-chat {
    min-height: 0;
    border: 1px solid var(--linea);
    border-radius: 22px;
    background: var(--panel);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    overflow: hidden;
  }
  body.vacio .chat { display: flex; }
  .chat:empty::before {
    content: "Aquí aparece la conversación.";
    margin: auto;
    color: var(--tenue);
    font-size: 15px;
  }
  .compositor { padding: 10px 12px 12px; }
  .panel {
    width: 440px;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 0 0 auto;
    border: 0;
    border-left: 1px solid var(--linea-fuerte);
    border-radius: 0;
  }
  .panel[open] { animation: deslizar 0.35s var(--suave) both; }
  .panel-misiones { width: min(600px, 100vw); }
}

/* En el celular las esquinas decorativas estorban a los botones */
@media (max-width: 599px) {
  .marco { display: none; }
}

/* Pantallas muy bajitas (celular acostado) */
@media (max-height: 520px) and (max-width: 899px) {
  .reactor { --tam: min(30vw, 30dvh, 150px); }
  body.vacio .reactor { --tam: min(40vw, 42dvh, 220px); }
  .oyendo { -webkit-line-clamp: 2; line-clamp: 2; }
}

/* ---------- Animaciones ---------- */
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes respirar {
  0%, 100% { transform: scale(0.93); opacity: 0.84; }
  50% { transform: scale(1.04); opacity: 1; }
}
@keyframes latido {
  from { transform: scale(0.95); }
  to { transform: scale(1.09); }
}
@keyframes parpadeo {
  0%, 100% { opacity: 1; transform: scale(0.97); }
  40% { opacity: 0.55; transform: scale(0.92); }
  55% { opacity: 0.95; }
}
@keyframes ecualizador {
  0% { transform: scaleY(0.14); }
  55% { transform: scaleY(0.95); }
  100% { transform: scaleY(0.36); }
}
@keyframes escucha {
  0%, 100% { transform: scaleY(0.15); }
  50% { transform: scaleY(0.42); }
}
@keyframes onda {
  0% { transform: scale(0.6); opacity: 0.85; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes onda-voz {
  0% { transform: scale(0.75); opacity: 0.5; }
  100% { transform: scale(1.25); opacity: 0; }
}
@keyframes aparecer-anillo {
  from { transform: scale(0.6) rotate(-40deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes aparecer {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes encender {
  from { opacity: 0; filter: brightness(1.8) blur(2px); }
  to { opacity: 1; filter: none; }
}
@keyframes subir {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes deslizar {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes titilar { 50% { opacity: 0.35; } }
@keyframes brinco {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Menos movimiento si el sistema lo pide: se quitan los giros, quedan colores y textos */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  body[data-estado="escuchando"] .onda { opacity: 0.5; transform: scale(1.1); }
  body[data-estado="hablando"] .r-barras rect { transform: scaleY(0.6); }
}
