/* =============================================
   LuxTool — /images/background-remover/background-remover.css
   Tool-specific styles only. Site chrome (nav, footer,
   buttons, panels, forms, drop-zone) comes from /style.css
   which this page also loads.
   ============================================= */


.bgrem-panel {
  width: 100%;
  max-width: none;
  margin: 0 auto 1rem;
}

.bgrem-header-wrap {
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

.bgrem-engine-row {
  margin-bottom: 1.1rem;
}

.bgrem-engine-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}

.bgrem-engine-btn {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem .9rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: rgba(30, 41, 59, .45);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: .2s;
}

.bgrem-engine-btn:hover {
  border-color: var(--gold-dim);
}

.bgrem-engine-btn.active {
  border-color: var(--gold);
  background: rgba(251, 191, 36, .1);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, .35) inset;
}

.bgrem-engine-icon {
  width: 1.3rem;
  height: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bgrem-engine-icon svg {
  width: 100%;
  height: 100%;
}

.bgrem-engine-text {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.bgrem-engine-title {
  font-weight: 700;
  font-size: .92rem;
}

.bgrem-engine-sub {
  font-size: .76rem;
  color: var(--muted);
}

.bgrem-engine-btn.active .bgrem-engine-sub {
  color: var(--gold);
}

.bgrem-engine-btn.quota-exhausted .bgrem-engine-sub {
  color: #f87171;
}

.bgrem-engine-btn.quota-exhausted,
.bgrem-engine-btn.quota-exhausted:hover {
  cursor: not-allowed;
  border-color: rgba(248, 113, 113, .55);
  background: rgba(127, 29, 29, .18);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, .14) inset;
  opacity: .82;
}

.bgrem-engine-btn.quota-exhausted .bgrem-engine-icon,
.bgrem-engine-btn.quota-exhausted .bgrem-engine-title {
  color: #f87171;
}

html.theme-light .bgrem-engine-btn.quota-exhausted,
html.theme-light .bgrem-engine-btn.quota-exhausted:hover {
  border-color: rgba(220, 38, 38, .38);
  background: rgba(254, 226, 226, .92);
}

.bgrem-model-status {
  margin-top: .8rem;
  padding: .85rem 1rem;
  border: 1px solid var(--gold-dim);
  border-radius: .75rem;
  background: rgba(251, 191, 36, .06);
}

.bgrem-model-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  font-size: .82rem;
  color: var(--text);
  margin-bottom: .5rem;
}

.bgrem-model-status-row #br-model-status-pct {
  color: var(--gold);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.bgrem-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width .25s ease;
}

.bgrem-model-status-note {
  margin-top: .5rem;
  font-size: .74rem;
  color: var(--muted);
}

.bgrem-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.bgrem-card {
  background: rgba(30, 41, 59, .45);
  border: 1px solid var(--border);
  border-radius: .8rem;
  padding: 1rem;
}

.bgrem-label {
  font-size: .78rem;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: .7rem;
}

.bgrem-preview-frame {
  min-height: 220px;
  border-radius: .7rem;
  border: 1px solid var(--gold-dim);
  background: rgba(15, 23, 42, .85);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem;
  position: relative;
}

.bgrem-preview-frame img {
  max-width: 100%;
  max-height: 280px;
  height: auto;
  display: none;
}

.bgrem-empty {
  min-height: 160px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .92rem;
  letter-spacing: .03em;
}

.bgrem-checker {
  background:
    linear-gradient(45deg, rgba(148, 163, 184, .16) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, .16) 75%, rgba(148, 163, 184, .16)),
    linear-gradient(45deg, rgba(148, 163, 184, .16) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, .16) 75%, rgba(148, 163, 184, .16));
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  background-color: rgba(15, 23, 42, .9);
}

.bgrem-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.bgrem-bg-controls {
  margin-top: .85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: rgba(30, 41, 59, .35);
}

.bgrem-more-tools {
  margin-top: .85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: rgba(15, 23, 42, .45);
}

