/* ==========================================================================
   拾光集 · 访客图库样式
   双主题（深色为默认）· 分组网格 · 氛围层为纯 CSS 渐变 + SVG 噪点
   ========================================================================== */

/* ---------- 主题 token ---------- */

:root {
  color-scheme: dark;

  --bg: #16131a;
  --bg-deep: #100e13;
  --surface: #201b26;
  --surface-2: #262130;
  --surface-sunken: rgb(255 255 255 / 0.04);

  --ink: #f0ebe4;
  --ink-soft: #a79e97;
  --ink-faint: #736b68;

  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.16);

  --accent: #e2b368;
  --accent-2: #b0523f;
  --accent-ink: #241505;
  --accent-soft: rgb(226 179 104 / 0.14);

  --radius: 8px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 30px rgb(0 0 0 / 0.28);
  --shadow-lift: 0 4px 10px rgb(0 0 0 / 0.45), 0 22px 48px rgb(0 0 0 / 0.45);

  /* 背景光晕：静态 radial-gradient，不用 filter:blur（大半径模糊逐帧高斯会掉帧）。
     neutral 基调：暖褐 + 朱砂 + 深紫，介于 classic 与 urban 之间。
     按相册切换的变体见下方 [data-ambience] 块。 */
  --glow:
    radial-gradient(1200px 620px at 12% -12%, rgb(46 36 26 / 0.85) 0%, transparent 62%),
    radial-gradient(900px 520px at 92% -4%, rgb(44 26 26 / 0.6) 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 108%, rgb(24 20 32 / 0.55) 0%, transparent 60%);

  /* SVG 噪点：feTurbulence，静态铺，opacity 极低，绝不动画它 */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-opacity: 0.05;
  --grain-blend: screen;

  --scrim: linear-gradient(0deg, rgb(0 0 0 / 0.78) 0%, rgb(0 0 0 / 0.42) 46%, transparent 100%);
  --img-placeholder: #23282f;

  --serif: Georgia, 'Times New Roman', 'Source Han Serif SC', 'Noto Serif SC', 'STSong', SimSun, serif;
  --sans: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;

  --ease-out: cubic-bezier(0.2, 0.92, 0.22, 1);
  --ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --row-unit: 8px;
  --grid-gap: 16px;
  /* 全站唯一栏宽：吸顶栏/中性头部/底部页签/主体四处共用一个度量，
     改栏宽只改这里（以前写死四遍 1400px，改一处就会漏三处） */
  --shell: 1400px;
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg: #f7f4ef;
  --bg-deep: #efeae2;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --surface-sunken: rgb(0 0 0 / 0.03);

  --ink: #1a1a1a;
  --ink-soft: #6b6b6b;
  --ink-faint: #9a9a9a;

  --line: #e4e1dd;
  --line-strong: #d2cec8;

  --accent: #222222;
  --accent-2: #b0523f;
  --accent-ink: #ffffff;
  --accent-soft: rgb(0 0 0 / 0.06);

  --radius: 10px;

  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.07);
  --shadow-lift: 0 4px 10px rgb(0 0 0 / 0.08), 0 20px 44px rgb(0 0 0 / 0.13);

  --glow:
    radial-gradient(1100px 560px at 14% -14%, rgb(255 255 255 / 0.95) 0%, transparent 64%),
    radial-gradient(820px 460px at 90% -6%, rgb(238 234 246 / 0.85) 0%, transparent 58%),
    radial-gradient(900px 620px at 50% 110%, rgb(232 229 224 / 0.7) 0%, transparent 62%);

  --grain-opacity: 0.032;
  --grain-blend: multiply;

  --img-placeholder: #e9e7e4;
}

/* ---------- 氛围层随相册切换（data-ambience 由 gallery.js 写入） ----------
   gradient 不可过渡，切换是瞬时的；光晕本就极淡，瞬切观感近似呼吸。
   映射不到的相册不设标记、走上方基础光晕（neutral）。 */

