/* ============================================================
   R36 移动端排版（正式版，全部规则限定在 html.m-view 下，桌面零影响）
   ============================================================ */

/* ---- 头部：行1 品牌+切换+🌓+管理 / 行2 搜索 / 行3 导航横滑 ----
   mast-right 用 display:contents 让其子元素直接参与 mast-inner 的 flex 排版，
   这样切回桌面视图时移除 m-view 即可完全还原，无需移动 DOM */
html.m-view .wrap{padding:0 14px;}
html.m-view .mast-inner{flex-wrap:wrap;height:auto;gap:8px 10px;padding:10px 0 6px;}
html.m-view .brand{font-size:19px;white-space:nowrap;flex:none;}
html.m-view .mast-right{display:contents;}
html.m-view .view-toggle{order:2;margin-left:auto;height:34px;padding:0 12px;font-size:13px;
  border-radius:999px;flex:0 0 auto;}
html.m-view .theme-btn{width:34px;height:34px;font-size:15px;border-radius:10px;order:2;}
html.m-view .admin-link{font-size:13px;padding:7px 13px;order:2;}
html.m-view .search-mini{order:3;flex:1 1 100%;}
html.m-view .search-mini input{flex:1;width:auto;min-width:0;height:38px;border-radius:10px 0 0 10px;padding-left:14px;}
html.m-view .search-mini button{height:38px;width:44px;}
html.m-view .nav{order:4;flex:1 1 100%;overflow-x:auto;gap:4px;scrollbar-width:none;
  -webkit-overflow-scrolling:touch;margin:0 -14px;padding:0 14px;}
html.m-view .nav::-webkit-scrollbar{display:none;}
html.m-view .nav > a, html.m-view .nav-cats .cat-link{font-size:14.5px;padding:7px 11px;border-radius:9px;flex:none;}
html.m-view .nav > a.active, html.m-view .nav-cats .cat-link.active{background:rgba(33,99,232,.10);}

/* ---- 内容区 ---- */
html.m-view main.wrap{padding-top:14px;padding-bottom:28px;}
html.m-view .sec-row{margin:4px 0 12px;}
html.m-view .sec{font-size:17px;}
html.m-view .grid{gap:11px;}
html.m-view .card{border-radius:14px;-webkit-tap-highlight-color:transparent;}
html.m-view .card .meta{padding:9px 11px;}
html.m-view .card .title{font-size:13px;}
html.m-view .card .cat{font-size:11.5px;}
html.m-view .sec-more{font-size:13px;}

/* ---- 图片详情页 ---- */
html.m-view .ph-topbar{margin:10px 0 8px;}
html.m-view .abtn{padding:8px 14px;font-size:13.5px;}
html.m-view .ph-nav{gap:8px;margin-top:16px;}
html.m-view .photo .tt{font-size:19px;}

/* ---- 相册页 ---- */
html.m-view .album-name{font-size:14px;}

/* ---- 分页 / 页脚 ---- */
html.m-view .pager{font-size:13px;gap:8px;}
html.m-view .foot{font-size:12px;padding:14px 0;}

/* ---- 电脑窗口里强制手机版：内容限宽居中 ---- */
@media (min-width:900px){
  html.m-view .wrap{max-width:560px;}
  html.m-view .photo{max-width:560px;}
}
/* ==========================================================================
   R40 移动端：贴边修复 + 切换按钮升级 + 触控目标
   —— 追加到 static/css/mobile.css 末尾；全部限定 html.m-view，桌面零影响
   ========================================================================== */

/* ---- 1. 根因修复 --------------------------------------------------------
   R36 的 html.m-view .mast-inner{padding:10px 0 6px} 把 .wrap 的左右 14px
   覆盖成了 0，导致品牌、管理按钮、搜索框全部贴死屏幕边缘。
   这里单独补左右内边距，并支持 iPhone 刘海/圆角的安全区。            */
html.m-view .mast-inner{
  padding-left:14px;
  padding-right:14px;
  padding-left:max(14px, env(safe-area-inset-left));
  padding-right:max(14px, env(safe-area-inset-right));
}

/* 内容区同样支持安全区（横屏刘海不会被切） */
html.m-view .wrap{
  padding-left:14px;
  padding-right:14px;
  padding-left:max(14px, env(safe-area-inset-left));
  padding-right:max(14px, env(safe-area-inset-right));
}

