/* ============================================================================
   galeria.css — Galería Acambuco (carrusel + subida a Storage).
   Máquina visual portada del "Centro de Recursos Visuales" (Departamento
   Médico, sección #carrete) y adaptada a Acambuco.
   - Prefijo propio gal-* / --gal-* para NO colisionar con dm-* ni styles.css.
   - Self-contained con tokens propios (--gal-*), igual que notes-wall.css:
     no depende de variables de styles.css.
   - Etapa 1: carrusel (viewport/track/slide/imagen, prev/next, dots),
     info (título/autor/fecha), modal "Agregar imagen" y modal de borrado.
   - Comentarios y likes: NO se maquetan en Etapa 1 (van en etapas 2 y 3).
   ========================================================================== */

/* Reset de box-sizing acotado al componente (self-contained: no depende del
   reset global de styles.css; evita overflow por width:100% + padding). */
.gal-root,
.gal-root *,
.gal-form-backdrop,
.gal-form-backdrop *,
.gal-confirm-backdrop,
.gal-confirm-backdrop * {
  box-sizing: border-box;
}

.gal-root,
.gal-form-backdrop,
.gal-confirm-backdrop {
  --gal-action: #0f5fa6;
  --gal-action-hover: #0b4e86;
  --gal-ink-strong: #042c53;
  --gal-ink-soft: #44607f;
  --gal-accent: #2a89e6;
  --gal-danger: #b91c1c;
  --gal-line: #e2e8f0;
  --gal-surface: #ffffff;
  --gal-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gal-t-fast: 0.14s;
  --gal-t-med: 0.22s;
  --gal-elev-1: 0 6px 18px rgba(10, 50, 101, 0.12);
  --gal-elev-2: 0 20px 60px rgba(15, 23, 42, 0.12);
}

/* ── Raíz / layout ────────────────────────────────────────────────────────── */
.gal-root {
  font-family: inherit;
  color: var(--gal-ink-strong);
}

/* Región viva solo para lectores de pantalla (anuncia el cambio de imagen). */
.gal-sr-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.gal-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 920px;
  margin: 0 auto;
}

/* ── Botón "+ Agregar imagen" (extremo derecho de la fila inferior) ───────── */
.gal-add {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(180deg, var(--gal-action) 0%, rgba(11, 95, 198, 0.62) 100%);
  box-shadow: var(--gal-elev-1);
  transition: filter var(--gal-t-fast) var(--gal-ease), transform var(--gal-t-fast) var(--gal-ease);
}
.gal-add:hover { filter: brightness(1.08); }
.gal-add:active { transform: translateY(1px); }
.gal-add:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.35); }
/* "+ Agregar comentario": secundario (no compite con el primario azul). */
.gal-add--secondary {
  color: var(--gal-action);
  background: rgba(42, 137, 230, 0.08);
  border: 1px solid rgba(15, 95, 166, 0.28);
  box-shadow: none;
}
.gal-add--secondary:hover { filter: none; background: rgba(42, 137, 230, 0.15); border-color: rgba(15, 95, 166, 0.45); }
.gal-add--secondary[aria-expanded="true"] {
  background: rgba(42, 137, 230, 0.16);
  border-color: var(--gal-action);
}
.gal-add--secondary[hidden] { display: none; }

/* ── Viewport (contenedor de scroll horizontal) ───────────────────────────── */
/* Wrap NO-scroll que aloja las flechas overlay (fuera del scroll container). */
.gal-viewport-wrap {
  position: relative;
  width: 100%;
}
.gal-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 520px;
  min-height: 280px;
  overflow: hidden;
  border-radius: 18px;
  background: #f1f5f9;
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--gal-line);
  /* touch-action: pan-y → en mobile el dedo scrollea la página en vertical; el
     swipe horizontal lo maneja el JS. NO usamos overscroll-behavior: contain
     porque atrapaba el scroll vertical de la rueda sobre el carrusel. */
  touch-action: pan-y;
}
.gal-viewport:focus-visible {
  outline: 3px solid rgba(42, 137, 230, 0.45);
  outline-offset: 2px;
}

