:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --ink: #1c1a17;
  --ink-2: #6f6a63;
  --line: #e5e2dc;
  --accent: #2c2a26;
  --radius: 10px;
  --gap: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* 预留滚动条宽度：否则「页面变高 → 出现滚动条 → 可用宽度变窄」会让
   按固定像素排的列溢出内容区几个像素。 */
html { scrollbar-gutter: stable; }

/* hidden 属性必须始终生效：
   否则像 .lightbox{display:flex} 这类作者样式会盖掉浏览器默认的
   [hidden]{display:none}，导致弹层默认显示、且关闭无效。 */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: baseline;
  gap: 26px;
  flex-wrap: wrap;
  padding: 18px 28px 12px;
  background: rgba(246, 245, 243, .93);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .02em; }
.brand-sub { font-size: 10px; color: var(--ink-2); letter-spacing: .18em; }

.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .16s, background .16s;
}
.nav button:hover { color: var(--ink); background: rgba(0, 0, 0, .05); }
.nav button.on { color: #fff; background: var(--accent); }

/* ---------- 二级分类 ---------- */
.subbar { padding: 14px 28px 0; }
.subnav { display: flex; gap: 8px; flex-wrap: wrap; }
.subnav button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .16s, color .16s;
}
.subnav button:hover { border-color: #cfcac3; color: var(--ink); }
.subnav button.on { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* ---------- 拼贴墙 ----------
   静态瀑布流：列数由 JS 在「加载 / 切换分类」时算一次（不是 CSS 多列）。
   用 CSS 多列时，"哪张照片进哪一列"由浏览器的平衡算法决定，会随
   张数与照片高度分布变化，出现右下方大片空白、甚至整列空掉。 */
.grid {
  display: flex;
  align-items: flex-start;
  justify-content: center;      /* 列宽有上限时整体居中，两侧留白对称，不会只剩右侧空 */
  gap: var(--gap);
  padding: 22px 28px 40px;
}
.col {
  flex: 1 1 0;                  /* 等宽分配：列宽始终精确等于内容宽 ÷ 列数 */
  min-width: 0;
  max-width: 430px;             /* 与 app.js 的 COL_MAX_W 保持一致 */
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card {
  position: relative;
  margin: 0;                    /* figure 默认带 margin，必须清掉 */
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(28, 26, 23, .07);
  transition: transform .22s cubic-bezier(.2, .7, .3, 1), box-shadow .22s;
}
.card:hover {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 12px 26px rgba(28, 26, 23, .17);
  z-index: 2;
}
.card img { display: block; width: 100%; height: auto; }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .05);
  pointer-events: none;
}

.empty { text-align: center; color: var(--ink-2); font-size: 14px; padding: 90px 20px; }
.foot { text-align: center; color: var(--ink-2); font-size: 12px; letter-spacing: .04em; padding: 0 0 36px; }

/* ---------- 详情弹层 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.lb-mask { position: absolute; inset: 0; background: rgba(20, 18, 16, .82); }
.lb-box {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  max-width: min(1100px, 92vw);
  max-height: 88vh;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .42);
}
.lb-img {
  display: block;
  max-width: 100%;
  max-height: calc(88vh - 104px);
  object-fit: contain;
  background: #12100e;
}
.lb-meta { padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.lb-date { font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.lb-list { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; }
.lb-list > div { display: flex; gap: 8px; font-size: 13px; }
.lb-list dt { color: var(--ink-2); }
.lb-list dd { margin: 0; }
.lb-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: #1c1a17;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.lb-close:hover { background: #fff; }

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 16px 10px; gap: 10px; }
  .brand-title { font-size: 17px; }
  .nav button { padding: 5px 12px; font-size: 13px; }
  .subbar { padding: 12px 16px 0; }
  .grid { padding: 16px; column-width: 155px; }
  .lightbox { padding: 12px; }
  .lb-box { max-height: 92vh; }
  .lb-img { max-height: calc(92vh - 104px); }
}
