/* EDITOR AUTOMATICO - APP_WEB. Mismo diseno que la app de Godot (APP_CELULAR). */
:root {
  --fondo: #0a0c13; --sup: #141826; --sup2: #1b2032; --sup3: #242a40;
  --borde: rgba(255,255,255,.07); --texto: #eef1f8; --tenue: #8a93aa;
  --acento: #7c5cff; --acento2: #19d3ff; --ok: #2fd98b; --aviso: #ffb547; --error: #ff5c7a;
  --radio: 22px; --sombra: 0 6px 24px rgba(0,0,0,.35);
  --arriba: env(safe-area-inset-top, 0px); --abajo: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.22,1,.36,1); --rebote: cubic-bezier(.34,1.56,.64,1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fondo); color: var(--texto);
  font: 16px/1.4 Roboto, Inter, "Segoe UI", system-ui, -apple-system, sans-serif; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
.oculto { display: none !important; }

/* ---------- fondo vivo */
#fondo { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
#fondo i { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .45; }
#fondo i:nth-child(1) { width: 70vmax; height: 70vmax; left: -30vmax; top: -35vmax; background: radial-gradient(circle, rgba(124,92,255,.55), transparent 65%); animation: flotar1 26s ease-in-out infinite alternate; }
#fondo i:nth-child(2) { width: 60vmax; height: 60vmax; right: -28vmax; bottom: -30vmax; background: radial-gradient(circle, rgba(25,211,255,.4), transparent 65%); animation: flotar2 31s ease-in-out infinite alternate; }
#fondo i:nth-child(3) { width: 50vmax; height: 50vmax; left: 25%; top: 35%; background: radial-gradient(circle, rgba(124,92,255,.14), transparent 70%); animation: flotar1 40s ease-in-out infinite alternate-reverse; }
@keyframes flotar1 { to { transform: translate(18vw, 10vh) scale(1.15); } }
@keyframes flotar2 { to { transform: translate(-14vw, -12vh) scale(1.1); } }

/* ---------- estructura */
#app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
.cargando-inicio { flex: 1; display: grid; place-items: center; }
.encabezado { display: flex; align-items: center; gap: 12px; padding: calc(var(--arriba) + 12px) 20px 8px; }
.logo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--acento), var(--acento2)); box-shadow: 0 6px 18px rgba(124,92,255,.45); }
.encabezado .titulo { flex: 1; min-width: 0; }
.encabezado h1 { font-size: 21px; margin: 0; font-weight: 700; }
.estado-con { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: var(--tenue); flex: none; animation: latido 1.8s ease-in-out infinite; }
.punto.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); } .punto.mal { background: var(--error); }
@keyframes latido { 50% { opacity: .35; } }
.paginas { flex: 1; position: relative; overflow: hidden; }
.pagina { position: absolute; inset: 0; overflow-y: auto; padding: 6px 16px 28px; -webkit-overflow-scrolling: touch; }
.pagina.entra-der { animation: entraDer .42s var(--ease); } .pagina.entra-izq { animation: entraIzq .42s var(--ease); }
@keyframes entraDer { from { opacity: 0; transform: translateX(22%); } }
@keyframes entraIzq { from { opacity: 0; transform: translateX(-22%); } }
.pila { display: flex; flex-direction: column; gap: 14px; }
h2.grande { font-size: 30px; margin: 6px 0 0; } .sub { color: var(--tenue); font-size: 15px; margin: 0; }
h3 { font-size: 18px; margin: 4px 0 0; }

/* ---------- barra inferior */
.nav { position: relative; display: flex; margin: 6px 16px calc(var(--abajo) + 8px); height: 66px; border-radius: 24px;
  background: rgba(20,24,38,.95); border: 1px solid var(--borde); box-shadow: var(--sombra); backdrop-filter: blur(12px); }
.nav button { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--tenue); font-size: 12px; font-weight: 700; position: relative; z-index: 1; cursor: pointer; transition: color .3s; }
.nav button.activo { color: var(--texto); } .nav button.activo .ic { color: var(--acento2); }
.nav .indicador { position: absolute; top: 6px; bottom: 6px; border-radius: 18px; background: rgba(124,92,255,.22);
  border: 1px solid rgba(124,92,255,.5); transition: left .45s var(--rebote), width .45s var(--rebote); }

