     /* 跨页别名（--primary/--card-bg/--shadow 等）已于 2026-10-17 集中到
        theme.css 的 back-compat 区统一管理，本页不再重复定义。
        （历史注记：这里原先还定义过 --bg: #ffd7e4 —— 那是 --accent 的值，
        复制粘贴错位。body 背景已被 theme.css 接管，错值从未生效，随别名
        集中一并删除。） */
    /* 宽度与留白引用 theme.css 的版面 token：原先各页自己写死
       （gallery 1600 / index 1400 / waterfall 1460），
       页面之间跳转时内容区会横向错位。 */
    #app { 
      max-width: var(--ui-width-wide); 
      margin: 0 auto; 
      padding: var(--ui-page-pad);
    }

    /* 页头（.header / .header-title / .header-actions）已删除：顶栏由
       app-shell.css 提供，各分区页共用同一段标记。这一页原本自带一套
       （标题「图片浏览器」+ 上传/管理/首页 + 页面级主题按钮），
       导航项文字与其它页不同，切换时像跳到了别处。 */

    /* 工具栏骨架（.toolbar / .toolbar-left / .toolbar-right）、搜索框、
       计数徽标、链接格式说明文字、批量条、分页、空态与加载态，都收在
       media-list.css（与视频页共用）。本文件只保留图库独有的部分：
       网格与瀑布流轨道、卡片内部、以及各断点里的差异覆盖。 */

    /* 图片网格 */
    .image-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
      gap: 20px;
    }

    /* 瀑布流：用 column-count 而不是 grid 的 dense 排列。
     *
     * grid 做瀑布流要么 grid-auto-rows: 1px + JS 量高，要么 dense 配
     * row-span —— 都要脚本参与，且 resize 时得重算一遍。这里用 CSS 多列：
     * 浏览器自己按内容高度分列，图多高就占多高，零 JS。
     *
     * 代价是排列顺序变成「先往下再往右」（column-fill 默认 balance），
     * 方格则是「先往右再往下」。这是两者的固有差别，不是 bug。
     * break-inside: avoid 是关键 —— 少了它，一张高图会被列边界切成两半。 */
    .image-grid.is-masonry {
      display: block;
      column-count: 5;
      column-gap: 20px;
    }

    .image-grid.is-masonry .image-card {
      /* 方格靠 aspect-ratio: 1 撑成正方形；瀑布流要让高度由图片决定，
         否则 column-count 排出来仍是一片等高方块，根本不成瀑布。 */
      aspect-ratio: auto;
      display: block;
      width: 100%;
      margin-bottom: 20px;
      break-inside: avoid;
    }

    .image-grid.is-masonry .image-card img {
      display: block;
      width: 100%;
      height: auto;
    }

    /* 占位卡在瀑布流里没有图片撑高度，必须自己给一个高度，
       否则 RAW / PSD 那些卡会塌成 0 高，布局就散了。 */
    .image-grid.is-masonry .image-card-placeholder {
      min-height: 160px;
    }

    .image-card {
      position: relative;
      aspect-ratio: 1;
      border-radius: var(--radius-md);
      overflow: hidden;
      background: var(--card-bg);
      backdrop-filter: var(--ui-card-backdrop-filter);
      -webkit-backdrop-filter: var(--ui-card-backdrop-filter);
      box-shadow: var(--shadow);
      cursor: pointer;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      border: 1px solid var(--ui-line);
      will-change: transform;
      contain: layout style paint;
    }

    .image-card:hover {
      border-color: var(--primary-light);
    }

    .image-card.selected {
      box-shadow: 0 0 0 3px var(--primary), var(--shadow-1);
    }

    .image-card img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.2s ease;
    }

    .image-card:hover img { transform: scale(1.05); }

    /* 不可渲染格式（RAW / PSD / tiff / heic / jxl）的占位卡。
       刻意不铺任何颜色块 —— 只用一条虚线边界说明"这里本该有张图"，
       让它一眼就和真的图片区分开，而不是伪装成一张深色缩略图。 */
    .image-card-placeholder {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 12px;
      text-align: center;
      background:
        repeating-linear-gradient(
          135deg,
          transparent 0 8px,
          var(--ui-surface-sunken) 8px 16px
        );
      color: var(--text-secondary);
    }

    .image-card-placeholder svg,
    .image-card-placeholder i {
      width: 28px;
      height: 28px;
      opacity: 0.55;
    }

    .image-card-format {
      font-size: 0.95rem;
      font-weight: 600;
      letter-spacing: 0.04em;
      color: var(--text-primary);
    }

    .image-card-format-hint {
      font-size: 0.72rem;
      line-height: 1.4;
      opacity: 0.8;
    }

    .image-card-overlay {
      position: absolute;
      top: 0; left: 0; right: 0; bottom: 0;
      background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,0.7) 100%);
      opacity: 0;
      transition: opacity 0.25s ease-out;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      padding: 12px;
    }

    .image-card:hover .image-card-overlay { opacity: 1; }
    .image-card.selected .image-card-overlay { opacity: 1; }

    .image-card-name {
      color: white;
      font-size: 0.8em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-bottom: 8px;
    }

    .image-card-actions {
      display: flex;
      gap: 6px;
      justify-content: center;
    }

    .image-card-checkbox {
      position: absolute;
      top: 10px;
      left: 10px;
      width: 24px;
      height: 24px;
      background: #ffffff;
      border-radius: var(--radius-sm);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.2s;
      cursor: pointer;
    }

    .image-card:hover .image-card-checkbox,
    .image-card.selected .image-card-checkbox { opacity: 1; }

    .image-card-checkbox.checked {
      background: var(--primary);
      color: var(--ui-brand-ink);
    }

    /* 批量操作栏 */
    /* 品牌/语义实心按钮上的文字一律用 token：--ui-brand-ink 随主题翻转，
       success/danger 用各自的 -strong 档（亮色档压白字只有 2.9:1）。 */

    /* 预览弹窗 - 原生图片 / iframe */
    .preview-modal {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      /* 遮罩与层级取统一定义的 token：此前 index/gallery 是 1000、
         admin 是 9999，同一个弹层在三处是三档。 */
      background: var(--ui-scrim-stage);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: var(--ui-z-modal);
      padding: 20px;
    }

    .preview-modal img {
      max-width: 90%;
      max-height: 90%;
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-3);
    }

    /* iframe 容器 - 90% 宽度，80% 高度 */
    .preview-modal .iframe-container {
      width: 90vw;
      height: 80vh;
      position: relative;
      border-radius: var(--radius-lg);
      overflow: hidden;
      background: #000;
    }

    .preview-modal .iframe-container iframe {
      width: 100%;
      height: 100%;
      border: none;
    }

    .preview-close {
      position: absolute;
      top: 20px;
      right: 20px;
      width: 50px;
      height: 50px;
      border: none;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.2);
      color: white;
      font-size: 1.5em;
      cursor: pointer;
      transition: all 0.2s ease-out;
    }

    .preview-close:hover {
      background: rgba(255, 255, 255, 0.4);
      transform: rotate(90deg);
    }

    .preview-info {
      position: absolute;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(0, 0, 0, 0.7);
      padding: 12px 24px;
      border-radius: var(--radius-md);
      color: white;
      display: flex;
      gap: 16px;
      align-items: center;
    }

    .preview-link {
      max-width: 400px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-family: monospace;
      font-size: 0.85em;
    }

    /* Toast 的入场动画统一在 theme.css（fadeUp）。这里曾有一份同名的
       slideIn，与 theme.css 那份撞名 —— 同名 keyframes 由后加载的定义
       覆盖，于是同一页里 toast 播的是从右侧滑入，与首页不同。已删除。 */

    /* 响应式 */
    @media (max-width: 768px) {
      /* 内边距落在内容容器上，不能落在 body：顶栏在 #app 外面，
         body 上留白会把全宽外框缩成内缩的一条（实测 390px 视口下
         顶栏只有 374px 宽），与其它三页不一致。 */
      #app { padding: 12px; }

      /* 顶栏的窄屏处理在 app-shell.css（各分区页共用），这里不用再管。
         工具栏与搜索框的窄屏规则（含 .toolbar-left/.toolbar-right/
         .stat-badge）在 media-list.css 的 768px 档里，两页共用。 */

      .toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        padding: 14px;
      }

      .segmented {
        justify-content: center;
      }

      .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
      }

      /* 窄屏减列而不是改网格轨道：瀑布流用的是 column-count，
         这里给 grid 写的 grid-template-columns 对它无效。 */
      .image-grid.is-masonry {
        column-count: 3;
        column-gap: 10px;
      }

      .image-grid.is-masonry .image-card {
        margin-bottom: 10px;
      }
      
      .image-card-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
      }
      
      .image-card-name {
        font-size: 0.75em;
      }

      /* 卡片操作按钮已改用 .btn .btn-icon，44px 的触摸下限由 ui-buttons.css
         统一负责（四个一行：4×44 + 3×8(gap) = 200px，320px 屏也放得下）。 */
      .image-card-actions { gap: 8px; }
      
      /* 批量条与搜索框的窄屏取值在 media-list.css（与视频页共用）。 */
    }

    @media (max-width: 480px) {
      /* 同上：留白给内容容器，别给 body —— 顶栏需要保持全宽贴边。 */
      #app { padding: 8px; }

      /* 搜索框与徽标的 480px 取值在 media-list.css（与视频页共用）。 */
      .toolbar {
        border-radius: var(--radius-md);
      }

      .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
      }

      /* 手机上瀑布流收到 2 列。再窄就只剩一列，那与方格的
         两列没有区别，不如让用户切回方格。 */
      .image-grid.is-masonry {
        column-count: 2;
        column-gap: 8px;
      }

      .image-grid.is-masonry .image-card {
        margin-bottom: 8px;
      }
      
      .image-card {
        border-radius: var(--radius-md);
      }
      
      .image-card-checkbox {
        width: 24px;
        height: 24px;
        font-size: 0.75em;
      }

      .image-card-name {
        font-size: 0.68em;
        padding: 6px 8px;
      }
      
      /* 原来竖排 + 每个按钮 width:100%，实测在 390px 宽下批量条高 249px ——
         比一张图片卡还高，几乎盖住整个视口底部，用户看不见自己选了什么。
         批量条横向换行、计数独占一行，取值都在 media-list.css
         （与视频页共用）。 */

      /* 移动端禁用高消耗效果。背景原先硬编码 #ffffff：暗色模式下移动端
         工具栏会被钉成白底，改回 --card-bg（跟随透明度旋钮，JS 未执行时
         回退 theme.css 集中区）。 */
      .toolbar,
      .image-card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--card-bg);
      }

      .image-card:hover {
        transform: none;
      }

      .image-card:hover img {
        transform: none;
      }

      .image-card-overlay {
        opacity: 1;
      }
    }

    /* 用户偏好减少动画 */
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
      }
    }
