.library-gallery { position: relative; margin: 8px 0 20px; }
/* Controles ocultos temporalmente, pero conservados en el HTML. */
.library-gallery .gallery-modes,
.library-gallery .gallery-controls { display: none !important; }
.gallery-modes { display: flex; justify-content: center; gap: 18px; }
.gallery-modes button { min-height: 36px; padding: 0 4px; font-size: 12px; color: #555; }
.gallery-modes button[aria-pressed="true"] { color: #111; text-decoration: underline; text-underline-offset: 4px; }
.gallery-modes button:focus-visible { outline: 2px solid #3c4043; outline-offset: 2px; }
.gallery-announcement, .gallery-controls {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.gallery-controls:focus-within {
  z-index: 2; width: auto; height: auto; clip-path: none; inset: auto 8px 0 auto;
  display: flex; background: white;
}
.gallery-controls[hidden] { display: none; }
.gallery-controls button { width: 44px; height: 44px; display: grid; place-items: center; }
.gallery-controls button span {
  width: 10px; height: 10px; border-top: 1.5px solid; border-right: 1.5px solid;
  transform: rotate(45deg);
}
.gallery-controls button:first-child span { transform: rotate(-135deg); }
.gallery-controls button[aria-disabled="true"] { opacity: .4; }
.library-viewport {
  --gallery-start-offset: 40px;
  --slide-width: min(82vw, 400px);
  --slide-height: clamp(310px, 45svh, 390px);
  position: relative; display: flex; gap: 10px;
  padding: 24px 12px 20px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity; overscroll-behavior-x: contain;
}
.library-viewport[data-has-slides] { padding-right: calc(100% - var(--slide-width) - 12px); }
.library-gallery[data-mode="centered"] .library-viewport {
  --slide-width: min(46vw, 600px); --slide-height: clamp(300px, 48svh, 460px);
  gap: 0; padding-inline: calc((100% - var(--slide-width)) / 2); scroll-snap-type: none;
}
.library-gallery[data-mode="centered"] .perfume-wrapper { scroll-snap-align: center; scroll-margin-left: 0; }
.library-gallery[data-mode="centered"] .gallery-panel { transform-origin: center; transform: none; }
.library-gallery[data-mode="centered"] .is-centered { z-index: 1; }
.library-gallery[data-mode="centered"] .gallery-open { transform-origin: left center; }
.library-gallery[data-mode="centered"] .gallery-accords { left: 31.2%; width: 75%; max-width: 220px; }
.library-gallery[data-mode="centered"] .gallery-accords { opacity: 0; }
.library-gallery[data-mode="centered"] .is-centered .gallery-accords { opacity: 1; }
.library-viewport.is-dragging { scroll-snap-type: none; user-select: none; cursor: grabbing; }
.library-viewport.is-dragging button { cursor: grabbing; }
.perfume-wrapper {
  flex: 0 0 var(--slide-width); min-width: 0; scroll-snap-align: start;
  scroll-margin-left: 12px; view-timeline: --fragancia inline;
}
.gallery-panel {
  position: relative; height: var(--slide-height);
  transform-origin: left 94%;
  transform: perspective(1100px) rotateY(18deg) rotateZ(2deg);
}
.gallery-open {
  position: absolute; inset: 0 auto 0 -6%; width: 85%; height: 100%;
  display: flex; align-items: center; justify-content: center; z-index: 1;
}
.gallery-bottle {
  display: block; width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,.15)); pointer-events: none;
}
.gallery-bottle[hidden] { display: none; }
.gallery-accords {
  position: absolute; left: 53%; top: 50%; translate: 0 -50%;
  display: flex; flex-direction: column; width: 57%; pointer-events: none;
}
.gallery-accords .accord-bar { height: 18px; font-size: 11px; padding-right: 10px; }
.gallery-panel .fav-card-btn {
  position: absolute; right: 0; bottom: 2px; width: 44px; height: 44px;
  background: transparent; color: #5f6368;
}
.gallery-open:focus-visible, .gallery-controls button:focus-visible,
.gallery-panel .fav-card-btn:focus-visible, #perfume-drawer [data-action="close-details"]:focus-visible {
  outline: 2px solid #3c4043; outline-offset: -3px;
}
.gallery-message { flex: 1 0 100%; padding: 44px 18px; margin: 0; text-align: center; font-size: .9rem; }
@media (min-width: 800px) {
  .library-viewport { --slide-width: min(28vw, 390px); --slide-height: clamp(380px, 56svh, 480px); gap: 4px; }
  .library-gallery[data-mode="centered"] .library-viewport { --slide-width: min(40vw, 620px); --slide-height: clamp(380px, 58svh, 550px); }
}
@media (max-width: 639px) {
  .library-gallery[data-mode="centered"] .gallery-accords { max-width: 135px; }
  .library-gallery[data-mode="centered"] .gallery-accords .accord-bar { height: 13px; font-size: 8.5px; padding-right: 6px; }
}
@media (hover: hover) { .gallery-open { cursor: grab; } }
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .gallery-panel {
      animation: gallery-perspective auto linear both;
      animation-timeline: --fragancia;
    }
    .library-gallery[data-mode="centered"] .gallery-panel {
      animation: gallery-centered auto linear both;
      animation-timeline: --fragancia;
    }
    .library-gallery[data-mode="centered"] .gallery-accords {
      animation: gallery-accord-fade auto ease-in-out both;
      animation-timeline: --fragancia;
    }
    .library-gallery[data-mode="centered"] .gallery-open {
      animation: gallery-bottle-focus auto ease-in-out both;
      animation-timeline: --fragancia;
    }
  }
}
@keyframes gallery-accord-fade {
  0%, 25%, 75%, 100% { opacity: 0; }
  50% { opacity: 1; }
}
@keyframes gallery-bottle-focus {
  0%, 25%, 75%, 100% { transform: scale(1); }
  50% { transform: scale(.765); }
}
@keyframes gallery-centered {
  0% { transform: scale(.32); }
  50% { transform: scale(1); }
  100% { transform: scale(1.55); }
}
@keyframes gallery-perspective {
  0% { transform: perspective(1100px) rotateY(32deg) rotateZ(2deg) scale(.78); }
  100% { transform: perspective(1100px) rotateY(10deg) rotateZ(1deg) scale(1.16); }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-panel { transform: none; }
  #perfume-drawer, #drawer-backdrop { transition: none; }
}
@media print {
  .gallery-controls, .gallery-panel .fav-card-btn { display: none; }
  .library-viewport[data-has-slides] { display: grid; grid-template-columns: repeat(2, 1fr); overflow: visible; padding: 0; }
  .perfume-wrapper { break-inside: avoid; }
  .perfume-wrapper .gallery-panel { animation: none; transform: none; height: 220px; }
}

