@font-face { font-family: "Orbitron"; src: url("/orbitron.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
:root {
  --fondo: #03080d; --panel: #07141f; --panel-2: rgba(10, 28, 40, .72); --borde: rgba(34, 211, 238, .16); --borde-f: rgba(34, 211, 238, .45);
  --cian: #22d3ee; --cian-f: #00e5ff; --texto: #e6f6fb; --sub: #7d9aa8; --rojo: #f87171; --oro: #fbbf24;
  --hud: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --abajo: env(safe-area-inset-bottom, 0px); --arriba: env(safe-area-inset-top, 0px);
  --letra: 15.5px;
}
body.letra-grande { --letra: 18px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
/* Fondo: resplandor cian arriba + rejilla tenue */
body { background:
  radial-gradient(640px 420px at 50% 0%, rgba(0, 229, 255, .10), transparent 70%),
  linear-gradient(rgba(34, 211, 238, .035) 1px, transparent 1px) 0 0 / 34px 34px,
  linear-gradient(90deg, rgba(34, 211, 238, .035) 1px, transparent 1px) 0 0 / 34px 34px,
  var(--fondo); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--cian-f); outline-offset: 2px; }

.vista { height: 100dvh; display: flex; flex-direction: column; }
.centro { align-items: center; justify-content: center; gap: 18px; padding: 32px; text-align: center; }
.centro p { margin: 0; color: var(--sub); line-height: 1.6; max-width: 340px; }
.error { color: var(--rojo) !important; }

/* Marca y logo (el fondo negro del logo se funde con la interfaz: mezcla «screen») */
.marca { margin: 0; font-family: var(--hud); font-size: 17px; font-weight: 700; letter-spacing: .12em; color: var(--cian);
  text-shadow: 0 0 14px rgba(0, 229, 255, .4); }
.centro .marca { font-size: 24px; }
.logo { width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%; overflow: hidden; display: block;
  box-shadow: 0 0 16px rgba(0, 229, 255, .35); }
.logo img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.18); mix-blend-mode: screen; display: block; }
.logo.grande { width: 120px; height: 120px; box-shadow: 0 0 40px rgba(0, 229, 255, .3); }
.bienvenida .logo.grande { width: 92px; height: 92px; }
body[data-estado="ASLEEP"] .cab .logo, body[data-estado="OFF"] .cab .logo { opacity: .5; }

/* Cabecera */
.cab { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--arriba)) 16px 10px;
  border-bottom: 1px solid var(--borde); background: linear-gradient(180deg, rgba(0, 229, 255, .05), transparent); }