/* 古风·汉服：暖金褐 + 朱砂余韵 */
:root[data-ambience='classic'] {
  --glow:
    radial-gradient(1200px 640px at 12% -12%, rgb(64 44 24 / 0.6) 0%, transparent 62%),
    radial-gradient(900px 520px at 92% -4%, rgb(70 30 24 / 0.42) 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 108%, rgb(34 26 18 / 0.5) 0%, transparent 60%);
}

/* 现代·都市：冷青蓝灰 */
:root[data-ambience='urban'] {
  --glow:
    radial-gradient(1200px 640px at 12% -12%, rgb(22 34 52 / 0.85) 0%, transparent 62%),
    radial-gradient(900px 520px at 92% -4%, rgb(18 30 46 / 0.6) 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 108%, rgb(14 24 32 / 0.55) 0%, transparent 60%);
}

/* 小黄怪·卡通：明黄暖调 */
:root[data-ambience='pop'] {
  --glow:
    radial-gradient(1200px 640px at 12% -12%, rgb(66 50 14 / 0.5) 0%, transparent 62%),
    radial-gradient(900px 520px at 92% -4%, rgb(60 44 12 / 0.38) 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 108%, rgb(30 24 14 / 0.5) 0%, transparent 60%);
}

:root[data-theme='light'][data-ambience='classic'] {
  --glow:
    radial-gradient(1100px 560px at 14% -14%, rgb(255 250 240 / 0.95) 0%, transparent 64%),
    radial-gradient(820px 460px at 90% -6%, rgb(250 236 224 / 0.9) 0%, transparent 58%),
    radial-gradient(900px 620px at 50% 110%, rgb(240 232 220 / 0.7) 0%, transparent 62%);
}

:root[data-theme='light'][data-ambience='urban'] {
  --glow:
    radial-gradient(1100px 560px at 14% -14%, rgb(246 250 255 / 0.95) 0%, transparent 64%),
    radial-gradient(820px 460px at 90% -6%, rgb(232 240 250 / 0.9) 0%, transparent 58%),
    radial-gradient(900px 620px at 50% 110%, rgb(228 232 238 / 0.7) 0%, transparent 62%);
}

:root[data-theme='light'][data-ambience='pop'] {
  --glow:
    radial-gradient(1100px 560px at 14% -14%, rgb(255 253 240 / 0.95) 0%, transparent 64%),
    radial-gradient(820px 460px at 90% -6%, rgb(252 244 220 / 0.9) 0%, transparent 58%),
    radial-gradient(900px 620px at 50% 110%, rgb(242 236 222 / 0.7) 0%, transparent 62%);
}

/* ---------- 基础 ---------- */

* { box-sizing: border-box; }

/* scroll-behavior 交由 Lenis / 显式 behavior 处理（CSS smooth 会与 Lenis 叠加打架） */
html { scroll-padding-top: 64px; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: var(--glow);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.32s ease, color 0.32s ease;
}

/* 噪点层：fixed 铺满，pointer-events 穿透，静态不动画。
   z-index 5 = 盖住页面内容（颗粒要落在图和字上才有意义），
   但低于 PhotoSwipe(100000)——看图层和它的详情面板都在那一层内，浮层保持干净。 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 200px 200px;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
}

.site-header, .page, .site-footer { position: relative; z-index: 1; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

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

::selection { background: var(--accent-soft); }

/* ---------- 头部 ---------- */

.site-header {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}

.header-bar {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 16px clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; flex: none; }

/* 站头标记就是首屏那枚朱砂印的缩小版（同一个 symbol），不再另画一套几何语言 */
.brand-mark {
  width: 34px;
  height: 34px;
  display: block;
  flex: none;
  filter: drop-shadow(0 1px 5px rgb(0 0 0 / 0.26));
}

.brand-name {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.18em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.22em;
}

.search-wrap { margin-left: auto; flex: 1 1 240px; max-width: 400px; position: relative; }

.search-wrap svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--ink-faint);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

#search::placeholder { color: var(--ink-faint); }

