.ficha-gallery {
  display: grid;
  gap: clamp(.9rem, 2.5vw, 1.6rem);
  max-width: 62rem;
  margin: clamp(1.5rem, 4vw, 3.15rem) auto 0;
}

.ficha-carousel {
  min-width: 0;
  padding: clamp(.65rem, 2vw, 1.15rem);
  overflow: hidden;
  border: 1px solid #cddacb;
  border-radius: 20px;
  background: linear-gradient(145deg, #fffff9, #edf3e8);
  box-shadow: 0 15px 32px -25px #0e382990;
}

.ficha-carousel-header {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: .6rem;
  margin: 0 .12rem .65rem;
}

.ficha-carousel-header h3 {
  color: #193a2d;
  font-size: clamp(.94rem, 2.4vw, 1.23rem);
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
}

.ficha-controls:not([hidden]) { display: flex; gap: .35rem; }

.ficha-controls button,
.ficha-dialog-close {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  padding: 0 0 .16rem;
  border: 1px solid #a3baaa;
  border-radius: .65rem;
  background: #f9fcf5;
  color: #143c2c;
  font-size: 1.6rem;
  line-height: 1;
  transition: background-color 180ms ease, color 180ms ease;
}

.ficha-controls button:disabled { opacity: .44; }
.ficha-controls button:not(:disabled):hover,
.ficha-dialog-close:hover { background: #143c2c; color: #fffdf2; }

.ficha-carousel :is(button, a, .ficha-track):focus-visible,
.ficha-dialog-close:focus-visible {
  outline: 2px solid #985027;
  outline-offset: 2px;
}

.ficha-track {
  position: relative;
  display: grid;
  grid-auto-columns: 78%;
  grid-auto-flow: column;
  gap: .7rem;
  margin: 0;
  padding: .2rem .18rem .65rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: .18rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #749783 #e4eee0;
}

.ficha-item { min-width: 0; scroll-snap-align: start; }

.ficha-track[data-ficha-continuous] {
  scroll-behavior: auto;
  scroll-snap-type: none;
}

.ficha-link {
  display: flex;
  height: 100%;
  flex-direction: column;
  color: #16332a;
  overflow: hidden;
  border: 1px solid #d0dbcc;
  border-radius: 11px;
  background: #fff;
  text-decoration: none;
  box-shadow: 0 4px 10px -7px #09201995;
}

.ficha-link img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1012 / 1430;
  background: #fff;
  object-fit: contain;
}

.ficha-caption {
  display: grid;
  min-height: 3.25rem;
  flex: 1;
  place-items: center;
  padding: .5rem .35rem;
  border-top: 1px solid #dce7d9;
  background: #f4f8f0;
  font-size: clamp(.69rem, 1.7vw, .82rem);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.ficha-link:hover .ficha-caption { background: #e3f0e0; }

.ficha-dialog {
  position: fixed;
  max-width: min(95vw, 50rem);
  max-height: 95dvh;
  margin: auto;
  padding: .45rem;
  overflow: auto;
  border: 1px solid #a5b7a5;
  border-radius: 12px;
  background: #f6f9f3;
  color: #142e27;
  text-align: left;
}

.ficha-dialog::backdrop { background: #0a211be0; }
.ficha-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: .35rem; padding: .15rem .25rem .45rem; }
.ficha-dialog-header h3 { padding-inline-start: .25rem; font-size: clamp(.8rem, 2.5vw, 1rem); font-weight: 800; }
.ficha-dialog-close { flex: 0 0 auto; }
.ficha-dialog-image { display: block; width: auto; max-width: 100%; max-height: 82dvh; height: auto; margin: 0 auto; object-fit: contain; }

@media (min-width: 37rem) {
  .ficha-carousel-header { grid-template-columns: 1fr auto 1fr; }
  .ficha-carousel-header h3 { grid-column: 2; }
  .ficha-controls { justify-self: end; }
  .ficha-track { grid-auto-columns: 44%; }
}

@media (min-width: 56rem) {
  .ficha-track { grid-auto-columns: 30.6%; }
}

@media (prefers-reduced-motion: reduce) {
  .ficha-controls button, .ficha-dialog-close { transition: none; }
}
