/* ---------- Base ---------- */
:root {
  --bg-fallback: #1c1c1e;
  --capture-color: rgba(255, 255, 255, 0.05); /* overlay neutro: no tiñe el fondo elegido */
  --bar-bg: rgba(28, 28, 30, 0.55);
  --icon-color: #d6d6d9; /* gris claro discreto */
  --icon-size: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-fallback) no-repeat center center;
  background-size: cover;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: var(--icon-color);
}

/* Alto real en iOS Safari, evita saltos por la barra de direcciones */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  /* Respeta el notch / home indicator del iPhone XS */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Área de captura ---------- */
#capture-area {
  flex: 1 1 auto;
  background: var(--capture-color);
  transition: height 0.25s ease, opacity 0.08s ease;
  cursor: pointer;
}

/* Pulso muy breve al capturar (feedback visual, sustituye a la vibración en iOS) */
#capture-area.flash {
  opacity: 0.55;
}

/* Cuando la galería está abierta, el área se achica hacia arriba */
#app.gallery-open #capture-area {
  flex: 0 0 42%;
}

/* ---------- Galería ---------- */
#gallery-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  background: #0e0e0f;
}
#gallery-grid.hidden { display: none; }

.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  background: #3a3a3c;
  display: block;
}

#gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 13px;
  color: #8e8e93;
  padding-top: 24px;
}

/* ---------- Barra inferior ---------- */
#bottom-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 12px;
  background: var(--bar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.bar-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--icon-color);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
}
.bar-btn:active { background: rgba(255,255,255,0.08); }

.bar-btn svg { width: var(--icon-size); height: var(--icon-size); }

#camera-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---------- Elementos de captura ocultos (nunca visibles) ---------- */
#video {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Modal ---------- */
#modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#modal.hidden { display: none; }

#modal-img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  -webkit-touch-callout: default; /* habilita el menú "Agregar a Fotos" al mantener presionado */
}

#modal-hint {
  color: #8e8e93;
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
  padding: 0 20px;
}

#modal-close {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 14px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
}

.hidden { display: none !important; }
