/* ============================================================
   ttPictureview — 图片浏览模板样式层
   可调项集中在 :root；换素材通常只需改 config.js。
   ============================================================ */

/* ---------- 主题令牌 ---------- */
:root {
  /* 网格密度：卡片最小宽度，由 JS 写入（--card-min） */
  --card-min: 250px;
  --gap: 14px;
  --radius-card: 14px;
  --radius-ui: 10px;
  --radius-pill: 999px;

  /* 页面留白 */
  --pad-x: 26px;
  --header-h: 62px;

  --accent: #7c9cff;
  --accent-soft: rgba(124, 156, 255, 0.16);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* ---- 灯箱底部悬浮层 ----
     胶片条与工具条都是绝对定位的浮层，不占文档流，
     所以 .lb-stage 必须自己留出对应的内边距，否则大图会被浮层压住。
     这里统一用变量描述，改一处即可保持对齐。 */
  --dock-h: 48px;              /* 工具条高度 */
  --dock-bottom: 20px;         /* 工具条距视口底 */
  --film-gap: 10px;            /* 胶片条与工具条之间的间距 */
  --film-h: 92px;              /* 胶片条高度（缩略图 72 + 上下内边距 10+10） */
  --film-bottom: calc(var(--dock-bottom) + var(--dock-h) + var(--film-gap));
  /* 当胶片条可见时，画面底部要让出的高度（含与大图之间的呼吸间距） */
  --stage-reserve: calc(var(--film-bottom) + var(--film-h) + 12px);
}

/* 深色（由 config.js 的 theme 决定默认值；当前默认为浅色）
   注意 `:root` 与 `[data-theme='dark']` 共用这套值，是为了在 JS 尚未执行前
   （index.html 的初始 data-theme 若为 dark）也能正确上色。 */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0b0e;
  --bg-elev: #14161b;
  --bg-elev-2: #1b1e25;
  --surface: rgba(16, 18, 23, 0.72);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.24);
  --text: #eef1f6;
  --text-dim: #98a1b0;
  /* 次级灰字：原 #666e7d 在控件底色上只有 3.5:1，低于 WCAG AA 4.5:1 */
  --text-faint: #8a93a2;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.32);
  --shadow-card-hi: 0 18px 44px rgba(0, 0, 0, 0.6);
  --shadow-float: 0 10px 40px rgba(0, 0, 0, 0.55);
  --scrim: rgba(5, 6, 8, 0.92);
  --glass: rgba(22, 24, 30, 0.66);
  --glass-hi: rgba(38, 41, 49, 0.8);
}

/* 浅色 */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #eceef2;
  --surface: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 20, 35, 0.15);
  /* 浅色下控件边界需要更明确：填色 #fff 和页面底 #f4f5f7 几乎同色，
     全靠这条描边区分。0.45 可到 2.99:1（≈WCAG 3:1），但视觉上偏重；
     这里取 0.30 → 约 1.95:1，在"看得清"和"不抢眼"之间取平衡。 */
  --border-strong: rgba(15, 20, 35, 0.30);
  --text: #171a21;
  --text-dim: #5c6472;
  /* 次级灰字：原 #8c94a2 在白底上只有 3.06:1，低于 WCAG AA 4.5:1 */
  --text-faint: #666e7d;
  --accent: #3f5fd6;
  --accent-soft: rgba(63, 95, 214, 0.12);
  --shadow-card: 0 1px 2px rgba(15, 20, 35, 0.07), 0 6px 16px rgba(15, 20, 35, 0.06);
  --shadow-card-hi: 0 14px 38px rgba(15, 20, 35, 0.2);
  --shadow-float: 0 10px 34px rgba(15, 20, 35, 0.18);
  --scrim: rgba(18, 20, 26, 0.9);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-hi: rgba(255, 255, 255, 0.9);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 背景微光 */
body::before {
  content: '';
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 60% at 18% 0%, var(--accent-soft), transparent 68%),
    radial-gradient(40% 55% at 82% 6%, rgba(255, 132, 190, 0.10), transparent 66%);
  opacity: 0.8;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--accent); color: #fff; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    color 0.16s var(--ease), transform 0.1s var(--ease);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); }
