/*! img：应用自身样式（布局/表格/画布尺寸等），来自原版 taez/tools/img/index.html 的 <style>。
 * metro.css 负责外层外观（面板、按钮、页头），本文件只补应用结构与几何，勿随意删减。 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f7f7; color: #222; padding: 24px 16px;
}
.wrap { max-width: 1100px; margin: 0 auto; }
h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.sub { color: #888; font-size: 13px; margin: 0 0 20px; }
.tabs { display: flex; border-bottom: 1px solid #ddd; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 10px 20px; cursor: pointer; font-size: 14px; color: #666;
  border: 1px solid transparent; border-bottom: none; border-radius: 2px 2px 0 0;
  margin-bottom: -1px; background: transparent; font-family: inherit;
}
.tab.active { background: #fff; border-color: #ddd; color: #222; font-weight: 600; }
.panel {
  background: #fff; border: 1px solid #ddd; border-radius: 2px;
  padding: 16px; margin-bottom: 16px;
}
.hidden { display: none !important; }
.btn {
  padding: 7px 16px; border: 1px solid #bbb; border-radius: 2px;
  background: #fff; color: #222; font-size: 13px; cursor: pointer; font-family: inherit;
  text-decoration: none; display: inline-block;
}
.btn:hover { background: #f0f0f0; }
.btn.primary { background: #2c5fa8; border-color: #2c5fa8; color: #fff; }
.btn.primary:hover { background: #244d8a; border-color: #244d8a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: #888; }
.status { font-size: 13px; margin-top: 8px; min-height: 18px; }
.status.err { color: #c62828; white-space: pre-wrap; }
.status.ok { color: #2e7d32; }
.drop {
  border: 2px dashed #ccc; border-radius: 2px; padding: 28px 16px;
  text-align: center; color: #666; font-size: 14px;
  background: #fff; cursor: pointer; margin-bottom: 16px;
}
.drop.over { border-color: #2c5fa8; background: #eef3fb; color: #2c5fa8; }
.linkbtn { color: #2c5fa8; text-decoration: underline; }

/* 参数区 */
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; margin-bottom: 14px; align-items: flex-start; }
.controls > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #666; }
.controls select, .controls input[type="text"], .controls input[type="number"] {
  padding: 5px 8px; border: 1px solid #ccc; border-radius: 2px;
  font-size: 13px; background: #fff; color: #222; font-family: inherit;
}
.controls input[type="number"] { width: 90px; }
.controls input[type="color"] {
  padding: 2px; width: 44px; height: 30px;
  border: 1px solid #ccc; border-radius: 2px;
}
.controls input[type="range"] { width: 140px; }
.controls .row { display: flex; align-items: center; gap: 8px; }
.val { font-size: 12px; color: #333; min-width: 60px; }

/* 图片列表 */
.img-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin-top: 12px;
}
.img-cell {
  position: relative; border: 1px solid #ddd; border-radius: 2px;
  background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 6px;
}
.img-cell.selected { border-color: #2c5fa8; box-shadow: 0 0 0 1px #2c5fa8; }
.img-cell .thumb {
  width: 100%; height: 100px; object-fit: contain;
  background: #f0f0f0; border-radius: 2px; cursor: pointer;
}
.img-cell .cap {
  font-size: 11px; color: #666;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.img-cell .del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0; line-height: 1;
  border: 1px solid #ccc; border-radius: 2px;
  background: rgba(255,255,255,.9); cursor: pointer;
  font-size: 12px; color: #888;
}
.img-cell .del:hover { color: #c62828; border-color: #c62828; }

/* 裁剪 */
.crop-stage {
  position: relative; display: inline-block;
  background: #f0f0f0; border: 1px solid #ddd;
  border-radius: 2px; overflow: hidden;
  user-select: none; touch-action: none;
  max-width: 100%;
}
.crop-stage img {
  display: block; max-width: 100%; max-height: 520px;
  pointer-events: none;
}
.crop-overlay {
  position: absolute; inset: 0; pointer-events: none;
  background: rgba(0,0,0,.5);
}
.crop-box {
  position: absolute; border: 2px solid #2c5fa8;
  cursor: move; box-shadow: 0 0 0 9999px rgba(0,0,0,.5);
  z-index: 2;
}
.crop-box .handle {
  position: absolute; width: 14px; height: 14px;
  background: #fff; border: 2px solid #2c5fa8;
  border-radius: 50%;
}
.crop-box .h-tl { top: -7px; left: -7px; cursor: nwse-resize; }
.crop-box .h-tr { top: -7px; right: -7px; cursor: nesw-resize; }
.crop-box .h-bl { bottom: -7px; left: -7px; cursor: nesw-resize; }
.crop-box .h-br { bottom: -7px; right: -7px; cursor: nwse-resize; }
.crop-box .h-t { top: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.crop-box .h-b { bottom: -7px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.crop-box .h-l { top: 50%; left: -7px; margin-top: -7px; cursor: ew-resize; }
.crop-box .h-r { top: 50%; right: -7px; margin-top: -7px; cursor: ew-resize; }

.crop-info { font-size: 12px; color: #666; margin-top: 8px; }

/* 结果预览 */
.result-list {
  display: flex; flex-direction: column; gap: 10px; margin-top: 12px;
}
.result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; background: #fff; border: 1px solid #ddd; border-radius: 2px;
}
.result-item img.preview {
  width: 60px; height: 60px; object-fit: contain;
  background: #f0f0f0; border-radius: 2px; flex-shrink: 0;
}
.result-item .meta { flex: 1; min-width: 0; font-size: 12px; }
.result-item .meta .name {
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-item .meta .info { color: #888; margin-top: 2px; }
.result-item .meta .info.ok { color: #2e7d32; }