#search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 主题切换 ---------- */

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  flex: none;
}

.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.theme-btn svg { width: 15px; height: 15px; }

.theme-btn:hover { color: var(--ink); }

.theme-btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.22);
}

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: 340px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

/* 开屏式 hero：有封面时占满首屏，站名居中，底部下滑箭头助推；
   滚动是连续的——hero 随滚动自然让位给内容（gallery.js 附加淡出效果） */
.site-header.has-hero .hero {
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  align-items: center;
  justify-content: center;
}

.site-header.has-hero .hero-inner {
  text-align: center;
  padding: 24px;
  will-change: transform, opacity;
}

.site-header.has-hero .site-title { font-size: clamp(40px, 6.4vw, 72px); }

.hero[hidden] { display: none; }

/* 轮播层：由 gallery.js 按探测到的封面动态创建，交叉淡入；
   激活层叠加缓慢放大的 Ken Burns，静态图也有呼吸感 */
.hero-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.4s ease;
}

.hero-slide.is-active {
  opacity: 1;
  animation: hero-kenburns 9s ease-out forwards;
}

@keyframes hero-kenburns {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

/* 下滑助推按钮：缓慢脉动（reduced-motion 全局兜底为静止） */
.hero-scroll {
  position: absolute;
  left: 50%;
  bottom: 30px;
  z-index: 2;
  width: 46px;
  height: 46px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 50%;
  background: rgb(0 0 0 / 0.28);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
  animation: hero-arrow-pulse 2.4s ease-in-out infinite;
}

.hero-scroll:hover { background: rgb(0 0 0 / 0.5); }

.hero-scroll svg { width: 20px; height: 20px; }

@keyframes hero-arrow-pulse {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(7px); }
}

.hero::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.1) 0%, rgb(0 0 0 / 0.62) 100%);
}

.hero-inner {
  position: relative; z-index: 1;
  padding: 48px clamp(20px, 6vw, 72px);
  color: #fff;
}

/* 开屏标题：竖排 + 朱砂小印。印章属标志类简单几何，符合素材分层约定（SVG 只做图标/标志）；
   竖排在「桌面左下」与「窄屏居中」两种容器里都成立。 */
.hero-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.hero .site-title {
  font-family: var(--serif);
  font-size: clamp(34px, 5.4vw, 58px);
  font-weight: 400;
  letter-spacing: 0.3em;
  margin: 0;
  writing-mode: vertical-rl;
  line-height: 1.14;
  text-shadow: 0 2px 14px rgb(0 0 0 / 0.45);
}

.hero-seal {
  width: clamp(40px, 3.8vw, 56px);
  height: auto;
  opacity: 0.94;
  filter: drop-shadow(0 1px 6px rgb(0 0 0 / 0.35));
  transform: rotate(2.4deg);
}

/* 没有 hero 素材时的中性头部：排版即主视觉 */
.site-header:not(.has-hero) .fallback-title {
  max-width: var(--shell);
  margin: 0 auto;
  padding: clamp(34px, 6vw, 62px) clamp(20px, 4vw, 48px) clamp(20px, 3vw, 30px);
}

