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

:root {
  --bg: #0b0d10;
  --surface: #141720;
  --border: #1e2230;
  --text: #d4d8e8;
  --text-dim: #6b7394;
  --accent: #5b8def;
  --accent-hover: #7aa5ff;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.search-box { flex: 1; max-width: 420px; }

.search-box input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }

.gallery {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  padding: 1.5rem 2rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.gallery-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  aspect-ratio: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid var(--border);
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

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

.gallery-item .caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 0.75rem 0.6rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-size: 0.78rem;
  color: #eee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-dim);
  font-size: 1rem;
}

.lightbox {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
}

.lightbox.active { display: flex; }

.lightbox-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0,0,0,0.92);
}

.lightbox-body {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
  -webkit-user-select: none;
  user-select: none;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0 0.25rem;
}

.lb-caption {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-actions { display: flex; gap: 0.5rem; }

.lb-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.lb-btn:hover {
  background: var(--border);
  border-color: var(--accent);
}

.lb-btn.copied {
  background: #1a3a2a;
  border-color: #2d6b45;
  color: #5ddb8a;
}

.lb-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
}

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

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-dim);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  line-height: 1.8;
}

footer a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

footer a:hover { color: var(--text); }

footer .icp { font-size: 0.7rem; }

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