/* Vista clásica: proporciones y cuadrícula de la biblioteca original. */
.library-gallery[data-mode="classic"] { margin-bottom: 0; }
.library-gallery[data-mode="classic"] .gallery-controls {
  position: static; display: flex; justify-content: center; gap: 24px;
  width: auto; height: 44px; clip-path: none; overflow: visible; background: transparent;
}
.library-gallery[data-mode="classic"] .gallery-controls[hidden] { display: none; }
.library-gallery[data-mode="classic"] .library-viewport[data-has-slides] {
  display: grid; grid-template-columns: repeat(var(--classic-columns, 2), calc((100% - 12px) / 2));
  grid-template-rows: repeat(2, auto); gap: 12px; align-content: start; height: auto;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  padding: 2px 2px 8px; scroll-snap-type: x mandatory;
}
.library-gallery[data-mode="classic"][data-auto-align="false"] .library-viewport[data-has-slides] { scroll-snap-type: none; }
.library-gallery[data-mode="classic"] .library-viewport.is-dragging { scroll-snap-type: none; }
.library-gallery[data-mode="classic"] .perfume-wrapper {
  position: relative; width: 100%; max-width: none; padding: 6px;
  grid-column: var(--classic-column); grid-row: var(--classic-row); scroll-snap-align: none; scroll-margin-left: 0;
}
.library-gallery[data-mode="classic"] .perfume-wrapper:nth-child(4n + 1) { scroll-snap-align: start; }
.library-gallery[data-mode="classic"] .gallery-panel {
  display: flex; align-items: center; width: 100%; max-width: 408px; margin-inline: auto; height: auto; min-height: 150px;
  transform: none !important; animation: none !important;
}
.library-gallery[data-mode="classic"] .gallery-open {
  position: relative; inset: auto; flex: 0 0 85px; width: 85px; height: 150px;
  margin-right: -30px; z-index: 20; transform: none !important; animation: none !important;
}
.library-gallery[data-mode="classic"] .gallery-accords {
  position: relative; left: auto; top: auto; translate: none; flex: 1 1 auto;
  width: 100%; max-width: 135px; margin-left: -4px; z-index: 10;
  opacity: 1 !important; animation: none !important;
}
.library-gallery[data-mode="classic"] .gallery-accords .accord-bar {
  height: 15px; font-size: 9.5px; padding-left: 4px; padding-right: 6px;
}
.library-gallery[data-mode="classic"] .gallery-panel .fav-card-btn { right: -2px; bottom: -2px; z-index: 30; }
@media (min-width: 640px) {
  .library-gallery[data-mode="classic"] .gallery-panel { min-height: 220px; }
  .library-gallery[data-mode="classic"] .gallery-open { flex-basis: 130px; width: 130px; height: 220px; margin-right: -50px; }
  .library-gallery[data-mode="classic"] .gallery-accords { max-width: 220px; margin-left: -8px; }
  .library-gallery[data-mode="classic"] .gallery-accords .accord-bar { height: 18px; font-size: 11px; padding-right: 10px; }
}
@media print {
  .gallery-modes { display: none; }
  .library-gallery[data-mode="classic"] .gallery-controls { display: none; }
  .library-gallery[data-mode="classic"] .library-viewport[data-has-slides] {
    grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none;
    overflow: visible; height: auto; padding: 0;
  }
  .library-gallery[data-mode="classic"] .perfume-wrapper { grid-column: auto; grid-row: auto; }
}
