/* ==========================================================================
   GitHub 图床 — 样式
   配色基线：stone（暖灰），主色：翡翠绿（跟 GitHub 的绿点呼应）
   ========================================================================== */

:root {
  --bg: #f5f5f4;
  --bg-elev: #ffffff;
  --bg-sub: #fafaf9;
  --bg-hover: #f0efed;

  --line: #e7e5e4;
  --line-strong: #d6d3d1;

  --text: #1c1917;
  --text-sub: #57534e;
  --text-mute: #a8a29e;

  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --primary-line: #a7f3d0;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --danger-text: #991b1b;
  --ok-text: #065f46;
  --warn: #d97706;

  --scroll-thumb: #d6d3d1;
  --scroll-thumb-hover: #a8a29e;
  --drop-mask-bg: rgba(250, 250, 249, .9);
  --thumb-a: #f5f5f4;
  --thumb-b: #ffffff;
  --sk-a: #f0efed;
  --sk-b: #f8f7f6;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .06), 0 1px 3px rgba(28, 25, 23, .04);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, .08), 0 2px 4px rgba(28, 25, 23, .04);
  --shadow-lg: 0 16px 40px rgba(28, 25, 23, .16), 0 4px 12px rgba(28, 25, 23, .08);

  --topbar-h: 54px;
  --toolbar-h: 50px;
  --status-h: 30px;
}

/* ==========================================================================
   夜晚主题 —— 只覆盖变量，其余全部规则自动跟随
   ========================================================================== */
html[data-theme="dark"] {
  --bg: #171514;
  --bg-elev: #211e1c;
  --bg-sub: #1b1917;
  --bg-hover: #2d2926;

  --line: #33302d;
  --line-strong: #47423e;

  --text: #f2f0ee;
  --text-sub: #b6aea7;
  --text-mute: #857d76;

  --primary: #10b981;
  --primary-hover: #34d399;
  --primary-soft: rgba(16, 185, 129, .15);
  --primary-line: rgba(16, 185, 129, .34);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .15);
  --danger-line: rgba(248, 113, 113, .34);
  --danger-text: #fca5a5;
  --ok-text: #6ee7b7;
  --warn: #fbbf24;

  --scroll-thumb: #3d3835;
  --scroll-thumb-hover: #57514d;
  --drop-mask-bg: rgba(23, 21, 20, .88);
  --thumb-a: #262220;
  --thumb-b: #2e2a27;
  --sk-a: #262220;
  --sk-b: #322d2a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6), 0 4px 12px rgba(0, 0, 0, .4);
}

* {
  box-sizing: border-box;
}

/* 关键：.welcome/.empty/.grid 都设了 display:grid，会压过浏览器默认的
   [hidden]{display:none}，导致 hidden 元素依然占位。必须强制。 */
[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 2px solid var(--bg);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

/* ==========================================================================
   顶栏
   ========================================================================== */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
  /* 需求 3：给 .fs-exit-hit 提供定位上下文 */
  position: relative;
}

.topbar button,
.topbar .repo-chip {
  -webkit-app-region: no-drag;
}

/* ==========================================================================
   需求 3：全屏时的「点顶部空白退出全屏」热区
   --------------------------------------------------------------------------
   为什么需要这个元素，而不是直接给 .topbar 绑 click：
   .topbar 整体是 -webkit-app-region: drag（用来拖窗口）。Chromium 对 drag
   区域的鼠标事件是「直接吞掉」的 —— 里面永远收不到 click / mousedown。
   所以必须在 drag 区之上叠一个 no-drag 的元素来接事件。

   关键：不要用 absolute + 固定 left/right 去「估算」空白区有多宽。
   第一版就是那么写的（left:160px; right:400px），结果窗口一窄、或者切到
   英文按钮变宽，热区就压到右侧按钮上 —— 热区是 no-drag 又盖在上面，
   用户点「同步」反而退出了全屏。实测 1280 宽时按钮区已经 368px。

   改成 flex 布局里的一块「弹性空白」：
     - 它是 .topbar 的子元素，flex: 1 1 auto 吃掉所有剩余空间；
     - 前面是 brand / repo-chip（0 0 auto 不会缩），后面是
       .topbar-actions（margin-left:auto 且 0 0 auto），所以热区的实际
       矩形永远精确等于「两者之间的空白」，不可能压到按钮；
     - 平时 display:none 完全不参与布局，全屏时才变成 block。
   ========================================================================== */
.fs-exit-hit {
  display: none;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  -webkit-app-region: no-drag;
  cursor: pointer;
}

/* 全屏时才铺开 */
html.is-fullscreen .fs-exit-hit:not([hidden]) {
  display: block;
}

/* .topbar-actions 本来靠 margin-left:auto 贴右边。
   全屏时热区用 flex:1 抢剩余空间，两者会打架（auto margin 优先吃光剩余
   宽度，热区就被挤成 0 宽）。所以全屏时把 auto margin 收掉，
   让热区真正拿到那段空白。 */
html.is-fullscreen .topbar-actions {
  margin-left: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #10b981, #047857);
  box-shadow: 0 2px 6px rgba(5, 150, 105, .3);
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
}