.btn[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent);
}
.btn.icon-only { padding: 0; width: 34px; }
.btn .ico { width: 16px; height: 16px; flex: none; }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #fff); }

/* 数字输入（幻灯片间隔） */
.numbox {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
  transition: border-color 0.16s var(--ease);
}
.numbox:focus-within { border-color: var(--accent); }
.numbox input {
  width: 56px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
}
.numbox .unit { font-size: 11.5px; color: var(--text-faint); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
  padding: 0 var(--pad-x);
  /* sticky 本身就是定位元素，自动下滑进度条（::after）以此为准 */
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

/* ---------- 全屏沉浸：顶栏自动隐藏 ----------
   全屏（F11 或桌面版原生全屏）时把顶栏收上去，指针移到屏幕顶端才唤出、
   移开自动收起。app.js 在 html 上写两个属性来驱动这件事：
     data-immersive="1"  全屏自动隐藏正在生效
     data-chrome="1"     顶栏当前已唤出
   非全屏时两个属性都不写，顶栏行为与改动前完全一致。
   收起来用 transform 而不是 display，文档流不动，内容不会跟着跳。 */
.topbar {
  transition: transform 0.26s var(--ease), opacity 0.26s var(--ease);
}
:root[data-immersive='1']:not([data-chrome='1']) .topbar {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}
.brand { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand .sub {
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .spacer { flex: 1 1 auto; }
.tools { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* ---------- 选择本地图片：按钮 + 下拉菜单 ---------- */
.src-picker { position: relative; display: flex; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 200px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
  box-shadow: var(--shadow-card-hi);
  animation: menuin 0.14s var(--ease);
}
@keyframes menuin {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s var(--ease);
}
.menu-item:hover { background: var(--bg-elev-2); }
.menu-t { display: block; font-size: 13px; font-weight: 550; }
.menu-d {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* 顶栏里的纯提示按钮（不抢视觉重量，但仍可点击） */
.hint-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-ui);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.hint-btn:hover { color: var(--text); border-color: var(--border-strong); }
.hint-btn .ico { flex: none; color: var(--text-faint); }

/* 自动下滑：按钮 + 速度框，视觉上归为一组 */
.scroll-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
}
.scroll-group .btn { border: 0; background: transparent; }
.scroll-group .btn.icon-only { padding: 0; }
.scroll-group .btn:hover { background: var(--bg-elev-2); }
.scroll-group .btn[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}
.numbox.compact {
  height: 28px;
  padding: 0 6px;
  border: 0;
  background: transparent;
}
.numbox.compact:focus-within { border-color: transparent; }
.numbox.compact input { width: 38px; font-size: 12px; }
.numbox.compact .unit { font-size: 10.5px; }

/* 自动下滑运行中：进度提示条（贴在顶栏下沿） */
.topbar[data-scrolling='1']::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  animation: barslide 2.4s linear infinite;
  pointer-events: none;
}
@keyframes barslide {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

.size {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
}
.size .ico { color: var(--text-faint); flex: none; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 104px;
  height: 4px;
  margin: 0;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--fill, 40%),
    var(--bg-elev-2) var(--fill, 40%) 100%
  );
  cursor: pointer;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
input[type='range']::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(0, 0, 0, 0.25);
}

.seg {
  display: flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
}
.seg .btn {
  height: 28px;
  border: 0;
  background: transparent;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.seg .btn:hover { background: var(--bg-elev-2); color: var(--text); }
.seg .btn[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

/* ---------- 主体 ---------- */
main { padding: 20px var(--pad-x) 72px; }

.filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 300px;
  height: 36px;
  padding: 0 12px;
  /* 搜索框需要比普通分隔线更明确的轮廓：填色和页面底色很接近，
     只靠 --border 会"糊"在背景里，所以这里单独加强描边 */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ui);
  background: var(--bg-elev);
  transition: border-color 0.16s var(--ease);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.search input::placeholder { color: var(--text-faint); }
.search .ico { color: var(--text-faint); flex: none; }

.count-pill {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 文件夹来源提示条 */
.source-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--accent-soft);
  color: var(--text-dim);
  font-size: 12.5px;
}
.source-note .ico { flex: none; color: var(--accent); }
.source-note b { color: var(--text); font-weight: 600; }

/* ---------- 网格 ---------- */
/* 两种排布都由 data-layout 显式声明，不依赖"基础样式 + 覆盖" */
.grid { gap: var(--gap); align-items: start; }
.grid[data-layout='uniform'] {
  display: grid;
  /* 保持 1fr：卡片吃掉行内余量，这是原本的"列数随窗口自适应"行为，
     回归测试里 250px → 5 列就是靠它。不要在容器上设 max-width，
     那会把小密度下的列数一起压掉（实测 150px 从 3 列变 1 列）。 */
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  /* 卡片有 max-width 之后可能出现"多余的列位"，从左排布避免留下怪间隙 */
  justify-content: start;
}

/* 密度滑杆上限提到 820 之后，auto-fill 在"只剩 1 列"时会把卡片撑满整行
   （实测 1440 视口下 1388px 宽、2081px 高，比视口还大）。
   所以把上限加在卡片自己身上：最多比设定值宽 18%，再宽就留白、不拉伸。
   用 max-width 而不是改列宽，是为了不动上面的 1fr 布局。 */
.grid[data-layout='uniform'] > .card {
  max-width: calc(var(--card-min) * 1.18);
}
.grid[data-layout='masonry'] {
  display: flex;
  align-items: flex-start;
}
.grid[data-layout='masonry'] .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg-elev);
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-card);
  text-align: left;
  color: inherit;
  font: inherit;
  /* 入场动画初态 */
  opacity: 0;
  transform: translate3d(0, 16px, 0) scale(0.985);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out),
    box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
