/* Archive-style single-column mask editor (object remover / AI replacer) */
.mask-editor {
  max-width: 920px;
  margin: 0 auto;
}

.mask-editor .me-card {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.mask-editor .me-card-content {
  padding: 1.25rem 1.35rem;
}

.mask-editor .upload-section {
  text-align: center;
  margin-bottom: 1.25rem;
}

/* One drop-zone frame only — strip nested inner border */
.mask-editor .upload-container-modern,
body.tool-ui-d .mask-editor .upload-container-modern {
  border: 1.5px dashed rgba(103, 232, 249, 0.35) !important;
  border-radius: 16px !important;
  background: rgba(8, 14, 26, 0.55) !important;
  padding: 1.25rem !important;
  min-height: 200px !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.mask-editor .upload-box-modern,
body.tool-ui-d .mask-editor .upload-box-modern,
body.tool-ui-d .mask-editor .upload-box-modern.td-upload {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: 0 !important;
  transform: none !important;
  width: 100% !important;
}

.mask-editor .upload-box-modern::before,
body.tool-ui-d .mask-editor .upload-box-modern::before {
  display: none !important;
}

.mask-editor .upload-box-modern:hover,
body.tool-ui-d .mask-editor .upload-box-modern:hover,
body.tool-ui-d .mask-editor .upload-box-modern.drag-over {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

.mask-editor .upload-content-modern,
body.tool-ui-d .mask-editor .upload-content-modern {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  min-height: 0 !important;
  width: 100% !important;
}

body.tool-ui-d .mask-editor .upload-container-modern:hover,
body.tool-ui-d .mask-editor .upload-container-modern:has(.drag-over) {
  border-color: var(--td-accent, #67e8f9) !important;
  background: rgba(163, 230, 53, 0.06) !important;
}

.mask-editor .upload-input {
  display: none !important;
}

.mask-editor .canvas-section {
  display: none;
  text-align: center;
}

.mask-editor .canvas-container {
  position: relative;
  display: inline-block;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  max-width: 100%;
  background: transparent;
  line-height: 0;
}

/* Visible photo layer — full brightness (no dimming overlay) */
.mask-editor .display-image {
  display: none;
  position: relative;
  z-index: 0;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  opacity: 1 !important;
  filter: none !important;
}

.mask-editor .canvas {
  display: block;
  border-radius: 12px;
  max-width: none !important;
  background: transparent !important;
}

/* Processing canvas only — must not cover the photo */
.mask-editor .base-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Mask strokes only — archive-style light transparent overlay */
.mask-editor .draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  cursor: none;
  opacity: 0.8 !important;
  transition: opacity 0.3s ease;
  background: transparent !important;
  mix-blend-mode: normal !important;
  filter: none !important;
}

.mask-editor .draw-canvas.hidden {
  opacity: 0 !important;
  pointer-events: none;
}

.mask-editor #masked_Image,
.mask-editor img#masked_Image {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.mask-editor .tools-section {
  display: none;
  margin-top: 0;
}

.mask-editor .tools-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.mask-editor .tool-buttons-row,
.mask-editor .action-buttons-row,
.mask-editor .toggle-button-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.mask-editor .tool-btn {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  font-weight: 550;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mask-editor .tool-btn:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.mask-editor .tool-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.mask-editor .tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mask-editor .replace-image-btn {
  padding: 0.55rem 0.85rem;
  white-space: nowrap;
}

.mask-editor .size-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
  font-size: 0.9rem;
}

.mask-editor .size-slider {
  width: 5.5rem;
  height: 0.35rem;
  background: #334155;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
}

.mask-editor .size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
}

.mask-editor .size-display {
  font-weight: 700;
  color: #38bdf8;
  min-width: 1.75rem;
}

.mask-editor .canvas-section {
  display: none;
  text-align: center;
}

.mask-editor .canvas-container {
  position: relative;
  display: inline-block;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  max-width: 100%;
}

.mask-editor .canvas {
  display: block;
  border-radius: 12px;
  max-width: 100%;
}

.mask-editor .base-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.mask-editor .draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  cursor: none;
  opacity: 0.8 !important;
  transition: opacity 0.3s ease;
  background: transparent !important;
  mix-blend-mode: normal !important;
  filter: none !important;
}

.mask-editor .draw-canvas.hidden {
  opacity: 0 !important;
  pointer-events: none;
}

.mask-editor .brush-cursor {
  position: fixed;
  pointer-events: none;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  z-index: 1000;
  display: none;
}

.mask-editor .prompt-section {
  display: none;
  margin: 0 auto 1rem;
  max-width: 640px;
  text-align: left;
}

