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

:root {
  --bg: #0a0a0a;
  --card: #161616;
  --border: #222;
  --text: #ddd;
  --muted: #555;
  --gap: 4px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* ── Index Header ── */
header {
  padding: 64px 40px 52px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--text);
}

/* ── Gallery Cards ── */
.galleries {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

.gallery-card {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  text-decoration: none;
  background: var(--card);
  display: flex;
  align-items: flex-end;
}

.card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.7s ease, opacity 0.3s ease;
  opacity: 0.85;
}

.gallery-card:hover .card-bg {
  transform: scale(1.05);
  opacity: 1;
}

.card-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.8) 0%,
    rgba(0, 0, 0, 0.15) 45%,
    transparent 100%
  );
}

.card-label {
  position: relative;
  z-index: 2;
  padding: 18px 20px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #fff;
  transition: opacity 0.2s;
}

/* Empty card — subtle grid texture */
.gallery-card.no-cover .card-bg {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 39px,
    var(--border) 39px,
    var(--border) 40px
  ),
  repeating-linear-gradient(
    90deg,
    transparent,
    transparent 39px,
    var(--border) 39px,
    var(--border) 40px
  );
  opacity: 0.3;
}

/* ── Gallery Page Header ── */
.gallery-header {
  display: flex;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  min-width: 60px;
}

.back-link:hover {
  color: var(--text);
}

.gallery-title {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text);
  flex: 1;
  text-align: center;
}

.gallery-count {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--muted);
  min-width: 60px;
  text-align: right;
}

/* ── Masonry Grid ── */
.masonry {
  columns: 3;
  column-gap: var(--gap);
  padding: var(--gap);
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: var(--gap);
  cursor: pointer;
  overflow: hidden;
  display: block;
}

.masonry-item img {
  width: 100%;
  display: block;
  transition: opacity 0.25s;
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
}

.masonry-item:hover img {
  opacity: 0.8;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 120px 40px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* ── Lightbox ── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden {
  display: none;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
  -webkit-touch-callout: none;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  padding: 16px;
  transition: color 0.2s;
  z-index: 1001;
  line-height: 1;
  font-weight: 300;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  color: #fff;
}

.lightbox-close {
  top: 16px;
  right: 20px;
  font-size: 20px;
}

.lightbox-prev {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
}

.lightbox-next {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
}

.lightbox-counter {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: rgba(255, 255, 255, 0.3);
}

/* ── Responsive ── */
@media (max-width: 960px) {
  .masonry { columns: 2; }
  .galleries { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .masonry { columns: 1; }
  .galleries { grid-template-columns: 1fr; }
  header { padding: 40px 20px 32px; }
  .gallery-header { padding: 18px 20px; }
}
