* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #050912; color: #e6ecf5;
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
canvas#cielo { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
/* Modo nocturno: todo en rojo y más oscuro, para no perder la adaptación del ojo a la oscuridad */
body.rojo canvas#cielo, body.rojo header, body.rojo nav, body.rojo section, body.rojo #mensaje, body.rojo #firma {
  filter: grayscale(1) brightness(1.15);
}
body.rojo::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1000;
  background: #c00000; mix-blend-mode: multiply;   /* deja solo el canal rojo, atenuado */
}
body.rojo #fichaFoto img { opacity: .55; }
header .derecha { display: flex; gap: 8px; align-items: center; }
.redondo {
  pointer-events: auto; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid #2f4466; background: #050912cc; font-size: 18px; line-height: 1; padding: 0;
}
body.rojo .redondo { border-color: #ff5a4a; background: #2a0505cc; }
.oculto { display: none !important; }

header#barra {
  position: fixed; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  pointer-events: none;
  background: linear-gradient(#050912cc, #05091200);
}
#estado { font-size: 13px; color: #b9c6da; text-shadow: 0 1px 2px #000; }
#lugar { font-weight: 600; color: #e6ecf5; }
#hora.adelantada { color: #ffcc33; }
.chip {
  pointer-events: auto; border: 1px solid #ffcc33; color: #ffcc33; background: #050912cc;
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px;
}

#mensaje {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 76px); transform: translateX(-50%);
  background: #16233acc; border: 1px solid #2f4466; padding: 8px 14px; border-radius: 10px;
  font-size: 14px; max-width: 90vw; text-align: center; backdrop-filter: blur(6px);
}

nav#abajo {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
  background: #08101ee6; border-top: 1px solid #1c2a42; backdrop-filter: blur(8px);
}
nav#abajo button {
  background: none; border: 0; color: #b9c6da; font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px;
}
nav#abajo button .ico { font-size: 20px; line-height: 1; }
nav#abajo button.activo { color: #ffcc33; background: #ffcc3314; }

#firma {
  position: fixed; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 66px);
  font-size: 11px; letter-spacing: .06em; color: #8193adb0; pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
#firma.tapada { display: none; }
#ficha {
  position: fixed; left: 8px; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 70px);
  background: #0d1729ee; border: 1px solid #22344f; border-radius: 14px;
  padding: 12px 14px; backdrop-filter: blur(8px); max-width: 480px; margin: 0 auto;
}
#ficha h2 { margin: 0 28px 6px 0; font-size: 17px; }
#ficha { max-height: 56vh; overflow-y: auto; }
#fichaFoto:empty { display: none; }
#fichaFoto { display: flex; gap: 10px; margin: 2px 0 8px; align-items: flex-start; }
#fichaFoto img { width: 112px; height: 84px; object-fit: cover; border-radius: 8px; background: #050912; display: block; flex: none; }
#fichaFoto .fotoTxt { font-size: 12.5px; color: #aab6c8; line-height: 1.3; }
#fichaFoto .ext { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#fichaFoto .fotoTxt b { color: #ffcc33; font-weight: 600; }
#fichaFoto .fotoTxt a { color: #8fc0ff; display: block; margin-top: 3px; }
#fichaFoto .fotoCargando { font-size: 12px; color: #8193ad; }
#fichaDatos { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; color: #c9d4e5; }
#fichaDatos .k { color: #8193ad; }
#fichaAcciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#fichaAcciones:empty { display: none; }

.cerrar {
  position: absolute; top: 6px; right: 8px; background: none; border: 0; color: #8193ad;
  font-size: 26px; line-height: 1; padding: 4px 8px;
}
.boton {
  background: #1b2c48; color: #e6ecf5; border: 1px solid #2f4466; border-radius: 10px;
  padding: 8px 12px; font: inherit; font-size: 14px;
}
.boton.principal { background: #ffcc33; color: #1a1400; border-color: #ffcc33; font-weight: 600; }

.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto;
  background: #0b1424f7; border-top: 1px solid #22344f; border-radius: 16px 16px 0 0;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 16px); backdrop-filter: blur(10px);
  max-width: 640px; margin: 0 auto;
}
.hojaTitulo { position: sticky; top: 0; background: #0b1424; padding: 14px 0 8px; z-index: 1; }
.hojaTitulo h2 { margin: 0; font-size: 18px; }
.hojaTitulo .cerrar { top: 8px; right: -6px; }
.hoja h3 { font-size: 14px; color: #ffcc33; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.nota { color: #8193ad; font-size: 13px; margin: 4px 0; }
.fila { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.fila.col { flex-direction: column; align-items: stretch; }
label.fila:not(.col) { flex-wrap: nowrap; }
.fila input[type=checkbox] { flex: none; }
.fila input[type=checkbox] { width: 20px; height: 20px; accent-color: #ffcc33; }
.fila input[type=range] { width: 100%; accent-color: #ffcc33; }
.fila input:not([type]) , .fila input[inputmode] {
  flex: 1 1 120px; min-width: 0; background: #050912; color: #e6ecf5; border: 1px solid #2f4466;
  border-radius: 8px; padding: 8px; font: inherit;
}

.dia { color: #ffcc33; font-size: 13px; font-weight: 600; margin: 14px 0 4px; text-transform: capitalize; }
.paso {
  display: grid; grid-template-columns: 82px 1fr auto; gap: 2px 10px; align-items: center;
  padding: 10px; margin: 6px 0; border-radius: 12px; background: #111d33; border: 1px solid #1c2a42;
  width: 100%; text-align: left; color: inherit; font: inherit;
}
.paso .h { font-weight: 700; font-size: 15px; white-space: nowrap; }
.paso .n { font-weight: 600; }
.paso .d { grid-column: 2 / 4; color: #9fb0c8; font-size: 13px; }
.paso .m { font-size: 13px; color: #c9d4e5; text-align: right; }
.paso.iss { border-color: #ffcc3366; }
.paso.css { border-color: #ff6b6b66; }
.paso.ahora { background: #1d2a12; border-color: #7ccf4a; }