.repo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  color: var(--text-sub);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.repo-chip:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
}

.repo-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-mute);
  transition: background .2s, box-shadow .2s;
}

.repo-chip .dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16);
}

.repo-chip .dot.offline {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .14);
}

.repo-chip .dot.checking {
  background: #f59e0b;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  /* 需求 3：语言切换时宽度必须恒定。
     min-width 由 JS 按「英文文案」量出来后写到 style 上（见 lockButtonWidths）,
     这里只负责让内容超宽时不要溢出，也别把按钮撑大。 */
  box-sizing: border-box;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, opacity .15s;
}

/* 已锁定宽度的按钮：文字居中，绝不再被内容撑开或收缩 */
.btn.width-locked {
  flex: 0 0 auto;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-lg {
  height: 40px;
  padding: 0 22px;
  font-size: 13.5px;
  border-radius: var(--radius);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-ghost {
  border-color: var(--line);
  background: var(--bg-elev);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(5, 150, 105, .28);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(.92);
}

.btn-danger-ghost {
  border-color: var(--danger-line);
  background: var(--bg-elev);
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-sub);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.spacer {
  flex: 1 1 auto;
}

/* ==========================================================================
   工具条
   ========================================================================== */
.toolbar {
  height: var(--toolbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  flex: 0 0 300px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-mute);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 31px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sub);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.search-wrap input:focus {
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .1);
}

.search-wrap input::placeholder {
  color: var(--text-mute);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-mute);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1 1 auto;
  min-width: 0;
  scrollbar-width: none;
  padding: 2px 0;
}

.filter-group::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--bg-sub);
  color: var(--text-sub);
  font-size: 11.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .15s;
}

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

.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--primary-hover);
  font-weight: 600;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.stat {
  font-size: 12px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.divider-v {
  width: 1px;
  height: 16px;
  background: var(--line);
}

/* ==========================================================================
   内容区
   ========================================================================== */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  position: relative;
  /* 1.3.0 需求 5：原来这里有 will-change: transform + transform 过渡，
     给 JS 的橡皮筋回弹（setupOverscroll）配动画。回弹已移除，
     这两条也一起去掉 —— 留着 will-change 还会白白占一个合成层。 */
}

/* ---------- 图片网格 ---------- */
/* 需求 1：固定每行 5 张，均匀分布。
   以前是 repeat(auto-fill, minmax(178px, 1fr))，列数会随窗口变化（3~7 列不定），
   看起来忽宽忽窄。现在锁死 5 列，1fr 让每张卡等宽平分，
   gap 用 clamp + vw 跟窗口宽度联动 —— 窗口拉宽时卡和间距一起变大，
   不会出现「卡变大但缝隙还是 12px」的割裂感。
   窗口最小宽度是 900px，5 列时每张仍有 ~150px，够放。

   需求 6：卡片高度由 JS 算好后写进 --card-h / --thumb-h，
   保证 10 张（2 行）在当前窗口里始终完整显示，不出现滚动。
   --card-h 有兜底值，JS 还没跑起来时布局也不会塌。 */
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.15vw, 22px);
  align-content: start;
}

/* 说明：1.3.0 曾经有个 .grid-fit class（10 条两行时切一下 align-content），
   后来发现它和上面的基础规则完全一样，纯属多余 —— 而且它在
   ResizeObserver 回调里 toggle，会连锁改变内容区尺寸，引发
   "ResizeObserver loop completed with undelivered notifications" 警告。
   已删除：CSS 规则和 JS 里的 toggle 都不再需要。 */

.card {
  position: relative;
  /* 需求 6：高度由 JS 算（--card-h），没算出来时用 4:3 的宽度推算兜底。
     用 height 而不是 aspect-ratio —— aspect-ratio 由宽度驱动，
     窗口很宽但很矮时会把卡片撑出可视区。 */
  height: var(--card-h, auto);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, .22);
}

.card-thumb {
  position: relative;
  /* 需求 6：高度来自 JS 算的 --thumb-h（= 卡片高 - 文字区高）。
     flex:1 让它吃掉卡片内除文字区之外的全部空间，
     这样 .card-meta 的固定高度一改，缩略图自动跟着调整。 */
  flex: 1 1 auto;
  min-height: 0;
  background:
    repeating-conic-gradient(var(--thumb-a) 0% 25%, var(--thumb-b) 0% 50%) 50% / 16px 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* PC / 移动端一致：优先显示完整图片，留白用探测到的相近色填充 */
.card-thumb.filled {
  background-image: none;
  background-color: var(--thumb-fill, var(--bg-sub));
}

.card-thumb img {
  /* 必须绝对定位铺满容器：grid 的 place-items:center 会让 img 按图片宽高比
     撑成 364x364，超出只有 195px 高的容器后被 overflow:hidden 裁掉下半部分，
     表现就是「object-fit:contain 了却仍显示不全」。 */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity .25s;
  opacity: 0;
}

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

.card-thumb .thumb-fallback {
  position: absolute;
  inset: 0;
  /* 只在图片彻底加载失败时才显示；默认隐藏，否则会盖在成功加载的图片上 */
  display: none;
  place-items: center;
  color: var(--text-mute);
  font-size: 11px;
  text-align: center;
  padding: 8px;
  word-break: break-all;
}
.card-thumb .thumb-fallback.show {
  display: grid;
  z-index: 1;
}

.card-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(28, 25, 23, .72);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.card-pick {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .9);
  background: rgba(28, 25, 23, .42);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  color: transparent;
  opacity: .55;
  transition: opacity .15s, background .15s, transform .12s;
}

