/* ==========================================================================
   内网工具集 · 图像工具共用样式
   ========================================================================== */

/* ---------- 上传 / 拖拽区 ---------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel-sunken);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.drop-zone .dz-ico {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  color: var(--text-faint);
}

.drop-zone .dz-main {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.drop-zone .dz-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
}

.drop-zone .dz-sub kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ---------- 图片舞台 ---------- */
.img-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-sunken);
  padding: 12px;
  display: flex;
  justify-content: center;
  min-height: 200px;
  overflow: auto;
}

/* 居中靠 auto 外边距，不用 align-items:center：
   画布高于 .tall 的 max-height 时，align-items 居中会把顶部溢出成负值，
   滚动条永远够不到上边缘（缩放 33% 以上就看不到图的上半截）。
   auto 外边距在空间富余时居中、空间不足时归零，两个方向都不裁。 */
.img-stage > img,
.img-stage > canvas {
  max-width: 100%;
  height: auto;
  display: block;
  margin-top: auto;
  margin-bottom: auto;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

.img-stage.tall {
  max-height: 62vh;
}

/* ---------- 信息条 ---------- */
.img-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 10px 14px;
  background: var(--panel-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.img-meta b {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.img-meta .ok {
  color: var(--ok, #067647);
}

.img-meta .warn {
  color: #b54708;
}

/* ---------- 对比条（压缩前 / 后） ---------- */
.cmp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cmp-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
}

.cmp-head {
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel-sunken);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.cmp-body {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  max-height: 300px;
  overflow: hidden;
}

.cmp-body img {
  max-width: 100%;
  max-height: 280px;
  display: block;
}

@media (max-width: 700px) {
  .cmp { grid-template-columns: 1fr; }

  /* 手机上没有 hover，工具栏按钮与上传区不需要那么大的留白 */
  .drop-zone { padding: 22px 14px; }
  .field-inline label { min-width: 64px; font-size: 12.5px; }
  .field-inline .val { min-width: 40px; font-size: 12.5px; }
}

/* 绘图画布：触摸拖动时必须禁止页面滚动，否则拖节点会变成滚页面 */
#stage { touch-action: none; -webkit-user-select: none; user-select: none; }

/* ---------- 比例按钮组（裁剪用） ---------- */
.ratio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ratio-row button {
  padding: 5px 11px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: all .12s;
}

.ratio-row button:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.ratio-row button.on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 500;
}

/* ---------- 裁剪画布 ---------- */
.crop-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-sunken);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.crop-wrap canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
}

/* ---------- 批量缩略图 ---------- */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 12px;
}

.thumb {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--panel);
  position: relative;
}

.thumb .tb {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-sunken);
  overflow: hidden;
}

.thumb .tb img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.thumb .tn {
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
  word-break: break-all;
}

.thumb .tn b {
  display: block;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 1px;
}

.thumb .tx {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(16, 24, 40, .55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb .tx:hover { background: #b42318; }

/* ---------- 拖拽排序 ---------- */
.thumb.dragging { opacity: .45; }

.thumb.drop-before::before,
.thumb.drop-after::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.thumb.drop-before::before { left: -7px; }
.thumb.drop-after::after { right: -7px; }

/* ---------- 参数行 ---------- */
.field-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

/* 颜色选择器不参与 .row 的 flex 拉伸 */
.row > input[type="color"],
input[type="color"] {
  flex: 0 0 auto;
  min-width: 0;
  width: 52px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  cursor: pointer;
}

/* 按钮不被同排的长文本挤扁 */
.btn-row > button,
.btn-row > a {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 72px;
}

/* 分隔线不参与 flex 拉伸 */
.row > .sep {
  flex: 0 0 auto;
  min-width: 0;
}

.field-inline label {
  font-size: 13px;
  color: var(--text-dim);
  min-width: 76px;
}

.field-inline input[type="range"] {
  flex: 1;
  max-width: 300px;
}

.field-inline .val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  min-width: 46px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- 概要条与并排控件（多页复用） ---------- */
.sum-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sum-row span {
  font-size: 12.5px; padding: 4px 9px; border-radius: 6px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
}
.sum-row b { color: var(--text); font-weight: 600; }

/* 两组 seg 并排时用 auto 宽度；.row 的 flex:1 会把后一组推到行中间 */
.seg-row { display: flex; flex-wrap: wrap; gap: 26px; align-items: flex-start; }
.seg-row .field { flex: 0 0 auto; margin-bottom: 16px; }

/* ---------- 一行并排的控件组（纸张/张数/复选框等） ----------
   .seg 高 36px，而全局 select 是 padding:12px 14px 约 50px，
   直接并排会一高一矮，所以在这一层统一高度。 */
.opts { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.opts .field { flex: 0 0 auto; margin-bottom: 0; }
.opts .seg { height: 36px; box-sizing: border-box; align-items: center; }
.opts .seg button { height: 28px; padding: 0 14px; display: inline-flex; align-items: center; }
.opts select {
  width: auto; min-width: 104px; height: 36px; box-sizing: border-box;
  padding: 0 10px; font-size: 13px; line-height: 34px;
}
.opts .cut-check {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap;
}
.opts .cut-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* 面板标题右侧的补充说明，靠右对齐、不抢标题 */
.panel-title .panel-note {
  margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-dim);
}
