/* ============================================================
   工具页通用布局层（2026-10-29 抽自「格式转换 / 批量调整尺寸」）
   ------------------------------------------------------------
   目的：图片类工具都是「预览卡 + 参数卡 + 文件列表条 + 结果条」四件套，
   以前每个工具各写一套（cv-* / rsz-* / cxo-*），改一次要改三处、还容易走形。
   这里只放**结构**，颜色全走主题令牌，具体工具只需挂上 tl-* 类名。

   用法：
     <div class="tl-main">
       <div class="tl-stage"><div class="tl-stage-hd">…</div><div class="tl-stage-bd">…</div></div>
       <aside class="tl-side"><div class="tl-side-hd">…</div><div class="tl-side-bd">…</div></aside>
     </div>
     <div class="tl-list"><div class="tl-list-hd">…</div><div class="tl-list-bd">…</div></div>
     <div class="tl-result">…</div>
   可调变量（挂在工具视图上即可）：
     --tool-maxw  内容区最大宽度
     --tool-side  参数栏宽度（默认 304）
     --tool-gap   卡片间距（默认 14）
   ============================================================ */

/* ---------- 主栅格：预览吃剩余宽度 + 参数栏定宽 ---------- */
.tl-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--tool-side, 304px);
  gap: var(--tool-gap, 14px);
  align-items: stretch;
  min-width: 0;
}

