:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --border: #2a2a32;
  --text: #f0f0f5;
  --muted: #8888a0;
  --accent: #7c6af5;
  --accent-hover: #9585ff;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ========== Header ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  max-width: 360px;
}

#search {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

#search:focus {
  border-color: var(--accent);
}

#search::placeholder {
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

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

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.view-btn {
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.view-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ========== Gallery ========== */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.gallery {
  columns: 4 260px;
  column-gap: 1rem;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

/* Images */
.gallery-item img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 4/3;
  background: #1a1a1f;
}

/* Videos */
.gallery-item video {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 16/9;
  background: #000;
}

/* Overlay */
.gallery-item .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 45%);
  opacity: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem;
  transition: opacity 0.25s;
  pointer-events: none;
}

.gallery-item:hover .overlay {
  opacity: 1;
}

.gallery-item .title {
  font-size: 0.95rem;
  font-weight: 600;
}

.gallery-item .tags {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Badge */
.media-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  backdrop-filter: blur(4px);
  z-index: 2;
}

/* Play icon */
.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: transform 0.2s, background 0.2s;
  z-index: 2;
  pointer-events: none;
}

.gallery-item:hover .play-icon {
  transform: translate(-50%, -50%) scale(1.1);
  background: rgba(124, 106, 245, 0.85);
}

.play-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  margin-left: 3px;
}

/* Audio card */
.audio-card {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e1e28, #16161c);
  padding: 1.5rem;
  text-align: center;
}

.audio-card .audio-icon {
  font-size: 2.8rem;
  margin-bottom: 0.5rem;
}

/* ========== List View ========== */
.gallery.list-view {
  columns: 1 !important;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gallery.list-view .gallery-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: 0;
  transform: none !important;
}

.gallery.list-view .gallery-item:hover {
  background: #22222a;
  box-shadow: none;
}

.gallery.list-view .gallery-item img,
.gallery.list-view .gallery-item video {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  aspect-ratio: auto;
}

.gallery.list-view .overlay {
  position: static;
  opacity: 1;
  background: none;
  padding: 0;
  flex: 1;
}

.gallery.list-view .media-badge {
  position: static;
  margin-left: auto;
}

.gallery.list-view .play-icon {
  display: none;
}

/* ========== Empty state ========== */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  font-size: 1.1rem;
}

/* ========== Lightbox ========== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.2s ease;
}

.lightbox[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#lightbox-img,
#lightbox-video {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#lightbox-video {
  background: #000;
}

.lightbox-info {
  text-align: center;
  max-width: 600px;
}

.lightbox-info.hidden {
  display: none;
}

.lightbox-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.lightbox-info p {
  color: var(--muted);
  font-size: 0.9rem;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-nav:hover {
  background: rgba(255,255,255,0.2);
}

.lightbox-nav.prev { left: 1.5rem; }
.lightbox-nav.next { right: 1.5rem; }

/* Audio player in lightbox */
.audio-player {
  background: var(--surface);
  border-radius: 16px;
  padding: 2rem;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: var(--shadow);
}

.audio-art {
  width: 180px;
  height: 180px;
  margin: 0 auto 1.5rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #3a2f8f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.audio-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.audio-info h2 {
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
}

.audio-info p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

#lightbox-audio {
  width: 100%;
  margin-top: 0.5rem;
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .gallery {
    columns: 3 200px;
  }
}

@media (max-width: 600px) {
  .gallery {
    columns: 2 140px;
  }

  .header-inner {
    padding: 0.75rem 1rem;
  }

  .lightbox-nav {
    display: none;
  }

  .gallery.list-view .gallery-item img,
  .gallery.list-view .gallery-item video {
    width: 80px;
    height: 60px;
  }
}