.fallback-title h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 5.6vw, 60px);
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1.12;
  margin: 0 0 10px;
  text-wrap: balance;
  background: linear-gradient(100deg, var(--ink) 20%, var(--ink-soft) 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fallback-title p {
  margin: 0;
  font-size: 13.5px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
}

.site-header.has-hero .fallback-title { display: none; }

/* ---------- 开屏桌面档（≥1024px）：满屏封面 + 左下竖排站名 ----------
   走过三段弯路，都留在这里当地标：
   ① 满铺单图 + 居中站名（v7.4~v7.13）：字压在人物脸上、白字落在皮肤亮部（3.43:1）；
   ② 左文右「3×2 作品墙」（v7.14~v7.16）：面积是填上了，但六张圆角卡与下方
      作品网格是同一组件，首屏退化成"正文第一屏"——用户判丑；
   ③ 满屏 + 左下文字块 + 右下两条「最新作品」窄预告（v7.18）：信息件堆在门面上，用户判吵。
   v7.20 定稿：预告、文字块与开屏功能按钮全删，左下只留竖排「拾光集」+ 朱砂印「dy幻想」，
   丰富度全部交还给封面本身（hero 直出原图分辨率 1296×2352，不再拿 882×1600 预览放大撑）。
   窄屏不走桌面档的压字方向——居中竖排标题 + 箭头。 */

@media (min-width: 1024px) {
  .site-header.has-hero .hero { display: block; }

  /* 桌面档的压字渐变改成「左下角定向」：斜向 105deg 把左侧压暗 + 底部一条补暗，
     右半与主图主体基本不动。这样左下白字有 15:1 以上，又不像整屏蒙黑那样糟蹋封面。 */
  .site-header.has-hero .hero::after {
    background:
      linear-gradient(105deg, rgb(0 0 0 / 0.66) 0%, rgb(0 0 0 / 0.24) 44%, transparent 70%),
      linear-gradient(0deg, rgb(0 0 0 / 0.44) 0%, transparent 38%);
  }

  /* ---- 左下品牌块：竖排标题 + 印 + 标签入口，贴在封面上，靠定向渐变托住 ---- */
  .site-header.has-hero .hero-inner {
    position: absolute;
    top: auto;
    right: auto;
    left: clamp(28px, 5vw, 96px);
    bottom: clamp(38px, 8vh, 92px);
    width: auto;
    max-width: min(46%, 540px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 0;
  }

  .site-header.has-hero .site-title {
    font-size: clamp(46px, 4.2vw, 74px);
  }

  /* 箭头回到基础档（底部居中）：左下是品牌块，中间留给下滑助推 */
}

/* ---------- 类型导航（sticky + scroll-spy） ---------- */

.type-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.25);
  border-top: 1px solid var(--line);
}

.type-nav-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.type-nav-inner::-webkit-scrollbar { display: none; }

.type-link {
  position: relative;
  /* 页签式：几个类型就整栏等宽平铺几个；类型多到放不下时靠容器横向滚动 */
  flex: 1 1 0;
  min-width: max-content;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  padding: 15px 16px 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.22s ease, border-color 0.22s ease;
}

.type-link:hover { color: var(--ink); }

/* 筛选后数量为 0 的类型：按钮保留、整体置灰，不参与 hover 抬色 */
.type-link.type-link-empty { color: var(--ink-faint); }
.type-link.type-link-empty:hover { color: var(--ink-faint); cursor: default; }

/* 切换类型时的编排式进场：不做整块平移，组标题与卡片由 JS 重置 is-in，
   按 IO + stagger 依次重新揭示（见 gallery.js render 的 animate 分支） */

.type-link .type-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  transition: color 0.22s, background 0.22s;
}