.cab-marca { display: flex; align-items: center; gap: 12px; }
.estado { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--sub); }
.estado b { width: 7px; height: 7px; border-radius: 50%; background: #475569; }
.estado.on b { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.estado.espera b { background: var(--oro); }
.ico { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--borde-f); background: rgba(0, 229, 255, .06); color: var(--cian);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: inset 0 0 12px rgba(0, 229, 255, .08); }
.ico svg { width: 20px; height: 20px; }

/* Invitación a instalar */
.instalar { display: flex; align-items: center; gap: 12px; margin: 10px 14px 0; padding: 10px 10px 10px 12px; border-radius: 16px;
  border: 1px solid var(--borde-f); background: linear-gradient(135deg, rgba(0, 229, 255, .12), rgba(7, 20, 31, .9)); }
.instalar img { width: 38px; height: 38px; border-radius: 10px; }
.instalar div { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.instalar b { font-size: 14px; }
.instalar span { font-size: 12px; color: var(--sub); line-height: 1.35; }
.instalar-si { height: 34px; padding: 0 14px; border-radius: 17px; border: 0; background: var(--cian-f); color: #021016; font-weight: 700; cursor: pointer; }
.instalar-no { width: 30px; height: 30px; border: 0; background: none; color: var(--sub); cursor: pointer; display: grid; place-items: center; }
.instalar-no svg { width: 16px; height: 16px; }

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

/* ============================================================ MODO VOZ */
.voz { align-items: center; padding: 14px 20px 6px; overflow-y: auto; gap: 4px; }

/* Reloj HUD */
.reloj { position: relative; width: 100%; max-width: 420px; padding: 14px 18px 12px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, rgba(0, 229, 255, .07), rgba(7, 20, 31, .55)); border: 1px solid var(--borde); }
.esq { position: absolute; width: 14px; height: 14px; border: 2px solid var(--cian); opacity: .8; }
.esq.a { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.esq.b { top: -1px; right: -1px; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.esq.c { bottom: -1px; left: -1px; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.esq.d { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.reloj-hora { font-family: var(--hud); font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: .04em; font-variant-numeric: tabular-nums;
  color: #f2fdff; text-shadow: 0 0 18px rgba(0, 229, 255, .45); display: inline-flex; align-items: baseline; }
.reloj-hora .sep { font-style: normal; margin: 0 2px; color: var(--cian); animation: latido 2s steps(1) infinite; }
@keyframes latido { 50% { opacity: .25; } }
.reloj-hora small { margin-left: 8px; font-size: 16px; font-weight: 600; color: var(--cian); text-shadow: none; min-width: 22px; text-align: left; }
.reloj-pie { margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--hud); font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--sub); }
.reloj-pie b { width: 4px; height: 4px; border-radius: 50%; background: var(--cian); box-shadow: 0 0 6px var(--cian); }

/* Escena: lienzo de ondas + núcleo (el logo es el botón de hablar) */
.escena { position: relative; width: min(84vw, 340px); aspect-ratio: 1; margin: auto 0; flex-shrink: 0; display: grid; place-items: center; }
.escena canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.orbe { --nivel: 0; position: relative; width: 58%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; background: var(--fondo); overflow: hidden;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 calc(30px + var(--nivel) * 50px) rgba(0, 229, 255, calc(.35 + var(--nivel) * .5));
  transform: scale(calc(1 + var(--nivel) * .08)); transition: transform .08s linear, opacity .3s; animation: respirar 4.5s ease-in-out infinite; }
.orbe img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.16); mix-blend-mode: screen; pointer-events: none; display: block; }
.orbe:active { transform: scale(.96); }
@keyframes respirar { 50% { box-shadow: 0 0 46px rgba(0, 229, 255, .55); } }
.orbe.activo, body[data-estado="SPEAKING"] .orbe { animation: none; }
body[data-estado="ASLEEP"] .orbe, body[data-estado="OFF"] .orbe, body[data-estado="CONECTANDO"] .orbe { opacity: .45; animation: none; }

.voz-estado { margin: 2px 0 0; text-align: center; font-size: 14.5px; color: var(--sub); min-height: 20px; transition: color .2s; }
body.escuchando .voz-estado { color: var(--cian); }
.subtitulo { width: 100%; max-width: 420px; min-height: 56px; max-height: 24vh; overflow-y: auto; text-align: center; display: flex; flex-direction: column; gap: 6px;
  padding: 4px 6px; }
body.sin-subs .subtitulo { visibility: hidden; }
.sub-usuario { font-size: calc(var(--letra) - 2px); color: var(--sub); font-style: italic; }
.sub-jarvis { font-size: calc(var(--letra) + .5px); line-height: 1.5; color: var(--texto); }
.sub-usuario:empty, .sub-jarvis:empty { display: none; }
.voz-acc { display: flex; gap: 10px; justify-content: center; min-height: 44px; }
.pildora { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 21px; cursor: pointer;
  border: 1px solid var(--borde-f); background: rgba(0, 0, 0, .35); font-size: 14px; }
.pildora svg { width: 16px; height: 16px; }
.pildora.peligro { color: var(--rojo); border-color: rgba(248, 113, 113, .45); }

/* ============================================================ MODO CHAT */
.conv { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.bienvenida { margin: auto 12px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.bienvenida p { margin: 0; color: var(--sub); font-size: 14px; line-height: 1.6; }
.bienvenida b { color: var(--texto); font-size: 17px; }
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 4px; }
.msg.usuario { align-self: flex-end; align-items: flex-end; }
.msg.jarvis { align-self: flex-start; }
.burbuja { padding: 12px 15px; border-radius: 16px; font-size: var(--letra); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.usuario .burbuja { background: linear-gradient(135deg, rgba(0, 229, 255, .22), rgba(0, 229, 255, .12)); border: 1px solid rgba(0, 229, 255, .4); border-bottom-right-radius: 5px; }
.msg.jarvis .burbuja { background: var(--panel-2); border: 1px solid var(--borde); border-bottom-left-radius: 5px; }
.msg.vivo .burbuja::after { content: '▍'; color: var(--cian-f); animation: parpadeo 1s infinite; }
@keyframes parpadeo { 50% { opacity: 0; } }
.msg.error .burbuja { border-color: rgba(248, 113, 113, .5); }
.meta { display: flex; align-items: center; gap: 12px; padding: 0 4px; font-size: 11.5px; color: var(--sub); }
.msg.jarvis .meta { justify-content: flex-end; }
.copiar { display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px; border: 0; background: none; color: var(--sub); cursor: pointer; font-size: 12px; }
.copiar svg { width: 14px; height: 14px; }
.msg.vivo .copiar { visibility: hidden; }

.redactar { padding: 8px 14px 10px; }
.caja-texto { display: flex; align-items: flex-end; gap: 6px; padding: 5px 5px 5px 16px; border-radius: 26px; border: 1px solid var(--borde-f);
  background: rgba(3, 12, 18, .85); box-shadow: 0 0 18px rgba(0, 229, 255, .08); }
.caja-texto:focus-within { border-color: var(--cian); box-shadow: 0 0 20px rgba(0, 229, 255, .2); }
.caja-texto textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; padding: 11px 0; border: 0; background: transparent; color: var(--texto);
  font: inherit; font-size: 16px; line-height: 1.3; outline: none; }
.caja-texto textarea:focus-visible { outline: none; }
.caja-texto textarea::placeholder { color: var(--sub); }
.enviar { width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #39ecff, #0891b2); color: #021016; box-shadow: 0 0 14px rgba(0, 229, 255, .45); transition: opacity .2s; }
.enviar svg { width: 19px; height: 19px; }
.enviar:disabled { opacity: .3; box-shadow: none; cursor: default; }
.enviar.parar { background: rgba(248, 113, 113, .15); color: var(--rojo); border: 1px solid rgba(248, 113, 113, .5); box-shadow: none; }

/* ============================================================ Navegación */
.nav { display: flex; gap: 8px; margin: 0 14px calc(10px + var(--abajo)); padding: 6px; border-radius: 20px; border: 1px solid var(--borde);
  background: rgba(7, 20, 31, .92); backdrop-filter: blur(8px); }
.nav-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border: 1px solid transparent; border-radius: 15px;
  background: transparent; color: var(--sub); font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.nav-btn svg { width: 20px; height: 20px; }
.nav-btn[aria-current="page"] { color: var(--cian); background: rgba(0, 229, 255, .1); border-color: var(--borde-f); box-shadow: inset 0 0 14px rgba(0, 229, 255, .1); }

/* ============================================================ Ajustes */
.hoja { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; }
.hoja-caja { width: 100%; max-height: 88dvh; display: flex; flex-direction: column; border-radius: 22px 22px 0 0; background: var(--panel);
  border-top: 1px solid var(--borde-f); }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.hoja-cab h2 { margin: 0; font-family: var(--hud); font-size: 15px; letter-spacing: .12em; color: var(--cian); }
.hoja-x { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--borde); background: none; color: var(--sub); cursor: pointer; display: grid; place-items: center; }
.hoja-x svg { width: 18px; height: 18px; }
.hoja-cuerpo { overflow-y: auto; padding: 0 16px calc(20px + var(--abajo)); overscroll-behavior: contain; }
.hoja h3 { margin: 16px 4px 8px; font-family: var(--hud); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--sub); font-weight: 600; }
.grupo { border: 1px solid var(--borde); border-radius: 14px; background: rgba(0, 0, 0, .22); overflow: hidden; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--borde); }
.grupo > .fila:last-child { border-bottom: 0; }
.fila.col { flex-direction: column; align-items: stretch; gap: 10px; }
.fila > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fila b { font-size: 14.5px; font-weight: 600; }
.fila small { color: var(--sub); font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }
.fila.apagada { opacity: .45; }
button.fila { width: 100%; border-left: 0; border-right: 0; border-top: 0; background: none; cursor: pointer; font-size: 14.5px; text-align: left; }
button.fila.peligro { color: var(--rojo); justify-content: center; font-weight: 600; }
/* Interruptor */
.sw { appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 46px; height: 26px; margin: 0; border-radius: 13px; position: relative; cursor: pointer;
  background: #1e2b35; border: 1px solid var(--borde); transition: background .2s; }
.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #8aa3b0; transition: transform .2s, background .2s; }
.sw:checked { background: rgba(0, 229, 255, .35); border-color: var(--cian); }
.sw:checked::after { transform: translateX(20px); background: #fff; box-shadow: 0 0 8px var(--cian-f); }
.sw:disabled { opacity: .5; }
/* Selector segmentado */
.segm { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: rgba(0, 0, 0, .35); border: 1px solid var(--borde); }
.segm button { flex: 1; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--sub); cursor: pointer; font-size: 13.5px; font-weight: 600; }
.segm button[aria-checked="true"] { background: rgba(0, 229, 255, .16); color: var(--cian-f); box-shadow: inset 0 0 0 1px var(--borde-f); }
input[type="range"] { width: 100%; accent-color: #00e5ff; }
.chip { flex-shrink: 0; padding: 4px 10px; border-radius: 10px; font-size: 12px; border: 1px solid var(--borde); color: var(--sub); }
.chip.ok { color: #4ade80; border-color: rgba(74, 222, 128, .4); }
.chip.aviso { color: var(--oro); border-color: rgba(251, 191, 36, .4); }
.mini { flex-shrink: 0; height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid var(--cian); background: rgba(0, 229, 255, .15); color: var(--cian-f); font-weight: 600; cursor: pointer; }

@media (max-height: 660px) { .reloj { display: none; } }
@media (prefers-reduced-motion: reduce) { .orbe, .reloj-hora .sep, .msg.vivo .burbuja::after { animation: none !important; } }
