/* ==========================================================================
   Picckq · 图片查看器
   设计概念：暗房画廊 — 深暖黑 + 琥珀点缀
   ========================================================================== */

/* ---------- 变量 ---------- */
:root {
  --bg: #100e0c;
  --bg-elev: #17130f;
  --bg-elev2: #1f1a14;
  --line: #2c251c;
  --line-soft: rgba(232, 180, 72, 0.14);
  --text: #f1e8d8;
  --text-dim: #b9ac97;
  --muted: #8a7d6b;
  --accent: #e2a83f;
  --accent-strong: #f0b94e;
  --accent-dim: rgba(226, 168, 63, 0.12);
  --danger: #d97b5a;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Courier New", monospace;
  --display: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", "Segoe UI", sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --topbar-h: 60px;
  --hint-h: 30px;
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* 保证 hidden 属性始终生效（防止 display:grid/flex 覆盖） */
[hidden] { display: none !important; }

/* iOS 橡皮筋回弹修复：文档级禁止 overscroll；灯箱/登录打开时锁死背景滚动 */
html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* 移动端长按：禁止选中文本、禁止系统长按菜单（复制 / 保存图片 / 分享） */
html, body {
  -webkit-touch-callout: none;          /* iOS Safari 长按菜单 */
  -webkit-user-select: none;            /* 旧版 WebKit */
  user-select: none;
}
canvas, img, a, button, label,
.scene3d, .lb-media {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* 输入框例外：保留可选中 / 可复制，否则无法粘贴密码等 */
input, textarea, select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 背景滚动锁：灯箱/登录打开时挂上，配合 JS 记录并恢复滚动位置 */
body.scroll-lock {
  position: fixed;
  left: 0; right: 0; top: 0;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
img { display: block; max-width: 100%; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-elev2);
  color: var(--text-dim);
  margin: 0 2px;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: rgba(226, 168, 63, 0.35); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e271d; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #453a28; }

/* ---------- 胶片颗粒 ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   顶栏
   ========================================================================== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 20px 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(180deg, rgba(16, 14, 12, 0.92), rgba(16, 14, 12, 0.75));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.06em;
}
.brand-dot { color: var(--accent); font-family: var(--display); font-size: 24px; }
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--muted);
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
}
.btn .icon { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent);
  color: #1b1408;
  box-shadow: 0 2px 10px rgba(226, 168, 63, 0.25);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  border: 1px solid var(--line);
  color: var(--text-dim);
  background: var(--bg-elev);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }
.btn-lg { height: 44px; padding: 0 24px; font-size: 14px; }

.count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==========================================================================
   主体
   ========================================================================== */
.page {
  padding: calc(var(--topbar-h) + 18px) 20px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

/* ---------- 画廊（瀑布流） ---------- */
.gallery {
  columns: 2 210px;
  column-gap: 14px;
}
.gallery.has-items { animation: galleryIn 0.6s var(--ease) both; }

/* ---------- 画廊视图模式 ---------- */
.gallery.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  column-gap: 5px;
}
.gallery.mode-grid .card { margin-bottom: 0; border-radius: var(--radius-sm); }
.gallery.mode-grid .card img { height: 32vw; max-height: 150px; min-height: 0; object-fit: cover; }
.gallery.mode-grid .card-caption { display: none; }

.gallery.mode-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}
.gallery.mode-strip .card { flex: 0 0 76vw; width: 76vw; margin-bottom: 0; scroll-snap-align: center; }
.gallery.mode-strip .card img { height: 62vh; min-height: 0; object-fit: contain; }

.gallery.mode-stack { display: flex; flex-direction: column; gap: 14px; }
.gallery.mode-stack .card { margin-bottom: 0; }
@keyframes galleryIn { from { opacity: 0; transform: translateY(8px); } }

/* 分片渲染哨兵：进入视口下方时触发加载下一批 */
.gallery-sentinel { height: 1px; pointer-events: none; }

/* ---------- 相册分组切换条 ---------- */
.albums {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(16, 14, 12, 0));
  scrollbar-width: none;
}
.albums::-webkit-scrollbar { display: none; }
.album-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}
.album-chip img {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-elev2);
}
.album-chip:hover { border-color: rgba(226, 168, 63, 0.4); color: var(--text); }
.album-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-dim);
}
.album-chip .album-count { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.album-chip.active .album-count { color: var(--accent); }

.card {
  position: relative;
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  cursor: zoom-in;
  animation: cardIn 0.55s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 22ms);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.card:hover {
  transform: translateY(-3px);
  border-color: rgba(226, 168, 63, 0.45);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.card img {
  width: 100%;
  height: auto;
  min-height: 120px;
  background: linear-gradient(135deg, #1d1914, #15120e);
  animation: shimmer 1.6s ease-in-out infinite;
}
.card img.loaded { animation: none; }
@keyframes shimmer {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.9; }
}

.card-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 26px 12px 9px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  background: linear-gradient(180deg, transparent, rgba(10, 8, 6, 0.85));
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.3s var(--ease);
}
.card:hover .card-caption { opacity: 1; transform: translateY(0); }
.card-caption .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-caption .meta { color: var(--accent); flex-shrink: 0; }

/* ---------- 空状态 ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100vh - var(--topbar-h) - var(--hint-h) - 80px);
  gap: 18px;
  padding: 40px 20px;
  animation: galleryIn 0.7s var(--ease) both;
}
.empty-mark {
  width: 86px; height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  border: 1px dashed rgba(226, 168, 63, 0.4);
  color: var(--accent);
  margin-bottom: 6px;
}
.empty-mark svg { width: 38px; height: 38px; stroke-width: 1.4; }
.empty-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: 32px;
  letter-spacing: 0.02em;
}
.empty-title em { font-style: italic; color: var(--accent); }
.empty-sub {
  font-size: 13px;
  line-height: 1.9;
  color: var(--muted);
}
.empty-actions { display: flex; gap: 12px; margin-top: 10px; }

/* ---------- 底部提示 ---------- */
.hintbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--hint-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: linear-gradient(0deg, rgba(16, 14, 12, 0.9), transparent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  pointer-events: none;
}
.hintbar span::before { content: "— "; color: var(--accent); }

/* ==========================================================================
   拖拽覆盖层
   ========================================================================== */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 6, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 56px 72px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: rgba(226, 168, 63, 0.07);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  animation: dropPulse 1.6s ease-in-out infinite;
}
.drop-box svg { width: 40px; height: 40px; stroke-width: 1.4; }
@keyframes dropPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(226, 168, 63, 0.25); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 18px rgba(226, 168, 63, 0); }
}