.bgrem-links {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.bgrem-continue-title {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.bgrem-continue-title > svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.bgrem-link {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  padding: .55rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: rgba(251, 191, 36, .08);
  color: var(--text);
  text-decoration: none;
  font-size: .82rem;
  transition: .2s;
}

.bgrem-link-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.bgrem-link:hover {
  background: rgba(251, 191, 36, .2);
  color: var(--gold);
}

.bgrem-chip-row {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.bgrem-chip {
  padding: .55rem .9rem;
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  background: rgba(251, 191, 36, .08);
  color: var(--text);
  font-family: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: .2s;
}

.bgrem-chip:hover,
.bgrem-chip.active {
  background: rgba(251, 191, 36, .2);
  color: var(--gold);
}

.bgrem-custom-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  align-items: end;
}

.bgrem-color-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--gold-dim);
  border-radius: .65rem;
  background: rgba(30, 41, 59, .7);
  cursor: pointer;
}

.bgrem-processing-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(2, 6, 23, .72), rgba(15, 23, 42, .92));
  backdrop-filter: blur(4px);
  color: var(--text);
}

/* Pulsing dots animation */
.bgrem-thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.bgrem-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.4;
  animation: bgremPulse 1.4s ease-in-out infinite both;
  will-change: opacity, transform;
}

.bgrem-dot:nth-child(1) {
  animation-delay: 0s
}

.bgrem-dot:nth-child(2) {
  animation-delay: 0.2s
}

.bgrem-dot:nth-child(3) {
  animation-delay: 0.4s
}

.bgrem-processing-overlay.is-animating .bgrem-dot {
  animation-play-state: running;
}

/* Status text with smooth fade transitions */
.bgrem-loading-title {
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 200ms ease, transform 200ms ease;
  will-change: opacity, transform;
  min-height: 1.4em;
}

@keyframes bgremPulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.9)
  }

  40% {
    opacity: 1;
    transform: scale(1.1)
  }
}

/* ── BGREM: card header + zoom controls (Fit / 100% / +/-) ── */
.bgrem-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .7rem;
}

.bgrem-card-head .bgrem-label {
  margin-bottom: 0;
}

.bgrem-zoom-controls {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.bgrem-zoom-btn {
  min-width: 1.9rem;
  padding: .22rem .5rem;
  border-radius: .5rem;
  border: 1px solid var(--gold-dim);
  background: rgba(251, 191, 36, .08);
  color: var(--text);
  font-family: inherit;
  font-size: .74rem;
  line-height: 1.4;
  cursor: pointer;
  transition: .2s;
}

.bgrem-zoom-btn:hover {
  background: rgba(251, 191, 36, .2);
  color: var(--gold);
}

.bgrem-zoom-btn.active {
  background: var(--gold);
  color: #0f172a;
  border-color: var(--gold);
  font-weight: 700;
}

.bgrem-zoom-frame {
  overflow: auto;
}

.bgrem-zoom-frame img.bgrem-zoomed {
  max-width: none;
  max-height: none;
}

.bgrem-info-line {
  margin-top: .5rem;
  font-size: .78rem;
  color: var(--muted);
  min-height: 1.1em;
}

/* ── BGREM: batch mode toggle ── */
.bgrem-batch-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .85rem;
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
}

.bgrem-batch-toggle small {
  color: var(--muted);
  font-weight: 400;
}

/* ── BGREM: blur strength slider ── */
.bgrem-blur-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: .7rem 0 1rem;
  flex-wrap: wrap;
}

.bgrem-range {
  flex: 1;
  max-width: 220px;
  accent-color: var(--gold);
}

/* ── BGREM: unified download panel (format / quality / size) ── */
.bgrem-download-panel {
  margin-top: .85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: rgba(30, 41, 59, .35);
}

.bgrem-dl-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin: .7rem 0;
}

.bgrem-dl-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.bgrem-dl-group-label {
  font-size: .78rem;
  color: var(--muted);
}

