:root {
  --ms-gallery-gap: 12px;
  --ms-gallery-radius: 14px;
}

.ms-gallery {
  --ms-gallery-columns: 4;
  padding: 0;
}

.ms-gallery--custom-cols {
  --ms-gallery-cols: 4;
  --ms-gallery-cols-mobile: 2;
}

.ms-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ms-gallery-gap);
}

.ms-gallery--custom-cols .ms-gallery-grid {
  grid-template-columns: repeat(var(--ms-gallery-cols, 4), minmax(0, 1fr));
}

.ms-gallery[data-columns="2"] .ms-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ms-gallery[data-columns="3"] .ms-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ms-gallery[data-columns="4"] .ms-gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ms-gallery[data-columns="5"] .ms-gallery-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ms-gallery[data-columns="6"] .ms-gallery-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 1024px) {
  .ms-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .ms-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .ms-gallery--custom-cols .ms-gallery-grid {
    grid-template-columns: repeat(var(--ms-gallery-cols-mobile, 2), minmax(0, 1fr));
  }
}

.ms-gallery--slider .ms-gallery-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow: visible;
  overflow-y: hidden;
  gap: var(--ms-gallery-gap);
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.ms-gallery--slider {
  position: relative;
}

.ms-gallery-viewport {
  overflow: hidden;
  touch-action: pan-y;
}

.ms-gallery--slider .ms-gallery-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.10) transparent;
}

.ms-gallery--slider .ms-gallery-viewport:hover {
  scrollbar-color: rgba(0,0,0,0.28) transparent;
}

.ms-gallery--slider .ms-gallery-viewport::-webkit-scrollbar {
  height: 4px;
}

.ms-gallery--slider .ms-gallery-viewport::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

.ms-gallery--slider .ms-gallery-viewport::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.10);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

.ms-gallery--slider .ms-gallery-viewport:hover::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.28);
}

.ms-gallery--slider .ms-gallery-viewport {
  cursor: grab;
  position: relative;
  z-index: 1;
}

.ms-gallery.ms-gallery-is-dragging,
.ms-gallery.ms-gallery-is-dragging * {
  user-select: none;
}

.ms-gallery--slider .ms-gallery-viewport:active {
  cursor: grabbing;
}

.ms-gallery-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.ms-gallery-nav:hover {
  background: rgba(0,0,0,0.68);
}

.ms-gallery-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ms-gallery-nav-prev {
  left: 10px;
}

.ms-gallery-nav-next {
  right: 10px;
}

.ms-gallery--slider .ms-gallery-album {
  flex: 0 0 calc((100% - (var(--ms-gallery-gap) * (var(--ms-gallery-cols, 3) - 1))) / var(--ms-gallery-cols, 3));
  scroll-snap-align: start;
}

@media (max-width: 768px) {
  .ms-gallery--slider .ms-gallery-album {
    flex-basis: calc((100% - (var(--ms-gallery-gap) * (var(--ms-gallery-cols-mobile, 2) - 1))) / var(--ms-gallery-cols-mobile, 2));
  }
}

.ms-gallery-item {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: var(--ms-gallery-radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.ms-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1);
  transition: transform 220ms ease, filter 220ms ease;
}

.ms-gallery-item:hover img {
  transform: scale(1.03);
  filter: brightness(0.98);
}

.ms-gallery-album {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: var(--ms-gallery-radius);
  overflow: hidden;
  border: 1px solid var(--ms-border-subtle);
  background: var(--ms-bg-card);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

.ms-gallery-album:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  border-color: var(--ms-accent);
}

.ms-gallery--slider .ms-gallery-album:hover,
.ms-gallery-album--widget:hover {
  transform: none;
  box-shadow: none;
}

.ms-gallery-album-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #eef2f7;
  overflow: hidden;
  position: relative;
}

.ms-gallery-album-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ms-gallery-album-thumb--empty {
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}

.ms-gallery-album-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1;
  backdrop-filter: blur(6px);
}

.ms-gallery-album-badge i {
  font-size: 0.9em;
}

.ms-gallery-album-cat {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: inline-flex;
  max-width: calc(100% - 20px);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-gallery-album-title {
  padding: 12px 12px 14px;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
}

.ms-gallery-album-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 12px 14px;
  color: var(--ms-text-muted);
  font-size: 0.86rem;
  line-height: 1.2;
}

.ms-gallery-album-meta i {
  margin-right: 6px;
}

.ms-gallery-empty {
  padding: 16px;
  border: 1px dashed var(--ms-border-subtle);
  border-radius: 12px;
  background: var(--ms-bg-card);
}

.ms-gallery-story {
  display: grid;
  grid-template-columns: 1fr;
  gap: 26px;
}

.ms-gallery-story-item {
  background: transparent;
}

.ms-gallery-story-media {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--ms-border-subtle);
}

body.ms-gallery-image-square .ms-gallery-story-media {
  border-radius: 0;
}

body.ms-gallery-image-square .ms-gallery-lightbox-img {
  border-radius: 0;
}

body.ms-gallery-image-soft .ms-gallery-story-media {
  border-radius: 12px;
}

body.ms-gallery-image-soft .ms-gallery-lightbox-img {
  border-radius: 16px;
}

body:not(.ms-gallery-no-hover) .ms-gallery-story-media {
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}

body:not(.ms-gallery-no-hover) .ms-gallery-story-media:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  border-color: var(--ms-accent);
}

body.ms-gallery-no-hover .ms-gallery-story-media:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--ms-border-subtle);
}

.ms-gallery-story-media .ms-gallery-item {
  aspect-ratio: 16 / 10;
  border-radius: 0;
}

.ms-gallery-story-media .ms-gallery-item img {
  transform: none;
}

.ms-gallery-story-media .ms-gallery-item:hover img {
  transform: none;
  filter: none;
}

.ms-gallery-count-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: #ef4444;
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

.ms-gallery-story-text {
  margin-top: 10px;
}

.ms-gallery-photo-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  line-height: 1.2;
  font-weight: 800;
}

.ms-gallery-photo-desc {
  font-size: 0.98rem;
  line-height: 1.55;
  opacity: 0.92;
}

.ms-gallery-photo-desc p {
  margin: 0 0 10px;
}

.ms-gallery-photo-desc p:last-child {
  margin-bottom: 0;
}

.ms-gallery-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.92rem;
  opacity: 0.8;
}

.ms-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
}

.ms-gallery-lightbox.is-open {
  display: block;
}

.ms-gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.ms-gallery-lightbox-inner {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px;
}

.ms-gallery-lightbox-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ms-gallery-lightbox-btn {
  border: 0;
  background: rgba(255,255,255,0.10);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
}

.ms-gallery-lightbox-btn:hover {
  background: rgba(255,255,255,0.16);
}

.ms-gallery-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ms-gallery-lightbox-img {
  max-width: min(1100px, 94vw);
  max-height: 72vh;
  width: auto;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
}

.ms-gallery-lightbox-caption {
  color: rgba(255,255,255,0.88);
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 10px 8px 0;
  text-align: center;
  max-width: min(1100px, 94vw);
  margin: 0 auto;
}

.ms-gallery-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
}

.ms-gallery-lightbox-prev { left: 10px; }
.ms-gallery-lightbox-next { right: 10px; }

@media (max-width: 768px) {
  .ms-gallery-lightbox-img {
    max-height: 66vh;
    border-radius: 14px;
  }
  .ms-gallery-lightbox-prev { left: 6px; }
  .ms-gallery-lightbox-next { right: 6px; }
}
