/* ============ 设计变量 ============ */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #14181f;
  --muted: #6b7280;
  --line: #e6e8ec;
  --accent: #2f6fed;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .07);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1180px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1015;
    --surface: #161a21;
    --surface-2: #1b2029;
    --text: #e8ebf1;
    --muted: #98a1b0;
    --line: #252b35;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
/* 作者样式里的 display 会盖掉 hidden 属性的 UA 规则，必须显式兜底 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ============ 图片广告 ============ */
.ad-image {
  display: block;
  margin: 0 0 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.ad-image[href]:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(16, 24, 40, .12); }
.ad-image img { width: 100%; height: auto; display: block; }

/* 横幅宽图：铺满容器，超出裁切（有损，但横幅本来就要满幅） */
.ad-image.mode-banner img { max-height: 400px; object-fit: cover; }

/* 原始比例：完整显示，绝不裁切 */
.ad-image.mode-origin img { max-height: 70vh; object-fit: contain; }

/*
 * 方形 / 微信加好友二维码
 * 关键三条：① 等比完整显示（contain，不裁切）② 白底 + 四周留白（扫码静区）
 *          ③ 限制到微信可扫的尺寸区间（约 220~260px），别被拉大或压小
 */
.ad-image.mode-square {
  display: grid;
  place-items: center;
  padding: 18px 16px;
  background: #ffffff;           /* 二维码必须是白底，深色模式下也是 */
  border: 1px solid var(--line);
}
.ad-image.mode-square img {
  width: auto;
  max-width: min(260px, 62vw);
  height: auto;
  object-fit: contain;
  border-radius: 0;              /* 不切圆角：用户上传的二维码可能没有静区，圆角会切到定位点 */
}
.ad-image.mode-square[href]:hover { transform: none; box-shadow: var(--shadow); }

/* ============ 文字广告 ============ */
.ad-text {
  margin: 0 0 22px;
  padding: 16px 18px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
}
.ad-text a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ============ 标题 ============ */
.sec-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--muted);
  margin: 0 2px 12px;
}

/* ============ 相册网格 ============ */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(186px, 1fr));
  gap: 16px;
}
.album-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
  padding: 0;
  text-align: left;
  display: block;
  width: 100%;
}
.album-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line); }
.album-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  overflow: hidden;
}
.album-thumb img { width: 100%; height: 100%; object-fit: cover; }
.album-thumb .ph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.album-body { padding: 10px 12px 12px; }
.album-name {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.album-sub { font-size: 12px; color: var(--muted); }
.album-desc {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ============ 相册详情 ============ */
.album-bar { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
.icon-btn {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.album-bar-text { min-width: 0; flex: 1; }
.album-bar-text h1 { font-size: 17px; margin: 0; font-weight: 650; }
.album-bar-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.album-count { font-size: 12.5px; color: var(--muted); flex: none; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}
.photo-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: none;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.photo-cell img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.photo-cell:hover img { transform: scale(1.05); }
.play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,.28));
  color: #fff;
}
.play-badge svg { filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.dur-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ============ 空态/加载 ============ */
.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 40px 0; }
.loading { display: grid; place-items: center; padding: 48px 0; }
.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 页脚 ============ */
.foot { text-align: center; padding: 34px 0 6px; }
.foot-title { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.foot-desc { margin: 4px 0 0; font-size: 12px; color: var(--muted); opacity: .8; }

/* ============ 图片查看器 ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 10, 14, .94);
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.lb-body { max-width: 100vw; max-height: 100vh; display: grid; place-items: center; padding: 8px; }
.lb-body img, .lb-body video {
  max-width: min(96vw, 1400px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
}
.lb-close, .lb-nav {
  position: fixed;
  z-index: 2;
  border: none;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 50%;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .15s ease;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .24); }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-prev[hidden], .lb-next[hidden] { display: none; }
.lb-meta {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255, 255, 255, .82);
  font-size: 12.5px;
  padding: 0 16px;
}

/* ============ 访问密码（门禁页） ============ */
.gate-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.gate-wrap { width: 100%; max-width: 340px; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 22px 24px;
  text-align: center;
}
.gate-lock {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
}
.gate-card h1 { font-size: 17px; font-weight: 650; margin: 0 0 6px; }
.gate-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 18px; }
.gate-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  text-align: center;
  letter-spacing: .04em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.gate-card input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .16);
}
.gate-btn {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter .15s ease, opacity .15s ease;
}
.gate-btn:hover { filter: brightness(1.07); }
.gate-btn:disabled { opacity: .62; cursor: default; }
.gate-msg {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #d93a3a;
  min-height: 1em;
}
@media (prefers-color-scheme: dark) {
  .gate-msg { color: #ff8b84; }
}

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .wrap { padding: 14px 12px calc(34px + env(safe-area-inset-bottom)); }
  .ad-image.mode-banner img { max-height: 210px; }
  .ad-image.mode-origin img { max-height: 62vh; }
  .ad-image.mode-square { padding: 14px 12px; }
  /* 手机上也别缩太小：二维码要能被另一台手机扫出来，220px 以下就吃力了 */
  .ad-image.mode-square img { max-width: min(260px, 68vw); }
  .ad-text { padding: 14px 15px; margin-bottom: 18px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
}
@media (max-width: 380px) {
  .album-grid { grid-template-columns: repeat(2, 1fr); }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
