:root {
  --gap: 12px;
  --card-radius: 20px;
  --thumb-shadow: 0 8px 26px rgba(0, 0, 0, 0.12);
  --overlay-bg: rgba(0, 0, 0, 0.86)
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  font-family: system-ui, Arial, Helvetica, sans-serif;
  background: #f5f5f5;
  color: #111;
  padding: 18px
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px
}

/* h1{font-size:18px;margin:0} */
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: #444
}

/* Grid */
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: start
}

.card {
  background: #fff;
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--thumb-shadow);
  transition: transform .18s ease, box-shadow .18s ease;
  display: block;
  text-decoration: none;
  color: inherit;
  position: relative
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16)
}

.card-media {
  width: 100%;
  height: 0;
  padding-bottom: 66.666%;
  position: relative;
  overflow: hidden;
  background: #000
}

.card-media img,
.card-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block
}

.card-info {
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
  color: #555;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden
}

/* Play button overlay for video cards */
.play-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 26px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  z-index: 6;
  transition: transform .12s ease, background .12s ease;
}

.play-btn:hover {
  transform: translate(-50%, -50%) scale(1.06);
  background: rgba(0, 0, 0, 0.7)
}

/* Inline video container when playing inside card */
.inline-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5
}

/* Lightbox */
.lb-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
  z-index: 9999;
  padding: 24px
}

.lb-overlay.show {
  opacity: 1;
  visibility: visible
}

.lb-topbar {
  width: 100%;
  max-width: calc(100vw - 80px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  margin-bottom: 10px
}

.lb-filename {
  font-size: 16px
}

.lb-content {
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 140px);
  border-radius: 10px;
  transform: scale(.95);
  transition: transform .28s cubic-bezier(.2, .9, .3, 1), opacity .28s ease;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center
}

.lb-overlay.show .lb-content {
  transform: scale(1);
  opacity: 1
}

.lb-content img,
.lb-content video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6)
}

.lb-close {
  position: fixed;
  right: 23px;
  top: 90px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: red;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 35px;
  z-index: 10000;
  transition: transform .15s ease
}

.lb-close:hover {
  transform: scale(1.06)
}

/* Prev/Next buttons in lightbox */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  z-index: 10001
}

.lb-nav:hover {
  background: rgba(0, 0, 0, 0.6)
}

.lb-prev {
  left: 18px
}

.lb-next {
  right: 18px
}

/* Pagination */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 12px 0;
  flex-wrap: wrap
}

.page-btn {
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  border: 1px solid #e6e6e6;
  color: #333;
  text-decoration: none;
  font-size: 14px
}

.page-btn.active {
  background: #111;
  color: #fff
}

/* Responsive tweaks */
@media (min-width:1000px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .card-media {
    padding-bottom: 60%
  }

  .lb-filename {
    text-align: center;
  }
}

@media (max-width: 700px) {
  .lb-close {
    top: 10px;
  }

  .lb-filename {
    text-align: center;

  }

  .lb-hint {
    display: none !important;
  }

  .lb-content {

    max-width: calc(100vw);
    max-height: calc(100vh);
  }  

}

@media (max-width:420px) {
  .grid {
    /* grid-template-columns: repeat(2, 1fr) */
    grid-template-columns: 1fr;
  }

  .play-btn {
    width: 52px;
    height: 52px;
    font-size: 22px
  }
}