* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui;
  background: #f5f7fb;
}

.app {
  margin-top:-150px !important;
  position:relative;
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 16px;
}

.title {
  text-align: center;
  margin-bottom: 24px;
}

/* ===== 上传区 ===== */
.dropzone {
  border: 2px dashed #3b82f6;
  border-radius: 14px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  background: #fff;
}

.dropzone.drag {
  background: #eef4ff;
}

.drop-inner .icon {
  font-size: 46px;
}

.drop-inner .text {
  margin-top: 12px;
  font-size: 16px;
}

.drop-inner .sub {
  margin-top: 6px;
  font-size: 13px;
  color: #666;
}

/* ===== 进度 ===== */
.progress {
  margin-top: 24px;
  background: #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.progress .bar {
  height: 6px;
  width: 0%;
  background: #2563eb;
  transition: width .3s;
}

.progress span {
  display: block;
  padding: 10px;
  text-align: center;
  font-size: 14px;
}

/* ===== 对比区 ===== */
.compare {
  margin-top: 30px;
  display: flex;
  justify-content: center;
}

.img-wrap {
  position: relative;
  --p: 50%;
  max-width: 900px;
  max-height: 70vh;
  overflow: hidden; /* 防止棋盘格/图层出现溢出边 */
}

/* 棋盘格 */
.checker {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(45deg,#ddd 25%,transparent 25%),
    linear-gradient(-45deg,#ddd 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#ddd 75%),
    linear-gradient(-45deg,transparent 75%,#ddd 75%);
  background-size: 20px 20px;
}

/* 图层 */
.layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: contain; /* ⭐ 核心改动 */
}

.layer.base {
  z-index: 1;
}

.layer.overlay {
  z-index: 2;
  clip-path: inset(0 calc(100% - var(--p)) 0 0);
}

/* 分割线 */
.slider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--p);
  width: 3px;
  background: #2563eb;
  z-index: 3;
  pointer-events: none;
}

.slider::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  background: #2563eb;
  border-radius: 50%;
  transform: translate(-50%,-50%);
}

/* ===== 操作 ===== */
.actions {
  margin-top: 24px;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn {
  background: #2563eb;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.btn.secondary {
  background: #6b7280;
}

.hidden {
  display: none;
}

/* ===== 编辑弹窗（仿图示布局） ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 999;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(1200px, 100%);
  height: min(720px, 92vh);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: #666;
}

.modal-close:hover {
  background: #f3f4f6;
}

.modal-toolbar {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.btn.outline {
  background: transparent;
  color: #2563eb;
  border: 1px solid #93c5fd;
}

.modal-toolbar .tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #111827;
  user-select: none;
}

.modal-toolbar .range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #111827;
}

.modal-toolbar input[type="range"] {
  width: 160px;
}

.modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: #f3f4f6;
}

.pane {
  display: flex;
  flex-direction: column;
  padding: 14px;
}

.pane-title {
  font-size: 13px;
  color: #374151;
  margin-bottom: 10px;
}

.pane-canvas {
  flex: 1;
  border: 1px solid #d1d5db;
  background:
    linear-gradient(45deg,#ddd 25%,transparent 25%),
    linear-gradient(-45deg,#ddd 25%,transparent 25%),
    linear-gradient(45deg,transparent 75%,#ddd 75%),
    linear-gradient(-45deg,transparent 75%,#ddd 75%);
  background-size: 20px 20px;
  background-position: 0 0,0 10px,10px -10px,-10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative; /* 确保子元素定位正确 */
}

.pane-canvas canvas {
  display: block;
  cursor: crosshair;
}

@media (max-width: 900px) {
  .modal-card { height: 92vh; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-toolbar { flex-wrap: wrap; }
  .modal-toolbar input[type="range"] { width: 140px; }
}


@media (max-width: 768px) {
  .img-wrap {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
  }
}

/* ===== 编辑弹窗：双光标 ===== */
.pane-canvas{ position: relative; }
.pane-canvas canvas{ display:block; }

.canvas-wrap{
  position: relative;
  display: inline-block;
  transform-origin: 0 0;
  will-change: transform;
  transition: transform 0.15s ease-out; /* 可选，丝滑 */
}

/* 编辑区：隐藏浏览器自带十字光标，只用我们自己的光标 */
#editCanvas{ cursor: none; }
#originCanvas{ cursor: none; }

/* 左侧原图蒙版层（紫色痕迹） */
#originMaskCanvas{
  position:absolute;
  left:0;
  top:0;
  pointer-events:none; /* 不抢鼠标 */
  mix-blend-mode: multiply;
}

#globalCursorLayer {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

.brush-cursor {
position: fixed; /* 改为 fixed，确保不被任何容器影响 */
  border: 2px solid rgba(99,102,241,.9);
  border-radius: 50%;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  z-index: 99999;
}

.brush-cursor.hand {
  border: none;
  border-radius: 0;
  width: 24px !important;
  height: 24px !important;
  background: none;
  position: fixed;
}

/* 用 SVG 或 CSS 画一个手 */
.brush-cursor.hand::before {
  content: "🤚";
  font-size: 22px;
  line-height: 24px;
  color: rgba(60,60,60,.85);
}

.editor-loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 16px;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