.bgrem-dl-group-label b {
  color: var(--gold);
  font-weight: 700;
}

.bgrem-seg {
  display: flex;
  border: 1px solid var(--gold-dim);
  border-radius: .6rem;
  overflow: hidden;
  width: fit-content;
}

.bgrem-seg-btn {
  padding: .4rem .75rem;
  border: none;
  background: rgba(251, 191, 36, .08);
  color: var(--text);
  font-family: inherit;
  font-size: .8rem;
  cursor: pointer;
  transition: .2s;
}

.bgrem-seg-btn + .bgrem-seg-btn {
  border-left: 1px solid var(--gold-dim);
}

.bgrem-seg-btn:hover {
  background: rgba(251, 191, 36, .2);
}

.bgrem-seg-btn.active {
  background: var(--gold);
  color: #0f172a;
  font-weight: 700;
}

.bgrem-seg-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.bgrem-dl-note {
  font-size: .78rem;
  color: var(--gold);
  margin: .2rem 0 .7rem;
}

/* ── BGREM: background history strip ── */
.bgrem-history {
  margin-top: .85rem;
}

.bgrem-label-sub {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.bgrem-history-strip {
  display: flex;
  gap: .6rem;
  overflow-x: auto;
  padding: .4rem 0;
}

.bgrem-history-thumb {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: .6rem;
  border: 2px solid var(--gold-dim);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: rgba(30, 41, 59, .45);
  cursor: pointer;
  padding: 0;
  transition: .2s;
}

.bgrem-history-thumb:hover {
  border-color: var(--gold);
}

.bgrem-history-thumb.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, .35) inset;
}

/* ── BGREM: batch mode (multi-image queue + grid) ── */
.bgrem-batch-actions {
  position: sticky;
  top: 76px;
  z-index: 8;
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .16);
  backdrop-filter: blur(12px);
}

.bgrem-batch-progress {
  margin-bottom: .9rem;
}

.bgrem-batch-progress-text {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .4rem;
}

.bgrem-batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: .8rem;
}

.bgrem-batch-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: rgba(30, 41, 59, .45);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0 .65rem;
  text-align: left;
  font-size: .72rem;
}

.bgrem-batch-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: contain;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, .16) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, .16) 75%, rgba(148, 163, 184, .16)),
    linear-gradient(45deg, rgba(148, 163, 184, .16) 25%, transparent 25%, transparent 75%, rgba(148, 163, 184, .16) 75%, rgba(148, 163, 184, .16));
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
  background-color: rgba(15, 23, 42, .9);
}

.bgrem-batch-name {
  display: block;
  margin: .65rem .65rem .35rem;
  overflow: hidden;
  color: var(--text);
  font-size: .8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-batch-dimensions {
  width: max-content;
  max-width: calc(100% - 1.3rem);
  margin-inline: .65rem;
  padding: .14rem .32rem;
  border-radius: 4px;
  background: rgba(148, 163, 184, .16);
  color: var(--muted);
  white-space: nowrap;
}

.bgrem-batch-status {
  min-height: 1.2rem;
  margin: .45rem .65rem;
  color: var(--muted);
}

.bgrem-batch-status.done {
  color: #a7f3d0;
}

.bgrem-batch-status.error {
  color: #fca5a5;
}

.bgrem-batch-item button {
  width: calc(100% - 1.3rem);
  margin-inline: .65rem;
  font-size: .7rem;
  padding: .35rem;
}

.bgrem-batch-item .bgrem-batch-remove {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: 34px;
  height: 34px;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(15, 23, 42, .88);
  color: var(--gold);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── Light theme overrides (moved here from the shared stylesheet —
   these classes only exist on this page) ── */
html.theme-light .bgrem-card,
html.theme-light .bgrem-preview-frame,
html.theme-light .bgrem-bg-controls,
html.theme-light .bgrem-more-tools,
html.theme-light .bgrem-engine-btn,
html.theme-light .bgrem-model-status,
html.theme-light .bgrem-download-panel,
html.theme-light .bgrem-history-thumb,
html.theme-light .bgrem-batch-item {
  background: rgba(255, 255, 255, .92);
  border-color: rgba(15, 23, 42, .12);
  color: var(--text);
}

html.theme-light .bgrem-batch-actions {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .1);
}

html.theme-light .bgrem-batch-item .bgrem-batch-remove {
  background: rgba(255, 255, 255, .94);
}

/* ── Mobile responsiveness (moved here from the shared stylesheet) ── */
@media(max-width:600px) {
  .bgrem-custom-row {
    grid-template-columns: 1fr
  }

  .bgrem-card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: .4rem;
  }

  .bgrem-dl-row {
    flex-direction: column;
    gap: .9rem;
  }

  .bgrem-seg {
    width: 100%;
  }

  .bgrem-seg-btn {
    flex: 1;
  }

  .bgrem-batch-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .bgrem-batch-actions {
    top: 64px;
  }
}