.gal-track {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
}
.gal-track > .gal-slide {
  flex: 0 0 100%;
}
.gal-slide {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  overflow: hidden;
}
.gal-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  cursor: zoom-in; /* indica que se puede ampliar (lightbox) */
  transition: opacity 0.3s var(--gal-ease);
}
.gal-slide img.is-loaded { opacity: 1; }
/* Imágenes verticales (alto > ancho): mostrar completas, sin recorte. */
.gal-slide.vertical img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
}

/* Estado vacío / cargando */
.gal-empty {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--gal-ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.5;
}
.gal-empty-msg { max-width: 34ch; }

/* ── Botones de navegación (overlay prev/next) ────────────────────────────── */
.gal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(15, 95, 166, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--gal-action);
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  /* Doble sombra (oscura + halo blanco) → contraste sobre imágenes claras Y oscuras. */
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.7);
  opacity: 0.9; /* siempre visibles (no dependen del hover) */
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: opacity var(--gal-t-med) var(--gal-ease), transform var(--gal-t-med) var(--gal-ease),
    background var(--gal-t-med) var(--gal-ease), border-color var(--gal-t-med) var(--gal-ease);
}
.gal-viewport-wrap:hover .gal-nav { opacity: 1; }
.gal-nav:hover {
  opacity: 1;
  background: #ffffff;
  border-color: rgba(15, 95, 166, 0.45);
  transform: translateY(-50%) scale(1.06);
}
.gal-nav:focus-visible {
  outline: none;
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.4);
}
.gal-nav--prev { left: 12px; }
.gal-nav--next { right: 12px; }
.gal-nav[hidden] { display: none; }

/* ── Like (overlay corazón + contador) ────────────────────────────────────── */
/* Esquina inferior-derecha del viewport: no pisa las flechas (centradas en
   vertical). Pill oscuro translúcido → legible sobre imágenes claras y oscuras. */
.gal-like {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 6px 11px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), transform var(--gal-t-fast) var(--gal-ease);
}
.gal-like[hidden] { display: none; }
.gal-like:hover { background: rgba(15, 23, 42, 0.7); }
.gal-like:active { transform: scale(0.93); }
.gal-like:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.7); }
.gal-like .gal-like-svg { width: 18px; height: 18px; display: block; }
/* Liked: corazón relleno rojo. */
.gal-like.is-liked .gal-like-svg { fill: #ff4d6d; stroke: #ff4d6d; }
.gal-like-count {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ── Autoplay (overlay esquina inferior-izquierda, discreto) ───────────────── */
.gal-autoplay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), transform var(--gal-t-fast) var(--gal-ease);
}
.gal-autoplay[hidden] { display: none; }
.gal-autoplay svg { width: 18px; height: 18px; display: block; }
.gal-autoplay:hover { background: rgba(15, 23, 42, 0.7); }
.gal-autoplay:active { transform: scale(0.93); }
.gal-autoplay:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.7); }
.gal-autoplay.is-playing { background: var(--gal-action); }

/* ── Fila inferior: [info + tacho] a la izquierda, "+ Agregar" a la derecha ── */
.gal-bottombar {
  width: 100%;
  padding: 12px 16px;
  background: var(--gal-surface);
  border: 1px solid var(--gal-line);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  gap: 10px 12px;
  flex-wrap: wrap;
}
/* Grupo izquierdo: info de la imagen + tacho de borrar, pegados. */
.gal-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}
.gal-info[hidden] { display: none; }
.gal-info-text { min-width: 0; }
.gal-info-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--gal-ink-strong);
  letter-spacing: -0.01em;
  word-break: break-word;
}
.gal-info-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--gal-ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.gal-info-meta .gal-sep { opacity: 0.5; }

/* Grupo de acciones (editar + borrar), pegado a la derecha, antes del "+ Agregar". */
.gal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: auto; /* empuja el grupo (y el "+ Agregar" que sigue) a la derecha */
}

