/* ==========================================================================
   Excamar Background Remover - hapus background gambar ala Canva
   - Magic Wand (klik area bg) + Chroma Key (hapus 1 warna global)
   - Kuas Hapus / Kembalikan manual + Undo + Toleransi + Ukuran kuas
   ========================================================================== */

/* Floating Launcher Button (di atas circuit-btn 242px) */
#excamar-bg-btn {
  position: fixed;
  bottom: 296px;
  right: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9990;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  outline: none;
}
#excamar-bg-btn:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(236, 72, 153, 0.55); }
#excamar-bg-btn:active { transform: scale(0.96); }
#excamar-bg-btn svg { width: 22px; height: 22px; }
#excamar-bg-btn.has-img::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0f172a;
}

/* Modal */
#excamar-bg-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}
#excamar-bg-modal[hidden] { display: none; }
.excamar-bg-panel {
  width: min(920px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}
.excamar-bg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 700;
}
.excamar-bg-head button {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.excamar-bg-head button:hover { color: #fff; }
.excamar-bg-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.excamar-bg-toolbtn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.excamar-bg-toolbtn:hover { background: #334155; }
.excamar-bg-toolbtn.active {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  border-color: transparent;
  color: #fff;
}
.excamar-bg-slider {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-size: 11px;
  margin-left: 4px;
}
.excamar-bg-slider input { width: 90px; accent-color: #ec4899; }
.excamar-bg-slider b { color: #e2e8f0; min-width: 30px; text-align: right; }
.excamar-bg-stage {
  flex: 1;
  min-height: 200px;
  max-height: 58vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    linear-gradient(45deg, #1e293b 25%, transparent 25%, transparent 75%, #1e293b 75%),
    linear-gradient(45deg, #1e293b 25%, transparent 25%, transparent 75%, #1e293b 75%),
    #0b1120;
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
#excamar-bg-canvas {
  max-width: 100%;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.excamar-bg-empty {
  color: #64748b;
  font-size: 13px;
  text-align: center;
  line-height: 1.8;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 40px 30px;
  cursor: pointer;
}
.excamar-bg-empty:hover { border-color: #ec4899; color: #cbd5e1; }
.excamar-bg-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.excamar-bg-foot button {
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1e293b;
  color: #e2e8f0;
}
.excamar-bg-foot button:hover { background: #334155; }
.excamar-bg-foot .primary {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  border-color: transparent;
  color: #fff;
}
.excamar-bg-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 10060;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