@media(max-width:420px) {
  .bgrem-batch-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Reduced-motion transition + button-variant styling
   (moved here from the shared stylesheet) ── */
@media (prefers-reduced-motion: no-preference) {
  .bgrem-chip,
  .bgrem-link {
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  }
}

/* Make button variant of bgrem-link look identical to anchor variant */
button.bgrem-link {
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}

button.bgrem-link:hover {
  background: rgba(251, 191, 36, .25);
  color: var(--gold);
  transform: translateY(-1px);
}

.bgrem-panel:has(#br-workspace:not(.hidden)) #br-drop-zone {
  min-height: 0;
  padding: .75rem;
  text-align: left;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) #br-drop-placeholder {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .15rem .65rem;
  align-items: center;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-title,
.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-description {
  grid-column: 1;
  margin: 0;
  min-width: 0;
  text-align: left;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-title {
  font-size: .86rem;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-description {
  overflow: hidden;
  color: var(--muted);
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-button {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: auto;
  min-height: 42px;
  padding: .55rem .8rem;
  border-radius: .6rem;
  font-size: .76rem;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .image-upload-drop-hint {
  display: none;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .drop-icon {
  grid-row: 1 / span 2;
  margin: 0;
  font-size: 1.45rem;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .drop-label {
  margin: 0;
  font-size: .82rem;
}

.bgrem-panel:has(#br-workspace:not(.hidden)) .drop-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
}

@media(max-width:600px) {
  .bgrem-grid {
    grid-template-columns: 1fr
  }

  .bgrem-engine-toggle {
    grid-template-columns: 1fr
  }

  .bgrem-preview-frame {
    min-height: 200px
  }
}

/* Wide workbench: engine/source stay compact while previews use the canvas. */
@media (min-width: 1100px) {
  .bgrem-panel {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
  }

  .bgrem-panel > #br-engine-row {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0;
  }

  .bgrem-panel > #br-single-mode {
    display: contents;
  }

  .bgrem-panel #br-drop-zone {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-height: 230px;
    margin: 0;
  }

  .bgrem-panel:has(#br-engine-row.hidden) #br-drop-zone {
    grid-column: 1 / -1;
  }

  .bgrem-panel:has(#br-workspace:not(.hidden)) #br-drop-zone {
    grid-column: 1;
    grid-row: 2;
  }

  .bgrem-panel #br-workspace:not(.hidden) {
    grid-column: 2;
    grid-row: 1 / span 4;
    min-width: 0;
    margin-top: 0 !important;
  }

  .bgrem-panel > #br-batch-section {
    grid-column: 1 / -1;
  }

  .bgrem-preview-frame {
    min-height: 300px;
  }
}

@media (min-width: 1500px) {
  .bgrem-panel {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  }

  .bgrem-panel #br-workspace:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(310px, .55fr);
    gap: .85rem 1.1rem;
    align-items: start;
  }

  #br-workspace > .bgrem-grid {
    grid-column: 1;
    grid-row: 1 / span 8;
  }

  #br-workspace > :not(.bgrem-grid) {
    grid-column: 2;
    margin-top: 0;
  }

  #br-workspace > .bgrem-actions {
    margin-top: 0;
  }

  #br-workspace > .bgrem-actions .btn,
  #br-workspace > .bgrem-download-panel .btn {
    width: 100%;
  }

  #br-workspace .bgrem-custom-row {
    grid-template-columns: 1fr;
  }

  #br-workspace .bgrem-dl-row {
    flex-direction: column;
    gap: .9rem;
  }

  #br-workspace .bgrem-seg {
    width: 100%;
  }

  #br-workspace .bgrem-seg-btn {
    flex: 1;
  }
}

