:root {
  --fondo: #070d1a;
  --panel: #0f1830;
  --borde: #1e2b47;
  --texto: #e2e8f0;
  --suave: #94a3b8;
  --acento: #60a5fa;
  --estado: #60a5fa;
  color-scheme: dark;
}
* { 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; }
body { display: flex; flex-direction: column; min-height: 100dvh; overscroll-behavior: none; }
a { color: var(--acento); }

/* Cabecera */
header { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--borde); }
header .marca { font-weight: 650; letter-spacing: .3px; }
header .marca small { display: block; font-weight: 400; color: var(--suave); font-size: 12px; }
header .punto { width: 9px; height: 9px; border-radius: 50%; background: #475569; margin-left: auto; box-shadow: 0 0 0 3px #0003; }
header .punto.ok { background: #34d399; }
header button.menu { background: none; border: 0; color: var(--suave); font-size: 22px; padding: 4px 6px; }

/* Escenario */
.escenario { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; padding: 22px 16px 8px;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--estado) 22%, transparent), transparent 62%); transition: background .5s; }
.retrato { position: relative; width: min(58vw, 250px); aspect-ratio: 1; }
.retrato img { position: absolute; inset: 9%; width: 82%; height: 82%; border-radius: 50%; object-fit: cover; object-position: 50% 30%;
  border: 2px solid color-mix(in srgb, var(--estado) 70%, #fff 0%); box-shadow: 0 0 28px color-mix(in srgb, var(--estado) 45%, transparent); transition: border-color .4s, box-shadow .4s; }
.retrato canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.estado { margin-top: 12px; font-size: 15px; color: var(--estado); min-height: 1.3em; text-align: center; transition: color .4s; }
.sugerencia { color: var(--suave); font-size: 13px; text-align: center; margin-top: 4px; min-height: 1.2em; }

/* Botón principal */
.controles { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 10px 0 6px; }
.hablar { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--estado); color: #04101f; font-size: 34px;
  box-shadow: 0 8px 26px color-mix(in srgb, var(--estado) 50%, transparent); transition: transform .15s, background .4s; display: grid; place-items: center; }
.hablar:active { transform: scale(.94); }
.hablar.colgar { background: #f43f5e; color: #fff; box-shadow: 0 8px 26px #f43f5e66; }
.redondo { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--borde); background: var(--panel); color: var(--texto); font-size: 20px; display: grid; place-items: center; }
.redondo.activo { background: #f59e0b; color: #111; border-color: #f59e0b; }
.redondo:disabled { opacity: .35; }

/* Conversación */
.conversacion { flex: 1 1 auto; overflow-y: auto; padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.burbuja { max-width: 86%; padding: 9px 12px; border-radius: 14px; line-height: 1.38; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.burbuja.yo { align-self: flex-end; background: #1d4ed8; border-bottom-right-radius: 4px; }
.burbuja.electa { align-self: flex-start; background: var(--panel); border: 1px solid var(--borde); border-bottom-left-radius: 4px; }
.aviso { align-self: center; font-size: 12px; color: var(--suave); background: #0b1324; border: 1px solid var(--borde); border-radius: 999px; padding: 4px 10px; }
.aviso.error { color: #fecdd3; border-color: #7f1d1d; background: #2a0d14; }
.aviso.agente { color: #c4b5fd; border-color: #3b2a6b; }

/* Entrada de texto */
form.escribir { display: flex; gap: 8px; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--borde); background: #0a1222; }
form.escribir input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--borde); color: var(--texto); border-radius: 999px; padding: 11px 15px; font-size: 16px; }
form.escribir button { border: 0; background: var(--acento); color: #04101f; border-radius: 999px; padding: 0 16px; font-weight: 650; font-size: 15px; }

/* Ajustes */
dialog { background: var(--panel); color: var(--texto); border: 1px solid var(--borde); border-radius: 16px; width: min(92vw, 420px); padding: 18px; }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label { display: block; margin: 12px 0 4px; color: var(--suave); font-size: 13px; }
dialog select { width: 100%; background: var(--fondo); color: var(--texto); border: 1px solid var(--borde); border-radius: 10px; padding: 10px; font-size: 15px; }
dialog .fila { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 14px; }
dialog .fila input { width: 20px; height: 20px; }
dialog .botones { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
dialog button { border: 0; border-radius: 10px; padding: 10px 14px; font-size: 14px; background: #334155; color: var(--texto); }
dialog button.peligro { background: #7f1d1d; }
dialog button.primario { background: var(--acento); color: #04101f; font-weight: 650; }

/* Pantallas sueltas (vincular, mensajes) */
body.centro { align-items: center; justify-content: center; padding: 24px; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: 18px; padding: 24px; width: min(92vw, 400px); text-align: center; }
.tarjeta h1 { font-size: 22px; margin: 10px 0 6px; }
.tarjeta p { color: var(--suave); line-height: 1.45; }
.tarjeta img { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; object-position: 50% 30%; border: 2px solid var(--acento); }
.tarjeta input { width: 100%; font: 600 30px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 10px; text-align: center; padding: 12px; border-radius: 12px;
  border: 1px solid var(--borde); background: var(--fondo); color: var(--acento); margin: 10px 0; }
.tarjeta button { width: 100%; padding: 13px; border: 0; border-radius: 12px; background: var(--acento); color: #04101f; font-weight: 700; font-size: 16px; }
.tarjeta .error { color: #fda4af; min-height: 1.3em; }

/* Rostro vivo encima de la foto */
.retrato canvas#rostro { position: absolute; inset: 9%; width: 82%; height: 82%; border-radius: 50%; opacity: 0; transition: opacity .6s;
  border: 2px solid color-mix(in srgb, var(--estado) 70%, #fff 0%); box-shadow: 0 0 28px color-mix(in srgb, var(--estado) 45%, transparent); }
.retrato.viva canvas#rostro { opacity: 1; }
.retrato.viva img { opacity: 0; }

/* Aplicativos */
.apps { display: flex; justify-content: center; gap: 14px; padding: 4px 12px 10px; border-bottom: 1px solid var(--borde); }
.app { display: flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none; color: var(--texto); width: 92px; }
.app .icono { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; box-shadow: 0 6px 16px #0006; transition: transform .15s; }
.app:active .icono { transform: scale(.92); }
.app .icono svg { width: 34px; height: 34px; }
.app .icono.lideres { background: linear-gradient(145deg, #f59e0b, #d97706); }
.app .icono.elector { background: linear-gradient(145deg, #8b5cf6, #6d28d9); }
.app .icono.voto { background: linear-gradient(145deg, #10b981, #047857); }
.app .nombre { font-size: 12px; color: var(--suave); }