/* ==========================================================================
   灯箱
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 7, 5, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.lightbox.open { opacity: 1; }

.lb-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(8, 7, 5, 0.75), transparent);
}
.lb-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45vw;
}
.lb-actions { display: flex; gap: 4px; flex-shrink: 0; }

.lb-btn {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-dim);
  transition: all 0.2s var(--ease);
}
.lb-btn:hover { background: var(--accent-dim); color: var(--accent); }
.lb-btn.on { background: var(--accent); color: #1b1408; }
.lb-btn svg { width: 19px; height: 19px; }

.lb-count {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--muted);
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 14, 12, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.lb-count-slash { margin: 0 6px; color: var(--accent); }

/* 导航箭头 */
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(20, 17, 13, 0.6);
  border: 1px solid var(--line);
  color: var(--text-dim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: all 0.25s var(--ease);
}
.lb-nav:hover { background: var(--accent); color: #1b1408; border-color: var(--accent); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-nav svg { width: 22px; height: 22px; }

/* 舞台 */
.lb-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  cursor: grab;
}
.lb-stage.panning { cursor: grabbing; }
.lb-media {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.lb-media img {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  opacity: 0;                 /* 解码完成前隐藏，避免白屏闪烁 */
  transition: opacity 0.25s var(--ease);
}
.lb-media img.ready { opacity: 1; }

/* 大图加载失败兜底浮层 */
.lb-error {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none; /* 让滑动手势穿透到 stage，仍可切图 */
  background: rgba(8, 7, 5, 0.55);
}
.lb-error-inner {
  pointer-events: auto;
  text-align: center;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 14, 12, 0.92);
}
.lb-error-title { font-family: var(--display); font-size: 15px; margin-bottom: 6px; }
.lb-error-sub { color: var(--muted); font-size: 11px; margin-bottom: 14px; }

/* 信息面板 */
.lb-info {
  position: absolute;
  top: 64px; right: 16px;
  z-index: 6;
  width: 250px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 14, 12, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: slideLeft 0.3s var(--ease);
}
@keyframes slideLeft { from { opacity: 0; transform: translateX(12px); } }
.lb-info h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.lb-info dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 12px; }
.lb-info dt { color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; padding-top: 1px; }
.lb-info dd { color: var(--text-dim); word-break: break-all; text-align: right; font-family: var(--mono); font-size: 11px; }
.lb-info-foot { margin-top: 14px; display: flex; justify-content: flex-end; }
.btn-sm { padding: 6px 12px; font-size: 11px; }

/* 缩略图条 */
.lb-strip {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  overflow-x: auto;
  background: linear-gradient(0deg, rgba(8, 7, 5, 0.85), transparent);
  scrollbar-width: none;
}
.lb-strip::-webkit-scrollbar { display: none; }
.lb-thumb {
  flex-shrink: 0;
  width: 58px; height: 58px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: 0.5;
  transition: all 0.25s var(--ease);
  background: var(--bg-elev2);
  padding: 0;
}
.lb-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lb-thumb:hover { opacity: 0.85; }
.lb-thumb.active { border-color: var(--accent); opacity: 1; }

