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

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-dark: #2459c4;
  --border: #e3e6ea;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 顶部 */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}

.search-bar {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary);
}

.count-select {
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 14px;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #eef1f6;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #dde3ec;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 状态与加载 */
.status {
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: var(--radius);
  font-size: 14px;
}

.status.error {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f5c6c2;
}

.status.info {
  background: #eaf3ff;
  color: var(--primary-dark);
  border: 1px solid #c8ddfb;
}

.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
  font-size: 15px;
}

/* 图库网格 */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 20px 0 60px;
}

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

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #e9ebee;
}

.gallery-item .item-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: #fff;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item .item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .item-actions {
  opacity: 1;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--primary);
}

/* 灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-body {
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.lightbox-body img {
  max-width: 90vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-info {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  color: #e5e7eb;
}

.lightbox-title {
  font-size: 15px;
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-meta {
  font-size: 13px;
  color: #9ca3af;
}

/* 响应式 */
@media (max-width: 640px) {
  .search-bar {
    flex-wrap: wrap;
  }
  .search-input {
    min-width: 100%;
  }
  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}