:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* 动态背景：结果里挑一张方向匹配的图，高斯模糊铺满 */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  filter: blur(8px) saturate(1.3);
  transform: scale(1.05);   /* 放大以遮住模糊后的透明边缘 */
  transition: background-image 0.6s ease;
}

/* 半透明遮罩：提亮背景，保证前景文字/卡片可读 */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(245, 246, 248, 0.72);
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 24px 32px 0;
  max-width: 1200px;
  margin: 0 auto;
}

header h1 { font-size: 22px; font-weight: 700; }

.stats { font-size: 13px; color: var(--muted); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 32px 48px;
}

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-bar .input-wrap { position: relative; flex: 1; }

.search-bar input {
  width: 100%;
  padding: 12px 38px 12px 16px;   /* 右侧留出清空按钮空间 */
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.15s;
}

/* 输入框右侧清空按钮（有内容时才显示）。用 .search-bar .clear-btn 提高优先级，
   压过 .search-bar button 的紫底/大padding/圆角，保证是小圆形 */
.search-bar .clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #cbd0d8;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-bar .clear-btn.show { display: flex; }
.search-bar .clear-btn:hover { background: var(--muted); }

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

.search-bar button {
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.search-bar button:hover { background: var(--accent-hover); }

.search-bar button.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.search-bar button.secondary:hover { border-color: var(--accent); color: var(--accent); }

.search-bar button:disabled { opacity: 0.5; cursor: not-allowed; }

.status { font-size: 13px; color: var(--muted); margin-bottom: 14px; min-height: 18px; }
.status.error { color: #dc2626; }

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

.placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 15px;
}

.load-more {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 16px 0;
}

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

.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }

.card img {
  width: 100%;
  aspect-ratio: 3 / 3;
  object-fit: contain;
  background: #eee;
  display: block;
}

.card-body { padding: 10px 12px 12px; }

.card-score {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-score .bar {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.25;
}

.card-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-path {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 点击放大 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
}

.lightbox.hidden { display: none; }

.lightbox-body {
  max-width: 90vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.lightbox-desc {
  color: #e5e7eb;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

/* 回到顶部搜索按钮（下滑后出现） */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgb(136,136,136);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(76, 76, 76, 0.35);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.12s, background 0.15s;
}

.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { transform: translateY(-2px); background: rgb(76, 76, 76); }
.to-top svg { display: block; }

/* 照片信息筛选面板 */
#filter-toggle { white-space: nowrap; }

.filter-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.filter-panel.hidden { display: none; }

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 0;
}
.filter-row + .filter-row { border-top: 1px solid var(--border); }

.filter-label {
  width: 76px;
  flex: none;
  font-size: 13px;
  color: var(--muted);
}

.filter-cameras { display: flex; gap: 14px; flex-wrap: wrap; }

.check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }

.presets { display: inline-flex; gap: 6px; }
.presets button {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text);
  transition: all 0.12s;
}
.presets button:hover { border-color: var(--accent); color: var(--accent); }
.presets button.active {
  background: rgba(79, 70, 229, 0.12);   /* 主色浅底 */
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.filter-panel input[type="number"],
.filter-panel input[type="date"] {
  padding: 5px 9px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  outline: none;
  width: 110px;
}
.filter-panel input:focus { border-color: var(--accent); }
.sep { color: var(--muted); }

.filter-actions button {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.filter-actions button.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
