/* ============================================================
   在线工具集 · 图片调整大小 / 缩放与裁切
   ============================================================ */

.image-tool-page {
  --crop-accent: #0891b2;
  --crop-accent-soft: #ecfeff;
  background:
    radial-gradient(1050px 620px at 8% -6%, rgba(14, 165, 233, 0.13), transparent 62%),
    radial-gradient(900px 580px at 100% 6%, rgba(139, 92, 246, 0.14), transparent 60%),
    linear-gradient(160deg, #fbfaff 0%, #f3f9ff 48%, #f8faff 100%);
}

.image-tool-page .tool-aura-1 {
  background: radial-gradient(circle, rgba(14, 165, 233, 0.22), transparent 68%);
}

.image-tool-page .tools-hero h1 .gradient-text {
  background: linear-gradient(120deg, #0ea5e9 0%, #6366f1 48%, #a855f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.image-tool-page .trust-row .icon { color: #0891b2; }

/* 上传区 */
.image-upload-icon {
  background: linear-gradient(145deg, #ecfeff, #eef2ff);
  border-color: rgba(14, 165, 233, 0.15);
  color: #0891b2;
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.12);
}

.upload-pdf-tag.image-tag,
.image-upload-icon .upload-pdf-tag {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  box-shadow: 0 4px 10px rgba(14, 165, 233, 0.26);
}

.image-file-emblem {
  color: #0284c7;
  background: linear-gradient(160deg, #ecfeff, #dbeafe);
  border-color: rgba(14, 165, 233, 0.16);
}

/* 目标尺寸 */
.size-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.size-field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 10.5px;
  color: #8b93a7;
}

.size-input-wrap {
  position: relative;
}

.size-input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 29px 0 27px;
  border: 1px solid rgba(33, 40, 65, 0.13);
  border-radius: 10px;
  background: #fbfbfe;
  color: #232d45;
  font-family: inherit;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -moz-appearance: textfield;
}

.size-input-wrap input::-webkit-outer-spin-button,
.size-input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.size-input-wrap input:focus {
  border-color: #67e8f9;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.11);
}

.size-input-wrap input.is-error {
  border-color: #fca5a5;
  background: #fffafa;
}

.size-input-wrap input:disabled {
  color: #56617a;
  background: #f1f3f9;
  border-color: rgba(33, 40, 65, 0.07);
  cursor: not-allowed;
  -webkit-text-fill-color: #56617a;
  opacity: 1;
}

.ratio-lock:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.size-prefix,
.size-unit {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  color: #a0a8b9;
  pointer-events: none;
  letter-spacing: 0.03em;
}

.size-prefix { left: 9px; }
.size-unit { right: 8px; font-weight: 500; }

.ratio-lock {
  width: 34px;
  height: 42px;
  border: 1px solid rgba(33, 40, 65, 0.1);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f7f8fc;
  color: #929bad;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ratio-lock .icon { width: 15px; height: 15px; }

.ratio-lock:hover { color: #6d28d9; background: #f5f0ff; }

.ratio-lock.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, #8b5cf6, #6366f1);
  box-shadow: 0 6px 14px rgba(99, 102, 241, 0.25);
}

.size-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  font-size: 10.5px;
  color: #969eb0;
}

.text-link {
  border: 0;
  background: none;
  padding: 0;
  color: #7c3aed;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.text-link:hover { color: #5b21b6; text-decoration: underline; }

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.preset-chips button {
  border: 1px solid rgba(33, 40, 65, 0.08);
  border-radius: 7px;
  background: #f7f8fc;
  padding: 5px 8px;
  color: #657089;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-variant-numeric: tabular-nums;
}

.preset-chips button:hover {
  border-color: rgba(14, 165, 233, 0.24);
  color: #0369a1;
  background: #f0f9ff;
}

.preset-chips button.active {
  border-color: rgba(14, 165, 233, 0.25);
  background: #ecfeff;
  color: #0e7490;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.08);
}

.resize-mode-group button { padding: 7px 2px 6px; font-size: 11px; }

.aspect-group { grid-template-columns: repeat(3, 1fr); }

.aspect-group button {
  font-size: 11px;
  padding: 8px 2px;
}

.aspect-group button small { display: none; }

/* 填充背景 */
.bg-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.bg-options button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  border: 1px solid rgba(33, 40, 65, 0.1);
  border-radius: 8px;
  background: #fbfbfe;
  color: #6f7890;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.bg-options button:hover { border-color: rgba(14, 165, 233, 0.26); }
.bg-options button.active {
  border-color: rgba(14, 165, 233, 0.35);
  background: #ecfeff;
  color: #0e7490;
}

.bg-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  flex: 0 0 auto;
}

.swatch-white { background: #fff; }
.swatch-dark { background: #0f172a; }
.swatch-transparent {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #d8dde8 25%, transparent 25%),
    linear-gradient(-45deg, #d8dde8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8dde8 75%),
    linear-gradient(-45deg, transparent 75%, #d8dde8 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0;
}

.output-estimate.is-error {
  background: #fff7f7;
  border-color: rgba(220, 38, 38, 0.13);
  color: #b91c1c;
}

.output-estimate.is-error .icon { color: #ef4444; }

.btn-generate.is-working {
  opacity: 0.72;
  pointer-events: none;
}

/* ===== 裁切工作区 ===== */
.crop-panel { overflow: hidden; }

.crop-head {
  padding: 22px 22px 15px;
  margin-bottom: 0;
  align-items: center;
}

.crop-stage {
  position: relative;
  height: 548px;
  margin: 0 16px;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background:
    radial-gradient(700px 400px at 50% 0%, rgba(14, 165, 233, 0.12), transparent 65%),
    linear-gradient(160deg, #0b0916 0%, #0e111f 55%, #081016 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.crop-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: #c8c3dc;
}

.crop-empty strong {
  font-size: 14.5px;
  font-weight: 600;
  color: #e7e3f7;
}

.crop-empty p {
  max-width: 320px;
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: #8c86a5;
}

.crop-editor {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-frame {
  position: relative;
  flex: 0 0 auto;
  line-height: 0;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e5e9f2 25%, transparent 25%),
    linear-gradient(-45deg, #e5e9f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e9f2 75%),
    linear-gradient(-45deg, transparent 75%, #e5e9f2 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
}

.crop-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
}

.crop-box {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.94);
  box-shadow:
    0 0 0 9999px rgba(4, 3, 12, 0.64),
    0 0 0 1px rgba(0, 0, 0, 0.25) inset;
  cursor: move;
  touch-action: none;
  z-index: 2;
}

.crop-line {
  position: absolute;
  background: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}

.crop-line.v { top: 0; bottom: 0; width: 1px; }
.crop-line.h { left: 0; right: 0; height: 1px; }

.crop-handle {
  position: absolute;
  z-index: 4;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.25);
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.crop-handle.nw { left: -7px; top: -7px; width: 13px; height: 13px; cursor: nwse-resize; border-radius: 3px 1px 3px 1px; }
.crop-handle.ne { right: -7px; top: -7px; width: 13px; height: 13px; cursor: nesw-resize; border-radius: 1px 3px 1px 3px; }
.crop-handle.se { right: -7px; bottom: -7px; width: 13px; height: 13px; cursor: nwse-resize; border-radius: 1px 3px 1px 3px; }
.crop-handle.sw { left: -7px; bottom: -7px; width: 13px; height: 13px; cursor: nesw-resize; border-radius: 3px 1px 3px 1px; }

.crop-handle.n { left: 50%; top: -6px; width: 24px; height: 7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.s { left: 50%; bottom: -6px; width: 24px; height: 7px; transform: translateX(-50%); cursor: ns-resize; }
.crop-handle.w { top: 50%; left: -6px; width: 7px; height: 24px; transform: translateY(-50%); cursor: ew-resize; }
.crop-handle.e { top: 50%; right: -6px; width: 7px; height: 24px; transform: translateY(-50%); cursor: ew-resize; }

.crop-size {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(7, 6, 15, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d5d0e8;
  font-size: 9.5px;
  line-height: 1.4;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.crop-stage.is-dragging,
.crop-stage.is-dragging .crop-box { cursor: grabbing; }

.crop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px 0;
}

.crop-tip {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: #8d96aa;
  font-size: 10.5px;
  line-height: 1.5;
}

.crop-tip .icon { width: 13px; height: 13px; color: #0891b2; }

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

.crop-actions .btn {
  padding: 7px 10px;
  font-size: 11px;
  border-radius: 7px;
}

/* 生成结果条 */
.crop-result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 20px 0;
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid rgba(14, 165, 233, 0.12);
  background: linear-gradient(120deg, #f2fdff, #f7f7ff);
}

.crop-result img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.crop-result-copy {
  min-width: 0;
  flex: 1;
}

.crop-result-copy strong {
  display: block;
  font-size: 11.5px;
  color: #25324a;
}

.crop-result-copy span {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  color: #8b94a7;
  font-variant-numeric: tabular-nums;
}

.crop-result-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #0e7490;
  font-size: 10.5px;
  font-weight: 650;
  text-decoration: none;
  padding: 5px 7px;
  border-radius: 6px;
  flex: 0 0 auto;
}

.crop-result-link:hover { background: #ecfeff; }
.crop-result-link .icon { width: 13px; height: 13px; }

/* 复用 PDF 工具的操作栏，但裁切面板需要一点额外间距 */
.crop-panel .preview-actions { padding-top: 15px; }

/* ===== 响应式 ===== */
@media (max-width: 1240px) {
  .crop-stage { height: 520px; }
}

@media (max-width: 1024px) {
  .crop-stage { height: 520px; }
}

@media (max-width: 960px) {
  .crop-stage { height: 500px; }
}

@media (max-width: 768px) {
  .crop-stage { height: 440px; margin: 0 12px; padding: 20px; }
  .crop-head { padding: 18px 18px 13px; }
  .crop-toolbar { padding: 11px 16px 0; }
  .crop-result { margin: 11px 16px 0; }
  .crop-panel .preview-actions { padding: 14px 16px 17px; }
}

@media (max-width: 520px) {
  .size-row { grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr); gap: 6px; }
  .size-input-wrap input { padding-left: 24px; padding-right: 25px; font-size: 13px; }
  .size-prefix { left: 7px; }
  .size-unit { right: 6px; }
  .ratio-lock { width: 32px; }
  .crop-stage { height: 370px; padding: 16px; }
  .crop-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .crop-actions { width: 100%; }
  .crop-actions .btn { flex: 1; }
  .crop-size { font-size: 9px; }
  .preset-chips button { font-size: 9.5px; }
}

@media (max-height: 720px) and (min-width: 961px) {
  .crop-stage { height: 480px; }
}
