/* Fotos de la tele: app de una columna para el pulgar; la foto (16:9) manda y la interfaz se aparta. */
:root {
  --fondo: #F3F5EE;
  --superficie: #FFFFFF;
  --superficie-2: #E9EDE1;
  --texto: #1D2318;
  --suave: #626C59;
  --linea: #D9DFCF;
  --acento: #4F6B26;
  --acento-texto: #FFFFFF;
  --lima: #C6E05C;
  --peligro: #B2412D;
  --sombra: 0 10px 30px -18px rgba(29, 35, 24, .45);

  --f-titulo: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --f-texto: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radio: 14px;
  --margen: max(18px, env(safe-area-inset-left, 0px));
  --margen-d: max(18px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fondo: #11140F;
    --superficie: #1A1F17;
    --superficie-2: #232A1F;
    --texto: #EDF1E6;
    --suave: #9CA791;
    --linea: #2D3528;
    --acento: #C6E05C;
    --acento-texto: #182010;
    --peligro: #EF7A64;
    --sombra: 0 12px 30px -16px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.5 var(--f-texto);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
/* Sin zoom por doble toque: si no, pulsar dos veces la misma tecla del PIN (1-1) se pierde */
button, label, input { touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lima); outline-offset: 2px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h1, h2 { font-family: var(--f-titulo); font-weight: 700; letter-spacing: -.01em; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.05; }
h2 { font-size: 22px; line-height: 1.2; }
.antetitulo { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--acento); }
.suave { color: var(--suave); margin: 0; }
.texto { color: var(--suave); margin: 0; max-width: 60ch; }

/* ---------- Pantallas */
.pantalla { min-height: 100%; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.centrada { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding-left: var(--margen); padding-right: var(--margen-d); }
.contenedor { padding-left: var(--margen); padding-right: var(--margen-d); max-width: 1100px; margin: 0 auto; }
.estrecho { max-width: 520px; padding-block: 40px 60px; display: flex; flex-direction: column; gap: 14px; }

/* Marca: un marco de foto con un sol lima */
.marca, .marca-grande {
  width: 56px; aspect-ratio: 1; border-radius: 16px; position: relative;
  background: var(--acento);
  box-shadow: var(--sombra);
}
.marca::before, .marca-grande::before {
  content: ""; position: absolute; inset: 24% 18% 30%; border: 3px solid var(--acento-texto); border-radius: 5px;
}
.marca::after, .marca-grande::after {
  content: ""; position: absolute; width: 18%; aspect-ratio: 1; border-radius: 50%; background: var(--lima);
  right: 14%; top: 14%;
}
.marca-grande { width: 72px; border-radius: 20px; animation: latido 1.6s ease-in-out infinite; }
@keyframes latido { 50% { transform: scale(.94); } }

/* ---------- Formularios */
.formulario { display: flex; flex-direction: column; gap: 18px; margin-top: 6px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span { font-weight: 600; font-size: 14px; }
.campo small { color: var(--suave); font-size: 13px; }
.campo input {
  width: 100%; min-width: 0; height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--linea);
  background: var(--superficie); font-size: 17px;
}
/* PIN oculto con puntos sin ser campo de contraseña (así el navegador no ofrece guardarlo) */
.campo input.oculto { -webkit-text-security: disc; letter-spacing: .3em; }
.campo input:focus { border-color: var(--acento); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 25%, transparent); }
.persona { min-width: 0; border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: var(--superficie); }
.persona legend { font-family: var(--f-titulo); font-weight: 700; padding: 0 6px; }
.dos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.error { color: var(--peligro); margin: 0; font-weight: 500; }
.hecho { display: flex; flex-direction: column; gap: 14px; }
.clave { display: flex; gap: 10px; align-items: center; background: var(--superficie-2); border-radius: 12px; padding: 10px 10px 10px 14px; }
.clave code { flex: 1; font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* ---------- Botones */
.boton {
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  transition: transform .12s ease, background-color .2s;
}
.boton:active { transform: scale(.97); }
.principal { background: var(--acento); color: var(--acento-texto); }
.secundario { background: var(--superficie-2); color: var(--texto); }
.peligro { background: var(--peligro); color: #fff; }
.boton[disabled] { opacity: .5; pointer-events: none; }
.boton-icono {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--superficie); color: var(--texto); box-shadow: var(--sombra);
}
.boton-texto { background: none; border: 0; font-weight: 600; color: var(--acento); padding: 10px 6px; }
.peligro-texto { color: var(--peligro); }

/* ---------- PIN */
.pin-caja { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pin-titulo { font-size: 28px; margin-top: 14px; }
.puntos { display: flex; gap: 14px; margin: 18px 0 26px; }
.puntos i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--suave); transition: background-color .15s, border-color .15s, transform .15s; }
.puntos i.lleno { background: var(--acento); border-color: var(--acento); transform: scale(1.1); }
.puntos.temblor { animation: temblor .4s; }
.puntos.temblor i { border-color: var(--peligro); }
@keyframes temblor { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; width: 100%; }
.teclado button {
  aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--superficie); box-shadow: var(--sombra);
  font: 600 28px/1 var(--f-titulo); display: grid; place-items: center;
  transition: transform .1s, background-color .15s;
}
.teclado button:active { transform: scale(.92); background: var(--superficie-2); }
.teclado .tecla-borrar { background: none; box-shadow: none; }
.teclado.ocupado { opacity: .5; pointer-events: none; }