/* Botones de ícono (editar / borrar): SOLO ícono, compactos y coherentes. */
.gal-iconbtn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  background: transparent;
  transition: background var(--gal-t-fast) var(--gal-ease), border-color var(--gal-t-fast) var(--gal-ease);
}
.gal-iconbtn svg { width: 17px; height: 17px; }
.gal-iconbtn[hidden] { display: none; }
/* Editar: neutro/azul. */
.gal-edit { color: var(--gal-action); border-color: rgba(15, 95, 166, 0.25); background: rgba(42, 137, 230, 0.07); }
.gal-edit:hover { background: rgba(42, 137, 230, 0.14); border-color: rgba(15, 95, 166, 0.4); }
.gal-edit:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.3); }
/* Borrar: danger/rojo. */
.gal-delete { color: var(--gal-danger); border-color: rgba(185, 28, 28, 0.25); background: rgba(185, 28, 28, 0.06); }
.gal-delete:hover { background: rgba(185, 28, 28, 0.12); border-color: rgba(185, 28, 28, 0.4); }
.gal-delete:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.28); }

/* ── Comentarios (card blanco debajo del carrusel, por imagen) ────────────── */
.gal-comments {
  margin-top: 6px;
  padding: 14px 16px;
  background: var(--gal-surface);
  border: 1px solid var(--gal-line);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}
.gal-comments[hidden] { display: none; }
.gal-comments__title {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gal-ink-strong);
}
.gal-comments__count { color: var(--gal-ink-soft); font-weight: 600; font-size: 0.86rem; }
.gal-comments__list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 0; }
.gal-comments__empty {
  margin: 0;
  padding: 6px 0;
  color: var(--gal-ink-soft);
  font-size: 0.84rem;
}
/* ── Card de comentario — estética editorial (Apple) ──────────────────────── */
.gal-comment {
  position: relative;
  overflow: hidden; /* la barra de acento respeta el radio del card */
  background: #fbfcff; /* off-white sutil, premium, sobre el card blanco contenedor */
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 14px;
  padding: 14px 16px 14px 18px; /* aire generoso; +izq por la barra de acento */
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
/* Barra de acento vertical (azul→turquesa institucional), fina y elegante. */
.gal-comment::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gal-action), var(--gal-accent));
}
/* Rótulos "Mensaje"/"Autor": tiny caps espaciadas y tenues (Apple labels). */
.gal-comment__label {
  display: block;
  margin: 0 0 4px 0;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gal-ink-soft);
  opacity: 0.6;
}
/* MENSAJE = protagonista: buen tamaño, peso medio, interlineado airoso. */
.gal-comment__text {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--gal-ink-strong);
  white-space: pre-wrap;
  word-break: break-word;
  padding-right: 60px; /* despeja lápiz + tacho */
}
/* Hairline divisorio entre MENSAJE y AUTOR. */
.gal-comment__divider {
  height: 1px;
  margin: 12px 0;
  background: rgba(15, 23, 42, 0.08);
}
/* Bloque AUTOR: avatar con inicial + nombre/fecha discretos. */
.gal-comment__author-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gal-comment__avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
  background: linear-gradient(135deg, var(--gal-action), var(--gal-accent));
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14);
  user-select: none;
}
.gal-comment__meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1px 6px;
  min-width: 0;
  font-size: 0.74rem;
  color: var(--gal-ink-soft);
}
.gal-comment__author { font-weight: 600; color: var(--gal-ink-soft); }
.gal-comment__date { color: var(--gal-ink-soft); opacity: 0.8; }
/* Herramientas (lápiz + tacho): juntas, esquina superior derecha; tocables. */
.gal-comment__tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: flex;
  gap: 2px;
}
.gal-comment__tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gal-ink-soft);
  opacity: 0.55;
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), color var(--gal-t-fast) var(--gal-ease), opacity var(--gal-t-fast) var(--gal-ease);
}
.gal-comment__tool svg { width: 15px; height: 15px; }
.gal-comment:hover .gal-comment__tool { opacity: 1; } /* realce en hover (desktop) */
/* Lápiz: realza a azul institucional; tacho: realza a rojo. */
.gal-comment__edit:hover { color: var(--gal-action); background: rgba(15, 95, 166, 0.08); opacity: 1; }
.gal-comment__edit:focus-visible { outline: none; opacity: 1; box-shadow: 0 0 0 3px rgba(15, 95, 166, 0.26); }
.gal-comment__del:hover { color: var(--gal-danger); background: rgba(185, 28, 28, 0.08); opacity: 1; }
.gal-comment__del:focus-visible { outline: none; opacity: 1; box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.28); }