/* hover 时明确提示可点，选中后常亮 */
.card:hover .card-pick {
  opacity: 1;
  transform: scale(1.06);
}

.card.selected .card-pick {
  opacity: 1;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.card-pick svg {
  width: 11px;
  height: 11px;
}

/* 悬停操作条 */
.card-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 1px;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity .16s, transform .16s;
}

.card:hover .card-actions {
  opacity: 1;
  transform: translateY(0);
}

.card-act {
  flex: 1 1 0;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  background: rgba(28, 25, 23, .76);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  transition: background .13s;
}

.card-act:hover {
  background: var(--primary);
}

.card-act.act-del:hover {
  background: var(--danger);
}

.card-act svg {
  width: 14px;
  height: 14px;
}

/* 需求 6：这个高度必须和 app.js 里的 CARD_META_H 常量严格一致（46px），
   JS 用「卡片总高 - 这个值」算缩略图高度。改 padding / line-height 时要同步。
   计算：7(上padding) + 18(文件名行) + 2(margin) + 16(副行) + 8(下padding) - 1(边框)= 46
   用 flex:0 0 auto 固定住，不让它被 flex 拉伸。 */
.card-meta {
  flex: 0 0 auto;
  height: 26px;
  box-sizing: border-box;
  padding: 4px 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.card-name {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 18px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  margin-top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  line-height: 16px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

.card-sub .dir {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 骨架屏 ---------- */
.skeleton-grid .sk {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  overflow: hidden;
}

.skeleton-grid .sk-thumb {
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 50%, var(--sk-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

.skeleton-grid .sk-line {
  height: 9px;
  margin: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--sk-a) 25%, var(--sk-b) 50%, var(--sk-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}

.skeleton-grid .sk-line.short {
  width: 46%;
  margin-top: -2px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- 空态 / 引导 ---------- */
.empty,
.welcome {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-items: center;
}

.empty-inner {
  text-align: center;
  color: var(--text-mute);
  max-width: 380px;
}

.empty-inner svg {
  color: var(--line-strong);
  margin-bottom: 10px;
}

.empty-inner p {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
}

.empty-inner span {
  font-size: 12px;
}

.welcome-inner {
  text-align: center;
  max-width: 460px;
  padding: 20px;
}

.welcome-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
}

.welcome h1 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
}

.welcome p {
  margin: 0 0 22px;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.6;
}

.welcome-hint {
  margin-top: 18px !important;
  font-size: 11.5px !important;
  color: var(--text-mute) !important;
}

.welcome-hint a {
  color: var(--primary);
  text-decoration: none;
}

.welcome-hint a:hover {
  text-decoration: underline;
}

.welcome-hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--text-sub);
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
}

/* ==========================================================================
   底栏：选中操作（左） + 分页（右）—— 需求 2
   以前选中操作条是 sticky 浮在网格顶部的，勾选后会把图片往下挤一截，
   而且和分页条分处屏幕上下两端，看着像两套东西。现在合成一条：
   固定在分页那一行，不参与网格布局，勾选前后网格高度完全不变。
   ========================================================================== */
/* ==========================================================================
   底栏：左 选中操作 / 中 分页导航 / 右 每页条数（需求 2）
   --------------------------------------------------------------------------
   布局用 grid 的 [1fr auto 1fr]：
     左右两列强制等宽（1fr 各占一半剩余空间），中间列按内容自适应。
     于是中间那组无论左右内容多宽，都严格落在整条栏的正中。
   为什么不用 flex + spacer：flex 里中间元素的位置取决于左右两侧的宽度差，
   中文切英文、选中数从 0 变成 100 都会让它左右漂。
   ========================================================================== */
.selzone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* 没勾选时整条灰掉、不可点（需求：默认灰色，不可选） */
.selzone.is-idle {
  opacity: .42;
  pointer-events: none;
  filter: saturate(.35);
}

/* 灰掉时仍然允许 hover 看到 tooltip，但不响应点击 */
.selzone.is-idle .btn {
  cursor: default;
}

.selbar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-hover);
  font-variant-numeric: tabular-nums;
  /* 固定宽度，避免「未选择」→「已选 1 张」→「已选 100 张」时整条左栏抖动。
     1.3.0 需求 2 把它从 58px 提到 76px：英文 "None selected" 需要约 74px，
     58px 会把文字挤成两行（或者撑开整条选中区，把分页条的中段挤歪）。
     76px 能同时容纳中文「已选 99 张」和英文 "99 selected"。 */
  min-width: 76px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selzone.is-idle .selbar-count {
  color: var(--text-mute);
  font-weight: 500;
}

/* ==========================================================================
   分页条
   ========================================================================== */
.pager {
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-sub);
  overflow: hidden;
}