/* 注意：.in 同时表示"已入场"，重排时不重放动画 */
.card.in { opacity: 1; transform: none; }

@media (hover: hover) {
  .card.in:hover {
    box-shadow: var(--shadow-card-hi);
    border-color: var(--border-strong);
  }
  .card.in:hover .frame > img { transform: scale(1.04); }
}

.card .frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;      /* 统一比例：先占位，图片到了也不跳版 */
  overflow: hidden;
  background: var(--bg-elev-2);
}
.card[data-natural='1'] .frame { aspect-ratio: auto; }

.card .thumb {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, var(--bg-elev-2) 0%, var(--bg-elev) 48%, var(--bg-elev-2) 100%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}
.card .thumb.done { animation: none; opacity: 0; }
@keyframes shimmer { to { background-position: -220% 0; } }

.card .frame > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s var(--ease-out), transform 0.55s var(--ease-out);
}
.card .frame > img.loaded { opacity: 1; }

/* 原比例：图片按自身比例参与排版 */
.card[data-natural='1'] .thumb { position: relative; inset: auto; }
.card[data-natural='1'] .frame > img {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* 卡片浮层 */
.card .meta {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 30px 11px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.28) 55%, transparent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
  pointer-events: none;
}
@media (hover: hover) {
  .card:hover .meta { opacity: 1; transform: none; }
}
.card:focus-visible .meta { opacity: 1; transform: none; }

.card .idx {
  flex: none;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.card .name {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-size: 11.5px;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.card.thumb-failed .frame::after {
  content: '缩略图缺失';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 12px;
}

/* 大列表优化：视口外的卡片跳过渲染与绘制 */
.grid[data-virtual='1'] .card {
  content-visibility: auto;
  contain-intrinsic-size: auto 380px;
}

/* 空状态 */
.empty {
  padding: 90px 20px;
  text-align: center;
  color: var(--text-dim);
}
.empty strong { display: block; font-size: 15px; color: var(--text); margin-bottom: 6px; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--scrim);
  backdrop-filter: blur(30px) saturate(140%);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  opacity: 0;
  transition: opacity 0.26s var(--ease);
}
.lightbox[data-open='1'] { opacity: 1; }

/* 顶部：仅编号与标题，居中；底部工具条承担所有操作 */
.lb-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  padding: 14px 20px 34px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
  pointer-events: none;
}
.lb-caption { min-width: 0; max-width: 70vw; text-align: center; color: #fff; }
.lb-title {
  font-size: 13.5px;
  font-weight: 550;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.lb-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.62);
  font-variant-numeric: tabular-nums;
}

