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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a;
  color: #f0f0f0;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  background: #111;
  border-bottom: 1px solid #333;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: 0.05em;
}

header p {
  color: #888;
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}

.gallery-item {
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  aspect-ratio: 4/3;
  position: relative;
}

.gallery-item .serial {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #ddd;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

.gallery-item .bookmark-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.9rem;
  z-index: 2;
  display: none;
}

.gallery-item.bookmarked .bookmark-badge {
  display: block;
}

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

.gallery-item:hover img {
  transform: scale(1.03);
  opacity: 0.9;
}

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

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-img-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
}

.magnifier {
  display: none;
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  background-repeat: no-repeat;
  z-index: 1010;
}

.lightbox-bottom {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: absolute;
  bottom: 1.5rem;
}

.magnifier-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ccc;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}

.magnifier-toggle:hover { background: rgba(255, 255, 255, 0.25); color: #fff; }
.magnifier-toggle.active { background: rgba(255, 255, 255, 0.3); color: #fff; border-color: #fff; }

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  padding: 0.5rem;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  color: #fff;
  cursor: pointer;
  background: none;
  border: none;
  padding: 1rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.lightbox-nav:hover { opacity: 1; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-counter {
  color: #aaa;
  font-size: 0.85rem;
}

@media (max-width: 600px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 4px;
    padding: 0.5rem;
  }
  header h1 { font-size: 1.3rem; }
}

.bookmark-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ccc;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}

.bookmark-btn:hover { background: rgba(255, 255, 255, 0.25); color: #fff; }
.bookmark-btn.active { color: #f5c518; border-color: #f5c518; }

.lightbox-serial {
  color: #aaa;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: #111;
  border-bottom: 1px solid #333;
}

.toolbar button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ccc;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s, color 0.2s;
}

.toolbar button:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.toolbar button.active { background: rgba(245, 197, 24, 0.2); color: #f5c518; border-color: #f5c518; }

.gallery-item.hidden { display: none; }