/* 左列：内容从左边开始 */
.pager-left {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

/* 中列：严格居中（它本来就是 auto 宽，居中由 grid 保证） */
.pager-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  /* 给一个最小宽度，翻页时页码从「第 1/1 页」变「第 1/12 页」
     不会把两侧挤动 */
  min-width: 190px;
}

/* 右列：内容贴右边 */
.pager-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.pager-info {
  min-width: 86px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
  white-space: nowrap;
}

/* 每页条数：三个选项等宽，切换语言时不会变宽变窄 */
.pager-size .seg {
  min-width: 40px;
}

/* 每页 >10 时的风险提示 */
.pager-warn {
  font-size: 11px;
  color: var(--warn);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   状态栏
   ========================================================================== */
.statusbar {
  height: var(--status-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-sub);
}

.muted {
  color: var(--text-mute);
}

/* ==========================================================================
   上传进度
   ========================================================================== */
.progress-wrap {
  position: fixed;
  right: 16px;
  bottom: calc(var(--status-h) + 14px);
  width: 268px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: slideUp .22s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
}

.progress-bar {
  height: 4px;
  border-radius: 3px;
  background: var(--bg-hover);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #34d399, #059669);
  transition: width .3s ease;
}

/* ==========================================================================
   拖拽遮罩
   ========================================================================== */
.drop-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: var(--drop-mask-bg);
  backdrop-filter: blur(3px);
}

.drop-inner {
  display: grid;
  place-items: center;
  gap: 10px;
  width: min(420px, 76vw);
  height: min(240px, 44vh);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-lg);
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 14px;
  font-weight: 600;
}

/* ==========================================================================
   设置抽屉
   ========================================================================== */
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(28, 25, 23, .28);
  animation: fadeIn .18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 92vw;
  z-index: 91;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: slideIn .22s cubic-bezier(.32, .72, 0, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 16px;
}

.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-sub);
}

/* ---------- 表单 ---------- */
.field {
  margin-bottom: 15px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.field label em {
  color: var(--danger);
  font-style: normal;
}

.field input,
.field select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sub);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.field select {
  padding-right: 6px;
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .1);
}

.field input::placeholder {
  color: var(--text-mute);
}

.field-hint {
  margin: 5px 0 0;
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.55;
}

.field-hint a {
  color: var(--primary);
  text-decoration: none;
}

.field-hint a:hover {
  text-decoration: underline;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.input-with-btn input {
  flex: 1 1 auto;
  min-width: 0;
}

.input-with-btn .btn {
  flex: 0 0 auto;
  height: 34px;
}

/* 结果提示框 */
.verify-box {
  margin: 4px 0 15px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid;
}

.verify-box.ok {
  background: var(--primary-soft);
  border-color: var(--primary-line);
  color: var(--ok-text);
}

.verify-box.err {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-text);
}

.verify-box b {
  font-weight: 600;
}

/* 高级折叠 */
.advanced {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.advanced summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.advanced summary::before {
  content: "▸ ";
  color: var(--text-mute);
}

.advanced[open] summary::before {
  content: "▾ ";
}

.advanced-body {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.8;
  word-break: break-all;
}

/* 关于面板里的维护操作按钮（需求 4） */
/* 需求 8：三个维护按钮**等宽均分**整行。
   flex: 1 1 0 + min-width: 0 是等分的关键 ——
     只写 flex:1 时，flex-basis 是 auto，三项会按各自内容宽度分配，
     「清空缓存」比「备份配置」字少，就会窄一截，看着不整齐。
   用 basis 0 才是真正的「平分剩余空间」。
   中英文切换时字长变化也不会破坏均分（min-width:0 允许收缩）。 */
/* 关于面板里的桌面版下载入口 */
.about-desktop {
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sub);
}
.about-desktop .btn {
  width: 100%;
  height: 32px;
  text-decoration: none;
}
.about-desktop .field-hint {
  margin: 6px 0 0;
}

.about-actions {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
  display: flex;
  gap: 7px;
  word-break: normal;
}

.about-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 4px;
  word-break: normal;
  /* 均分之后宽度由容器决定，不再需要 JS 锁的 min-width，否则会互相挤 */
  min-width: 0 !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 签名（需求 6 / 需求 9）
   注意这里不能用 data-i18n 整体赋值 —— 里面有两处可点击链接，
   整体 textContent 会把 <a> 冲掉。改由 renderSignature() 拼 DOM。 */
.about-cache-hint {
  margin: 7px 0 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--text-mute);
  word-break: normal;
}

.about-sign {  margin: 14px 0 2px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-mute);
  text-align: center;
  word-break: normal;
  letter-spacing: .2px;
}

/* 签名里的可点击部分（作者名 / 网址） */
.about-sign .sign-link {
  color: var(--text-sub);
  text-decoration: none;
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 1px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.about-sign .sign-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.about-sign .sign-sep {
  color: var(--line-strong);
  padding: 0 2px;
}

.advanced-body code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  color: var(--text-sub);
}

