/* Fade-in al entrar desde el CTA del hero */
  html.gallery-fade-in .gallery {
    animation: galleryFadeIn 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  @keyframes galleryFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .gallery {
    min-height: 0;
    background: #ffffff;
    /* Justo bajo la topbar fija (JS pone --mad-topbar-h); sin hueco extra */
    padding-top: var(--mad-topbar-h, 5rem);
    transition: opacity 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  @media (max-width: 1119px) {
    .gallery {
      overflow-x: hidden;
    }
  }

  .gallery__error {
    color: #b54a3d;
    font-size: 0.9rem;
    padding: 2rem 0;
  }

  .gallery__empty {
    padding: 4rem 0;
    text-align: center;
    color: var(--warm-600);
  }

  .gallery__empty-hint {
    font-size: 0.9rem;
    margin-top: 0.5rem;
  }

  .gallery__empty a {
    color: #E07B39;
    text-decoration: underline;
  }

  .gallery__layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
  }

  @media (min-width: 1120px) {
    .gallery__layout {
      grid-template-columns: 240px 1fr;
      gap: 0;
    }
  }

  .gallery__sidebar {
    padding: 1.25rem var(--px) 0;
    border-bottom: 1px solid rgba(45, 11, 61, 0.08);
  }

  @media (min-width: 1120px) {
    .gallery__sidebar {
      padding: 1.25rem 0 0 var(--px);
      border-bottom: none;
      border-right: none;
    }
  }

  .gallery__filters-check {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  .gallery__filters-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #2d0b3d;
    background: transparent;
    border: 1px solid rgba(45, 11, 61, 0.2);
    cursor: pointer;
    margin-bottom: 1rem;
  }

  .gallery__filters-toggle:hover {
    color: #e07b39;
    border-color: #e07b39;
  }

  .gallery__sidebar-inner {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 1.15rem;
    align-items: center;
  }

  @media (max-width: 1119px) {
    .gallery__filters-toggle {
      display: none;
    }

    /*
     * No usar aside a pantalla completa (fixed + inset:0): en iOS/WebKit a veces intercepta
     * scroll o toques aunque tenga pointer-events:none. Solo el backdrop y el panel van fixed al abrir.
     */
    .gallery__sidebar {
      position: static;
      inset: auto;
      z-index: auto;
      padding: 0;
      border: none;
      background: transparent;
      pointer-events: none;
      display: block;
      width: 100%;
      min-height: 0;
    }

    /* Por encima de .topbar (1000) y del float de WhatsApp (1500), por debajo del menú móvil (1998) y SearchOverlay (2000). */
    .gallery__filters-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 1600;
      background: rgba(26, 22, 18, 0.35);
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.25s, visibility 0.25s;
      pointer-events: none;
      cursor: pointer;
    }

    .gallery__filters-check:checked ~ .gallery__filters-backdrop {
      display: block;
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    .gallery__sidebar-inner {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 1601;
      width: 100%;
      max-width: 100vw;
      max-height: 85vh;
      overflow-x: hidden;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      background: var(--cantera, #ffffff);
      padding: 1.5rem var(--px) 2rem;
      padding-top: calc(var(--mad-topbar-h, 5.5rem) + 0.5rem);
      display: none;
      flex-direction: column;
      flex-wrap: nowrap;
      flex-flow: column nowrap;
      align-items: stretch;
      box-shadow: 0 12px 40px rgba(45, 11, 61, 0.12);
      border-radius: 0 0 20px 20px;
      border: none;
      border-bottom: 1px solid rgba(45, 11, 61, 0.08);
      transform: translateY(-100%);
      transition: transform 0.3s ease;
      pointer-events: auto;
      box-sizing: border-box;
    }

    .gallery__filters-check:checked ~ .gallery__sidebar-inner {
      display: flex !important;
      transform: translateY(0);
    }

    .gallery__sidebar-inner .gallery__filter {
      flex: 0 0 auto;
      flex-basis: 100%;
      min-width: 0;
      width: 100%;
      max-width: 100%;
      display: block;
      overflow: visible;
    }

    .gallery__sidebar-inner .gallery__filter-content-inner {
      overflow-x: hidden;
      min-width: 0;
    }

    .gallery__sidebar-inner .gallery__sort {
      min-width: 0;
    }

    .gallery__sidebar-inner .gallery__filter-options {
      overflow-x: hidden;
      min-width: 0;
    }

    .gallery__filters-close {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      padding-bottom: 1rem;
      margin-bottom: 1rem;
      border-bottom: 1px solid rgba(45, 11, 61, 0.1);
      font-size: 0.8rem;
      font-weight: 600;
      color: #2d0b3d;
      cursor: pointer;
    }

    .gallery__filters-close:hover {
      color: #e07b39;
    }
  }

  @media (min-width: 1120px) {
    .gallery__filters-toggle {
      display: none;
    }

    .gallery__filters-check {
      display: none;
    }

    .gallery__sidebar {
      position: static;
      inset: auto;
      z-index: auto;
      padding: 1.25rem 0 0 var(--px);
      border-bottom: none;
      border-right: none;
      background: transparent;
      pointer-events: auto;
    }

    .gallery__filters-backdrop {
      display: none !important;
    }

    .gallery__sidebar-inner {
      position: relative;
      transform: none;
      display: flex !important;
      flex-direction: column;
      flex-wrap: nowrap;
      align-items: stretch;
      gap: 1.15rem;
      max-height: min(90dvh, calc(100dvh - 6rem));
      overflow-y: auto;
      overflow-x: hidden;
      padding: 0.75rem 0.5rem 1rem 0;
      border-radius: 0;
      background: transparent;
      border: none;
      box-shadow: none;
    }

    .gallery__sidebar-inner .gallery__filter {
      flex: 0 0 auto;
      width: 100%;
      min-width: 0;
    }

    .gallery__sidebar-inner .gallery__filter-content-inner {
      overflow-x: hidden;
      min-width: 0;
    }

    .gallery__sidebar-inner .gallery__filter-options {
      flex-wrap: nowrap;
      flex-direction: column;
    }

    .gallery__sidebar-inner .gallery__sort {
      min-width: 0;
    }

    .gallery__filters-close {
      display: none !important;
    }
  }

  .gallery__sort {
    flex: 1;
    min-width: 160px;
  }

  .gallery__sort-row > .gallery__sort {
    flex: 0 1 auto;
    min-width: 0;
  }

  .gallery__sort-label {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.6rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #2D0B3D;
    opacity: 0.6;
    margin-bottom: 0.4rem;
  }

  .gallery__sort-details {
    position: relative;
    width: 100%;
    min-width: 0;
  }

  .gallery__sort-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem 0.8rem;
    padding-right: 0.65rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.35;
    font-weight: 500;
    color: #2d0b3d;
    background: #ffffff;
    border: 1px solid rgba(45, 11, 61, 0.2);
    border-radius: 0;
    list-style: none;
    cursor: pointer;
  }

  .gallery__sort-summary:focus {
    outline: none;
  }

  .gallery__sort-summary:focus-visible {
    outline: 2px solid #e07b39;
    outline-offset: 2px;
  }

  .gallery__sort-summary::-webkit-details-marker {
    display: none;
  }

  .gallery__sort-summary::marker {
    content: '';
  }

  .gallery__sort-current {
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .gallery__sort-chevron {
    flex-shrink: 0;
    display: flex;
    opacity: 0.85;
    line-height: 0;
    transition: transform 0.2s ease;
  }

  .gallery__sort-details[open] .gallery__sort-chevron {
    transform: rotate(180deg);
  }

  .gallery__sort-panel {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 80;
    margin: 0;
    padding: 0.35rem 0;
    background: #ffffff;
    border: 1px solid rgba(45, 11, 61, 0.22);
    box-shadow: 0 10px 28px rgba(45, 11, 61, 0.12);
    box-sizing: border-box;
  }

  .gallery__sort-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.45rem 0.85rem;
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.35;
    font-weight: 400;
    color: #2d0b3d;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .gallery__sort-option:hover {
    background: rgba(45, 11, 61, 0.06);
  }

  .gallery__sort-option input {
    accent-color: #e07b39;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
  }

  .gallery__filter {
    width: 100%;
  }

  .gallery__filter-trigger {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    min-height: 44px;
    padding: 0.6rem 0;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: #2d0b3d;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
  }

  .gallery__filter-trigger:hover {
    color: #e07b39;
  }

  .gallery__filter-icon {
    display: flex;
    opacity: 0.7;
  }

  .gallery__filter-plus {
    margin-left: auto;
    font-size: 1rem;
    font-weight: 300;
    opacity: 0.6;
  }

  .gallery__filter-content {
    display: grid;
    grid-template-rows: 0fr;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overflow: clip;
    min-height: 0;
    transition: grid-template-rows 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .gallery__filter-content:not(.is-collapsed) {
    grid-template-rows: 1fr;
    overflow: visible;
  }

  .gallery__filter-content.is-collapsed {
    pointer-events: none;
    margin-bottom: 0;
    overflow: hidden;
  }

  .gallery__filter-content-inner {
    min-height: 0;
    overflow: hidden;
    padding: 0.5rem 0 0.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: padding 0.45s cubic-bezier(0.22, 1, 0.36, 1), gap 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .gallery__filter-content:not(.is-collapsed) .gallery__filter-content-inner {
    overflow: visible;
  }

  /* Igual que antes del acordeón en grid: sin padding vertical si está cerrado (evita asomar inputs). */
  .gallery__filter-content.is-collapsed .gallery__filter-content-inner {
    padding-top: 0;
    padding-bottom: 0;
    gap: 0;
  }

  .gallery__filter[data-filter="sort"] .gallery__filter-content-inner {
    padding-left: 0;
  }

  .gallery__filter[data-filter="sort"] .gallery__sort-label {
    margin-bottom: 0.5rem;
  }

  .gallery__filter-search {
    width: 100%;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: #2d0b3d;
    background: transparent;
    border: 1px solid rgba(45, 11, 61, 0.2);
    outline: none;
    transition: border-color 0.2s;
  }

  .gallery__filter-search::placeholder {
    color: rgba(45, 11, 61, 0.4);
  }

  .gallery__filter-search:focus {
    border-color: #e07b39;
  }

  .gallery__filter-price-hint {
    margin: 0 0 0.65rem;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    line-height: 1.35;
    color: rgba(45, 11, 61, 0.55);
  }

  .gallery__filter-price-fields {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  .gallery__filter-price-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .gallery__filter-price-label {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 500;
    color: #2d0b3d;
  }

  .gallery__filter-search--price {
    margin-bottom: 0;
  }

  .gallery__filter-dim-subtitle {
    margin: 0.75rem 0 0.35rem;
    font-family: var(--font-sans);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(45, 11, 61, 0.75);
  }

  .gallery__filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow: visible;
  }

  .gallery__filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.25rem 0;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    color: #2d0b3d;
    cursor: pointer;
  }

  .gallery__filter-option.is-active {
    color: #e07b39;
  }

  .gallery__filter-option input {
    accent-color: #e07b39;
  }

  .gallery__filter-option--color-db {
    gap: 0.5rem;
  }

  .gallery__filter-options--colors {
    max-height: min(42vh, 280px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;
    margin-right: -0.25rem;
    scrollbar-gutter: stable;
  }

  /* Lista larga de artistas: scroll interno; el resto de filtros abre a altura completa */
  .gallery__filter[data-filter='artist'] .gallery__filter-options {
    max-height: min(52vh, 360px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.25rem;
    margin-right: -0.25rem;
    scrollbar-gutter: stable;
  }

  .gallery__main {
    padding: 1rem var(--px) 6rem;
  }

  @media (max-width: 1119px) {
    .gallery__main {
      padding-top: 0;
    }
  }

  @media (min-width: 1120px) {
    .gallery__main {
      padding: 1.25rem var(--px) 8rem;
    }
  }

  .gallery__header {
    margin-bottom: 3rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem 1rem;
  }

  .gallery__header-titles {
    flex: 1 1 12rem;
    min-width: 0;
  }

  @media (max-width: 1119px) {
    .gallery__header {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-rows: auto auto;
      column-gap: 0.75rem;
      row-gap: 0.85rem;
      align-items: start;
    }

    .gallery__header-titles {
      grid-column: 1;
      grid-row: 1;
      flex: none;
    }

    .gallery__filters-icon-btn {
      grid-column: 2;
      grid-row: 1;
      justify-self: end;
      align-self: start;
    }

    .gallery__header-tools {
      grid-column: 1 / -1;
      grid-row: 2;
      justify-self: stretch;
      width: 100%;
      margin-left: 0;
    }
  }

  @media (min-width: 1120px) {
    .gallery__header-tools {
      margin-left: auto;
    }
  }

  .gallery__header-tools {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0;
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
  }

  .gallery__sort-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
  }

  .gallery__sort-select-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
  }

  .gallery__sort-field {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    align-items: stretch;
  }

  .gallery__sort--header .gallery__layout-cluster {
    align-items: flex-start;
  }

  .gallery__sort--header .gallery__sort-details {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
  }

  .gallery__sort--header .gallery__sort-summary {
    box-sizing: border-box;
    height: var(--gallery-controls-h);
    min-height: var(--gallery-controls-h);
    padding-top: 0;
    padding-bottom: 0;
    align-items: center;
  }

  .gallery__layout-cluster {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
    /* Evita que el flex comprima el grupo por debajo del ancho real de los botones (recorte con overflow:hidden del grupo). */
    min-width: max-content;
  }

  .gallery__layout-stack {
    flex-direction: column;
    flex-shrink: 0;
  }

  .gallery__layout-stack--mobile {
    display: none;
    align-items: flex-start;
  }

  @media (max-width: 1119px) {
    .gallery__layout-stack--mobile {
      display: flex;
    }
  }

  /* Escritorio (3|4): como antes; oculto en móvil (ahí va 1|2) */
  .gallery__layout-stack:not(.gallery__layout-stack--mobile) {
    display: none;
    align-items: flex-end;
  }

  @media (min-width: 1120px) {
    .gallery__layout-stack:not(.gallery__layout-stack--mobile) {
      display: flex;
    }
  }

  .gallery__layout-group {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    width: fit-content;
    border: 1px solid rgba(0, 0, 0, 0.18);
    overflow: hidden;
    font-family: var(--font-sans);
  }

  .gallery__layout-btn {
    margin: 0;
    box-sizing: border-box;
    width: 2.625rem;
    height: 2.625rem;
    aspect-ratio: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #111;
    background: #ffffff;
    border: none;
    border-right: 1px solid rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .gallery__layout-btn:last-child {
    border-right: none;
  }

  .gallery__layout-btn:hover {
    color: #e07b39;
  }

  .gallery__layout-btn.is-active {
    background: #111;
    color: #ffffff;
  }

  .gallery__layout-btn.is-active:hover {
    color: #ffffff;
  }

  .gallery__sort--header {
    --gallery-controls-h: 2.25rem;
    min-width: 0;
    flex: 1 1 auto;
    width: 100%;
    max-width: min(100%, 36rem);
  }

  /* Misma caja exterior que el select (borde 1px del grupo); botones cuadrados al alto interno */
  .gallery__sort--header .gallery__layout-group {
    box-sizing: border-box;
    height: var(--gallery-controls-h);
    align-items: stretch;
  }

  .gallery__sort--header .gallery__layout-btn {
    box-sizing: border-box;
    flex: 0 0 var(--gallery-controls-h);
    width: var(--gallery-controls-h);
    min-width: var(--gallery-controls-h);
    height: var(--gallery-controls-h);
    min-height: var(--gallery-controls-h);
    align-self: center;
    font-size: 0.72rem;
  }

  @media (min-width: 1120px) {
    .gallery__sort--header {
      min-width: min(100%, 28rem);
    }

    .gallery__sort--header .gallery__layout-stack:not(.gallery__layout-stack--mobile) {
      align-items: flex-start;
    }
  }

  /* Misma tipografía e interlineado para "Ordenar por" y "Disposición" (misma fila de título) */
  .gallery__sort--header .gallery__sort-label {
    font-size: 0.68rem;
    line-height: 1.25;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
  }

  .gallery__filters-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    color: #e07b39;
    cursor: pointer;
    padding: 0;
    background: transparent;
    border: none;
    margin-top: 0.25rem;
  }

  .gallery__filters-icon-btn:hover {
    color: #c96a2f;
  }

  .gallery__filters-icon-btn svg {
    width: 24px;
    height: 24px;
  }

  @media (min-width: 1120px) {
    .gallery__filters-icon-btn {
      display: none;
    }
  }

  .gallery__label {
    font-family: var(--font-sans);
    font-size: 0.65rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: rgba(45, 11, 61, 0.5);
    margin-bottom: 0.5rem;
  }

  .gallery__title {
    font-family: 'Google Sans', sans-serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    color: #E07B39;
    line-height: 1.1;
    margin-bottom: 0.5rem;
  }

  .gallery__count {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: rgba(45, 11, 61, 0.5);
  }

  /* Rejilla y cards: `gallery-grid-cards.css` (global; el island React no recibe el scope de Astro) */