.type-link[aria-current='true'] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.type-link[aria-current='true'] .type-count {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 主体 ---------- */

.page {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 26px clamp(20px, 4vw, 48px) 80px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.result-count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.filter-right { margin-left: auto; display: flex; gap: 8px; }

.select-wrap select {
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 7px 11px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.select-wrap select:hover { border-color: var(--line-strong); }

.select-wrap select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- 标签二次筛选 ---------- */

.tag-filter-wrap {
  margin: -10px 0 30px;
}

.tag-filter-wrap[hidden] { display: none; }

/* 筛选入口按钮：半实底金 + 不透明金边，尺寸比旁边两个排序 select 大一档（层级不能倒挂） */
.tag-toggle {
  /* 浅色主题 --accent 是黑色，直接继承会让这颗主操作按钮变成黑疙瘩
     （v7.11 组标题踩过同一坑），所以本地变量覆盖成铜金，与门面同源。 */
  --ft-accent: var(--accent);
  --ft-ink: var(--accent-ink);
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--ft-accent);
  background: color-mix(in srgb, var(--ft-accent) 26%, transparent);
  color: var(--ft-accent);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 14.5px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

/* 浅金的文字对比只有 2.71:1（14.5px 不算大字号，AA 要 4.5:1），
   所以按钮用深一档的旧铜 #6f4718（4.88:1），不沿用组标题那支 #a6763a——那是大字号标题专用。 */
:root[data-theme='light'] .tag-toggle { --ft-accent: #6f4718; --ft-ink: #fff8ef; }

.tag-toggle:hover { background: color-mix(in srgb, var(--ft-accent) 40%, transparent); }

.tag-toggle:focus-visible { outline: 2px solid var(--ft-accent); outline-offset: 1px; }

/* 展开态：实底反色，明确「面板已开」 */
.tag-toggle[aria-expanded="true"] {
  background: var(--ft-accent);
  border-color: var(--ft-accent);
  color: var(--ft-ink);
}

.tag-toggle-icon { width: 14px; height: 14px; }

.tag-toggle-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--accent-2);
  color: #fff;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.tag-toggle-badge[hidden] { display: none; }

.tag-filter {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tag-filter[hidden] { display: none; }

.tag-chip {
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12.5px;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.tag-chip:hover { border-color: var(--line-strong); color: var(--ink); }

.tag-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tag-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.tag-chip-count {
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.tag-chip[aria-pressed="true"] .tag-chip-count { color: var(--accent); }

.tag-chip-clear {
  border-style: dashed;
  color: var(--ink-faint);
}

/* ---------- 分组区块 ---------- */

.group { margin-bottom: clamp(48px, 7vw, 84px); scroll-margin-top: 64px; }

.group:last-child { margin-bottom: 0; }

/* 组标题揭示：clip-path inset 从中间展开（Cosmos / Format 实测手法）。
   裁剪必须放在内层 .group-head-inner 上：IntersectionObserver 的可见面积
   会被 clip-path 影响，若直接裁 .group-head，被裁成零宽后 IO 的
   intersectionRatio 恒为 0，threshold 永不满足，is-in 永远加不上，
   标题会一直是隐形的。外层保持完整尺寸供 IO 观察。 */
.group-head { margin-bottom: 22px; }

.group-head-inner {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.9s var(--ease-soft);
}

.group-head.is-in .group-head-inner { clip-path: inset(0 0 0 0); }

.group-title {
  font-family: var(--serif);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

.group-index {
  font-family: var(--sans);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  padding-bottom: 5px;
}

.group-count {
  margin: 0 0 2px;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* 古风氛围：组标题走金墨渐变、序号染金，呼应暖金光晕 */
:root[data-ambience='classic'] .group-title {
  background: linear-gradient(100deg, var(--ink) 30%, var(--accent) 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:root[data-ambience='classic'] .group-index { color: var(--accent); }

/* 浅色主题下 --accent 是黑色，金墨渐变改用固定的金铜色，两主题气质接上 */
:root[data-theme='light'][data-ambience='classic'] .group-title {
  background: linear-gradient(100deg, #1a1a1a 35%, #a6763a 92%);
  -webkit-background-clip: text;
  background-clip: text;
}

:root[data-theme='light'][data-ambience='classic'] .group-index { color: #a6763a; }

.group-desc {
  flex-basis: 100%;
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  max-width: 62ch;
}

/* ---------- 作品网格 ----------
   实测 6 个 AI/设计站（吐司、liblib、站酷、recraft 等）的 CSS 里
   column-count / masonry / justified 命中数为 0，主流是 auto-fill grid。
   CSS 多列的填充顺序是先竖后横，会把同一组作品竖着撕裂，且 DOM 顺序 ≠
   视觉顺序（Tab 与读屏错乱），因此分组展示必须用 Grid。
   行高用 8px 细粒度轨道 + JS 算 span，保留原图比例不裁切。
   ------------------------------------------------------------------------ */

.group-grid {
  display: grid;
  /* 列宽下限 260px：1440 屏约 4 列。行式排版：JS 按行统一 span（取该行
     最高图），行内顶端严格对齐，行不满从左排；不开 dense 回填。 */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: var(--row-unit);
  gap: 0 var(--grid-gap);
}

.card {
  position: relative;
  grid-row-end: span var(--span, 30);
  margin: 0 0 var(--grid-gap);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--img-placeholder);
  box-shadow: var(--shadow-card);
  cursor: zoom-in;
  transform: translateY(0);
  transition:
    transform 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out),
    opacity 0.3s ease;
}

/* hover 抬升 4px：liblib 与吐司实测一致的值；
   另加一圈内描边提亮卡片轮廓，只用半透明白，深浅主题通吃 */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card:hover, .card:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
}

.card:hover::after, .card:focus-within::after { opacity: 1; }

.card-media {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.card-media img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  /* 遮罩揭示：图加载完成后先保持 scale(1.12)，待卡片揭示（is-in）
     再缓慢收缩回 1，产生「从画框里长出来」的观感 */
  transform: scale(1.12);
  transition: opacity 0.55s ease, transform 1.35s var(--ease-soft);
}

.card-media img.loaded { opacity: 1; }

.card.reveal.is-in .card-media img.loaded { transform: scale(1); }

.card.reveal.is-in:hover .card-media img.loaded { transform: scale(1.035); filter: brightness(1.04); }

/* 浅色主题：卡片常驻细边线与纸底拉开层次（Behance/Cosmos 手法），
   hover 描边换深色加深；深色主题维持 hover 才亮的半透明白描边 */
:root[data-theme='light'] .card::after {
  opacity: 1;
  border-color: rgb(26 26 26 / 0.09);
}

:root[data-theme='light'] .card:hover::after,
:root[data-theme='light'] .card:focus-within::after {
  border-color: rgb(26 26 26 / 0.3);
}

:root[data-theme='light'] .card:hover, :root[data-theme='light'] .card:focus-within {
  box-shadow: 0 4px 10px rgb(0 0 0 / 0.1), 0 22px 48px rgb(0 0 0 / 0.17);
}

/* 常驻底部信息条：liblib 实测原值（32px / 12px / rgba(0,0,0,.3) / blur 4px） */
.card-foot {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
  line-height: 1.35;
  color: #fff;
  background: rgb(0 0 0 / 0.34);
  backdrop-filter: blur(4px);
  z-index: 2;
}

.card-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.card-author {
  margin-left: auto;
  flex: none;
  opacity: 0.78;
  font-variant-numeric: tabular-nums;
}

/* hover 遮罩层：只在有指针的设备上出现 */
.card-veil {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(0deg, rgb(0 0 0 / 0.62), rgb(0 0 0 / 0.62));
  opacity: 0;
  transition: opacity 0.26s ease;
  pointer-events: none;
}

.card-veil-tags { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; min-width: 0; }

.veil-tag {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: rgb(255 255 255 / 0.16);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.18);
}

.veil-dl {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
}

.veil-dl svg { width: 12px; height: 12px; }

/* hover 露出的展示标题（左下角）；文字直接压在图上，靠阴影保可读性 */
.veil-title {
  position: absolute;
  left: 12px;
  bottom: 10px;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.55);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover .card-veil, .card:focus-within .card-veil { opacity: 1; }
  .card:hover .card-foot { background: rgb(0 0 0 / 0.5); }
  /* 聚光灯：hover 一张时其余卡片压暗，视线聚焦（:has 不支持的浏览器自动跳过） */
  .group-grid:has(.card:hover) .card:not(:hover, :focus-within) { opacity: 0.5; }
}

/* 触屏降级：没有 hover 就常驻显示可下载标记，否则手机上信息完全看不到。
   吐司实测用同一套 @media (hover:none) or (pointer:coarse) 处理。 */
@media (hover: none), (pointer: coarse) {
  .card-veil {
    opacity: 1;
    background: none;
    padding: 8px;
    align-items: flex-start;
  }
  .card-veil-tags { display: none; }
  .card-foot { background: rgb(0 0 0 / 0.5); }
  /* 触屏没有 hover：标题随角标一起常驻（与可下载标记同一降级策略） */
  .veil-title {
    left: 8px;
    bottom: 8px;
    font-size: 11px;
  }
}

/* ---------- 进场揭示（IntersectionObserver 加 .is-in） ---------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 1s var(--ease-soft) var(--stagger, 0ms),
    transform 1s var(--ease-soft) var(--stagger, 0ms);
}

.reveal.is-in { opacity: 1; transform: none; }

/* 卡片不做位移揭示：软感全部交给 opacity + 图片缩放归位（遮罩揭示） */
.card.reveal { transform: none; }

/* 卡片已就位后 hover 抬升要快。注意 transition 的取值来自「目标状态」：
   若这里整条覆盖 transition，opacity 会掉回 0.3s/零延迟的硬切，
   揭示与错峰全部失效——opacity 必须单独保留软曲线与 stagger 延迟。 */
.card.reveal.is-in {
  transform: translateY(0);
  transition:
    transform 0.3s var(--ease-out),
    box-shadow 0.3s var(--ease-out),
    opacity 1s var(--ease-soft) var(--stagger, 0ms);
}

.card.reveal.is-in:hover, .card.reveal.is-in:focus-within { transform: translateY(-4px); }

/* ---------- 空状态 / 页脚 ---------- */

.empty {
  text-align: center;
  padding: 100px 20px;
  color: var(--ink-soft);
}

.empty-title {
  font-family: var(--serif);
  font-size: 26px;
  letter-spacing: 0.2em;
  color: var(--ink);
  margin: 0 0 10px;
}

.empty-sub { margin: 0; font-size: 14px; max-width: 46ch; margin-inline: auto; }

.site-footer {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 70%, transparent);
  text-align: center;
  color: var(--ink-faint);
  font-size: 12.5px;
  padding: 24px 16px;
}

/* ---------- 看图层（PhotoSwipe）补充 ---------- */

.pswp__work-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 20px clamp(16px, 4vw, 44px) 22px;
  background: var(--scrim);
  color: #f4f5f6;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  pointer-events: auto;
  z-index: 10;
}

.pswp-caption-text { min-width: 0; }

.pswp-caption-title {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.05em;
  margin: 0 0 3px;
}

.pswp-caption-meta { margin: 0; font-size: 12.5px; opacity: 0.82; }

.pswp-caption-actions { margin-left: auto; display: flex; gap: 10px; flex: none; }

.pswp-btn-light {
  border: 1px solid rgb(255 255 255 / 0.45);
  background: transparent;
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

.pswp-btn-light:hover { background: rgb(255 255 255 / 0.14); }

.pswp-btn-light.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.pswp-btn-light.primary:hover { filter: brightness(1.1); }

/* ---------- 信息件（看图层说明栏与详情面板共用） ---------- */

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }

.tag {
  font-size: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
}

.fact-list { border-top: 1px solid var(--line); margin: 0 0 24px; }

.fact-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.fact-list dt { color: var(--ink-faint); flex: none; }

.fact-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.license-note { font-size: 12px; color: var(--ink-faint); margin: 11px 0 0; text-align: center; }

/* 标签在说明栏里：底色恒为深，不能用主题变量（浅色主题下会黑字压黑底） */
.pswp-caption-tags { margin: 0; max-width: 46vw; }

.pswp__work-caption .tag {
  background: rgb(255 255 255 / 0.08);
  border-color: rgb(255 255 255 / 0.26);
  color: #e8e6e3;
}

/* ---------- 看图层内的详情面板（就地展开，不退出大图） ---------- */

.pswp .pswp__work-info {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(340px, 86vw);
  padding: 22px 22px 30px;
  background: var(--surface);
  color: var(--ink);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 44px rgb(0 0 0 / 0.42);
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 12;
  transform: translateX(102%);
  transition: transform 0.34s var(--ease-out);
}

.pswp.info-open .pswp__work-info { transform: none; }

/* 面板展开时说明栏让出右侧宽度，详情/下载按钮不被盖住 */
.pswp.info-open .pswp__work-caption { right: min(340px, 86vw); }

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.info-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 400;
  letter-spacing: 0.06em;
  margin: 0;
}

.info-close {
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.info-close:hover { color: var(--ink); border-color: var(--line-strong); }

.info-desc { font-size: 14px; margin: 0 0 16px; white-space: pre-wrap; color: var(--ink-soft); }

/* ---------- 主题切换转场（View Transitions，Chromium 111+） ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

@keyframes theme-sweep {
  from { clip-path: circle(0% at var(--vt-x, 50%) var(--vt-y, 50%)); }
  to { clip-path: circle(150% at var(--vt-x, 50%) var(--vt-y, 50%)); }
}

::view-transition-new(root) { animation: theme-sweep 0.5s var(--ease-out); }

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

/* ≥1800 才放宽栏宽：1680 栏在 1584 内容宽下按 minmax(260) 自动排到 5 列（6 列要 1640 放不下）。
   卡宽 304 CSS px，2x 屏需 608 物理 px，grid-700 档仍够，不必再加档位。
   只动 --shell 一个值，吸顶栏/页签/主体跟着一起对齐。 */
@media (min-width: 1800px) {
  :root { --shell: 1680px; }
}

@media (max-width: 900px) {
  .group-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 56px; }
  .header-bar { padding: 12px 16px; gap: 12px; }
  .brand-sub { display: none; }
  .search-wrap { order: 3; max-width: none; flex-basis: 100%; margin-left: 0; }
  .theme-switch { margin-left: auto; }
  .type-nav-inner { padding: 0 16px; }
  .type-link { padding: 12px 13px 11px; font-size: 14px; }
  .page { padding: 20px 16px 64px; }
  .group { scroll-margin-top: 56px; }
  /* 只改 --grid-gap：列间距与卡片下边距都引用它，JS 算 span 时也读它，
     一处改三处同步，不会出现排版与脚本各算一套。 */
  .group-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); --grid-gap: 12px; }
  .group-head { margin-bottom: 16px; padding-bottom: 12px; }
  .filter-right { margin-left: 0; width: 100%; }
  .select-wrap { flex: 1; }
  .select-wrap select { width: 100%; }
  /* 窄屏说明栏改顶部条，但必须让开 PhotoSwipe 顶栏（计数与关闭按钮），
     且底色不能跟主题——看图层永远是深的，浅色主题下米白配白字会直接看不见。 */
  .pswp__work-caption {
    position: static;
    margin-top: 64px;
    background: #0d0c10;
    padding: 14px 16px 18px;
  }
  .pswp-caption-tags { max-width: 100%; }
  /* 窄屏放不下右侧栏，详情面板改从底部升起（说明栏此时是顶部条，两者不打架） */
  .pswp .pswp__work-info {
    top: auto; left: 0; right: 0; bottom: 0;
    width: auto; max-height: 62vh;
    padding: 18px 16px 26px;
    border-left: 0;
    border-top: 1px solid var(--line);
    transform: translateY(102%);
  }
}

@media (max-width: 400px) {
  .group-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  /* 窄屏卡片只有 ~160px 宽，标题与作者挤一行会双双被截断，
     保留标题、隐去作者（作者在看图层说明栏与详情面板里仍有）。 */
  .card-author { display: none; }
}

/* ---------- 减少动态效果：三层兜底，缺一不可 ----------
   时长用 0.01ms 而不是 none，是为了让 transitionend / animationend
   仍然触发，否则依赖这些事件解锁状态的代码会卡死。 */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html { scroll-behavior: auto; }

  .reveal { opacity: 1; transform: none; }
  .group-head-inner { clip-path: none; }
  .card:hover, .card:focus-within { transform: none; }
  .card-media img { transform: none; }

  /* 部分用户对纹理敏感，静态噪点也一并去掉 */
  body::after { display: none; }

  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none !important; }
}