/* ── Modo edición inline del comentario (coherente con la card editorial) ── */
.gal-comment__editfield {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--gal-ink-strong);
  background: #ffffff;
  border: 1px solid var(--gal-line);
  border-radius: 10px;
  padding: 8px 10px;
  transition: border-color var(--gal-t-fast) var(--gal-ease), box-shadow var(--gal-t-fast) var(--gal-ease);
}
.gal-comment__editfield:focus {
  outline: none;
  border-color: var(--gal-accent);
  box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.16);
}
.gal-comment__edittext {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  resize: vertical;
  min-height: 64px;
}
.gal-comment__editauthor { font-size: 0.85rem; }
.gal-comment__editactions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.gal-comment__editbtn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), color var(--gal-t-fast) var(--gal-ease), border-color var(--gal-t-fast) var(--gal-ease), opacity var(--gal-t-fast) var(--gal-ease);
}
.gal-comment__editbtn--cancel {
  color: var(--gal-ink-soft);
  background: transparent;
  border: 1px solid var(--gal-line);
}
.gal-comment__editbtn--cancel:hover { background: rgba(15, 23, 42, 0.04); color: var(--gal-ink-strong); }
.gal-comment__editbtn--save {
  color: #ffffff;
  background: var(--gal-action);
  border: 1px solid var(--gal-action);
}
.gal-comment__editbtn--save:hover:not(:disabled) { background: var(--gal-accent); border-color: var(--gal-accent); }
.gal-comment__editbtn--save:disabled { opacity: 0.5; cursor: not-allowed; }
.gal-comment__editbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.4); }
/* Formulario de comentario DESPLEGABLE: animación de alto con grid-rows 0fr→1fr
   (suave, sin max-height mágico). El form queda inert/clipeado cuando está cerrado. */
.gal-comment-formwrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--gal-t-med) var(--gal-ease);
}
.gal-comment-formwrap.is-open { grid-template-rows: 1fr; }
.gal-comment-form {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* separación del listado cuando está abierto, toda DENTRO de la caja clipeada
     (sin margin: evita que "asome" cuando el grid está colapsado a 0fr). */
  padding-top: 12px;
  border-top: 1px solid var(--gal-line);
}
.gal-comment-text {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--gal-line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--gal-ink-strong);
  background: #fff;
  transition: border-color var(--gal-t-fast) var(--gal-ease), box-shadow var(--gal-t-fast) var(--gal-ease);
}
.gal-comment-form__row { display: flex; gap: 8px; align-items: center; }
.gal-comment-author {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--gal-line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--gal-ink-strong);
  background: #fff;
  transition: border-color var(--gal-t-fast) var(--gal-ease), box-shadow var(--gal-t-fast) var(--gal-ease);
}
.gal-comment-text:focus,
.gal-comment-author:focus {
  outline: none;
  border-color: var(--gal-accent);
  box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.18);
}
.gal-comment-send {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(180deg, var(--gal-action) 0%, rgba(11, 95, 198, 0.62) 100%);
  transition: filter var(--gal-t-fast) var(--gal-ease);
}
.gal-comment-send:hover { filter: brightness(1.08); }
.gal-comment-send:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.gal-comment-send:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.35); }

