:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c1f23;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1f6feb;
  --brand-soft: #e8f0fe;
  --ok: #0f7b4f;
  --ok-soft: #e6f4ec;
  --warn: #9a6700;
  --warn-soft: #fff6dd;
  --err: #b42318;
  --err-soft: #fdeceb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --card: #1e2128;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --line: #2e333c;
    --brand: #5b9bff;
    --brand-soft: #1d2a44;
    --ok: #4cc38a;
    --ok-soft: #16302a;
    --warn: #e2b341;
    --warn-soft: #3a2f14;
    --err: #f97066;
    --err-soft: #3a1d1a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.site {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px 16px;
}

/* 频道页「回主站」入口：与 h1 同一行，排在标题左侧。
   胶囊外观保留（图标 + 文字），比纯图标更容易被认出来；
   h1 作为 flex item 需要 min-width:0 才能在长标题时收缩换行。 */
.site-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}
.site .site-bar h1 { margin: 0; flex: 0 1 auto; min-width: 0; }

.home-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.home-link svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.home-link:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.home-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.site h1 { margin: 0 0 8px; font-size: 24px; font-weight: 600; }
.site .sub { margin: 0; color: var(--muted); }
.site .privacy {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 12px;
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ---------- 子菜单（页签）：主流程与三个工具同级，同页切换 ---------- */
/* 容器做成一体化分段控件，而不是四个独立按钮：
   独立按钮看起来像「推荐位」，分段控件才像「同一层级的几个页面」。 */
.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 14px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.tab.is-active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.tab.is-active:hover { background: var(--brand); color: #fff; }

/* 切换时先摘后挂，中间会有一帧没有面板；给它一个最小高度，
   避免页面高度瞬间塌陷导致滚动条乱跳。 */
.tab-panel { min-height: 120px; }
.tab-panel[aria-busy="true"] { opacity: .6; transition: opacity .1s; }

/* 工具页上「返回批量处理」这类链接，嵌进工作台后就没意义了（上面有页签） */
.tab-panel .only-standalone { display: none; }

/* 短标签默认不显示，只在窄屏媒体查询里换出来（顺序不能反，同权重下后写的赢） */
.tab-short { display: none; }

@media (max-width: 430px) {
  /* 四个页签在 390px 上刚好差一点放不下，会逼用户横向滑一下才能看到最后一个。
     这里收紧凑一点 + 主流程用短标签，让四个一次性全露出来。 */
  .tabs { gap: 2px; padding: 3px; }
  .tab { padding: 8px 10px; font-size: 13px; }
  .tab-full { display: none; }
  .tab-short { display: inline; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
}

.preset-group { margin-bottom: 12px; }
.preset-group-name { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.opts label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.opts select,
.opts input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  min-width: 150px;
}

.opts input[type="number"] { min-width: 110px; }
.opts select:disabled,
.opts input:disabled { opacity: .5; }

.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.muted { color: var(--muted); font-size: 12px; }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drop.over { border-color: var(--brand); background: var(--brand-soft); }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.quota { font-size: 12px; color: var(--muted); }
.quota.warn { color: var(--warn); }
.quota.ok { color: var(--ok); }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* 链接形态的按钮（如结果区的「回到主页」），与 button 视觉一致 */
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

.status { font-size: 12px; color: var(--muted); }

.grid { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.grid th, .grid td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}
.grid th { color: var(--muted); font-weight: 500; font-size: 12px; }
.grid td.cell-name { max-width: 220px; word-break: break-all; }
.grid tr.empty td { color: var(--muted); text-align: center; padding: 18px; }
.grid tr.locked td { color: var(--warn); }

.tag {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  margin: 2px 4px 2px 0;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.error { background: var(--err-soft); color: var(--err); }

.link {
  border: 0;
  background: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

/* 广告位占位（顶部横幅 / 结果区）当前一律不展示。
   占位结构仍留在 HTML 里，将来真要接广告时把 display 改回 block 即可，
   不用回头改 index.html 与两个模板。 */
.ad {
  display: none;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}

.prose h2 { margin-top: 22px; }
.prose h3 { margin: 18px 0 6px; font-size: 14px; font-weight: 500; }
.prose p { color: var(--text); }
.prose table.grid td:first-child { white-space: nowrap; color: var(--muted); width: 120px; }

.crumb {
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px 12px;
}
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand); }
.crumb span { color: var(--text); }

.cta { display: inline-block; text-decoration: none; padding: 10px 18px; margin: 6px 0 0; }
.cta-card h2 { margin-top: 0; }
.cta-card p { color: var(--muted); font-size: 13px; }

.rel { margin: 0; padding-left: 18px; font-size: 13px; }
.rel li { margin: 6px 0; }
.rel a { color: var(--brand); text-decoration: none; }
.rel a:hover { text-decoration: underline; }

/* 首页「更多主图工具」：三个工具做成入口卡片，与上面的主流程卡片同级，
   不做成文字列表——列表在视觉上会被当成脚注，点击率不可比。 */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.tool-grid li { margin: 0; }
.tool-grid a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.tool-grid a:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}
.tool-grid strong { display: block; margin-bottom: 4px; font-size: 15px; color: var(--brand); }
.tool-grid span { display: block; font-size: 13px; line-height: 1.65; color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .45);
  overflow: auto;
  padding: 20px;
}

.modal.show { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: 12px;
  padding: 22px;
  width: 320px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-box h3 { margin: 0; font-size: 15px; }

.site-foot {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.9;
}

.foot-line { margin: 4px 0; }

.foot-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  font-variant-numeric: tabular-nums;
}

/* 标签与编号作为一组，避免被父级 flex 的 gap 拉开、也避免换行时两者分离 */
.foot-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.foot-label { white-space: nowrap; }

.foot-icp {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 1px;
}

.foot-icp:hover { color: var(--accent); border-bottom-color: var(--accent); }

.foot-todo {
  color: #b4690e;
  background: #fdf0d9;
  border: 1px dashed #e0a544;
  border-radius: 4px;
  padding: 1px 6px;
}

/* ============ 工具页共用组件（多尺寸 / 重命名 / 切图） ============ */

/* 平台多选：视觉上复用 chip，选中态靠 .active，
   这里只补「已选数量」这类角标的间距 */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip .cnt { opacity: .75; margin-left: 4px; font-size: 11px; }

/* 结果缩略图网格 */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.thumb {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--bg);
  border-radius: 6px;
}
.thumb .nm { font-size: 12px; word-break: break-all; line-height: 1.35; }
.thumb .meta { font-size: 11px; color: var(--muted); }

/* 切分预览：原图 + 绝对定位的切分线，线随图缩放自动对齐 */
.split-wrap {
  margin-top: 12px;
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.split-stage { position: relative; line-height: 0; }
.split-stage img { width: 100%; display: block; }
.split-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px dashed var(--brand);
  pointer-events: none;
}
.split-line span {
  position: absolute;
  right: 4px;
  top: 2px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.4;
}
.split-line.v { border-top: 0; border-left: 1.5px dashed var(--brand); top: 0; bottom: 0; }
.split-line.v span { top: 4px; right: 2px; }

.inline-note { color: var(--muted); font-size: 12px; }

.empty-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 18px 8px;
}

/* 文件名预览表：新旧名对照，冲突行标红 */
.rename-table td.old { color: var(--muted); text-decoration: line-through; }
.rename-table td.new { font-weight: 500; }
.grid tr.dup td.new { color: var(--err); }
.grid tr.dup td.new::after { content: " 重名"; font-size: 11px; }

/* hidden 属性必须能压过组件自身的 display 设置。
   .opts label 等是有 display:flex 的，UA 默认的 [hidden]{display:none}
   特异性太低会被覆盖，导致按模式隐藏的字段仍然显示出来。 */
[hidden] { display: none !important; }
