/* ==========================================================================
   Background Remover
   ========================================================================== */

.bgr [hidden] { display: none !important; }

.bgr-note { margin: -0.6rem 0 0; }
.bgr-privacy {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.84rem;
  line-height: 1.5;
}
.bgr-privacy .icon { flex: none; width: 16px; height: 16px; margin-top: 0.15rem; color: var(--success); }

/* Thumbnails when several photos are added */
.bgr-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.bgr-list li { position: relative; }
.bgr-item {
  position: relative;
  display: block;
  width: 64px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.bgr-item img { width: 100%; height: 100%; object-fit: cover; }
.bgr-item.is-selected { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }
.bgr-item:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
.bgr-item-state {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}
.bgr-item-state .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.bgr-item-state .spinner { width: 11px; height: 11px; border-width: 2px; }
.bgr-item.is-done .bgr-item-state { background: var(--success); }
.bgr-item.is-error .bgr-item-state { background: var(--danger); }
.bgr-item-x {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text-2);
  cursor: pointer;
}
.bgr-item-x .icon { width: 11px; height: 11px; }
.bgr-item-x:hover { color: var(--danger); }

/* Before / after stage */
.bgr-stage {
  position: relative;
  height: clamp(280px, 52vh, 480px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(rgba(var(--ink), 0.09) 0 25%, rgba(var(--ink), 0.02) 0 50%) 0 0 / 20px 20px;
  touch-action: pan-y;
}
.bgr-before, .bgr-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bgr-after { clip-path: inset(0 calc(100% - var(--split)) 0 0); }
.bgr-stage.is-busy .bgr-before { filter: saturate(0.6) brightness(0.55); }
.bgr-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  transform: translateX(-1px);
  pointer-events: none;
}
.bgr-line span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  color: #111827;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}
.bgr-line .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.bgr-tag {
  position: absolute;
  top: 0.6rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  pointer-events: none;
}
.bgr-tag.is-after { left: 0.6rem; }
.bgr-tag.is-before { right: 0.6rem; }
.bgr-split {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.bgr-stage.is-busy .bgr-line, .bgr-stage.is-busy .bgr-tag, .bgr-stage.is-busy .bgr-split,
.bgr-stage.is-cropped .bgr-before, .bgr-stage.is-cropped .bgr-line, .bgr-stage.is-cropped .bgr-tag, .bgr-stage.is-cropped .bgr-split { display: none; }
.bgr-split:focus-visible ~ .bgr-line span, .bgr-split:focus-visible + .bgr-progress { outline: 2px solid var(--lilac); }

.bgr-progress {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.5rem;
  color: #fff;
  text-align: center;
}
.bgr-progress p { margin: 0; font-weight: 600; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.bgr-progress .spinner { width: 26px; height: 26px; border-width: 3px; }
.bgr-bar { width: min(280px, 80%); height: 6px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.25); }
.bgr-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--grad); transition: width 0.3s var(--ease); }
.bgr-progress .bgr-progress-sub { color: rgba(255, 255, 255, 0.85); font-size: 0.82rem; font-weight: 500; }

.bgr-controls { display: flex; flex-direction: column; gap: 1rem; }
.bgr-swatches { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.bgr-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--border-2);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
.bgr-swatch[aria-pressed="true"] { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3); }
.bgr-swatch:focus-visible, .bgr-custom:focus-within { outline: 2px solid var(--lilac); outline-offset: 2px; }
.bgr-custom { background: conic-gradient(#f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e); color: #fff; }
.bgr-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.bgr-custom .icon { width: 15px; height: 15px; stroke-width: 2.6; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); pointer-events: none; }
.bgr-controls .check { align-self: end; padding-bottom: 0.7rem; }
.bgr-meta { margin-top: -0.4rem; }
.bgr-redo { align-self: flex-start; margin-top: -0.6rem; }