/* ---------- Galería */
.cabecera {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 28px var(--margen-d) 20px var(--margen); max-width: 1100px; margin: 0 auto;
}
.cabecera .suave { margin-top: 6px; }
.rejilla { list-style: none; margin: 0; padding: 0 0 120px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; }
@media (min-width: 700px) { .rejilla { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; } }
.foto {
  position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--superficie-2);
  border: 0; padding: 0; width: 100%; display: block;
}
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s; }
.foto img.cargada { opacity: 1; }
.foto .pie {
  position: absolute; inset: auto 0 0; padding: 18px 10px 7px; text-align: left;
  font-size: 12px; font-weight: 500; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55));
}
.foto.nueva { outline: 3px solid var(--lima); outline-offset: -3px; }
.vacio { text-align: center; padding: 60px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vacio .texto { max-width: 34ch; }
.vacio-marco { width: 120px; aspect-ratio: 16/9; border-radius: 12px; border: 2px dashed var(--linea); margin-bottom: 8px; }

.boton-flotante {
  position: fixed; right: var(--margen-d); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px; padding: 0 22px 0 18px; height: 56px; border-radius: 999px;
  background: var(--acento); color: var(--acento-texto); font-weight: 600; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .55);
  cursor: pointer; transition: transform .12s;
}
.boton-flotante:active { transform: scale(.96); }

/* ---------- Capas (editor, visor, hojas) */
.capa { position: fixed; inset: 0; z-index: 10; }
.oscura {
  background: #0B0D0A; color: #F1F4EC; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) var(--margen-d) env(safe-area-inset-bottom, 0px) var(--margen);
}
.editor-barra { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; }
.editor-barra h2 { font-size: 17px; }
.boton-icono.claro { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: none; }
.oscura .boton-texto { color: #D8EC86; }
.editor-centro { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; min-height: 0; }
.marco-tele {
  position: relative; width: 100%; max-width: 1100px; margin: 0 auto; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden;
  background: #000; box-shadow: 0 0 0 6px #1C1F1A, 0 24px 50px -20px #000; touch-action: none;
}
.marco-tele canvas, .marco-tele img { width: 100%; height: 100%; display: block; object-fit: contain; }
.hora-muestra {
  position: absolute; right: 4.5%; bottom: 6%; display: flex; align-items: baseline; gap: .45em; color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6); pointer-events: none; font-size: clamp(9px, 2.6vw, 22px);
}
.hora-muestra b { font-weight: 400; font-size: 2.6em; line-height: 1; }
.editor-ayuda { text-align: center; color: #A8B29E; margin: 0; font-size: 14px; }
.zoom { display: flex; align-items: center; gap: 10px; max-width: 420px; width: 100%; margin: 0 auto; color: #A8B29E; }
.zoom input { flex: 1; accent-color: var(--lima); }
.editor-pie { display: flex; gap: 10px; padding: 14px 0 18px; justify-content: flex-end; flex-wrap: wrap; }
.editor-pie .principal { min-width: 140px; }
.oscura .principal { background: var(--lima); color: #182010; }
.boton.claro { background: rgba(255, 255, 255, .12); color: #fff; }
.visor-info { margin: 0; color: #C9D1BF; font-size: 14px; text-align: center; }
.progreso {
  position: absolute; inset: 0; background: rgba(11, 13, 10, .88); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 24px;
}
.progreso p { margin: 0; font-size: 17px; font-weight: 600; }
.barra { width: min(320px, 80%); height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.barra i { display: block; height: 100%; width: 0; background: var(--lima); border-radius: inherit; transition: width .3s; }

.hoja-fondo { background: rgba(10, 12, 8, .45); display: flex; align-items: flex-end; justify-content: center; }
.hoja {
  width: 100%; max-width: 560px; background: var(--superficie); border-radius: 22px 22px 0 0;
  padding: 10px var(--margen-d) calc(20px + env(safe-area-inset-bottom, 0px)) var(--margen);
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 -20px 40px -20px rgba(0, 0, 0, .4);
  animation: subir .25s ease-out; max-height: 92%; overflow-y: auto;
}
@keyframes subir { from { transform: translateY(30px); opacity: .5; } }
.hoja-asa { width: 40px; height: 5px; border-radius: 9px; background: var(--linea); margin: 0 auto 4px; }
.hoja-pie { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
.ajuste { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.ajuste small { display: block; color: var(--suave); font-size: 13px; }
.nota { margin: 0; font-size: 13px; color: var(--suave); }
.contador { display: flex; align-items: center; gap: 4px; background: var(--superficie-2); border-radius: 999px; padding: 4px; }
.contador button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--superficie); font-size: 20px; font-weight: 600; }
.contador output { min-width: 64px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.interruptor {
  appearance: none; width: 52px; height: 32px; border-radius: 99px; background: var(--linea); position: relative;
  transition: background-color .2s; flex: none; cursor: pointer;
}
.interruptor::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
.interruptor:checked { background: var(--acento); }
.interruptor:checked::after { transform: translateX(20px); }

.aviso {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 20; background: var(--texto); color: var(--fondo); padding: 12px 18px; border-radius: 12px;
  font-weight: 500; box-shadow: var(--sombra); max-width: calc(100% - 40px); text-align: center;
  animation: subir .2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