/* 导航横滑：负边距与父内边距严格成对，首尾项不贴边且能滚到屏幕边 */
html.m-view .nav{
  margin-left:-14px;
  margin-right:-14px;
  padding-left:14px;
  padding-right:14px;
  margin-left:calc(-1 * max(14px, env(safe-area-inset-left)));
  margin-right:calc(-1 * max(14px, env(safe-area-inset-right)));
  padding-left:max(14px, env(safe-area-inset-left));
  padding-right:max(14px, env(safe-area-inset-right));
}
/* 导航高亮改用变量，跟着新蓝走（原来是写死的旧蓝 rgba(33,99,232,.10)） */
html.m-view .nav > a.active,
html.m-view .nav-cats .cat-link.active{background:var(--primary-soft);color:var(--primary);}

/* ---- 2. 切换按钮（手机端 / 电脑端）升级 --------------------------------
   做成有实体感的胶囊：中性底 + 细描边，按下变实心蓝，图标与文字同色  */
html.m-view .view-toggle{
  order:2;
  margin-left:auto;
  height:38px;
  padding:0 14px;
  gap:7px;
  font-size:13.5px;
  font-weight:600;
  letter-spacing:.01em;
  border-radius:999px;
  flex:0 0 auto;
  background:var(--primary-soft);
  border:1px solid var(--primary-line);
  color:var(--primary);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.5);
}
html.m-view .view-toggle:hover{background:var(--primary);color:#fff;border-color:var(--primary-d)}
html.m-view .view-toggle:active{transform:scale(.94)}

/* 顶栏右侧按钮组之间留一点呼吸，不再互相贴 */
html.m-view .theme-btn{margin-left:2px;width:38px;height:38px;border-radius:999px;}
html.m-view .admin-link{margin-left:2px;min-height:38px;display:inline-flex;align-items:center;}

/* ---- 3. 触控目标 ≥38~44px（原来 brand 30px、主题 34px 偏小） ---- */
html.m-view .brand{min-height:40px;display:inline-flex;align-items:center;}

/* ---- 4. 悬浮元素避开 iPhone Home 指示条 ---- */
html.m-view .to-top{
  right:16px;
  bottom:20px;
  right:max(16px, env(safe-area-inset-right));
  bottom:calc(20px + env(safe-area-inset-bottom, 0px));
}
html.m-view .toast{
  bottom:28px;
  bottom:calc(28px + env(safe-area-inset-bottom, 0px));
}

/* ---- 5. 页脚 / 分页不贴边（R36 的 padding:14px 0 曾把左右清成 0） ---- */
html.m-view .foot{
  padding-left:14px;
  padding-right:14px;
  padding-left:max(14px, env(safe-area-inset-left));
  padding-right:max(14px, env(safe-area-inset-right));
}
html.m-view .pager{padding-left:0;padding-right:0}
/* ---- end R40 ---- */
/* ==========================================================================
   R41 手机端：搜索框右侧补回圆角 + 列数控件排版
   —— 追加到 static/css/mobile.css 末尾
   ========================================================================== */

/* 1. 搜索框右侧圆角（原 R36 的 10px 0 0 10px 让右侧成了直角） */
html.m-view .search-mini input{
  border-radius:999px;
  padding-right:50px;
}
html.m-view .search-mini button{
  width:38px;
  height:38px;
  right:5px;
  border-radius:50%;
}

/* 2. 列数控件：与搜索框同一行，放在搜索右侧 */
html.m-view .search-mini{order:3;flex:1 1 auto;min-width:0}
html.m-view .cols-ctl{
  order:3;
  flex:none;
  margin-left:2px;
  padding:3px;
}
html.m-view .cols-b{width:32px;height:32px}
html.m-view .cols-b svg{width:16px;height:16px}

/* 3. 手机上 4 列时收紧间距，保证卡片不挤 */
html.m-view html[data-cols="4"] .grid,
html[data-cols="4"] .grid{gap:9px}

/* ---- end R41 ---- */
/* ==========================================================================
   R42 手机端：列数控件与搜索框强制同行 + 控件样式优化
   —— 追加到 static/css/mobile.css 末尾
   ========================================================================== */

/* 1. 让搜索框可自由收缩，保证列数控件落在其右侧同一行
      （原 flex:1 1 auto 用了 input 的固有宽度，容器放不下就换行了） */
html.m-view .search-mini{
  order:3;
  flex:1 1 0;
  min-width:0;
  width:auto;
}
html.m-view .search-mini input{flex:1 1 0;width:100%;min-width:0}

/* 2. 列数控件：手机端更紧凑、固定在搜索右侧 */
html.m-view .cols-ctl{
  order:3;
  flex:none;
  margin-left:8px;
  padding:2px;
  gap:1px;
  background:var(--bg2);
  border:1px solid var(--line);
}
html.m-view .cols-b{width:30px;height:30px}
html.m-view .cols-b svg{width:15px;height:15px}

/* 3. 手机端列数对应的间距：3 列舒适、4 列收紧、5 列极紧 */
html.m-view html[data-cols="4"] .grid,
html[data-cols="4"] .grid{gap:9px}
html[data-cols="5"] .grid{gap:7px}
html[data-cols="5"] .card{border-radius:10px}
html[data-cols="5"] .card .meta{padding:7px 8px}
html[data-cols="5"] .card .title{font-size:12px}
html[data-cols="5"] .card .cat{font-size:10.5px}
/* ---- end R42 ---- */
/* ==========================================================================
   R43 手机端：强制「搜索 + 列数控件」落在同一行
   —— 追加到 static/css/mobile.css 末尾
   问题：搜索框 flex-basis 设成 0 后能被塞进第一行（被挤成 92px 宽），
        列数控件反而掉到下一行。
   解法：在 mast-inner 里插一个 order:3、flex-basis:100% 的零高度占位，
        强制在「品牌 + 视图切换 + 主题 + 管理」这一行之后断开，
        后面的搜索框（basis 0，可自由收缩）与列数控件就会稳定落在同一行。
   ========================================================================== */
html.m-view .mast-inner::before{
  content:"";
  flex:1 1 100%;
  order:3;
  height:0;
  margin:0;
  padding:0;
}
html.m-view .search-mini{
  order:3;
  flex:1 1 0;
  min-width:0;
  width:auto;
}
html.m-view .search-mini input{flex:1 1 0;width:100%;min-width:0}
html.m-view .cols-ctl{
  order:3;
  flex:none;
  margin-left:8px;
  padding:2px;
  gap:1px;
  background:var(--bg2);
  border:1px solid var(--line);
}
html.m-view .cols-b{width:30px;height:30px}
html.m-view .cols-b svg{width:15px;height:15px}
/* 上一版 R42 里 search-mini 的 flex:1 1 0 已被本块重申，无需改动 style.css */
/* ---- end R43 ---- */
/* ==========================================================================
   R44 手机端顶栏：搜索收成放大镜 + 列数控件并入端切换组
   —— 追加到 static/css/mobile.css 末尾（全部限定 html.m-view，桌面零影响）
   目标布局（手机）：
     行1  影集 ................ [切换] [⚙]
     行2  搜索框（R48：常驻整行）
     行3  导航横滑
   ========================================================================== */

/* ---- 1. 取消 R43 的强制断行伪元素（长搜索框已不存在，不需要了） ---- */
html.m-view .mast-inner::before{display:none;content:none}

/* ---- 2. 行1 排布：brand 左，右侧按钮簇靠右 ---- */
html.m-view .mast-inner{gap:8px}
html.m-view .search-toggle{order:2;width:36px;height:36px}
html.m-view .search-toggle svg{width:17px;height:17px}

/* 端切换 连体，作为一个整体靠右（margin-left:auto 已下移给 search-panel，
   由它统一把「搜索+切换+管理」整组推到右端，三者源顺序相邻故紧贴成一组） */
html.m-view .view-group{
  order:2;
  margin-left:0;
  gap:6px;
  flex:0 0 auto;
}
/* 复位 R36/R43 留在 .cols-ctl / .view-toggle 上的 order，
   否则组内会按 order 排序，列数控件跑到端切换右边 */
html.m-view .view-group .cols-ctl,
html.m-view .view-group .view-toggle{order:0}
html.m-view .view-group .cols-ctl{
  margin-left:0;margin-right:0;
  padding:3px;gap:1px;
  background:var(--bg2);
  border:1px solid var(--line);
}
html.m-view .view-group .cols-b{width:28px;height:28px}
html.m-view .view-group .cols-b svg{width:14px;height:14px}

/* 端切换：手机上只留图标（文字会挤爆行宽），语义靠 aria-label 保留 */
html.m-view .vt-txt{display:none}
html.m-view .view-group .view-toggle{
  margin-left:0;
  height:38px;
  padding:0 12px;
  gap:0;
  font-size:13px;
}
html.m-view .view-group .view-toggle svg{width:17px;height:17px}

/* 主题 / 管理：紧跟在端切换之后，压缩到最小可用尺寸 */
html.m-view .admin-link{
  order:2;margin-left:0;
  width:36px;height:36px;padding:0;
  display:inline-flex;align-items:center;justify-content:center;
}
html.m-view .admin-link svg{width:17px;height:17px}
/* R45：深浅色按钮已移除，其移动端规则一并作废（元素不存在，仅留注释备忘） */

/* ---- 3. R48 移动端：搜索框缩短，与「切换/管理」同处顶栏第一行（右侧按钮组）----
   不再独占整行；search-panel 取 margin-left:auto 接管「推右」角色，
   源顺序为 search→view→admin，三者紧贴成一组被推到右端；
   nav(order:4) 仍独占下一行。搜索内容多为编号/短中文，限宽 ~140px 即可。 */
/* R50 修正：搜索框加长至 168px(原 160) + 收紧左右 padding(40/14→32/12)，
   给占位「搜索编号和关键词」腾出 ~18px，确保 13px 占位文字完整可见不截断。 */
html.m-view .search-panel{order:2;flex:0 1 168px;max-width:182px;min-width:0;
  display:flex;margin:0;margin-left:auto}
html.m-view .search-panel .search-mini{flex:1 1 auto;min-width:0;order:initial;display:flex}
html.m-view .search-panel .search-mini input{
  height:38px;font-size:15px;border-radius:999px;
  padding:0 32px 0 12px;background:var(--bg2);
}
html.m-view .search-panel .search-mini input::placeholder{
  font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
html.m-view .search-panel .search-mini button{width:30px;height:30px;right:4px}
/* 极窄屏（≤360px）：占位 11px + 框 154/167，保证「搜索编号和关键词」仍完整可见 */
@media (max-width:360px){
  html.m-view .search-panel{flex-basis:154px;max-width:167px}
  html.m-view .search-panel .search-mini input::placeholder{font-size:11px}
}

/* ---- R51 移动端：详情页一屏收敛（手机顶栏可换行，--mast-h 由脚本实测；main padding 14+28=42）
     用 height 而非 min-height（min-height 不约束 flex 子项收缩，首版实测踩坑） ---- */
html.m-view .photo{min-height:calc(100vh - var(--mast-h) - 42px);
  min-height:calc(100dvh - var(--mast-h) - 42px)}
html.m-view .ph-topbar{margin:8px 0 6px}
html.m-view .ph-meta{margin-top:10px}
html.m-view .ph-nav{margin-top:10px}
/* ---- end R51 ---- */

/* ---- 4. 上一版 R41/R43 里 search-mini 的 order / flex 不再适用于展开层 ---- */
html.m-view .search-panel .search-mini{order:initial;flex:1 1 auto;min-width:0}

/* ---- 5. 窄屏兜底（≤340px，如 iPhone SE 一代 / 老安卓）---------------------
   去掉主题按钮 + 管理改图标后，行1 在 360px 上已非常宽松（实测占 259/332），
   只有 340px 以下才可能挤出「管理」。这里让管理靠右，换行也像独立次行。 */
@media (max-width:340px){
  html.m-view .mast-inner{gap:8px 6px}
  html.m-view .admin-link{margin-left:auto;width:34px;height:34px}
}
/* ---- end R44 ---- */

/* ==========================================================================
   R46 列数固定：手机 3 列 / 电脑 5 列
   —— 继续追加到 static/css/mobile.css 末尾
   R41 给手机写的 `html[data-cols="4"] .grid{gap:9px}` 没有限定 m-view，
   电脑端降级到 4 列时会误用手机的 9px 间距，这里按视图拆开。
   ========================================================================== */
html.m-view[data-cols="4"] .grid{gap:9px}
html:not(.m-view)[data-cols="4"] .grid{gap:14px}
html.m-view[data-cols="3"] .grid{gap:9px}

/* R42 留在 mobile.css 里的 `html[data-cols="5"] .grid{gap:7px}` 没限定 m-view，
   而 mobile.css 后于 style.css 加载，会把电脑端 5 列的间距压到 7px。按视图拆开： */
html.m-view[data-cols="5"] .grid{gap:7px}
html:not(.m-view)[data-cols="5"] .grid{gap:12px}

/* 超窄屏（≤340px）3 列会把卡片压到 91px，降为 2 列保证缩略图可读 */
@media (max-width:340px){
  html.m-view[data-cols="3"] .grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px}
}
/* ---- end R46 ---- */

/* ==========================================================================
   R47 移动端 hover 粘滞修复（触屏点按后不再粘滞实心蓝）
   —— 追加到 static/css/mobile.css 末尾（最后加载，覆盖基础 mobile.css）
   基础 mobile.css 的 `html.m-view .view-toggle:hover{background:var(--primary)}`
   特异性 (0,2,1) 会压过不加 important 的 R47 重置；这里用 !important 强制覆盖，
   并限定 (hover:none) 只作用于触屏设备，桌面 hover 不受影响。
   ========================================================================== */
@media (hover:none){
  html.m-view .view-toggle:hover{
    background:var(--primary-soft)!important;color:var(--primary)!important;
    border-color:var(--primary-line)!important;box-shadow:none!important;transform:none!important;
  }
  html.m-view .admin-link:hover{
    background:var(--primary-soft)!important;color:var(--primary)!important;
    border-color:var(--primary-line)!important;box-shadow:none!important;transform:none!important;
  }
  html.m-view .search-panel .search-mini button:hover{
    filter:none!important;transform:translateY(-50%)!important;
  }
}
/* ---- end R47 ---- */

/* ICP beacon (R52) */
html.m-view .foot .foot-icp{margin-top:5px;font-size:11px}

/* ==========================================================================
   R56 手机端：3 列映射补全 + 搜索按钮放大
   R46 规格「手机 3 列」的 JS（data-cols="3"）早已上线，但 CSS 侧只有 gap
   规则、没有 grid-template-columns 映射 → 列数一直由 style.css 旧媒体查询
   决定（宽视口会命中 5 列小卡）。这里补上正式映射；
   ≤340px 窄屏降 2 列的兜底（上方 R46 块，带 !important）仍然生效。
   搜索按钮 30px 偏小（杨总反馈图标小），放大到 34px + 图标显式 19px。
   ========================================================================== */
html.m-view[data-cols="3"] .grid{grid-template-columns:repeat(3,minmax(0,1fr))}
html.m-view .search-panel .search-mini button{width:34px;height:34px;right:3px}
html.m-view .search-panel .search-mini button svg{width:19px;height:19px}
/* ---- end R56 ---- */

/* ==========================================================================
   R74 炉子式顶栏（手机端）：进度线通栏贴底，布局保持通栏 sticky 不变
   —— 桌面端 style.css R74 段把 .masthead 改成了悬浮胶囊(fixed)，
   手机端 m-view 是三行堆叠布局，胶囊化会破坏 R55 已调好的排版，
   这里覆盖回通栏 sticky（sticky 占文档流，无需 main 补偿），
   仅保留 ::after 进度线（改为通栏贴底）。
   ========================================================================== */
html.m-view .masthead{
  position:sticky;top:0;left:auto;transform:none;width:auto;
  border-left:0;border-right:0;border-top:0;
  border-bottom:1px solid var(--line);
  border-radius:0;
  background:var(--bg);
  -webkit-backdrop-filter:saturate(1.4) blur(10px);
  backdrop-filter:saturate(1.4) blur(10px);
  box-shadow:none;
}
html.m-view .masthead.scrolled{box-shadow:0 6px 24px rgba(20,40,80,.08)}
html.m-view .masthead::after{left:0;right:0;border-radius:0;}
html.m-view main.wrap{padding-top:14px}
