:root {
  --primary: #ef4444;
  --primary-hover: #dc2626;
  --surface: #ffffff;
  --bg: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-lg: 0 16px 32px -4px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hero-sec {
  max-width: 1080px;
  margin: 1.5rem auto 1rem auto;
  padding: 0 1.25rem;
  text-align: center;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #b91c1c;
  background: #fee2e2;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 0.6rem;
  border: 1px solid #fecaca;
}
.hero-title {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.4rem;
  color: #0f172a;
}
.hero-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 720px;
  margin: 0 auto;
}

.container {
  max-width: 1080px;
  margin: 0 auto 3rem auto;
  padding: 0 1.25rem;
}
.main-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s ease;
  position: relative;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #ef4444;
  background: #fff5f5;
}
.dropzone-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem auto;
  color: #ef4444;
  display: block;
}
.dropzone-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.35rem;
}
.dropzone-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* AI Laser Light Sweep Showcase (Ultra-lightweight GPU CSS) */
.ai-scan-stage {
  position: relative;
  width: 100% !important;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  user-select: none;
  background: #ffffff;
  cursor: pointer;
}

/* Layer 1: Clean result underneath */
.ai-scan-clean-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #ffffff;
}
.ai-scan-clean-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Layer 2: Original image with text banner on top, clipped by scan sweep */
.ai-scan-text-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  animation: aiTextWipe 5.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: clip-path, opacity;
}
.ai-scan-text-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Layer 3: The AI Sweeping Glowing Light Beam */
.ai-scan-beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3.5px;
  background: #ffffff;
  z-index: 5;
  pointer-events: none;
  animation: aiBeamSweep 5.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: left, opacity;
  box-shadow: 
    0 0 10px 2px #60a5fa,
    0 0 24px 6px rgba(99, 102, 241, 0.85),
    0 0 48px 12px rgba(168, 85, 247, 0.6);
}

/* Soft light trail behind the beam */
.ai-scan-beam-glow {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 100%;
  width: 90px;
  background: linear-gradient(to left, rgba(99, 102, 241, 0.4), rgba(56, 189, 248, 0.15), transparent);
  pointer-events: none;
}

/* AI Status Badge */
.ai-scan-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  z-index: 10;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(10px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.ai-scan-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: aiDotPulse 1.5s ease-in-out infinite;
}
@keyframes aiDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* 100% GPU-accelerated Keyframes: Sweeping across eliminates the text layer */
@keyframes aiTextWipe {
  0%, 15% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
  45% {
    clip-path: inset(0 0 0 100%);
    opacity: 1;
  }
  75% {
    clip-path: inset(0 0 0 100%);
    opacity: 1;
  }
  85% {
    clip-path: inset(0 0 0 100%);
    opacity: 0;
  }
  90% {
    clip-path: inset(0 0 0 0);
    opacity: 0;
  }
  96%, 100% {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes aiBeamSweep {
  0%, 14% {
    left: 0%;
    opacity: 0;
  }
  15% {
    left: 0%;
    opacity: 1;
  }
  45% {
    left: 100%;
    opacity: 1;
  }
  48%, 100% {
    left: 100%;
    opacity: 0;
  }
}
.canvas-floating-upload {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  user-select: none;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  width: auto;
  max-width: 90%;
}
.btn-cutout-minimal {
  position: relative;
  overflow: hidden;
  padding: 9px 24px;
  border-radius: 9999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-cutout-minimal:hover {
  background: #f8fafc;
  border-color: #ef4444;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}
.btn-cutout-minimal:active {
  transform: translateY(0);
}
.btn-upload-svg {
  width: 16px;
  height: 16px;
  stroke: #ef4444;
  flex-shrink: 0;
}
.upload-specs-hint {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 3px 12px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.03em;
}


/* Inpaint Canvas Stage & Workspace */
.inpaint-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

/* Floating Clean Toolbar */
.inpaint-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 0.75rem 1.15rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.brush-size-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 5px 12px;
  border-radius: 9px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.brush-size-wrap input[type="range"] {
  width: 90px;
  accent-color: #ef4444;
  cursor: pointer;
}

.brush-val {
  font-size: 0.82rem;
  font-weight: 700;
  color: #ef4444;
  min-width: 38px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateY(-1px);
}

.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.54rem 1.25rem;
  border-radius: 9px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
  transition: all 0.15s ease;
}

.btn-primary-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.42);
}

.btn-primary-action:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-export-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #1e293b;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.54rem 1.25rem;
  border-radius: 9px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
  transition: all 0.15s ease;
}

.btn-export-action:hover {
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
}

/* Canvas Viewport: Constrained and centered, absolutely preventing overflow */
.canvas-viewport {
  position: relative;
  width: 100%;
  max-width: 680px;
  min-height: 420px;
  max-height: 680px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
  background: #0b0f19;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.canvas-layers-box {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

#baseImageCanvas {
  display: block;
  max-width: 100%;
  max-height: 640px;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

#maskOverlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.brush-cursor-ring {
  position: absolute;
  border: 2px solid rgba(239, 68, 68, 0.95);
  background: rgba(239, 68, 68, 0.25);
  border-radius: 50%;
  pointer-events: none;
  display: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.45);
  z-index: 40;
  will-change: left, top, width, height;
}

/* In-Canvas Processing Overlay (覆盖在画布正上方) */
.canvas-processing-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 1.5rem;
  text-align: center;
  border-radius: inherit;
  pointer-events: auto;
  user-select: none;
}

.processing-spinner {
  width: 46px;
  height: 46px;
  border: 3.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ef4444;
  border-radius: 50%;
  animation: inpaintSpinnerSpin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes inpaintSpinnerSpin {
  to { transform: rotate(360deg); }
}

.processing-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.processing-tip {
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  max-width: 320px;
  line-height: 1.45;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