.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* 顶部固定 56px（留标题），底部按浮层实际高度预留；
     上下不对称会让画面看起来偏上，所以胶片条可见时才加预留量 */
  padding: 56px 16px 56px;
}
/* 胶片条展开时才把底部空间让出来（否则画面可以更大）。
   画面应当居中在"标题以下、胶片条以上"的安全区里 —— 这是能同时满足
   "不被浮层压住"和"视觉居中"的唯一解；画面在胶片条展开时是高度受限的，
   硬要让它对齐整个视口的几何中心，就必然钻到胶片条下面去。 */
.lightbox:has(.lb-film:not([hidden])) .lb-stage {
  padding-bottom: var(--stage-reserve);
}
.lb-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform-origin: center center;
  transition: transform 0.24s var(--ease), opacity 0.26s var(--ease-out);
  opacity: 0;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-y;
}
.lb-img.loaded { opacity: 1; }
.lb-img.grabbing { transition: none; cursor: grabbing; }
.lb-stage[data-zoomed='1'] .lb-img { cursor: grab; }

.lb-spinner {
  position: absolute;
  width: 28px; height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lb-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  width: 48px; height: 78px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  box-shadow: var(--shadow-float);
  transition: opacity 0.24s var(--ease), background 0.16s var(--ease);
}
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 14px; }
.lb-nav:hover { background: var(--glass-hi); }
.lightbox:hover .lb-nav { opacity: 1; }
.lb-nav:focus-visible { opacity: 1; }
.lb-nav .ico { width: 22px; height: 22px; }
.lb-nav[disabled] { opacity: 0 !important; pointer-events: none; }

/* 底部悬浮工具条 */
.lb-dock {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px;
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: var(--shadow-float);
  max-width: calc(100vw - 20px);
  overflow: visible;   /* 不能用 auto：会产生滚动容器，把按钮的圆形轮廓裁掉 */
}
.lb-dock .btn {
  background: transparent;
  border-color: transparent;
  color: rgba(255, 255, 255, 0.9);
}
.lb-dock .btn:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.lb-dock .btn[aria-pressed='true'] {
  background: rgba(255, 255, 255, 0.92);
  color: #14161b;
  border-color: transparent;
}
.lb-dock .btn.play[aria-pressed='true'] { background: var(--accent); color: #fff; }
.lb-dock .sep {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: rgba(255, 255, 255, 0.16);
  flex: none;
}
.lb-dock .numbox {
  height: 30px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.08);
  border-color: transparent;
}
.lb-dock .numbox input { color: #fff; width: 52px; }
.lb-dock .numbox .unit { color: rgba(255, 255, 255, 0.55); }
.lb-dock .lbl { font-size: 12px; color: rgba(255, 255, 255, 0.7); padding-left: 2px; }

/* 幻灯片进度 */
.lb-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.lightbox[data-playing='1'] .lb-progress { opacity: 1; }
.lb-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* 播放时隐藏界面，只留画面；鼠标靠近即恢复 */
.lightbox[data-playing='1'] .lb-chrome { opacity: 0; pointer-events: none; }
.lightbox[data-playing='1'] .lb-nav { opacity: 0; }
.lightbox[data-playing='1']:hover .lb-chrome { opacity: 1; pointer-events: auto; }
.lightbox[data-playing='1']:hover .lb-nav { opacity: 1; }
.lb-chrome { transition: opacity 0.3s var(--ease); }

/* 胶片条 */
.lb-film {
  position: absolute;
  left: 0; right: 0; bottom: var(--film-bottom);
  z-index: 3;
  height: var(--film-h);
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
  scroll-behavior: smooth;
}
.film-item {
  position: relative;
  flex: none;
  width: 52px; height: 72px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.film-item img { width: 100%; height: 100%; object-fit: cover; }
.film-item:hover { opacity: 0.92; transform: translateY(-2px); }
.film-item[aria-current='true'] {
  opacity: 1;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.16);
}
.film-item .n {
  position: absolute;
  inset: auto 0 0 0;
  padding: 6px 0 2px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: #fff;
  font-size: 9.5px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 开播倒计时 */
.lb-countdown {
  position: absolute;
  left: 50%; top: 50%;
  z-index: 6;
  transform: translate(-50%, -50%);
  padding: 16px 30px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  animation: pop 0.28s var(--ease-out);
}
.lb-countdown b { font-size: 28px; font-variant-numeric: tabular-nums; }
.lb-countdown .k { font-size: 11.5px; color: rgba(255, 255, 255, 0.62); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.92); } }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 200;
  transform: translateX(-50%) translateY(14px);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card-hi);
  opacity: 0;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- 回顶 ---------- */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-card-hi);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.28s var(--ease), transform 0.28s var(--ease);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--bg-elev-2); }

