.template-stage {
  padding-top: clamp(22px, 2.5vw, 32px);
  padding-bottom: 24px;
}

.template-stage .stage-head {
  max-width: 720px;
}

.template-stage h1 {
  font-size: clamp(34px, 4.2vw, 50px);
}

.template-stage .lead {
  margin-top: 9px;
}

.gallery-change {
  margin: 12px 0 0;
  border: 0;
  padding: 2px 0;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: #d4cddd;
  text-underline-offset: 4px;
  transition: color 200ms ease, transform 200ms ease;
}

.gallery-change:hover {
  color: var(--violet);
}

.gallery-change:focus-visible,
.gallery-filters button:focus-visible,
.flyer-row-head button:focus-visible,
.flyer-tile:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.22);
  outline-offset: 4px;
}

.gallery-filters {
  display: flex;
  gap: clamp(22px, 2.4vw, 34px);
  margin-top: clamp(24px, 3vw, 34px);
  overflow-x: auto;
  border-bottom: 1px solid #ece8ef;
  scrollbar-width: none;
}

.gallery-filters::-webkit-scrollbar {
  display: none;
}

.gallery-filters button {
  position: relative;
  flex: none;
  border: 0;
  padding: 0 0 12px;
  color: #7b7580;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  transition: color 180ms ease;
}

.gallery-filters button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--violet);
  content: "";
  opacity: 0;
  transform: scaleX(0.55);
  transition: opacity 180ms ease, transform 180ms ease;
}

.gallery-filters button:hover,
.gallery-filters button.is-active {
  color: var(--ink);
}

.gallery-filters button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.flyer-wall {
  width: 100%;
  margin-top: 0;
  overflow: hidden;
  padding-bottom: 12px;
  background: #fff;
}

.flyer-row {
  --flyer-width: clamp(180px, 13vw, 200px);
  --flyer-gap: clamp(14px, 1.25vw, 18px);
  padding-top: clamp(22px, 2.5vw, 30px);
}

.flyer-row:last-child {
  padding-bottom: clamp(20px, 2.4vw, 30px);
}

.flyer-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 15px;
}

.flyer-row h2 {
  margin: 0;
  color: #312d36;
  font-size: clamp(16px, 1.2vw, 18px);
  font-weight: 650;
  letter-spacing: -0.015em;
}

.flyer-row-head span,
.flyer-row-head button {
  flex: none;
  border: 0;
  padding: 0;
  color: #807985;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
}

.flyer-row-head button:hover {
  color: var(--violet);
}

.flyer-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 24px), transparent 100%);
}

.flyer-viewport::-webkit-scrollbar {
  display: none;
}

.flyer-track {
  display: flex;
  width: max-content;
  transform: translate3d(0, 0, 0);
  animation: flyer-wall-scroll var(--row-duration) linear infinite;
}

.flyer-row-right .flyer-track {
  animation-direction: reverse;
}

.flyer-group {
  display: flex;
  flex: none;
  gap: var(--flyer-gap);
  align-items: flex-start;
  padding-right: var(--flyer-gap);
}

.flyer-tile {
  position: relative;
  display: block;
  width: var(--flyer-width);
  flex: 0 0 var(--flyer-width);
  overflow: visible;
  border: 0;
  border-radius: 10px;
  padding: 0;
  color: inherit;
  background: transparent;
  box-shadow: 0 7px 20px rgba(47, 39, 57, 0.09);
  transition: transform 220ms ease, box-shadow 220ms ease;
  scroll-snap-align: start;
}

.flyer-tile img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #f0edef;
  object-fit: contain;
  image-rendering: auto;
  pointer-events: none;
  user-select: none;
}

.flyer-tile.is-selected {
  z-index: 2;
  border-radius: 10px;
  opacity: 1 !important;
  box-shadow: 0 0 0 2px var(--violet), 0 10px 28px rgba(73, 43, 110, 0.17);
}

.flyer-choose {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: rgba(24, 21, 29, 0.94);
  box-shadow: 0 7px 18px rgba(24, 21, 29, 0.18);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.flyer-check {
  position: absolute;
  z-index: 3;
  top: 6px;
  right: 6px;
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  color: #fff;
  background: var(--violet);
  box-shadow: 0 3px 10px rgba(53, 28, 82, 0.22);
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 180ms ease, transform 180ms ease;
}

.flyer-tile.is-selected .flyer-check {
  opacity: 1;
  transform: scale(1);
}

.flyer-row.is-user-controlled .flyer-track {
  animation: none;
  transform: none;
  will-change: auto;
}

.flyer-row.is-filtered .flyer-track {
  animation: none;
  transform: none;
  will-change: auto;
}

.gallery-actions {
  width: min(100%, 1180px);
  margin: 28px auto 0;
}

.gallery-actions .primary {
  min-width: 220px;
}

@keyframes flyer-wall-scroll {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(-1 * var(--marquee-distance)), 0, 0); }
}

@media (hover: hover) and (pointer: fine) {
  .flyer-viewport:hover .flyer-track {
    animation-play-state: paused;
  }

  .flyer-tile:hover {
    z-index: 3;
    opacity: 1;
    box-shadow: 0 13px 32px rgba(47, 39, 57, 0.17);
    transform: translateY(-5px);
  }

  .flyer-tile:hover .flyer-choose {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 680px) {
  html,
  body {
    overflow-x: hidden;
  }

  .template-stage {
    padding-top: 22px;
    padding-bottom: 98px;
  }

  .template-stage h1 {
    font-size: clamp(34px, 10vw, 42px);
  }

  .template-stage .kicker {
    margin-bottom: 9px;
  }

  .template-stage .lead {
    margin-top: 9px;
    font-size: 15px;
  }

  .gallery-change {
    margin-top: 11px;
  }

  .gallery-filters {
    gap: 24px;
    margin-top: 22px;
    margin-right: -14px;
    padding-right: 14px;
  }

  .gallery-filters button {
    padding-bottom: 11px;
    font-size: 13px;
  }

  .flyer-row {
    --flyer-width: clamp(174px, 48vw, 194px);
    --flyer-gap: 12px;
    padding-top: 22px;
  }

  .flyer-row-head {
    margin-bottom: 12px;
  }

  .flyer-row h2 {
    font-size: 15px;
    font-weight: 650;
  }

  .flyer-row-head span,
  .flyer-row-head button {
    font-size: 12px;
  }

  .flyer-track {
    animation-duration: calc(var(--row-duration) * 0.82);
  }

  .flyer-viewport {
    margin-right: -14px;
    padding-right: 14px;
    scroll-snap-type: x mandatory;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 14px), transparent 100%);
  }

  .flyer-tile,
  .flyer-tile img {
    border-radius: 9px;
  }

  .flyer-check {
    top: 5px;
    right: 5px;
    width: 19px;
    height: 19px;
    font-size: 10px;
  }

  .flyer-choose {
    display: none;
  }

  .gallery-actions {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    margin: 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.96) 24%, #fff 50%);
    pointer-events: none;
  }

  .gallery-actions .primary {
    width: 100%;
    min-height: 58px;
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(79, 39, 132, 0.2);
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flyer-track {
    animation: none;
    transform: none;
  }

  .flyer-viewport {
    overflow-x: auto;
  }
}