/* ── Selected-image workbench ─────────────────────────────────────────────
   The empty state remains intentionally simple. Once images are selected,
   the previews own the main canvas and every control lives in a compact,
   independently scrolling rail on the right. */
.bgrem-selected-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 24vw, 330px);
  min-height: 620px;
  height: min(760px, calc(100vh - var(--app-nav-h) - 42px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(8, 13, 27, .56);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .18);
}

/* Cancel the previous wide-screen placement now that the selected state has
   a dedicated shell of its own. */
.bgrem-panel,
.bgrem-panel > #br-single-mode {
  display: block;
}

.bgrem-panel #br-drop-zone {
  grid-column: auto;
  grid-row: auto;
  width: 100%;
  margin: 0;
}

.bgrem-stage #br-workspace:not(.hidden) {
  display: block;
  height: 100%;
}

.bgrem-stage {
  min-width: 0;
  overflow: auto;
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 191, 36, .5) transparent;
}

.bgrem-tool-rail {
  min-width: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: .75rem;
  border-left: 1px solid var(--border);
  background: rgba(10, 16, 31, .88);
  scrollbar-width: thin;
  scrollbar-color: rgba(251, 191, 36, .62) transparent;
}

.bgrem-stage::-webkit-scrollbar,
.bgrem-tool-rail::-webkit-scrollbar {
  width: 5px;
}

.bgrem-stage::-webkit-scrollbar-thumb,
.bgrem-tool-rail::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(251, 191, 36, .55);
}

.bgrem-selected-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .7rem;
  padding: .7rem;
  border: 1px solid rgba(251, 191, 36, .3);
  border-radius: .75rem;
  background: linear-gradient(135deg, rgba(251, 191, 36, .12), rgba(251, 191, 36, .035));
}

.bgrem-picker-visual {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid rgba(251, 191, 36, .42);
  border-radius: .65rem;
  background: rgba(251, 191, 36, .14);
  color: var(--gold);
}

.bgrem-picker-visual svg {
  width: 25px;
  height: 25px;
}

.bgrem-picker-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  flex: 1;
  gap: .12rem;
}

.bgrem-picker-copy strong {
  overflow: hidden;
  color: var(--text);
  font-size: .82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-picker-copy > span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: .66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-picker-kicker {
  color: var(--gold);
  font-size: .61rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.bgrem-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: .32rem;
  min-height: 34px;
  padding: .38rem .62rem;
  border: 1px solid var(--gold-dim);
  border-radius: .55rem;
  background: rgba(251, 191, 36, .12);
  color: var(--gold);
  font: 700 .7rem/1 Inter, sans-serif;
  cursor: pointer;
}

.bgrem-picker-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.bgrem-picker-button:hover {
  background: rgba(251, 191, 36, .22);
}

.bgrem-compare-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.bgrem-compare-head h2 {
  margin: .12rem 0 0;
  color: var(--text);
  font-size: 1.05rem;
}

.bgrem-compare-head p {
  margin: 0;
  margin-left: auto;
  color: var(--muted);
  font-size: .72rem;
}

.bgrem-compare-head .bgrem-quick-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 38px;
  margin: 0;
  padding: .55rem .85rem;
  border-color: var(--gold);
  background: var(--gold);
  color: #111827;
  font-size: .72rem;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(251, 191, 36, .2);
}