/* ── Dots + contador "Imagen X de N" (misma zona, debajo de la imagen) ─────── */
.gal-dotsbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.gal-counter {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gal-ink-soft);
  font-variant-numeric: tabular-nums;
}
.gal-counter:empty { display: none; }
.gal-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.gal-dots:empty { margin-top: 0; }
.gal-dot {
  width: 9px;
  height: 9px;
  border: 0;
  padding: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: width var(--gal-t-fast) var(--gal-ease), background var(--gal-t-fast) var(--gal-ease);
}
.gal-dot.is-active { width: 22px; background: var(--gal-action); }
.gal-dot:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.4); }

/* ── Modales (Agregar imagen + Confirmar borrado) ─────────────────────────── */
/* Patrón espejado de notes-wall.css: backdrop fijo + diálogo con entrada. */
.gal-form-backdrop,
.gal-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(8, 30, 56, 0.46);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--gal-t-med) var(--gal-ease);
  font-family: inherit;
}
.gal-form-backdrop.is-open,
.gal-confirm-backdrop.is-open { opacity: 1; pointer-events: auto; }
.gal-form-backdrop[hidden],
.gal-confirm-backdrop[hidden] { display: none; }

.gal-form,
.gal-confirm {
  width: min(460px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(10, 50, 101, 0.3);
  padding: 22px;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--gal-t-med) var(--gal-ease);
}
.gal-form-backdrop.is-open .gal-form { transform: none; }
.gal-confirm { width: min(380px, 100%); }
.gal-confirm-backdrop.is-open .gal-confirm { transform: translateY(0) scale(1); }

.gal-form__title,
.gal-confirm__title {
  margin: 0 0 12px 0;
  font-size: 1.04rem;
  font-weight: 800;
  color: var(--gal-ink-strong);
}

/* Form de subida */
.gal-form form { display: flex; flex-direction: column; gap: 12px; }
.gal-file-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1.5px dashed rgba(15, 95, 166, 0.45);
  border-radius: 12px;
  background: rgba(42, 137, 230, 0.05);
  color: var(--gal-action);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), border-color var(--gal-t-fast) var(--gal-ease);
}
.gal-file-label:hover { background: rgba(42, 137, 230, 0.1); border-color: var(--gal-action); }
.gal-file-label input[type="file"] { display: none; }
.gal-file-label[hidden] { display: none; } /* oculto en modo edición */
.gal-file-icon { width: 22px; height: 22px; flex: 0 0 auto; }
.gal-file-text { min-width: 0; word-break: break-word; }

.gal-preview {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid var(--gal-line);
}
.gal-preview[hidden] { display: none; }
.gal-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: #f1f5f9;
}

.gal-form input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--gal-line);
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--gal-ink-strong);
  background: #fff;
  transition: border-color var(--gal-t-fast) var(--gal-ease), box-shadow var(--gal-t-fast) var(--gal-ease);
}
.gal-form input[type="text"]:focus {
  outline: none;
  border-color: var(--gal-accent);
  box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.18);
}

.gal-form-error {
  margin: -4px 0 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gal-danger);
}
.gal-form-error[hidden] { display: none; }

.gal-form-actions,
.gal-confirm__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.gal-form-actions button,
.gal-confirm__actions button {
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease), filter var(--gal-t-fast) var(--gal-ease),
    box-shadow var(--gal-t-fast) var(--gal-ease);
}
.gal-cancel,
.gal-confirm__cancel {
  background: rgba(45, 127, 208, 0.12);
  color: var(--gal-ink-strong);
}
.gal-cancel:hover,
.gal-confirm__cancel:hover,
.gal-cancel:focus-visible,
.gal-confirm__cancel:focus-visible { background: rgba(45, 127, 208, 0.2); outline: none; }
.gal-save {
  background: linear-gradient(180deg, var(--gal-action) 0%, rgba(11, 95, 198, 0.6) 100%);
  color: #ffffff;
}
.gal-save:hover { filter: brightness(1.08); }
.gal-save:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }
.gal-save:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.35); }
.gal-confirm__delete { background: var(--gal-danger); color: #ffffff; }
.gal-confirm__delete:hover { filter: brightness(1.08); }
.gal-confirm__delete:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.32); }

