/* Namespaced styles so the component does not disturb the host application. */
:root {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #172033;
}

.demo-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 40px auto;
}

.bg-remover {
  --bgr-border: #d9e0ea;
  --bgr-muted: #667085;
  --bgr-primary: #2f6fed;
  --bgr-primary-dark: #235fd4;
  --bgr-success: #12805c;
  --bgr-danger: #b42318;
  --bgr-surface: #ffffff;

  width: 100%;
  border: 1px solid var(--bgr-border);
  border-radius: 18px;
  background: var(--bgr-surface);
  padding: 24px;
  box-shadow: 0 16px 50px rgba(16, 24, 40, 0.08);
}

.bg-remover__header {
  margin-bottom: 20px;
}

.bg-remover__eyebrow {
  margin: 0 0 6px;
  color: var(--bgr-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.bg-remover__title {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.12;
}

.bg-remover__subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--bgr-muted);
  line-height: 1.6;
}

.bg-remover__dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  padding: 28px;
  border: 2px dashed #b8c4d4;
  border-radius: 16px;
  background: #fafcff;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.bg-remover__dropzone:hover,
.bg-remover__dropzone:focus-visible,
.bg-remover__dropzone.is-dragover {
  border-color: var(--bgr-primary);
  background: #f2f7ff;
  outline: none;
}

.bg-remover__dropzone.is-dragover {
  transform: scale(.995);
}

.bg-remover__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.bg-remover__drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #e8f0ff;
  color: var(--bgr-primary);
  font-size: 30px;
  font-weight: 300;
}

.bg-remover__dropzone span,
.bg-remover__dropzone small,
.bg-remover__preview-heading span {
  color: var(--bgr-muted);
}

.bg-remover__status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  min-height: 24px;
  font-size: 14px;
}

.bg-remover__status[data-state="error"] {
  color: var(--bgr-danger);
}

.bg-remover__status[data-state="success"] {
  color: var(--bgr-success);
}

.bg-remover__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #dce4ef;
  border-top-color: var(--bgr-primary);
  border-radius: 50%;
  animation: bgr-spin .8s linear infinite;
}

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

.bg-remover__progress {
  margin-top: 12px;
}

.bg-remover__progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #edf1f6;
}

.bg-remover__progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--bgr-primary);
  transition: width .2s ease;
}

.bg-remover__progress span {
  display: block;
  margin-top: 6px;
  color: var(--bgr-muted);
  font-size: 12px;
}

.bg-remover__previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.bg-remover__preview-card {
  overflow: hidden;
  border: 1px solid var(--bgr-border);
  border-radius: 14px;
  background: #fff;
}

.bg-remover__preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bgr-border);
  font-size: 13px;
}

.bg-remover__image-stage {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 12px;
  background: #f2f4f7;
}

.bg-remover__image-stage--transparent {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e8ebef 25%, transparent 25%),
    linear-gradient(-45deg, #e8ebef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8ebef 75%),
    linear-gradient(-45deg, transparent 75%, #e8ebef 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.bg-remover__image-stage img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.bg-remover__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.bg-remover__button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .18s ease, transform .18s ease, background .18s ease;
}

.bg-remover__button:active {
  transform: translateY(1px);
}

.bg-remover__button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.bg-remover__button--secondary {
  border-color: var(--bgr-border);
  background: #fff;
  color: #344054;
}

.bg-remover__button--primary {
  background: var(--bgr-primary);
  color: #fff;
}

.bg-remover__button--primary:hover {
  background: var(--bgr-primary-dark);
}

.bg-remover__button--success {
  background: var(--bgr-success);
  color: #fff;
}

.bg-remover__saved {
  margin: 12px 0 0;
  color: var(--bgr-success);
  font-size: 13px;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .demo-shell {
    width: min(100% - 20px, 1180px);
    margin: 14px auto;
  }

  .bg-remover {
    padding: 16px;
    border-radius: 14px;
  }

  .bg-remover__dropzone {
    min-height: 180px;
    padding: 20px 14px;
  }

  .bg-remover__previews {
    grid-template-columns: 1fr;
  }

  .bg-remover__image-stage {
    min-height: 240px;
  }

  .bg-remover__actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .bg-remover__button {
    width: 100%;
  }
}