.bgrem-download-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-right: .38rem;
}

.bgrem-compare-head .bgrem-quick-download:hover {
  background: #f8cf55;
  color: #111827;
  transform: translateY(-1px);
}

.bgrem-stage #br-workspace {
  margin-top: 0 !important;
}

.bgrem-stage .bgrem-grid {
  gap: 0;
  overflow: hidden;
  height: calc(100% - 48px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: .85rem;
  background: rgba(17, 24, 39, .34);
}

.bgrem-stage .bgrem-card {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  min-width: 0;
  padding: .75rem;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.bgrem-stage .bgrem-card + .bgrem-card {
  border-left: 1px solid var(--border);
}

.bgrem-stage .bgrem-preview-frame {
  min-height: 360px;
  height: 100%;
  padding: .6rem;
  border: 0;
  border-radius: .6rem;
}

.bgrem-stage .bgrem-preview-frame img {
  max-height: 540px;
}

.bgrem-tool-rail .bgrem-engine-row,
.bgrem-tool-rail .bgrem-actions,
.bgrem-tool-rail .bgrem-bg-controls,
.bgrem-tool-rail .bgrem-download-panel,
.bgrem-tool-rail .bgrem-history,
.bgrem-tool-rail .bgrem-more-tools,
.bgrem-tool-rail .bgrem-batch-actions {
  margin: 0 0 .7rem;
}

.bgrem-tool-rail .bgrem-engine-row {
  padding: .7rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: rgba(30, 41, 59, .28);
}

.bgrem-tool-rail .bgrem-label {
  margin-bottom: .48rem;
  font-size: .65rem;
}

.bgrem-tool-rail .bgrem-engine-toggle {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .38rem;
}

.bgrem-tool-rail .bgrem-engine-btn {
  min-width: 0;
  gap: .38rem;
  padding: .55rem .48rem;
  border-radius: .62rem;
}

.bgrem-tool-rail .bgrem-engine-icon {
  width: .95rem;
  height: .95rem;
}

.bgrem-tool-rail .bgrem-engine-title {
  font-size: .7rem;
}

.bgrem-tool-rail .bgrem-engine-sub {
  overflow: hidden;
  font-size: .58rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-tool-rail .bgrem-model-status {
  margin-top: .5rem;
  padding: .6rem;
}

.bgrem-tool-rail .bgrem-model-status-note {
  display: none;
}

.bgrem-tool-rail .bgrem-actions {
  display: block;
}

.bgrem-tool-rail .bgrem-actions .btn,
.bgrem-tool-rail .bgrem-download-panel > .btn,
.bgrem-tool-rail .bgrem-batch-actions .btn {
  width: 100%;
}

.bgrem-tool-rail .bgrem-bg-controls,
.bgrem-tool-rail .bgrem-download-panel,
.bgrem-tool-rail .bgrem-more-tools {
  padding: .72rem;
  border-radius: .75rem;
}

.bgrem-tool-rail .bgrem-tool-locked {
  opacity: .52;
  pointer-events: none;
}

.bgrem-tool-rail .bgrem-tool-locked::after {
  content: 'Available after background removal';
  display: block;
  margin-top: .55rem;
  color: var(--muted);
  font-size: .63rem;
  line-height: 1.35;
}

.bgrem-tool-rail .is-batch-context .bgrem-actions,
.bgrem-tool-rail .is-batch-context .bgrem-download-panel,
.bgrem-tool-rail .is-batch-context .bgrem-history {
  display: none !important;
}

.bgrem-tool-rail .is-batch-context .bgrem-tool-locked::after {
  content: 'Use Edit on a finished image to apply this feature';
}

.bgrem-back-to-batch {
  flex: 0 0 auto;
  min-height: 36px;
  margin-left: auto;
  padding: .48rem .7rem;
  border: 1px solid var(--gold-dim);
  border-radius: .58rem;
  background: rgba(251, 191, 36, .1);
  color: var(--gold);
  font: 700 .7rem/1 Inter, sans-serif;
  cursor: pointer;
}

.bgrem-back-to-batch:hover {
  background: rgba(251, 191, 36, .2);
}

.bgrem-batch-item .bgrem-batch-edit {
  margin-bottom: .4rem;
}

.bgrem-tool-rail .bgrem-chip-row {
  gap: .35rem;
  margin-bottom: .65rem;
}

.bgrem-tool-rail .bgrem-chip {
  padding: .4rem .58rem;
  font-size: .68rem;
}

.bgrem-tool-rail .bgrem-custom-row {
  grid-template-columns: 64px minmax(0, 1fr);
  gap: .55rem;
}

.bgrem-tool-rail .lux-label {
  font-size: .66rem;
}

.bgrem-tool-rail .lux-input {
  min-width: 0;
  padding: .42rem;
  font-size: .65rem;
}

.bgrem-tool-rail .bgrem-color-input {
  height: 36px;
}

.bgrem-tool-rail .bgrem-dl-row {
  flex-direction: column;
  gap: .65rem;
  margin: .5rem 0;
}

.bgrem-tool-rail .bgrem-seg {
  width: 100%;
}

.bgrem-tool-rail .bgrem-seg-btn {
  flex: 1;
  min-width: 0;
  padding: .36rem .3rem;
  font-size: .67rem;
}

.bgrem-tool-rail .bgrem-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .38rem;
}

.bgrem-tool-rail .bgrem-link {
  justify-content: center;
  min-width: 0;
  padding: .45rem .35rem;
  font-size: .67rem;
}

.bgrem-tool-rail .bgrem-batch-actions {
  position: static;
  display: grid;
  gap: .5rem;
  padding: .7rem;
  box-shadow: none;
}

.bgrem-stage #br-batch-section {
  margin-top: 0 !important;
}

.bgrem-stage .bgrem-batch-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
}