/* 状态标签 */
.lb-status {
  position: absolute;
  top: 70px; left: 16px;
  z-index: 5;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}
.lb-status-sep { margin: 0 6px; color: var(--accent); }

/* ==========================================================================
   帮助弹层
   ========================================================================== */
.help {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: rgba(8, 7, 5, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s var(--ease);
}
.help-panel {
  width: min(460px, 90vw);
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  animation: helpIn 0.35s var(--ease);
}
@keyframes helpIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.help-panel h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.05em;
  margin-bottom: 18px;
  text-align: center;
}
.help-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-table td { padding: 9px 4px; border-bottom: 1px solid rgba(44, 37, 28, 0.6); }
.help-table tr:last-child td { border-bottom: none; }
.help-table td:last-child { text-align: right; color: var(--text-dim); }
.help-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(44, 37, 28, 0.6);
  font-size: 11px;
  line-height: 1.8;
  color: var(--muted);
}
.help-panel .btn { width: 100%; margin-top: 20px; }

/* ==========================================================================
   轻提示
   ========================================================================== */
.toast {
  position: fixed;
  bottom: calc(var(--hint-h) + 18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 400;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s var(--ease);
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 760px) {
  :root { --topbar-h: 52px; --hint-h: 26px; }
  .topbar { padding: env(safe-area-inset-top) 12px 0; gap: 10px; }
  .brand-name { font-size: 18px; }
  .btn span { display: none; }
  .btn { padding: 0 11px; }
  .btn-lg span { display: inline; }
  .page { padding: calc(var(--topbar-h) + 14px) 12px 40px; }
  .hintbar { gap: 12px; }
  .hintbar span:nth-child(3), .hintbar span:nth-child(4) { display: none; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-strip { padding: 10px 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .lb-thumb { width: 48px; height: 48px; }
  .lb-info { width: 200px; right: 8px; top: 58px; }
  .drop-box { padding: 40px 34px; text-align: center; }
  .empty-title { font-size: 26px; }
}

@media (max-width: 420px) {
  .lb-nav { width: 38px; height: 38px; }
  .lb-actions .lb-btn:nth-child(2), .lb-actions .lb-btn:nth-child(3) { display: none; }
  .lb-status { top: 60px; }
}

/* ==========================================================================
   登录（纯前端验证）
   ========================================================================== */
.auth {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 7, 5, 0.97);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s var(--ease);
}
.auth-panel {
  width: min(360px, 92vw);
  padding: 34px 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  text-align: center;
  animation: helpIn 0.4s var(--ease);
}
.auth-brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: 0.12em;
  color: var(--text);
}
.auth-brand::after { content: "·"; color: var(--accent); }
.auth-sub { margin-top: 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.auth-form { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }
.auth-input {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev2);
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-align: center;
  outline: none;
  transition: border-color 0.25s var(--ease);
}
.auth-input:focus { border-color: var(--accent); }
.auth-btn { width: 100%; margin-top: 4px; }
.auth-error { min-height: 16px; font-size: 12px; color: var(--danger); letter-spacing: 0.03em; }
.auth-link {
  display: block;
  margin: 16px auto 0;
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-link:hover { color: var(--accent); }

/* ==========================================================================
   视频（画廊卡片 + 灯箱）
   ========================================================================== */
.card-video { cursor: pointer; }
.card-video .play-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(8, 7, 5, 0.55);
  border: 1px solid rgba(226, 168, 63, 0.5);
  color: var(--accent);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.card-video .play-badge svg { width: 24px; height: 24px; fill: currentColor; stroke: none; margin-left: 3px; }
/* 无海报时仍保留 16:9 占位，避免卡片塌陷；有海报时按实际比例显示 */
.card-video { background: #0d0b09; }
.card-video img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #0d0b09; }
.card-video .video-ph { width: 100%;height: 32vw;aspect-ratio: 16 / 9; background: #0d0b09 center / cover no-repeat; }

.lb-media video {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  max-width: 94vw;
  max-height: 86vh;
  width: auto; height: auto;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
}
.lb-media video.ready { opacity: 1; }

.lb-thumb-ph {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: var(--bg-elev2);
  color: var(--accent);
}
.lb-thumb-ph svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }

/* ==========================================================================
   第四版 · 3D 漫游（阶段 A）
   ========================================================================== */
.scene3d {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0c0a08;
}
.scene3d[hidden] { display: none; }
.scene3d canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
/* 进入 3D 时隐藏 2D 主体，保留顶栏用于退出 */
body.in-3d .page,
body.in-3d .hintbar,
body.in-3d .albums { display: none !important; }
body.in-3d .topbar { z-index: 80; }

/* 移动端虚拟摇杆（左下，避开安全区） */
.g3d-joystick {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(30px, env(safe-area-inset-bottom));
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  touch-action: none;
  z-index: 70;
}
.g3d-joystick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

/* 画作 tap 预览（全屏覆盖，高于摇杆/顶栏） */
.g3d-preview {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 6, 5, 0.92);
  touch-action: none;
}
.g3d-preview-media-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: env(safe-area-inset-top) 12px 0;
}
.g3d-preview-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  background: #000;
}
.g3d-preview-close {
  position: absolute;
  z-index: 2;
  top: calc(10px + env(safe-area-inset-top));
  right: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 阶段 C：门后房间顶栏（返回走廊） */
.g3d-room-bar {
  position: fixed;
  z-index: 95; /* 高于 3D 顶栏(z-index:80)，否则会被顶栏盖住导致点不到“返回走廊” */
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 8px 16px;
  background: rgba(20, 16, 12, 0.72);
  color: #f3ead9;
  border: 1px solid rgba(243, 234, 217, 0.25);
  border-radius: 999px;
  font-size: 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.g3d-room-name { max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g3d-room-back {
  appearance: none; border: none; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  color: #1d1813; background: #f3ead9; font-size: 14px; font-weight: 600;
}

/* 阶段 D2/D3：HUD（自动巡游开关 + 位置指示），底部居中，避让虚拟摇杆 */
.g3d-hud {
  position: fixed;
  z-index: 73;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px;
  background: rgba(20, 16, 12, 0.62);
  color: #f3ead9;
  border: 1px solid rgba(243, 234, 217, 0.22);
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.g3d-tour-btn {
  appearance: none; border: none; cursor: pointer;
  padding: 6px 13px; border-radius: 999px;
  color: #1d1813; background: #f3ead9; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.g3d-tour-btn.off { color: #f3ead9; background: rgba(243, 234, 217, 0.18); }
.g3d-loc { opacity: 0.85; white-space: nowrap; }

/* ==========================================================================
   阶段 F · UI 与配置（顶栏模式切换 / 3D 帮助 / 设置浮层 / 引导条）
   ========================================================================== */

/* V4-F1：3D 态隐藏 2D 布局按钮；「设置」按钮仅 3D 态出现（顶栏一键切 2D/3D） */
body.in-3d #btnView { display: none; }
body:not(.in-3d) #btnSettings { display: none; }

/* V4-F3：帮助弹层内容随模式切换（2D 灯箱说明 ↔ 3D 操作说明） */
.help-table.help-3d,
p.help-3d { display: none; }
body.in-3d .help-table.help-2d,
body.in-3d p.help-2d { display: none; }
body.in-3d .help-table.help-3d { display: table; }
body.in-3d p.help-3d { display: block; }

/* V4-F4：设置浮层（画框风格 / 巡游速度 / 光照强度） */
.g3d-settings {
  position: fixed;
  inset: 0;
  z-index: 100; /* 高于顶栏(z 80)/HUD(73)，低于帮助(z 300) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 8, 6, 0.5);
}
.g3d-settings-panel {
  width: min(340px, 92vw);
  padding: 18px 20px 16px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: helpIn 0.3s var(--ease);
}
.g3d-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.06em;
}
.g3d-settings-close {
  appearance: none; border: none; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
}
.g3d-settings-row { margin-bottom: 16px; }
.g3d-settings-label {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.g3d-settings-label em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}
.g3d-settings-seg { display: flex; gap: 8px; }
.g3d-settings-seg button {
  appearance: none; border: 1px solid var(--line); cursor: pointer;
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-elev2);
}
.g3d-settings-seg button.on {
  color: #1d1813;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.g3d-settings-row input[type="range"] {
  display: block;
  width: 100%;
  height: 24px;
  accent-color: var(--accent);
}
/* v5-H：设置面板开关行（精装/绿植/尘埃） */
.g3d-settings-switch { margin-bottom: 12px; }
.g3d-settings-switch label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-dim); cursor: pointer;
}
.g3d-settings-switch input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0;
}
/* 面板内容过多时允许滚动，避免被小屏截断 */
.g3d-settings-panel { max-height: 86vh; overflow-y: auto; }
.g3d-settings-foot { display: flex; justify-content: flex-end; }
.g3d-settings-reset {
  appearance: none; border: 1px solid var(--line); cursor: pointer;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
}

/* V4-F3：首次进入 3D 的引导条（不挡操作，数秒自动消失） */
.g3d-guide {
  position: fixed;
  z-index: 70;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 58px); /* 避开房间顶栏(距顶 +10) */
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(20, 16, 12, 0.78);
  color: #f3ead9;
  border: 1px solid rgba(243, 234, 217, 0.25);
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
@media (max-width: 640px) {
  .g3d-guide {
    padding: 6px 12px;
    font-size: 12px;
  }
}