/* ==========================================================================
   右键菜单
   ========================================================================== */
.ctx-menu {
  position: fixed;
  z-index: 120;
  min-width: 178px;
  padding: 5px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: ctxIn .12s ease-out;
}

@keyframes ctxIn {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.ctx-item:hover {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.ctx-item.danger {
  color: var(--danger);
}

.ctx-item.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.ctx-item .ctx-key {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--text-mute);
}

.ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-stack {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 460px;
  padding: 9px 15px;
  border-radius: 22px;
  background: rgba(28, 25, 23, .92);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .24s cubic-bezier(.32, .72, 0, 1);
}

.toast.ok {
  background: rgba(5, 150, 105, .95);
}

.toast.err {
  background: rgba(220, 38, 38, .95);
}

.toast.warn {
  background: rgba(217, 119, 6, .96);
}

.toast.leaving {
  animation: toastOut .2s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(.96); }
}

/* ==========================================================================
   分段控件（语言切换 / 每页条数）
   --------------------------------------------------------------------------
   需求 4：外框高度必须和它后面的 .btn 一致（32px）。
   原来写的是 28px，比旁边的主题按钮、同步按钮矮 4px，顶栏一行看过去
   语言切换明显陷下去一块，基线不齐。

   算式：1(border) + 2(padding) + 26(.seg) + 2(padding) + 1(border) = 32
   所以 .seg 同步改成 26px（原 22px），保持内缩 2px 的视觉层次。
   padding 用 0 而不是 0 7px：高度已经由 height 定死，左右留白交给 padding
   会让 min-width 算法跟着变，英文 "EN" 和中文 "中" 宽度差异被放大。
   ========================================================================== */
.seg-group {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 2px;
  border-radius: 8px;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  box-sizing: border-box;
  flex: 0 0 auto;
}

.seg {
  min-width: 30px;
  height: 26px;
  padding: 0 7px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-mute);
  font-size: 11.5px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  box-sizing: border-box;
  transition: background .14s, color .14s, box-shadow .14s;
}

.seg:hover {
  color: var(--text-sub);
}

.seg.active {
  background: var(--bg-elev);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   图标按钮 + 主题图标切换
   ========================================================================== */
.btn-icon {
  width: 32px;
  padding: 0;
  border-color: var(--line);
  background: var(--bg-elev);
  color: var(--text-sub);
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

/* 白天显示太阳（点它去夜晚），夜晚显示月亮 */
.btn-icon .ico-moon { display: none; }
html[data-theme="dark"] .btn-icon .ico-sun { display: none; }
html[data-theme="dark"] .btn-icon .ico-moon { display: block; }

/* ==========================================================================
   状态栏：上传目标徽标
   ========================================================================== */
.target-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 300px;
  height: 19px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  color: var(--primary-hover);
  font-size: 10.5px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.target-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

/* 独立成段的说明文字（跨整行的 hint） */
.hint-block {
  margin: -8px 0 15px;
}

/* ==========================================================================
   深色主题下需要单独微调的几处（用纯色写法的阴影 / 高光）
   ========================================================================== */
html[data-theme="dark"] .card.selected {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, .3);
}

html[data-theme="dark"] .brand-logo {
  background: linear-gradient(140deg, #10b981, #065f46);
  box-shadow: 0 2px 8px rgba(16, 185, 129, .28);
}

html[data-theme="dark"] .card-act {
  background: rgba(10, 9, 8, .74);
}

html[data-theme="dark"] .drawer-mask {
  background: rgba(0, 0, 0, .55);
}

html[data-theme="dark"] .toast {
  background: rgba(52, 47, 44, .96);
}

html[data-theme="dark"] .btn-primary {
  color: #06231a;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

html[data-theme="dark"] .btn-danger {
  color: #2a0a0a;
  font-weight: 600;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
}

/* 主题切换不加全局 transition：
   大范围元素的 background-color 过渡会和 CSS 变量刷新不同步，
   切换瞬间容易残留旧配色，直接切更稳。 */

/* ==========================================================================
   通用弹窗（需求 1）
   --------------------------------------------------------------------------
   为什么不用原生 window.confirm：
     - 它是 Chromium 自绘的，配色跟系统走，不跟应用的白天/夜晚主题
     - 按钮文案固定成「确定/取消」，改不了
     - 加不了图标、加不了勾选框、加不了副标题
     - 在 Electron 里它还会阻塞渲染进程（整个窗口卡住，动画全停）
   所以自绘一个，位置固定在屏幕中央偏上（视觉重心舒服，不会被任务栏挡）。
   ========================================================================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 25, 23, .42);
  backdrop-filter: blur(3px);
  animation: modalMaskIn .16s ease-out;
}

.modal-mask.leaving {
  animation: modalMaskOut .15s ease-in forwards;
}

@keyframes modalMaskIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalMaskOut {
  to { opacity: 0; }
}

.modal {
  width: 100%;
  max-width: 424px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  padding: 20px 20px 16px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s cubic-bezier(.32, .72, 0, 1);
}

.modal-mask.leaving .modal {
  animation: modalOut .15s ease-in forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalOut {
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}

/* ---------- 头部：图标 + 标题 + 副标题 ---------- */
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  flex: 0 0 auto;
}

.modal-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-line);
}

