.p2vr-gallery{
  display: grid;
  grid-template-columns: repeat(var(--p2vr-cols-desktop, 4), minmax(0, 1fr));
  gap: var(--p2vr-gap, 12px);
}

@media (max-width: 640px){
  .p2vr-gallery{ grid-template-columns: repeat(var(--p2vr-cols-mobile, 3), minmax(0, 1fr)); }
}

.p2vr-thumbwrap{ display:flex; flex-direction:column; gap: 6px; }

.p2vr-thumbwrap.p2vr-hidden{ display:none !important; }

.p2vr-filterbar{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.p2vr-filter{
  border: 0;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
  color: inherit;
  font-size: 14px;
  line-height: 1;
}

.p2vr-filter.is-active{
  background: rgba(0,0,0,.12);
}

.p2vr-thumb{
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: block;
  position: relative;
}

.p2vr-thumb img{
  width: 100%;
  display: block;
  border-radius: var(--p2vr-thumb-radius, 10px);
  height: var(--p2vr-thumb-h, auto) !important;
  object-fit: cover;
}

.p2vr-thumb::after{
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--p2vr-thumb-radius, 10px);
  background: var(--p2vr-hover-color, #000000);
  opacity: 0;
  transition: opacity var(--p2vr-hover-fade, 160ms) ease;
  pointer-events: none;
}

.p2vr-thumb:hover::after,
.p2vr-thumb:focus-visible::after{
  opacity: var(--p2vr-hover-opacity, 0.25);
}

.p2vr-thumbtitle{
  text-align: center;
  font-size: var(--p2vr-thumb-title-size, 14px);
  color: var(--p2vr-thumb-title-color, #111);
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--p2vr-thumb-title-bg, transparent);
  line-height: 1.2;
  word-break: break-word;
}

.p2vr-modal-open{
  overflow: hidden !important;
}

.p2vr-modal{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483647 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p2vr-modal[hidden]{
  display: none !important;
}

.p2vr-modal__overlay{
  position: absolute;
  inset: 0;
  background: var(--p2vr-overlay-color, #000000);
  opacity: var(--p2vr-overlay-opacity, 0.65);
}

/*
  Shell holds the popup panel (iframe) and the caption below.
  Caption is OUTSIDE the iframe area and does not affect iframe sizing.
*/
.p2vr-modal__shell{
  position: relative;
  z-index: 1;
  width: min(var(--p2vr-modal-max-width, 1100px), var(--p2vr-modal-width, 92vw));
  margin: 0;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.p2vr-modal__topbar{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: var(--p2vr-topbar-mb, 8px);
  position: relative;
  z-index: 60;
}

.p2vr-modal__panel{
  position: relative;
  width: 100%;
  height: min(
    var(--p2vr-modal-max-height, 700px),
    var(--p2vr-modal-height, 82vh),
    calc(100vh - var(--p2vr-safe-top, 88px) - var(--p2vr-safe-bottom, 88px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
  );
  border-radius: var(--p2vr-iframe-radius, 16px);
  overflow: visible;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
  display:flex;
  flex-direction: column;
}

@media (max-width: 640px){
  .p2vr-modal__shell{
    width: min(var(--p2vr-modal-max-width-mobile, 96vw), var(--p2vr-modal-width-mobile, 96vw));
  }
  .p2vr-modal__panel{
    height: min(
      var(--p2vr-modal-max-height-mobile, 86vh),
      var(--p2vr-modal-height-mobile, 86vh),
      calc(100vh - var(--p2vr-safe-top, 88px) - var(--p2vr-safe-bottom, 88px) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))
    );
  }
}

.p2vr-modal__inner{
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  border-radius: var(--p2vr-iframe-radius, 16px);
  box-sizing: border-box;
  border: var(--p2vr-iframe-border-width, 0px) solid var(--p2vr-iframe-border-color, #000000);
  overflow: hidden;
  background: #111;
}

.p2vr-loaderwrap{
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.p2vr-loader{
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 3px solid var(--p2vr-loader-color, #ffffff);
  border-top-color: transparent;
  animation: p2vrspin 0.8s linear infinite;
  box-sizing: border-box;
  opacity: 0.9;
}

@keyframes p2vrspin{
  from{ transform: rotate(0deg); }
  to{ transform: rotate(360deg); }
}

.p2vr-caption{
  text-align:center;
  font-size: var(--p2vr-popup-caption-size, 16px);
  color: var(--p2vr-popup-caption-color, #fff);
  padding: 10px 12px;
  background: var(--p2vr-popup-caption-bg, transparent);
  border-radius: 12px;
  line-height: 1.2;
  margin-top: 10px;
}

.p2vr-close{
  position: relative;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 0;
  cursor: pointer;
  background: var(--p2vr-close-bg, #ffffff);
  border-radius: var(--p2vr-close-radius, 999px);
  color: var(--p2vr-close-color, #111111);
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
padding-bottom: 5px;
}

.p2vr-nav{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  width: 44px;
  height: 44px;
  border: 0;
  cursor: pointer;
  background: var(--p2vr-nav-bg, rgba(255,255,255,.92));
  color: var(--p2vr-nav-color, #111);
  font-size: 34px;
  line-height: 1;
  border-radius: var(--p2vr-nav-radius, 99px);
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
padding-bottom: 6px;
}

.p2vr-nav--prev{ left: -56px; }
.p2vr-nav--next{ right: -56px; }

@media (max-width: 640px){
  .p2vr-nav--prev{ left: -12px; }
  .p2vr-nav--next{ right: -12px; }
}

.p2vr-iframe{
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}


/* YouTube API player container (used for YouTube-only gallery loop mode) */
.p2vr-ytwrap{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.p2vr-ytwrap[hidden]{
  display: none !important;
}
.p2vr-ytplayer{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.p2vr-ytplayer iframe{
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  display: block !important;
}