html.theme-light .bgrem-selected-shell {
  background: rgba(241, 245, 249, .78);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .1);
}

html.theme-light .bgrem-tool-rail {
  background: rgba(255, 255, 255, .92);
}

html.theme-light .bgrem-stage .bgrem-grid {
  background: rgba(255, 255, 255, .65);
}

/* Strong light-mode contrast for transparency and engine selection. */
html.theme-light .bgrem-checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%, transparent 75%, #cbd5e1 75%, #cbd5e1),
    linear-gradient(45deg, #cbd5e1 25%, transparent 25%, transparent 75%, #cbd5e1 75%, #cbd5e1);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

html.theme-light .bgrem-engine-btn {
  border-color: #cbd5e1;
  background: #f8fafc;
}

html.theme-light .bgrem-engine-btn.active {
  position: relative;
  border-color: #b77900;
  background: #fff3c4;
  box-shadow: 0 0 0 2px rgba(183, 121, 0, .2), 0 8px 20px rgba(183, 121, 0, .1);
}

html.theme-light .bgrem-engine-btn.active .bgrem-engine-title,
html.theme-light .bgrem-engine-btn.active .bgrem-engine-sub {
  color: #704800;
}

html.theme-light .bgrem-engine-btn.active::after {
  position: absolute;
  top: .3rem;
  right: .35rem;
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border-radius: 50%;
  background: #9a6700;
  color: #fff;
  content: '✓';
  font-size: .58rem;
  font-weight: 900;
}

@media (max-width: 900px) {
  .bgrem-selected-shell {
    display: flex;
    height: auto;
    min-height: 0;
    flex-direction: column;
    overflow: visible;
  }

  .bgrem-stage {
    overflow: visible;
    order: 1;
  }

  .bgrem-tool-rail {
    order: 2;
    height: min(68vh, 620px);
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 600px) {
  .bgrem-stage {
    padding: .6rem;
  }

  .bgrem-stage .bgrem-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bgrem-stage .bgrem-card {
    grid-template-rows: auto minmax(230px, 1fr) auto;
    padding: .45rem;
  }

  .bgrem-stage .bgrem-card + .bgrem-card {
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .bgrem-stage .bgrem-card-head {
    align-items: flex-start;
  }

  .bgrem-stage .bgrem-zoom-controls {
    display: none;
  }

  .bgrem-stage .bgrem-preview-frame {
    min-height: 230px;
  }

  .bgrem-compare-head p {
    display: none;
  }

  .bgrem-compare-head .bgrem-quick-download {
    min-height: 34px;
    padding: .45rem .62rem;
    font-size: .66rem;
  }
}

/* ── Draggable one-canvas comparison ───────────────────────────────────── */
.bgrem-stage .bgrem-grid {
  display: flex;
  min-height: 520px;
  flex-direction: column;
}

.bgrem-compare-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  padding: .55rem .7rem;
  border-bottom: 1px solid var(--border);
}

.bgrem-compare-toolbar .bgrem-card-head {
  gap: .55rem;
  margin: 0;
}

.bgrem-compare-toolbar .bgrem-label {
  margin: 0;
  font-size: .64rem;
}

.bgrem-compare-canvas {
  --compare-position: 50%;
  position: relative;
  min-height: 420px;
  flex: 1;
  overflow: hidden;
  background: rgba(15, 23, 42, .85);
  isolation: isolate;
}

.bgrem-compare-canvas > .bgrem-preview-frame,
.bgrem-compare-result-layer,
.bgrem-compare-result-layer > .bgrem-preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
}

.bgrem-compare-result-layer {
  z-index: 2;
  visibility: hidden;
  overflow: hidden;
  clip-path: inset(0 calc(100% - var(--compare-position)) 0 0);
  pointer-events: none;
}

.bgrem-compare-canvas.is-ready .bgrem-compare-result-layer {
  visibility: visible;
}

.bgrem-compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--compare-position);
  z-index: 5;
  display: none;
  width: 3px;
  padding: 0;
  border: 0;
  background: var(--gold);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .3), 0 0 18px rgba(251, 191, 36, .35);
  cursor: ew-resize;
  touch-action: none;
  transform: translateX(-50%);
}