.gal-confirm__text {
  margin: 0 0 18px 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--gal-ink-soft);
}

/* Spinner mientras comprime/sube */
.gal-save.is-busy { position: relative; color: transparent; }
.gal-save.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: galSpin 0.7s linear infinite;
}
@keyframes galSpin { to { transform: rotate(360deg); } }

/* ── Lightbox (ampliar imagen: zoom/pan, navegación, fullscreen) ──────────── */
.gal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2400; /* sobre todo lo demás (modales de galería en 2300) */
  display: flex;
  background: rgba(8, 12, 20, 0.92);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--gal-t-med) var(--gal-ease);
}
.gal-lightbox.is-open { opacity: 1; pointer-events: auto; }
.gal-lightbox[hidden] { display: none; }
/* Stage: ocupa todo; la imagen se centra y se clipa al hacer zoom. */
.gal-lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none; /* gestionamos pan/pinch nosotros */
}
.gal-lightbox__img {
  max-width: 92vw;
  max-height: 84vh;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-out; /* un click cierra el lightbox (toggle) */
  transform-origin: center center;
  transition: transform 0.08s linear; /* respuesta fluida al zoom */
  will-change: transform;
}
/* Barra superior con controles. */
.gal-lightbox__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.55), rgba(8, 12, 20, 0));
}
.gal-lightbox__caption {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gal-lightbox__spacer { flex: 1 1 auto; }
.gal-lb-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease);
}
.gal-lb-btn[hidden] { display: none; }
.gal-lb-btn svg { width: 20px; height: 20px; display: block; }
.gal-lb-btn:hover { background: rgba(255, 255, 255, 0.22); }
.gal-lb-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.7); }
/* Flechas de navegación dentro del lightbox. */
.gal-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background var(--gal-t-fast) var(--gal-ease);
}
.gal-lb-nav[hidden] { display: none; }
.gal-lb-nav:hover { background: rgba(255, 255, 255, 0.22); }
.gal-lb-nav:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 137, 230, 0.7); }
.gal-lb-nav--prev { left: 14px; }
.gal-lb-nav--next { right: 14px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .gal-viewport { aspect-ratio: 4 / 3; max-height: none; }
  .gal-nav { width: 40px; height: 40px; opacity: 0.9; }
  /* MOBILE: imagen COMPLETA dentro del cajón (sin recorte) → contain para TODAS
     (horizontal o vertical), con franjas BLANCAS arriba/abajo (o a los costados).
     El tamaño del cajón NO cambia; solo el ajuste de la imagen adentro. */
  .gal-slide { background: #ffffff; }
  .gal-slide img,
  .gal-slide.vertical img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
  }
}
@media (max-width: 430px) {
  .gal-stage { gap: 10px; }
  .gal-viewport { aspect-ratio: 1 / 1; }
  /* La fila inferior envuelve: info+tacho en la 1ª línea, "+ Agregar" full-width abajo. */
  .gal-add { width: 100%; margin-left: 0; text-align: center; }
  /* Lightbox compacto en mobile (controles tocables, sin pisar la imagen). */
  .gal-lightbox__img { max-width: 96vw; max-height: 80vh; }
  .gal-lb-nav { width: 42px; height: 42px; }
  .gal-lb-nav--prev { left: 8px; }
  .gal-lb-nav--next { right: 8px; }
  .gal-lb-btn { width: 38px; height: 38px; }
  .gal-lightbox__caption { max-width: 48vw; }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .gal-root *,
  .gal-form-backdrop *,
  .gal-confirm-backdrop *,
  .gal-lightbox,
  .gal-lightbox *,
  .gal-form-backdrop,
  .gal-confirm-backdrop { transition: none !important; animation: none !important; }
}