/* ---------- 底部 ---------- */
footer {
  padding: 0 var(--pad-x) 40px;
  color: var(--text-faint);
  font-size: 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
footer kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  text-align: center;
}

/* ---------- 响应式 ---------- */

/* 顶栏按钮宽度是常量，逐级收起不常用的，避免工具条把页面撑出横向滚动。
   顺序：全屏提示 → 下滑速度 → 密度预设 → 自动下滑 → 幻灯片间隔 → 按钮文字。
   原则：自动下滑（用户自定义功能）比密度预设更晚收；间隔在灯箱里还有一份。 */
@media (max-width: 1280px) {
  /* F11 是浏览器原生键，提示收起不影响功能 */
  .hint-btn { display: none; }
}

@media (max-width: 1120px) {
  /* 收起速度数值框，速度设定值仍保留 */
  .scroll-group .numbox { display: none; }
}

@media (max-width: 1080px) {
  .tools .size { display: none; }
}

@media (max-width: 980px) {
  .seg[data-role='density'] { display: none; }
}

@media (max-width: 860px) {
  .scroll-group { display: none; }
}

@media (max-width: 760px) {
  .numbox { display: none; }
}

@media (max-width: 560px) {
  /* 只留图标，避免"幻灯片/文件夹"文字把顶栏撑爆 */
  #play-btn .lbl, #dir-btn .lbl { display: none; }
  #play-btn, #dir-btn { padding: 0; width: 34px; justify-content: center; }
  /* 窄屏下菜单改为贴着右边缘展开，避免超出视口 */
  .menu { right: 0; min-width: 180px; }
}

/* 极窄屏：工具条最小需要 ≈281px（排布分段 155 + 三个按钮 + 间隙），
   剩下的宽度留给标题。标题让位，保证最后一个按钮不会挤出视口。 */
@media (max-width: 430px) {
  .brand { max-width: 64px; }
  .brand h1 { font-size: 13px; }
  .brand .sub { display: none; }
  .topbar { gap: 8px; padding: 0 12px; }
}
@media (max-width: 380px) {
  .brand { max-width: 40px; }
}
@media (max-width: 340px) {
  /* 连标题也不再显示，工具条独占一行 */
  .brand { display: none; }
}

@media (max-width: 900px) {
  :root {
    --pad-x: 16px; --header-h: 56px; --gap: 11px;
    /* 浮层位置变了，胶片条的预留量随之自动重算 */
    --dock-bottom: 12px;
  }
  .topbar { gap: 10px; }
  .brand h1 { font-size: 14px; }
  .lb-nav { width: 40px; height: 62px; }
  .lb-nav.prev { left: 8px; }
  .lb-nav.next { right: 8px; }
  .lb-dock { gap: 3px; padding: 5px; }
  .lb-dock .lbl { display: none; }
  .lb-stage { padding-top: 50px; }
}

@media (max-width: 640px) {
  .card .meta { opacity: 1; transform: none; }
  .filterbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .count-pill { margin-left: 0; }
  .lb-stage { padding-top: 46px; }
  .lb-dock .numbox { display: none; }
  .lb-caption { max-width: 88vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card { opacity: 1; transform: none; }
}

/* 打印：紧凑图录 */
@media print {
  .topbar, .lb-dock, .lb-film, .lb-nav, .lb-top, .lb-progress,
  .to-top, footer, .filterbar, .source-note { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .grid[data-layout] { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .grid[data-layout='masonry'] .col { display: contents; }
  .card { opacity: 1 !important; transform: none !important; box-shadow: none; border-color: #ddd; }
  .card .meta { opacity: 1; transform: none; position: static; background: none; padding: 4px; }
  .card .name { color: #333; text-shadow: none; -webkit-line-clamp: 1; }
  .card .idx { background: #eee; color: #333; }
}