.bgrem-compare-canvas.is-ready .bgrem-compare-divider {
  display: block;
}

.bgrem-compare-divider span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  color: #111827;
  font-size: 1rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.bgrem-compare-divider:focus-visible span {
  outline: 3px solid rgba(251, 191, 36, .36);
  outline-offset: 3px;
}

.bgrem-compare-canvas.is-ready::before,
.bgrem-compare-canvas.is-ready::after {
  position: absolute;
  top: .75rem;
  z-index: 4;
  padding: .28rem .5rem;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(2, 6, 23, .72);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .06em;
  pointer-events: none;
  text-transform: uppercase;
}

.bgrem-compare-canvas.is-ready::before {
  left: .75rem;
  content: 'Result';
}

.bgrem-compare-canvas.is-ready::after {
  right: .75rem;
  content: 'Original';
}

.bgrem-compare-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-height: 36px;
  padding: .45rem .75rem;
  border-top: 1px solid var(--border);
}

.bgrem-compare-meta .bgrem-info-line {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  font-size: .7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bgrem-compare-meta .bgrem-info-line:last-child {
  text-align: right;
}

@media (max-width: 600px) {
  .bgrem-stage .bgrem-grid {
    display: flex;
    min-height: 390px;
  }

  .bgrem-compare-toolbar {
    min-height: 38px;
    padding: .4rem .5rem;
  }

  .bgrem-compare-toolbar .bgrem-card-head:last-child {
    margin-left: auto;
  }

  .bgrem-compare-canvas {
    min-height: 315px;
  }

  .bgrem-compare-divider span {
    width: 34px;
    height: 34px;
  }
}
