:root {
  --bg: #14161a;
  --panel: #1e2229;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #4f8cff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid #2a2f38;
}

h1 { margin: 0; font-size: 1.4rem; }

.count { color: var(--muted); font-size: 0.9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 24px;
}

.item {
  position: relative;
  display: block;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  text-decoration: none;
  color: var(--text);
  aspect-ratio: 1;
}

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

.item:hover img { transform: scale(1.04); }

.item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.item:hover video { transform: scale(1.04); }

.badge-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1rem;
  pointer-events: none;
}

.item .caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 20px 10px 8px;
  font-size: 0.78rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item:hover .caption { opacity: 1; }

.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}

.empty code {
  background: var(--panel);
  padding: 2px 8px;
  border-radius: 6px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}

.lightbox[hidden] { display: none; }

.lightbox figure {
  margin: 0;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox img,
.lightbox video {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox figcaption {
  color: var(--muted);
  font-size: 0.85rem;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 20px;
}

.lightbox-close,
.lightbox-nav {
  background: none;
  border: none;
  color: #fff;
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 8px 14px;
  user-select: none;
  z-index: 101;
}

.lightbox-close:hover,
.lightbox-nav:hover { color: var(--accent); }

.lightbox-prev { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); }
.lightbox-next { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