.mask-editor .prompt-textarea {
  width: 100%;
  min-height: 7.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
}

.mask-editor .prompt-textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.mask-editor .prompt-textarea::placeholder {
  color: #94a3b8;
}

.mask-editor .me-actions {
  text-align: center;
  margin-top: 0.5rem;
}

.mask-editor .action-buttons {
  display: none;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.mask-editor .action-buttons.showNow {
  display: inline-flex;
}

.mask-editor .generate-btn,
.mask-editor .download-btn,
body.tool-ui-d .mask-editor .generate-btn,
body.tool-ui-d .mask-editor .generate-btn.td-run,
body.tool-ui-d .mask-editor .download-btn {
  border: none !important;
  padding: 0.85rem 1.4rem !important;
  min-height: 48px !important;
  width: auto !important;
  min-width: 148px;
  font: 800 0.95rem/1 "Plus Jakarta Sans", system-ui, sans-serif !important;
  border-radius: 12px !important;
  cursor: pointer;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.45rem !important;
  box-shadow: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.mask-editor .generate-btn,
body.tool-ui-d .mask-editor .generate-btn,
body.tool-ui-d .mask-editor .generate-btn.td-run {
  display: inline-flex !important;
}

.mask-editor .download-btn,
body.tool-ui-d .mask-editor .download-btn {
  display: none !important;
}

.mask-editor .download-btn.is-ready,
body.tool-ui-d .mask-editor .download-btn.is-ready {
  display: inline-flex !important;
}

.mask-editor .generate-btn,
body.tool-ui-d .mask-editor .generate-btn,
body.tool-ui-d .mask-editor .generate-btn.td-run {
  background: linear-gradient(135deg, #7c3aed 0%, #6366f1 100%) !important;
  color: #fff !important;
}

.mask-editor .generate-btn:hover,
body.tool-ui-d .mask-editor .generate-btn:hover:not(:disabled),
body.tool-ui-d .mask-editor .generate-btn.td-run:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 10px 24px rgba(124, 58, 237, 0.28) !important;
}

.mask-editor .generate-btn:disabled,
body.tool-ui-d .mask-editor .generate-btn:disabled,
body.tool-ui-d .mask-editor .generate-btn.td-run:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}

.mask-editor .download-btn,
body.tool-ui-d .mask-editor .download-btn {
  background: #22d3ee !important;
  color: #083344 !important;
}

.mask-editor .download-btn:hover,
body.tool-ui-d .mask-editor .download-btn:hover {
  background: #06b6d4 !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.28) !important;
}

.mask-editor #masked_Image {
  display: none !important;
}

.mask-editor .loader {
  display: none;
  margin: 1.25rem auto;
  border: 4px solid rgba(148, 163, 184, 0.25);
  border-top: 4px solid #38bdf8;
  border-radius: 50%;
  width: 3.25rem;
  height: 3.25rem;
  animation: me-spin 1s linear infinite;
}

@keyframes me-spin {
  to { transform: rotate(360deg); }
}

.mask-editor .queue-panel {
  display: none;
  width: 100%;
  max-width: 420px;
  margin: 1rem auto 0;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.85);
  text-align: left;
  box-sizing: border-box;
}

.mask-editor .queue-panel.active {
  display: block;
}

.mask-editor .queue-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
}

.mask-editor .queue-meta {
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: 0.85rem;
}

.mask-editor .progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.mask-editor .progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #67e8f9, #a3e635);
  transition: width 0.25s ease;
}

.mask-editor .queue-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.mask-editor .stat-chip {
  font-size: 0.72rem;
  color: #94a3b8;
}

.mask-editor #msg {
  margin-top: 1rem;
  text-align: center;
}

.mask-editor .success-message {
  color: #6ee7b7;
  background: rgba(6, 95, 70, 0.35);
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.mask-editor .error-message {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.4);
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.mask-editor .turnstile-wrap {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
}

@media (max-width: 768px) {
  .mask-editor .tools-container {
    flex-direction: column;
  }

  .mask-editor .tool-buttons-row,
  .mask-editor .action-buttons-row,
  .mask-editor .toggle-button-row,
  .mask-editor .size-control {
    width: 100%;
    justify-content: center;
  }

  .mask-editor .generate-btn,
  .mask-editor .download-btn,
  body.tool-ui-d .mask-editor .generate-btn,
  body.tool-ui-d .mask-editor .generate-btn.td-run,
  body.tool-ui-d .mask-editor .download-btn {
    width: auto !important;
    flex: 1 1 auto;
    min-width: 132px;
    justify-content: center;
  }
}
