  .ig-reels {
  --thumb-w: 140px;
  --thumb-h: 250px;
  --gap: 14px;
}

.ig-reels__track {
  overflow-x: auto;
  padding: 14px 6px;
  -webkit-overflow-scrolling: touch;
}

.ig-reels__inner {
  display: inline-flex;
  gap: var(--gap);
  min-width: 100%;
  justify-content: center; /* centre si pas assez */
  scroll-snap-type: x mandatory;
}

.ig-reels__track::-webkit-scrollbar { height: 8px; }
.ig-reels__track::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); border-radius: 8px; }

.ig-reels__item {
  flex: 0 0 auto;
  width: var(--thumb-w);
  height: var(--thumb-h);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  scroll-snap-align: start;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  background: #eee;
}

.ig-reels__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ig-reels__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
}

/* Modal */
.ig-reels-modal[aria-hidden="true"] { display: none; }
.ig-reels-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.ig-reels-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1;
}

.ig-reels-modal__panel {
  position: relative;
  width: min(440px, calc(100vw - 24px));
  height: min(780px, calc(100vh - 24px));
  margin: 12px auto;
  background: transparent;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 2; /* panel au-dessus du backdrop */
}

.ig-reels-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 26px;
  z-index: 3; /* au-dessus du panel */
}

.ig-reels-nav--prev { left: 18px; }
.ig-reels-nav--next { right: 18px; }

@media (max-width: 520px) {
  .ig-reels-nav--prev { left: 8px; }
  .ig-reels-nav--next { right: 8px; }
}

.ig-reels-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  color: #fff;
  font-size: 14px;
}

.ig-reels-modal__iglink {
  color: #fff;
  text-decoration: none;
  opacity: .9;
  font-size: 13px;
}

.ig-reels-modal__media {
  --v-left: 0px;
  --v-top: 0px;
  --v-w: 100%;
  --v-h: 100%;
  position: relative;
  flex: 1 1 auto;
  display: flex;
  min-height: 0; /* IMPORTANT pour éviter les débordements flex */
  align-items: center;
  justify-content: center;
  background: transparent;
}

.ig-reels-modal__video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: transparent;
}

.ig-reels-modal__top-right {
  position: absolute;
  top: calc(var(--v-top) + 14px);
  right: calc((100% - (var(--v-left) + var(--v-w))) + 14px);

  display: flex;
  flex-direction: column;   /* close au-dessus, son dessous */
  align-items: flex-end;    /* même bord droit */
  gap: 10px;

  z-index: 5;
}

/* Le X un poil plus gros */
.ig-reels-modal__close {
  font-size: 22px;
  line-height: 1;
}

.ig-reels-modal__cta {
  position: absolute;
  left: calc(var(--v-left) + (var(--v-w) / 2));
  bottom: auto;
  top: calc(var(--v-top) + var(--v-h) - 18px);
  transform: translate(-50%, -100%);
  z-index: 5;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 46px;
  padding: 0 22px;
  border-radius: 999px;

  background: var(--primary); /* rouge type CTA */
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .2px;
}

.ig-reels-modal__cta:hover {
  color:#fff;
  text-decoration: none;
}

/* petit hover desktop */
@media (hover: hover) and (pointer: fine) {
  .ig-reels-modal__cta:hover {
    filter: brightness(1.05);
  }
}

.ig-reels-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 1;
  padding: 0;
}

.ig-reels-btn svg {
  display: block;
}

.ig-reels__item { position: relative; }

.ig-reels__preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* ici on accepte le recadrage, c'est une vignette */
  display: none;
}

.ig-reels__item.is-previewing img {
  display: none;
}

.ig-reels__item.is-previewing .ig-reels__preview-video {
  display: block;
}

/* Zoom léger au hover (desktop) */
@media (hover: hover) and (pointer: fine) {
  .ig-reels__item {
    transition: transform .18s ease, box-shadow .18s ease;
    will-change: transform;
  }

  .ig-reels__item:hover {
    transform: scale(1.04);
    box-shadow: 0 10px 26px rgba(0,0,0,.22);
  }

  .ig-reels__item img,
  .ig-reels__preview-video {
    transition: transform .18s ease;
  }
}

@media (max-width: 520px) {
  .ig-reels-modal__panel {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    margin: 6px auto;
    border-radius: 14px;
  }
}
/* Desktop : panel quasi plein écran, marge 60px haut/bas */
@media (min-width: 521px) {
  .ig-reels-modal__panel {
    width: min(900px, calc(100vw - 40px));   /* largeur max raisonnable, ajuste si tu veux */
    height: calc(100vh - 120px);             /* 60px top + 60px bottom */
    margin: 60px auto;
  }

  /* La zone vidéo prend tout l'espace disponible */
  .ig-reels-modal__media {
    flex: 1 1 auto;
    min-height: 0;
  }
}