.modal-icon svg {
  width: 19px;
  height: 19px;
}

/* 危险操作：红色调 */
.modal.danger .modal-icon {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-line);
}

/* 警告（比如流量风险）：琥珀色 */
.modal.warn .modal-icon {
  background: rgba(217, 119, 6, .1);
  color: var(--warn);
  border-color: rgba(217, 119, 6, .3);
}

.modal-heading {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 1px;
}

.modal-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text);
  word-break: normal;
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-mute);
  word-break: normal;
}

/* ---------- 正文 ---------- */
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  margin-top: 13px;
  font-size: 12.5px;
  line-height: 1.72;
  color: var(--text-sub);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* 正文里的强调片段（文件名、路径） */
.modal-body .mk {
  color: var(--text);
  font-weight: 600;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  word-break: break-all;
}

.modal-body .mk-danger {
  color: var(--danger-text);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}

/* ---------- 勾选框 ---------- */
.modal-check {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg-sub);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s;
}

.modal-check:hover {
  border-color: var(--line-strong);
}

/* 真正的 checkbox 藏起来，用自绘方块 —— 原生在各平台长得都不一样 */
.modal-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.modal-check-box {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg-elev);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}

.modal-check-box svg {
  width: 11px;
  height: 11px;
}

.modal-check input:checked + .modal-check-box {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.modal-check input:focus-visible + .modal-check-box {
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .22);
}

/* ---------- 按钮区 ---------- */
.modal-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.modal-foot .btn {
  min-width: 86px;
  height: 34px;
}

/* 危险确认的主按钮走红色 */
.modal.danger #modalOk {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 2px rgba(220, 38, 38, .28);
}

.modal.danger #modalOk:hover:not(:disabled) {
  filter: brightness(.92);
}

/* 白天模式下 danger 按钮文字保持白色；夜晚模式文字要深色才看得清 */
html[data-theme="dark"] .modal.danger #modalOk {
  color: #2a0a0a;
  font-weight: 600;
}

html[data-theme="dark"] .modal-mask {
  background: rgba(0, 0, 0, .58);
}

html[data-theme="dark"] .modal {
  box-shadow: 0 24px 60px rgba(0, 0, 0, .7), 0 8px 20px rgba(0, 0, 0, .5);
}

html[data-theme="dark"] .modal-check input:checked + .modal-check-box {
  color: #06231a;
}

/* ===== Web 版微调（已合并，减少一个 HTTP 请求） =====
   桌面端用 -webkit-app-region 拖窗口，浏览器里没有原生标题栏，统一放开点击区域。 */
.topbar {
  -webkit-app-region: no-drag !important;
}

/* 关于面板里的长段说明在窄屏下不要挤成一团 */
.advanced-body code {
  overflow-wrap: anywhere;
  word-break: break-all;
}

/* ===== 图片大图预览灯箱 =====
   层级 250：高于 toast(200)，低于确认弹窗(300)，
   这样在预览里触发的确认框仍然盖在图片上面。 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 52px 72px 64px;
  background: rgba(12, 10, 9, .9);
  animation: lbIn .14s ease-out;
}
.lightbox[hidden] {
  display: none;
}
@keyframes lbIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  /* 给舞台明确尺寸，图片的 max-height:100% 才有参照物；
     否则大图会按原始尺寸溢出视口，看起来「放大后显示不全」。 */
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}
.lb-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 16px 56px rgba(0, 0, 0, .55);
}
.lb-fallback {
  padding: 24px 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: #e7e5e4;
  font-size: 13px;
  text-align: center;
}
.lb-fallback[hidden] {
  display: none;
}

.lb-close,
.lb-nav,
.lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #f5f5f4;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.lb-close:hover,
.lb-nav:hover,
.lb-btn:hover {
  background: rgba(255, 255, 255, .22);
}
.lb-close:active,
.lb-nav:active,
.lb-btn:active {
  transform: scale(.94);
}

.lb-close {
  top: 14px;
  right: 18px;
  width: 38px;
  height: 38px;
}
.lb-nav {
  top: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
}
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-nav[hidden] {
  display: none;
}

