:root {
  --bg: #0f1218;
  --panel: #181c27;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #6c9fff;
  --border: #2a3142;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.top {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.top h1 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 650;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.hint code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.82rem;
}

.hint a {
  color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15, 18, 24, 0.92);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.toolbar input[type="search"],
.toolbar select {
  min-width: 220px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}

.stats {
  flex: 1;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav button {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

.nav button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.nav button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#pageInfo {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 8rem;
  text-align: center;
}

.error {
  margin: 1rem 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #3a1f24;
  border: 1px solid #6b2f3a;
  color: #ffb4bc;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
  padding: 1rem 1.25rem 3rem;
}

.group-header {
  grid-column: 1 / -1;
  margin: 1.25rem 0 0.35rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--accent);
  background: linear-gradient(90deg, rgba(108, 159, 255, 0.12), transparent);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.group-header:first-child {
  margin-top: 0;
}

.group-meta {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 0.5rem;
}

.card {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #000;
}

.card figcaption {
  padding: 0.35rem 0.45rem;
  font-size: 0.65rem;
  color: var(--muted);
  word-break: break-all;
  max-height: 3.4rem;
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-inner {
  margin: 0;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
}

.lightbox-inner img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
  border-radius: 6px;
}

.lightbox-inner figcaption {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: #ccc;
  word-break: break-all;
}

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

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid #444;
  background: rgba(30, 30, 30, 0.9);
  color: #fff;
  cursor: pointer;
  border-radius: 6px;
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}
