/* ============================================================
   wei253.cn 相册 —— 简约白底响应式网格
   无外部依赖，不引任何 CDN
   ============================================================ */

:root {
  --bg:        #ffffff;
  --fg:        #1a1a1a;
  --fg-soft:   #8a8a8e;
  --line:      #e8e8ed;
  --hover:     #f5f5f7;
  --radius:    10px;
  --gap:       12px;
  --maxw:      1440px;
  --shadow:    0 8px 30px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }

/* 关键：display:flex 等规则会覆盖 hidden 属性，这里强制生效 */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  flex-wrap: wrap;
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* 相册标签 */
.albums {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  flex: 1;
  min-width: 0;
}

.albums::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-soft);
  font: inherit;
  font-size: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}

.tab:hover { background: var(--hover); color: var(--fg); }

.tab.is-active {
  background: var(--fg);
  color: #fff;
}

.tab .n {
  opacity: .55;
  font-size: 12px;
  margin-left: 4px;
}

/* ---------------- 网格 ---------------- */

main { padding-top: 18px; padding-bottom: 40px; }

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

@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

.cell {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--hover);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  line-height: 0;
  transition: transform .18s ease, box-shadow .18s ease;
}

.cell:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 2px;
}

@media (hover: hover) {
  .cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .35s ease;
}

.cell img.is-loaded { opacity: 1; }

/* 加载中的骨架微光 */
.cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
  pointer-events: none;
}

.cell.is-ready::after { display: none; }

@keyframes shimmer {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .cell::after { animation: none; }
  .cell { transition: none; }
}

/* ---------------- 状态提示 ---------------- */

.state {
  text-align: center;
  color: var(--fg-soft);
  padding: 60px 20px;
  margin: 0;
  font-size: 14px;
}

.state-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--fg-soft);
}

.state-empty strong { color: var(--fg); font-size: 16px; }

.state-empty code {
  background: var(--hover);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.state-error { color: #c0392b; }

/* ---------------- 页脚 ---------------- */

.foot {
  padding-top: 0;
  padding-bottom: 32px;
  color: var(--fg-soft);
  font-size: 12.5px;
  text-align: center;
}

/* ---------------- 灯箱 ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .93);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lbIn .18s ease;
}

@keyframes lbIn { from { opacity: 0; } }

.lb-stage {
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 72px 24px;
}

@media (max-width: 640px) {
  .lb-stage { padding: 52px 12px 18px; }
}

.lb-stage img {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: 6px;
  display: block;
  background: #111;
}

.lb-cap {
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90vw;
  text-align: center;
}

.lb-meta { color: rgba(255, 255, 255, .42); font-size: 12px; }

.lb-btn {
  position: absolute;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
  z-index: 2;
}

.lb-btn:hover { background: rgba(255, 255, 255, .22); }

.lb-close { top: 16px; right: 16px; }
.lb-prev  { left: 16px;  top: 50%; transform: translateY(-50%); }
.lb-next  { right: 16px; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
  .lb-btn { width: 40px; height: 40px; background: rgba(255, 255, 255, .14); }
}

.lb-btn[disabled] { opacity: .22; cursor: default; }
