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

:root {
  --bg: #000000;
  --surface: #111111;
  --text: #f0f0f0;
  --text-muted: #888888;
  --accent: #ffffff;
  --border: #2a2a2a;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 32px rgba(0,0,0,0.7);
  --radius: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────── */

header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

/* ── Home hero (logo) ────────────────────────────────── */

.home-hero {
  display: flex;
  justify-content: center;
  padding: 3rem 2rem 0;
}

.home-logo {
  max-width: min(560px, 90vw);
  width: 100%;
  height: auto;
  display: block;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

.back-btn svg { flex-shrink: 0; }

/* ── Main content ────────────────────────────────────── */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.page-title {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

/* ── Album grid ──────────────────────────────────────── */

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.album-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.album-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.album-cover {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.album-info {
  padding: 1rem 1.125rem 1.25rem;
}

.album-name {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Photo grid ──────────────────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.photo-thumb {
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  cursor: pointer;
  background: var(--border);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.photo-thumb:hover {
  transform: scale(1.02);
  opacity: 0.92;
}

/* ── Album header ────────────────────────────────────── */

.album-header {
  margin-bottom: 2rem;
}

.album-description {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  max-width: 60ch;
}

/* ── Lightbox ────────────────────────────────────────── */

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

#lightbox.open { display: flex; }

#lightbox img {
  max-width: min(92vw, 1200px);
  max-height: 88vh;
  max-height: 88dvh;
  object-fit: contain;
  border-radius: 4px;
  display: block;
}

.lb-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  backdrop-filter: blur(4px);
}

.lb-btn:hover { background: rgba(255,255,255,0.2); }

#lb-prev { left: 1.25rem; }
#lb-next { right: 1.25rem; }

#lb-close {
  position: fixed;
  top: max(1.25rem, env(safe-area-inset-top));
  right: 1.25rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  backdrop-filter: blur(4px);
}

#lb-close:hover { background: rgba(255,255,255,0.2); }

#lb-caption {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80vw;
  text-align: center;
}

/* ── States ──────────────────────────────────────────── */

.loading, .error-msg {
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.error-msg { color: #c0392b; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────── */

@media (orientation: landscape) {
  #lb-prev { left: max(1.25rem, env(safe-area-inset-left)); }
  #lb-next { right: max(1.25rem, env(safe-area-inset-right)); }
  #lb-close { right: max(1.25rem, env(safe-area-inset-right)); }
}

@media (max-width: 600px) {
  main { padding: 2rem 1rem; }
  header { padding: 0 1rem; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
  .lb-btn { width: 40px; height: 40px; font-size: 1rem; }
  #lb-prev { left: 0.5rem; }
  #lb-next { right: 0.5rem; }
}