.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent);
}
.lb-counter {
  font-size: 12px;
  color: #d6d3d1;
  font-variant-numeric: tabular-nums;
}
.lb-bar-spacer {
  flex: 1 1 auto;
}
.lb-btn {
  position: static;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

/* 灯箱右下角：红色删除按钮 */
.lb-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(248, 113, 113, .55);
  background: rgba(127, 29, 29, .55);
  color: #fecaca;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.lb-delete:hover { background: #dc2626; border-color: #f87171; color: #fff; }
.lb-delete:active { transform: scale(.96); }

@media (max-width: 640px) {
  .lightbox { padding: 48px 12px 60px; }
  .lb-nav { width: 36px; height: 36px; margin-top: -18px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
}

/* MOBILE-BASE-BEGIN */
.mobile-only,
.mobile-tool-row,
.pager-info-m,
.pager-size-select,
.sync-label-m,
.theme-switch-mobile { display: none; }
.topbar-menu { display: flex; align-items: center; gap: 6px; }

/* 设置抽屉：跟顶栏/分页一致的圆角、柔和底色与聚焦绿环 */
.drawer { border-radius: 14px 0 0 14px; }
.drawer-head { padding: 16px 18px; }
.drawer-head h2 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.drawer-body { padding: 18px; }
.drawer-foot { padding: 12px 18px; }
.field { margin-bottom: 17px; }
.field label { margin-bottom: 7px; font-size: 12.5px; font-weight: 700; color: var(--text-sub); }
.field input,
.field select {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-sub);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2357534e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.field input:focus,
.field select:focus {
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, .12);
}
.field-hint { line-height: 1.6; }
/* MOBILE-BASE-END */

/* MOBILE-STRUCT-BEGIN */
/* 移动端适配：只在这里改，PC 端的规则完全不动 */
@media (max-width: 768px) {
  :root {
    --topbar-h: 56px;
    --toolbar-h: 50px;
    --status-h: 0px;
  }
  body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

  /* 顶部：左 logo，右 菜单 / 刷新 / 上传 */
  .topbar { gap: 8px; padding: 0 12px; }
  .brand { gap: 7px; }
  .brand-name { display: inline; font-weight: 700; white-space: nowrap; }
  .repo-chip { display: none; }
  .topbar-actions { gap: 6px; margin-left: auto; }
  .topbar .divider-v { display: none; }
  .topbar .btn { height: 38px; padding: 0 9px; }
  .topbar .btn span { display: none; }
  .topbar-actions > #btnUpload span { display: inline; }
  .mobile-only { display: inline-flex !important; }
  #btnUpload { padding: 0 12px; }

  /* 顶部折叠菜单：语言 / 主题 / 同步 / 设置 */
  .topbar .topbar-menu {
    position: absolute;
    top: calc(var(--topbar-h) - 2px);
    right: 10px;
    z-index: 70;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 156px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-elev);
    box-shadow: var(--shadow-lg);
  }
  .topbar .topbar-menu.open { display: flex; }
  .topbar-menu .btn { width: 100%; height: 38px; justify-content: flex-start; }
  .topbar .topbar-menu .btn span { display: inline; }
  .topbar-menu .seg-group { width: 100%; height: 38px; }
  .topbar-menu .seg { height: 34px; flex: 1 1 0; }
  .topbar .topbar-menu .seg.active { background: var(--primary); color: #fff; box-shadow: none; }
  .topbar .topbar-menu #btnTheme { display: none; }
  .theme-switch-mobile { display: flex; }
  .topbar .topbar-menu #btnSync .sync-label-pc { display: none; }
  .topbar .topbar-menu #btnSync .sync-label-m { display: inline; }
  .topbar-menu .divider-v { display: none; }

  /* 第二行：左 仓库名 / 右 文件夹下拉 */
  .toolbar { gap: 8px; padding: 0 10px; }
  .toolbar > .search-wrap,
  .toolbar > .filter-group,
  .toolbar > .toolbar-right { display: none; }
  .mobile-tool-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }
  .mobile-repo {
    flex: 1 1 auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 62%;
    height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-sub);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
    color: var(--text);
  }
  .mobile-repo-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(14px, calc(12.5px + 0.38vw), 20px);
    font-weight: 600;
  }
  .mobile-repo .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--text-mute);
    transition: background .2s, box-shadow .2s;
  }
  .mobile-repo .dot.online { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }
  .mobile-repo .dot.offline { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .14); }
  .mobile-repo .dot.checking { background: #f59e0b; animation: pulse 1.1s ease-in-out infinite; }

  .mobile-dir-wrap {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .mobile-dir-label {
    color: var(--text-sub);
    font-size: clamp(13px, calc(11.5px + 0.34vw), 18px);
    font-weight: 700;
    white-space: nowrap;
  }
  .mobile-dir-select {
    appearance: none;
    -webkit-appearance: none;
    max-width: 100%;
    height: 36px;
    padding: 0 32px 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background-color: var(--bg-elev);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
    color: var(--text);
    font-weight: 600;
    font-size: clamp(14px, calc(12.5px + 0.38vw), 20px);
  }
  .mobile-dir-select:focus,
  .pager-size-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(5, 150, 105, .14); }

  .content { padding: 12px; }
  .grid {
    /* 窄屏 1 列；屏宽足够时自动变 2 列，PC 端仍是固定 5 列 */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: clamp(10px, 3vw, 18px);
  }
  .card-meta { height: 34px; padding: 5px 10px; }
  .thumb-fallback { font-size: 14px; }
  .card-badge { top: 8px; left: 8px; }

  /* 整图优先：留白用图片近似色填充；三个操作按钮在手机上常驻 */
  .card-thumb {
    background-image: none !important;
    background-color: var(--thumb-fill, var(--bg-sub));
  }
  .card-thumb img { object-fit: contain; }
  .card-actions { opacity: 1; transform: none; }
  .card-act { height: 34px; }
  /* 移动端不需要多选：右上角勾选圈不再显示 */
  .card-pick { display: none !important; }

  /* 底栏：只留 上一页 / 当前页-总页数 / 下一页（左）和每页条数下拉（右） */
  .pager {
    height: auto;
    min-height: 56px;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, .05);
  }
  .pager-left { display: none; }
  .pager-nav { justify-content: flex-start; min-width: 0; gap: 6px; }
  .pager-right { justify-content: flex-end; min-width: 0; }
  .pager-info, .pager-size, .pager-warn { display: none; }
  .pager-info-m {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    color: var(--primary-hover);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    white-space: nowrap;
  }
  .pager-size-select {
    display: block;
    appearance: none;
    -webkit-appearance: none;
    height: 34px;
    padding: 0 30px 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background-color: var(--bg-elev);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
    color: var(--text);
    font-weight: 600;
    font-size: clamp(14px, calc(12.5px + 0.38vw), 20px);
  }
  .pager .btn-sm {
    height: 34px;
    padding: 0 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-sub);
    color: var(--text);
    font-weight: 600;
  }
  .pager .btn-sm:disabled { opacity: .42; }
  .selzone { gap: 6px; }

  /* 最底部同步状态栏不显示 */
  .statusbar { display: none; }

  .drawer { width: 100%; max-width: 100%; top: 24px; border-radius: 16px 16px 0 0; }
  .drawer-body { padding: 18px 14px; }
  .field-row { grid-template-columns: 1fr; gap: 14px; }
  .field input, .field select { height: 44px; border-radius: 12px; }
  .drawer-foot { flex-wrap: wrap; padding: 10px 12px; }
  .drawer-foot .btn { flex: 1 1 auto; }
  .about-actions { flex-wrap: wrap; }
  .about-actions .btn { flex: 1 1 45%; }

  .lightbox { padding: 56px 12px 64px; }
  .lb-bar { height: 56px; padding: 0 12px; }
  .lb-btn { width: 38px; height: 38px; }
  .lb-delete { height: 38px; padding: 0 13px; }
}
/* MOBILE-STRUCT-END */