/* ---------- iconos */
.ic { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.ic.g { width: 26px; height: 26px; } .ic.p { width: 18px; height: 18px; }
.gira svg { animation: girar 1s linear infinite; } @keyframes girar { to { transform: rotate(360deg); } }

/* ---------- tarjetas */
.tarjeta { background: rgba(20,24,38,.92); border: 1px solid var(--borde); border-radius: var(--radio); padding: 18px;
  box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 12px; }
.tarjeta.oscura { background: rgba(6,7,12,.94); }
.cab-seccion { display: flex; align-items: center; gap: 10px; }
.num { width: 28px; height: 28px; border-radius: 14px; display: grid; place-items: center; font-size: 14px; font-weight: 700;
  background: rgba(124,92,255,.2); border: 1px solid rgba(124,92,255,.6); flex: none; }
.cab-seccion .t { flex: 1; font-size: 18px; font-weight: 700; }
.meta { color: var(--tenue); font-size: 13px; }

/* ---------- botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 18px;
  border-radius: 16px; border: 1px solid var(--borde); background: var(--sup2); font-weight: 700; font-size: 17px; cursor: pointer;
  transition: transform .45s var(--rebote), background .2s, filter .2s; user-select: none; position: relative; overflow: hidden; }
.btn:hover { background: var(--sup3); } .btn:active { transform: scale(.95); transition-duration: .09s; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primario { border: 0; color: #fff; background: linear-gradient(135deg, var(--acento), #3fa0ff 60%, var(--acento2)); background-size: 160% 160%;
  box-shadow: 0 8px 22px rgba(124,92,255,.35); animation: degradado 6s ease-in-out infinite alternate; }
.btn.primario::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  transform: translateX(-120%); animation: reflejo 3.6s ease-in-out infinite; }
.btn.primario:disabled { filter: grayscale(.6); animation: none; } .btn.primario:disabled::after { display: none; }
@keyframes degradado { to { background-position: 100% 100%; } }
@keyframes reflejo { 0%, 55% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
.btn.fantasma { background: transparent; color: var(--acento2); border-color: rgba(25,211,255,.35); }
.btn.peligro { background: rgba(255,92,122,.14); color: var(--error); border-color: rgba(255,92,122,.35); }
.btn.alto { min-height: 66px; font-size: 18px; letter-spacing: .5px; }
.btn.chico { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-ic { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--borde); background: var(--sup2); display: grid; place-items: center;
  cursor: pointer; flex: none; transition: transform .45s var(--rebote), background .2s; color: var(--texto); padding: 0; }
.btn-ic:hover { background: var(--sup3); } .btn-ic:active { transform: scale(.9); transition-duration: .09s; }
.btn-ic:disabled { opacity: .35; } .btn-ic.chico { width: 36px; height: 36px; border-radius: 12px; }
.fila { display: flex; gap: 10px; align-items: center; } .fila > .crece { flex: 1; min-width: 0; }
.fila-btn { display: flex; gap: 10px; } .fila-btn > * { flex: 1; }

/* segmentado */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--sup2); border: 1px solid var(--borde); position: relative; }
.seg button { flex: 1; min-height: 44px; border: 0; background: none; border-radius: 13px; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--tenue); font-weight: 700; cursor: pointer; position: relative; z-index: 1; transition: color .3s; }
.seg button.activo { color: #fff; }
.seg .marca { position: absolute; top: 4px; bottom: 4px; width: calc(50% - 6px); border-radius: 13px; background: var(--acento);
  box-shadow: 0 4px 14px rgba(124,92,255,.45); transition: transform .45s var(--rebote); }
.seg.der .marca { transform: translateX(calc(100% + 4px)); }

/* baldosas 4 y 5 */
.baldosas { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.baldosa { text-align: left; background: rgba(20,24,38,.92); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; min-height: 150px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer; box-shadow: var(--sombra); transition: transform .45s var(--rebote), border-color .3s; }
.baldosa:hover { border-color: var(--c); } .baldosa:active { transform: scale(.95); transition-duration: .09s; }
.baldosa .circ { width: 46px; height: 46px; border-radius: 23px; display: grid; place-items: center; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.baldosa .cab { display: flex; justify-content: space-between; } .baldosa .n { color: rgba(138,147,170,.7); font-weight: 700; font-size: 14px; }
.baldosa b { font-size: 17px; } .baldosa span.d { color: var(--tenue); font-size: 13px; }

/* listas */
.item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--sup2); border: 1px solid var(--borde); }
.item .nro { color: var(--acento2); font-weight: 700; font-size: 14px; min-width: 22px; }
.item .nombre { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.resalta { background: rgba(124,92,255,.18); border-color: var(--acento); animation: resalta .4s var(--rebote); }
@keyframes resalta { from { transform: scale(1.04); } }
.vacio { color: var(--tenue); font-size: 14px; text-align: center; padding: 6px; }

/* guia */
.marco { width: 72px; height: 72px; border-radius: 16px; background: var(--sup3); overflow: hidden; display: grid; place-items: center; flex: none; color: var(--acento2); }
.marco img { width: 100%; height: 100%; object-fit: cover; animation: aparece .35s; }
@keyframes aparece { from { opacity: 0; } }
.tarj-guia { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 12px; border-radius: 20px; cursor: pointer;
  background: var(--sup); border: 1px solid var(--borde); transition: transform .45s var(--rebote), border-color .3s; }
.tarj-guia:active { transform: scale(.97); transition-duration: .09s; }
.tarj-guia.elegida { border: 2px solid var(--acento); background: rgba(124,92,255,.1); }
.tarj-guia .marco { width: 80px; height: 80px; border-radius: 14px; }
.tarj-guia b { display: block; font-size: 17px; }
.dos-lineas { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* formularios */
label.etq { font-size: 14px; color: var(--tenue); font-weight: 700; margin-bottom: -4px; }
input.campo, textarea.campo, select.campo { width: 100%; min-height: 52px; padding: 13px 14px; border-radius: 14px; background: var(--sup2);
  border: 1px solid var(--borde); font-size: 17px; outline: none; transition: border-color .2s, box-shadow .2s; }
input.campo:focus, textarea.campo:focus, select.campo:focus { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
textarea.campo { resize: vertical; line-height: 1.45; }
textarea.directiva { min-height: 420px; font-size: 15px; }
.codigo-2fa { letter-spacing: 8px; text-align: center; font-size: 24px !important; font-variant-numeric: tabular-nums; }

/* grilla de imagenes */
.grilla { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.celda { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--sup3); }
.celda img { width: 100%; height: 100%; object-fit: cover; }
.celda .btn-ic { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 17px; background: rgba(0,0,0,.6); color: var(--error); border: 0; }

/* produccion */
.trabajo { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 14px; border-radius: 20px; cursor: pointer;
  background: rgba(20,24,38,.92); border: 1px solid color-mix(in srgb, var(--c) 25%, transparent); transition: transform .45s var(--rebote); color: var(--texto); }
.trabajo:active { transform: scale(.97); transition-duration: .09s; }
.trabajo .ic.g { color: var(--c); } .trabajo .cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.trabajo .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trabajo .u { color: var(--c); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pastilla { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; white-space: nowrap; color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.salidas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.salida { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 20px; background: rgba(20,24,38,.92); border: 1px solid var(--borde);
  cursor: pointer; text-align: left; color: var(--texto); transition: transform .45s var(--rebote), border-color .3s; }
.salida:hover { border-color: var(--acento2); } .salida:active { transform: scale(.96); transition-duration: .09s; }
.salida .mini { position: relative; aspect-ratio: 9 / 14; border-radius: 14px; background: #05060a; overflow: hidden; display: grid; place-items: center; }
.salida .mini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.salida .play { position: relative; width: 52px; height: 52px; border-radius: 26px; background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.5); display: grid; place-items: center; }
.salida b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.salida .meta { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* progreso */
.barra { height: 10px; border-radius: 5px; background: var(--sup3); overflow: hidden; }
.barra i { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--acento2); box-shadow: 0 0 12px var(--acento2); transition: width .3s var(--ease); }

/* consola */
.consola-pag { display: flex; flex-direction: column; gap: 12px; height: 100%; }
.consola { flex: 1; min-height: 200px; overflow-y: auto; padding: 14px; border-radius: 18px; background: rgba(6,7,12,.94); border: 1px solid var(--borde);
  font: 13px/1.45 "Roboto Mono", Consolas, Menlo, monospace; color: #c9d1e4; user-select: text; }
.consola div { white-space: pre-wrap; word-break: break-word; animation: aparece .3s; }
.consola .h { color: #5d6478; } .consola .tr { color: var(--tenue); }
.l-ok { color: var(--ok); } .l-error { color: var(--error); } .l-aviso { color: var(--aviso); } .l-claude { color: var(--acento2); } .l-app { color: #b6a6ff; }
.mini-consola div { font: 12px/1.5 "Roboto Mono", Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: aparece .3s; }
.mono { font-family: "Roboto Mono", Consolas, Menlo, monospace; font-size: 13px; }

/* ---------- hojas (pantallas que entran desde la derecha) */
#hojas { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hoja { position: absolute; inset: 0; pointer-events: auto; }
.hoja .velo { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: velo .3s; }
@keyframes velo { from { opacity: 0; } }
.hoja .panel { position: absolute; inset: 0; margin: 0 auto; max-width: 760px; background: var(--fondo); display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,.5); animation: hojaEntra .42s var(--ease); }
@keyframes hojaEntra { from { transform: translateX(100%); } }
.hoja.sale .panel { animation: hojaSale .32s cubic-bezier(.5,0,.75,0) forwards; } .hoja.sale .velo { animation: velo .3s reverse forwards; }
@keyframes hojaSale { to { transform: translateX(100%); } }
.hoja.atras .panel { transform: translateX(-18%); transition: transform .42s var(--ease); }
.hoja .cab { display: flex; align-items: center; gap: 10px; padding: calc(var(--arriba) + 12px) 16px 8px 12px; }
.hoja .cab h2 { flex: 1; margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hoja .contenido { flex: 1; overflow-y: auto; padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 12px; }
.hoja .pie { padding: 8px 18px calc(var(--abajo) + 12px); display: flex; flex-direction: column; gap: 10px; }
.hoja .pie:empty { display: none; }
.paginas.atras { transform: scale(.96); transition: transform .42s var(--ease); } .paginas { transition: transform .36s var(--ease); }

/* ---------- avisos, dialogos, reproductor */
#avisos { position: fixed; left: 16px; right: 16px; top: calc(var(--arriba) + 10px); z-index: 30; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 600px; margin: 0 auto; }
.aviso { display: flex; gap: 10px; align-items: center; padding: 14px; border-radius: 16px; background: rgba(27,32,50,.97); border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  box-shadow: 0 14px 30px rgba(0,0,0,.45); animation: avisoEntra .45s var(--rebote); font-size: 15px; }
.aviso .ic { color: var(--c); } .aviso.sale { animation: velo .35s reverse forwards; }
@keyframes avisoEntra { from { opacity: 0; transform: translateY(-14px) scale(.92); } }
.dialogo { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 24px; }
.dialogo .velo { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: velo .2s; }
.dialogo .tarjeta { position: relative; width: min(440px, 100%); animation: avisoEntra .4s var(--rebote); background: var(--sup2); }
.dialogo.sale { animation: velo .2s reverse forwards; }
.reproductor { position: fixed; inset: 0; z-index: 26; background: rgba(0,0,0,.92); display: flex; flex-direction: column; animation: velo .25s; }
.reproductor .fila { padding: calc(var(--arriba) + 10px) 14px 10px; }
.reproductor video { flex: 1; min-height: 0; width: 100%; background: #000; }
.festejo { position: absolute; left: 50%; top: 45%; width: 140px; height: 140px; margin: -70px; border-radius: 70px; background: var(--ok);
  display: grid; place-items: center; color: #fff; box-shadow: 0 0 60px rgba(47,217,139,.6); animation: festejo .7s var(--rebote); z-index: 5; }
.festejo .ic { width: 70px; height: 70px; }
@keyframes festejo { from { transform: scale(.2); opacity: 0; } }
.chispa { position: absolute; left: 50%; top: 45%; width: 10px; height: 10px; border-radius: 5px; animation: chispa .9s cubic-bezier(.16,1,.3,1) forwards; z-index: 4; }
@keyframes chispa { to { transform: translate(var(--x), var(--y)); opacity: 0; } }

/* entrada en cascada */
.entra { animation: entra .55s var(--rebote) backwards; animation-delay: var(--d, 0ms); }
@keyframes entra { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(25,211,255,.18); border-top-color: var(--acento2); animation: girar .8s linear infinite; }
.centro { display: grid; place-items: center; padding: 40px; }

/* ---------- login */
.login { flex: 1; display: grid; place-items: center; padding: calc(var(--arriba) + 20px) 18px 20px; }
.login .tarjeta { width: min(420px, 100%); padding: 26px; gap: 14px; }
.login .logo { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto; }
.login h1 { text-align: center; margin: 4px 0 0; font-size: 26px; }
.login .error { color: var(--error); font-size: 14px; min-height: 18px; text-align: center; }
.seguro { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--tenue); }
.seguro.si { color: var(--ok); } .seguro.no { color: var(--aviso); }
.control { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.control:last-child { border-bottom: 0; } .control .ic { margin-top: 1px; }
.control.ok .ic { color: var(--ok); } .control.aviso .ic { color: var(--aviso); } .control.riesgo .ic { color: var(--error); }
.secreto { font: 700 20px/1.6 "Roboto Mono", Consolas, monospace; letter-spacing: 2px; text-align: center; padding: 12px; border-radius: 14px; background: var(--sup2); user-select: all; word-break: break-all; }

@media (min-width: 900px) {
  .pagina { padding: 10px 24px 32px; }
  .salidas { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
