* {
  box-sizing: border-box;
}

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
  --radius: 16px;
}

html,
body {
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-family: Arial, sans-serif;
}

body {
  min-height: 100vh;
}

.gallery {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.gallery-title {
  margin: 0 0 20px;
  font-size: 32px;
  line-height: 1.2;
}

.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.search-wrap {
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.filter-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filter-summary {
  margin-top: 12px;
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.results-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.clear-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.clear-btn:hover {
  background: #f9fafb;
}

.thumbnails {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(17, 24, 39, 0.16);
}

.card-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #e5e7eb;
  overflow: hidden;
}

.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #e5e7eb;
}

.card-play-badge {
  position: absolute;
  inset: auto auto 12px 12px;
  background: rgba(17, 24, 39, 0.78);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.card-body {
  padding: 14px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.35;
}

.card-description {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
}

.empty-state {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.page-btn {
  min-width: 42px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 10px;
  cursor: pointer;
}

.page-btn:hover {
  background: #f9fafb;
}

.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.page-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.page-info {
  text-align: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(17, 24, 39, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #0f172a;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.lightbox-media {
  width: 100%;
  background: #000;
  aspect-ratio: 16 / 9;
}

.lightbox-media iframe,
.lightbox-media video {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.lightbox-caption {
  background: #fff;
  padding: 18px;
}

.lightbox-title {
  margin: 0 0 8px;
  font-size: 24px;
}

.lightbox-description {
  margin: 0 0 12px;
  color: #4b5563;
  line-height: 1.6;
}

.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.close-btn,
.nav-btn {
  position: absolute;
  z-index: 2;
  border: none;
  cursor: pointer;
  color: #fff;
  background: rgba(17, 24, 39, 0.7);
}

.close-btn {
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 28px;
  line-height: 1;
}

.nav-btn {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
  font-size: 26px;
}

.nav-prev {
  left: 10px;
}

.nav-next {
  right: 10px;
}

.close-btn:hover,
.nav-btn:hover {
  background: rgba(17, 24, 39, 0.9);
}

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

@media (max-width: 640px) {
  .gallery {
    padding: 16px 12px 24px;
  }

  .gallery-title {
    font-size: 26px;
  }

  .thumbnails {
    grid-template-columns: 1fr;
  }

  .card-title {
    font-size: 17px;
  }

  .lightbox {
    padding: 10px;
  }

  .lightbox-content {
    max-height: calc(100vh - 20px);
  }

  .lightbox-title {
    font-size: 20px;
  }

  .nav-btn {
    width: 40px;
    height: 40px;
  }
}

.card-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #dbeafe, #e5e7eb);
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}