/* ---------- 预览卡：外层一张卡，内部标题行 / 舞台 / 可选底栏 ---------- */
.tl-stage {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.tl-stage-hd {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 14px; min-height: 40px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.tl-stage-t {
  font-size: var(--hx-t12-5); color: var(--text-2); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tl-stage-m {
  flex: none; font-size: var(--hx-t12); color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
/* 舞台本体：棋盘透明底；图只缩不放，小图保持原尺寸居中 */
.tl-stage-bd {
  --tl-pad: 14px;
  position: relative; flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center; padding: var(--tl-pad); overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #eceef1 25%, transparent 25%, transparent 75%, #eceef1 75%),
    linear-gradient(45deg, #eceef1 25%, transparent 25%, transparent 75%, #eceef1 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  transition: background-color .15s var(--ease);
}
/* 拍平预览（JPEG / BMP 等无透明格式）：背景色只铺在 img 自己的盒子上
   （见 convert-tool.js syncFlat），舞台的棋盘必须留着。
   ⚠️ 这里曾经有一条 `.tl-stage-bd.is-flat{background-image:none}`，
   会把整块舞台一起变成纯白，看起来像输出的 JPEG 整张画布都被填白 —— 已删。 */
.tl-stage-empty {
  font-size: var(--hx-t12-5); color: #8a9099; line-height: 1.75;
  padding: 0 24px; text-align: center;
}
.tl-stage-empty[hidden] { display: none; }
/* 内容层绝对铺满：img 的 max-height:100% 需要确定参照，
   否则大图会把舞台顶高，下面的文件列表被挤出视口（历史踩坑） */
.tl-inner {
  position: absolute; inset: var(--tl-pad, 14px);
  display: flex; align-items: center; justify-content: center; min-height: 0;
}
.tl-inner img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
/* 卡内底栏（进度条等）：与外层共壳，只留一条发丝线 */
.tl-stage-ft {
  flex: none; padding: 10px 14px;
  border-top: 1px solid var(--border); background: var(--bg);
}

/* ---------- 参数项（标签行 + 控件） ----------
   标签行右端可跟一个数值（质量 85 / 精度 快），控件永远在标签行下方一整行。
   抠图页原来自己写了一套 grid（标签 | 数值 同排两列），与格式转换页对不齐，
   这里抽成共享类，两个页面用同一份规格。 */
.tl-param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 14px;
}
.tl-param { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl-param > label {
  margin: 0; font-size: var(--hx-t12); color: var(--text-2);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.tl-param > label > span {
  color: var(--text-3); font-variant-numeric: tabular-nums; flex: none;
}
.tl-param select, .tl-param input { width: 100%; }
.tl-param input[type="range"] { width: 100%; margin: 0; }

/* ---------- 参数卡 ---------- */
.tl-side {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.tl-side-hd {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px 0;
  font-size: var(--hx-t12); color: var(--text-3); letter-spacing: .06em;
}
.tl-side-hd .muted { color: var(--text-3); font-size: var(--hx-t12); }
/* 内容区自己滚，标题行固定 —— 参数多时（选 JPEG 会多两项）不会把卡片顶破 */
.tl-side-bd {
  flex: 1 1 auto; min-height: 0; padding: 10px 14px 14px;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}

/* ---------- 文件列表条（跨整宽，与主栅格同宽） ---------- */
.tl-list {
  min-width: 0; margin-top: var(--tool-gap, 14px);
  border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-1);
  overflow: hidden;
}
.tl-list.h { display: none; }
.tl-list-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; background: var(--bg); border-bottom: 1px solid var(--border);
  font-size: var(--hx-t12-5); color: var(--text-2);
}
.tl-list-hd .muted { color: var(--text-3); font-size: var(--hx-t12); margin-left: 6px; }
.tl-list-bd {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent;
}
.tl-list-hd-acts { display: flex; align-items: center; gap: 8px; flex: none; }
/* 末位「+ 添加」占位：与缩略图同高，顶部拖放条收起后它就是唯一的添加入口 */
.tl-add {
  flex: none; align-self: stretch; width: 68px; min-height: 86px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 0; border: 1px dashed var(--text-3); border-radius: var(--r-btn);
  background: transparent; color: var(--text-3);
  font-family: inherit; font-size: var(--hx-t12); line-height: 1;
  cursor: pointer;
  transition: border-color .12s var(--ease), color .12s var(--ease), background .12s var(--ease);
}
.tl-add svg { width: var(--hx-t14); height: var(--hx-t14); stroke: currentColor; fill: none; stroke-width: 1.8; }
.tl-add:hover { border-color: var(--text); color: var(--text); background: var(--bg); }
.tl-add:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 结果条（处理完成后出现，跨整宽） ---------- */
.tl-result {
  flex: none; margin-top: var(--tool-gap, 14px);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--surface); box-shadow: var(--shadow-1);
  font-size: var(--hx-t13); color: var(--text-2);
}
.tl-result.h { display: none; }

/* ---------- 响应式 ---------- */
/* 中窄视口：定宽参数栏会把预览挤成一条缝，改按比例分配 */
@media (max-width: 1140px) {
  .tl-main { grid-template-columns: minmax(0, 1fr) 320px; }
}
/* 窄屏：单列堆叠，预览 → 参数 → 列表 → 结果 */
@media (max-width: 900px) {
  .tl-main { display: flex; flex-direction: column; gap: 12px; }
  /* 单列时卡片不许被压扁：让整页自然变高、由页面自己滚，
     否则舞台被挤到一百多像素、图被 overflow 切掉（390 实测） */
  .tl-stage { min-height: 0; flex: none; }
  /* 窄屏舞台定个最低高度，图按 max-height:100% 缩在这个盒子里 ——
     不要再单独放大 img 的 max-height，否则图会溢出舞台被 overflow 切掉（390 实测） */
  .tl-stage-bd { min-height: 260px; }
  .tl-side { overflow: visible; }
  .tl-side-bd { overflow: visible; }
}

/* ---------- 全屏拖入遮罩（整页都是投放区，拖到哪松手都能导入） ----------
   pointer-events:none 是关键：遮罩只做反馈，不能挡住底下的 drop 事件，
   否则 dragover/drop 全被它吃掉，导入反而失效。 */
.tl-dropmask {
  position: fixed; inset: 0; z-index: var(--hx-z-pop, 240);
  display: none; place-items: center; padding: 24px;
  pointer-events: none;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.tl-dropmask.is-on { display: grid; }
.tl-dropmask-bx {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: min(560px, 100%); padding: 34px 32px;
  border: 1.5px dashed var(--text-3); border-radius: var(--r-card);
  background: var(--surface);
  text-align: center;
}
.tl-dropmask-i {
  width: 34px; height: 34px; color: var(--text-2);
  stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.tl-dropmask-t { font-size: var(--hx-t16, 16px); font-weight: 700; color: var(--text); line-height: 1.3; }
.tl-dropmask-s { font-size: var(--hx-t12); color: var(--text-3); line-height: 1.5; }