/* MOBILE-FONTS-BEGIN */
/* 由 gen-mobile.js 从 style.css 自动生成：所有字号随屏宽浮动并整体放大 */
@media (max-width: 768px) {
  body { font-size: clamp(15px, calc(13.5px + 0.40vw), 21px); }
  .brand-name { font-size: clamp(15.5px, calc(14px + 0.42vw), 21.5px); }
  .repo-chip { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .btn { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .btn-sm { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .btn-lg { font-size: clamp(15px, calc(13.5px + 0.40vw), 21px); }
  .icon-btn { font-size: clamp(21.5px, calc(19px + 0.57vw), 29.5px); }
  .search-wrap input { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .search-clear { font-size: clamp(17px, calc(15px + 0.45vw), 23.5px); }
  .chip { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .stat { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .card-thumb .thumb-fallback { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .card-badge { font-size: clamp(11px, calc(10px + 0.30vw), 15.5px); }
  .card-name { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .card-sub { font-size: clamp(12px, calc(10.5px + 0.32vw), 16.5px); }
  .empty-inner p { font-size: clamp(15px, calc(13.5px + 0.40vw), 21px); }
  .empty-inner span { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .welcome h1 { font-size: clamp(21.5px, calc(19px + 0.57vw), 29.5px); }
  .welcome p { font-size: clamp(14.5px, calc(13px + 0.39vw), 20px); }
  .welcome-hint { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px) !important; }
  .welcome-hint code { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .selbar-count { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .pager { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .pager-warn { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .statusbar { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .progress-head { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .drop-inner { font-size: clamp(15.5px, calc(14px + 0.42vw), 21.5px); }
  .drawer-head h2 { font-size: clamp(17px, calc(15px + 0.45vw), 23.5px); }
  .field label { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .field input, .field select { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .field-hint { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .verify-box { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .advanced summary { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .advanced-body { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .about-cache-hint { font-size: clamp(12px, calc(10.5px + 0.32vw), 16.5px); }
  .about-sign { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .advanced-body code { font-size: clamp(12.5px, calc(11px + 0.33vw), 17px); }
  .ctx-item { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .ctx-item .ctx-key { font-size: clamp(12px, calc(10.5px + 0.32vw), 16.5px); }
  .toast { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .seg { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .target-badge { font-size: clamp(12px, calc(10.5px + 0.32vw), 16.5px); }
  .modal-title { font-size: clamp(16px, calc(14.5px + 0.43vw), 22.5px); }
  .modal-sub { font-size: clamp(13px, calc(11.5px + 0.34vw), 18px); }
  .modal-body { font-size: clamp(14px, calc(12.5px + 0.38vw), 19.5px); }
  .modal-body .mk { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .modal-check { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .lb-fallback { font-size: clamp(14.5px, calc(13px + 0.39vw), 20px); }
  .lb-counter { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
  .lb-delete { font-size: clamp(13.5px, calc(12px + 0.36vw), 18.5px); }
}
/* MOBILE-FONTS-END */
