*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: #ffffff;
  color: #222222;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* Main Thumbnail Grid */
.gallery-container {
  padding: 20px;
  max-width: 1920px;
  margin: 0 auto;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 6px;
}

.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background-color: #f0f0f0;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 105px 105px;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.grid-item:hover img {
  transform: scale(1.04);
  filter: brightness(0.95);
}

/* Lightbox Overlay */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: #000000;
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  user-select: none;
}

/* Top Autoplay Progress Bar */
.autoplay-progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.12);
  z-index: 1050;
}

.autoplay-progress-bar {
  height: 100%;
  width: 0%;
  background-color: #e53935;
}

/* Main Viewer Area */
.lightbox-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
}

/* Top Toolbar */
.lightbox-topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: #999999;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 10;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: #999999;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  text-decoration: none;
}

.icon-btn:hover {
  color: #ffffff;
}

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

/* Stage Area */
.lightbox-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.stage-image-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.15s ease;
}

.stage-loader {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Left / Right Navigation Arrows */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.35);
  border: none;
  color: #999999;
  cursor: pointer;
  padding: 12px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
  z-index: 5;
}

.nav-btn:hover {
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.nav-prev {
  left: 14px;
}

.nav-next {
  right: 14px;
}

/* Bottom Thumbnail Filmstrip */
.filmstrip-wrapper {
  position: relative;
  background-color: #0a0a0a;
  flex-shrink: 0;
  transition: height 0.25s ease;
}

.toggle-thumbs-btn {
  position: absolute;
  top: -38px;
  right: 14px;
  width: 36px;
  height: 32px;
  background-color: #141414;
  color: #999999;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background-color 0.15s ease;
  z-index: 6;
}

.toggle-thumbs-btn:hover {
  color: #ffffff;
  background-color: #222222;
}

.toggle-thumbs-btn svg {
  width: 18px;
  height: 18px;
}

.filmstrip {
  height: 94px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.filmstrip::-webkit-scrollbar {
  display: none;
}

.filmstrip-wrapper.collapsed .filmstrip {
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.filmstrip-item {
  flex: 0 0 78px;
  width: 78px;
  height: 78px;
  border: 2px solid #ffffff;
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.85;
  transition: border-color 0.15s ease, opacity 0.15s ease;
}

.filmstrip-item:hover {
  opacity: 1;
}

.filmstrip-item.active {
  border-color: #d32f2f;
  opacity: 1;
}

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

/* Right Image Information Sidebar */
.info-sidebar {
  width: 310px;
  height: 100%;
  background-color: #0b0b0b;
  border-left: 1px solid #262626;
  color: #cccccc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

.info-header {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #333333;
}

.info-title {
  font-size: 16px;
  font-weight: 400;
  color: #b0b0b0;
}

.info-body {
  padding: 16px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: #9e9e9e;
  word-break: break-all;
}

.info-row {
  margin-bottom: 8px;
}

.info-label {
  color: #888888;
  margin-right: 4px;
}

.info-value {
  color: #b8b8b8;
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 4px;
  }

  .info-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 260px;
  }
}