/* =============================================================
   Advanced BG Remover — Studio workspace
   Dark theme with red accents, single cutout preview.
   ============================================================= */
:root {
  --st-bg:        #08080a;
  --st-panel:     #0f1013;
  --st-panel-2:   #141519;
  --st-card:      #121317;
  --st-line:      rgba(255,255,255,.07);
  --st-line-2:    rgba(255,255,255,.12);
  --st-text:      #f2f3f5;
  --st-muted:     #9aa0a8;
  --st-faint:     #6b7078;
  --st-red:       #ff1f3d;
  --st-red-2:     #e00a28;
  --st-red-glow:  rgba(255,31,61,.35);
  --st-radius:    16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 500px at -5% -10%, rgba(255,31,61,.14), transparent 60%),
    radial-gradient(900px 500px at 105% 110%, rgba(255,31,61,.12), transparent 60%),
    var(--st-bg);
  color: var(--st-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
svg { width: 100%; height: 100%; }

.st-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 14px 20px 18px;
  gap: 14px;
}

/* ===================== Top bar ===================== */
.st-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.st-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--st-text);
  justify-self: start;
}
.st-brand-logo {
  width: 42px; height: 42px;
  border-radius: 11px;
  object-fit: cover;
  box-shadow: 0 0 20px var(--st-red-glow);
}
.st-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.st-brand-text strong { font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.st-brand-text strong em { color: var(--st-red); font-style: normal; }
.st-brand-text small { color: var(--st-muted); font-size: 12px; margin-top: 2px; }

.st-topbar-center { display: inline-flex; gap: 12px; justify-self: center; }
.st-topbar-right { display: inline-flex; align-items: center; gap: 12px; justify-self: end; }

.st-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid var(--st-line-2);
  background: var(--st-panel-2);
  color: var(--st-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}
.st-pill svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-pill-primary svg { fill: currentColor; stroke: none; }
.st-pill:hover { border-color: var(--st-line-2); transform: translateY(-1px); }
.st-pill-primary {
  background: linear-gradient(180deg, #ff2f4a, var(--st-red-2));
  border-color: transparent;
  box-shadow: 0 8px 26px -8px var(--st-red-glow), inset 0 1px 0 rgba(255,255,255,.18);
}
.st-pill-primary:hover { box-shadow: 0 10px 30px -6px var(--st-red-glow); }

.st-credits {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--st-line-2);
  background: var(--st-panel-2);
  font-size: 14px;
  color: var(--st-muted);
  font-weight: 500;
}
.st-credits b { color: var(--st-text); font-weight: 700; }
.st-credits svg { width: 16px; height: 16px; fill: var(--st-red); stroke: none; }
/* Credits pill now stacks the count over a small plan label. */
.st-credits-text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.st-credits-line { font-size: 13px; color: var(--st-muted); }
.st-credits-line b { color: var(--st-text); font-weight: 700; }
.st-plan { font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--st-muted); opacity: .8; }
.st-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--st-line-2);
  background: var(--st-panel-2);
  color: var(--st-muted);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px;
  overflow: hidden;
}
.st-avatar svg { stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-avatar:hover { color: var(--st-text); border-color: var(--st-line-2); }
/* When a Google profile picture is available it fills the button. */
.st-avatar.has-img { padding: 0; }
.st-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

/* ---- Touch-up tools (top bar centre) ---- */
.st-tools {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--st-panel-2);
  border: 1px solid var(--st-line);
  border-radius: 12px;
  padding: 5px;
}
.st-tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--st-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.st-tool svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-tool:hover:not(:disabled) { color: var(--st-text); background: rgba(255,255,255,.05); }
.st-tool.is-active { background: rgba(255,31,61,.14); border-color: rgba(255,31,61,.5); color: #fff; }
.st-tool.is-active svg { stroke: var(--st-red); }
.st-tool:disabled { opacity: .4; cursor: not-allowed; }
.st-tool-size {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 0 8px;
  color: var(--st-faint);
}
.st-tool-size svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.st-tool-size input[type=range] { width: 92px; accent-color: var(--st-red); cursor: pointer; }
.st-tool-size input[type=range]:disabled { opacity: .4; cursor: not-allowed; }

/* Editable cutout canvas (overlays the result image while a tool is active) */
.st-edit-canvas {
  position: absolute;
  top: 0; left: 0;
  touch-action: none;
  cursor: none;
  z-index: 5;
}
/* While editing, show the full result (no slider clip) */
.st-compare.is-editing .st-pane-result { width: 100% !important; }
.st-compare.is-editing .st-slider { display: none; }

/* Brush-size cursor ring */
.st-brush-cursor {
  position: fixed;
  z-index: 6;
  border: 1.5px solid rgba(255,255,255,.9);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.5), inset 0 0 0 1.5px rgba(0,0,0,.35);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* ===================== Main ===================== */
.st-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  min-height: 0;
  align-items: start;           /* don't stretch the canvas panel to the sidebar height */
}

/* ---- Canvas area ---- */
.st-canvas-area {
  background: var(--st-panel);
  border: 1px solid var(--st-line);
  border-radius: var(--st-radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.st-stage {
  flex: 1;
  position: relative;
  border-radius: 12px;
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(255,255,255,.03), transparent 70%),
    #0b0c0f;
  overflow: hidden;
  min-height: 66vh;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Empty state */
.st-empty {
  text-align: center;
  color: var(--st-faint);
  padding: 30px;
  pointer-events: none;
}
.st-empty svg { width: 56px; height: 56px; stroke: var(--st-faint); stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 12px; }
.st-empty h2 { margin: 0 0 6px; font-size: 20px; color: var(--st-muted); font-weight: 700; }
.st-empty p { margin: 0; font-size: 13px; }
.st-stage.is-dragover { outline: 2px dashed var(--st-red); outline-offset: -8px; }

/* Compare viewport — in-flow so the stage (and panel) shrink to the image */
.st-viewport { position: relative; display: flex; align-items: center; justify-content: center; }
.st-compare-zoom { transform-origin: center center; transition: transform .08s ease-out; }
.st-compare {
  position: relative;
  line-height: 0;
  user-select: none;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.7);
  border-radius: 8px;
  overflow: hidden;
}
.st-pane { position: absolute; inset: 0; overflow: hidden; }
.st-pane-original { position: relative; }       /* defines the box size */
.st-pane-original img, .st-pane-result img { display: block; max-width: 58vw; max-height: 72vh; width: auto; height: auto; }
.st-pane-result { width: 100%; }
.st-result-bg { position: absolute; inset: 0; }
/* result img must sit at the same box as original (not clipped-scaled) */
.st-pane-result .st-result-bg img { position: absolute; top: 0; left: 0; }

.st-pane-label {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 3;
  background: rgba(10,11,14,.82);
  color: var(--st-text);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  line-height: 1;
  backdrop-filter: blur(6px);
  border: 1px solid var(--st-line);
}
.st-pane-label-result {
  background: linear-gradient(180deg, #ff2f4a, var(--st-red-2));
  border-color: transparent;
  box-shadow: 0 6px 18px -8px var(--st-red-glow);
}

/* Preview background modes (applied to .st-result-bg) */
.st-result-bg.bg-transparent,
.st-stage .st-checker, .st-bg-checker {
  background-color: #cfd2d6;
  background-image:
    linear-gradient(45deg, #9a9ea4 25%, transparent 25%, transparent 75%, #9a9ea4 75%, #9a9ea4),
    linear-gradient(45deg, #9a9ea4 25%, transparent 25%, transparent 75%, #9a9ea4 75%, #9a9ea4);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}
/* Transparent-black: a DARK checkerboard — still represents real alpha
   (nothing is baked into the export), just shown on a dark surface. */
.st-result-bg.bg-black, .st-bg-checker-dark {
  background-color: #141414;
  background-image:
    linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%, #262626),
    linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%, #262626);
  background-size: 22px 22px;
  background-position: 0 0, 11px 11px;
}

/* Slider handle */
.st-slider {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
  z-index: 4;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}
.st-slider-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--st-red); box-shadow: 0 0 10px var(--st-red-glow); }
.st-slider-knob {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff2f4a, var(--st-red-2));
  box-shadow: 0 6px 18px -4px var(--st-red-glow), inset 0 1px 0 rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
}
.st-slider-knob svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Busy overlay */
.st-busy {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: rgba(8,9,11,.72);
  backdrop-filter: blur(3px);
  color: var(--st-text);
  font-size: 14px; font-weight: 600;
}
.st-spin {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.14);
  border-top-color: var(--st-red);
  animation: st-spin 0.8s linear infinite;
}
@keyframes st-spin { to { transform: rotate(360deg); } }

/* ---- Canvas toolbar ---- */
.st-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.st-zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--st-panel-2);
  border: 1px solid var(--st-line);
  border-radius: 11px;
  padding: 5px;
}
.st-zoom-btn {
  min-width: 34px; height: 34px;
  border: none;
  background: transparent;
  color: var(--st-text);
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.st-zoom-btn:hover { background: rgba(255,255,255,.07); }
.st-zoom-fit svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-zoom-val { min-width: 52px; text-align: center; font-size: 13px; color: var(--st-muted); font-weight: 600; }

.st-bgtoggle { display: inline-flex; gap: 6px; background: var(--st-panel-2); border: 1px solid var(--st-line); border-radius: 11px; padding: 5px; }
.st-bg-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--st-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.st-bg-opt:hover { color: var(--st-text); }
.st-bg-opt.is-active { background: rgba(255,31,61,.12); border-color: rgba(255,31,61,.4); color: var(--st-text); }
.st-bg-swatch { width: 16px; height: 16px; border-radius: 5px; border: 1px solid rgba(255,255,255,.25); }

/* ===================== Sidebar ===================== */
.st-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: auto;
}
.st-card {
  background: var(--st-card);
  border: 1px solid var(--st-line);
  border-radius: var(--st-radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.st-card-remove::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(260px 160px at 80% -10%, rgba(255,31,61,.12), transparent 70%);
  pointer-events: none;
}
.st-card-remove { text-align: center; }
.st-card-ico {
  width: 64px; height: 64px;
  margin: 2px auto 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,47,74,.22), rgba(224,10,40,.12));
  border: 1px solid rgba(255,31,61,.35);
  display: flex; align-items: center; justify-content: center;
  padding: 15px;
  box-shadow: 0 0 24px -6px var(--st-red-glow);
}
.st-card-ico svg { fill: var(--st-red); stroke: none; }
.st-card-remove h3 { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.st-card-remove p { margin: 0 0 20px; font-size: 14px; color: var(--st-muted); line-height: 1.5; }

/* Output quality (2K / 4K) */
.st-quality {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}
.st-quality-label { font-size: 13px; font-weight: 600; color: var(--st-muted); }
.st-quality-seg {
  display: inline-flex;
  gap: 4px;
  background: var(--st-panel-2);
  border: 1px solid var(--st-line);
  border-radius: 10px;
  padding: 4px;
}
.st-quality-opt {
  min-width: 48px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--st-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.st-quality-opt:hover { color: var(--st-text); }
.st-quality-opt.is-active { background: rgba(255,31,61,.14); border-color: rgba(255,31,61,.5); color: var(--st-text); }

/* Keep / Remove guidance prompts — optional hints fed to the AI cutout */
.st-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
  text-align: left;
}
.st-guide-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--st-panel-2);
  border: 1px solid var(--st-line);
  border-radius: 10px;
  padding: 4px 4px 4px 8px;
}
.st-guide-row:focus-within { border-color: rgba(255,31,61,.5); }
.st-guide-tag {
  flex: none;
  min-width: 58px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 7px;
}
.st-guide-keep   { color: #7bffb0; background: rgba(40,220,130,.14); border: 1px solid rgba(40,220,130,.4); }
.st-guide-remove { color: #ff8fa3; background: rgba(255,31,61,.14); border: 1px solid rgba(255,31,61,.4); }
.st-guide-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--st-text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
}
.st-guide-input::placeholder { color: var(--st-muted); opacity: .7; }

.st-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  border: 1px solid var(--st-line-2);
  border-radius: 12px;
  background: var(--st-panel-2);
  color: var(--st-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, filter .15s;
  position: relative;
}
.st-btn svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-btn-primary svg:not(.st-btn-arrow) { fill: currentColor; stroke: none; }
.st-btn-primary {
  background: linear-gradient(180deg, #ff2f4a, var(--st-red-2));
  border-color: transparent;
  box-shadow: 0 10px 28px -8px var(--st-red-glow), inset 0 1px 0 rgba(255,255,255,.18);
}
.st-btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 34px -8px var(--st-red-glow); }
.st-btn-arrow { position: absolute; right: 18px; }
.st-btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }
/* Credit-cost hint inside the Remove button label (e.g. "· 4 credits"). */
.st-cost { font-style: normal; font-weight: 600; opacity: .85; }

.st-features {
  list-style: none;
  margin: 22px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--st-line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}
.st-features li { display: flex; align-items: center; gap: 13px; font-size: 14.5px; font-weight: 600; color: var(--st-text); }
.st-features svg { flex: 0 0 22px; width: 22px; height: 22px; stroke: var(--st-red); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Download card */
.st-card-download h3 { margin: 0 0 16px; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.st-card-download h3 svg { width: 20px; height: 20px; stroke: var(--st-red); stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-formats { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
.st-format { flex-direction: row; justify-content: center; padding: 11px; }
.st-format svg { margin-bottom: 0; }
.st-format {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  border: 1px solid var(--st-line);
  border-radius: 11px;
  background: var(--st-panel-2);
  color: var(--st-muted);
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s;
}
.st-format svg { width: 18px; height: 18px; margin-bottom: 4px; stroke: var(--st-faint); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-format b { font-size: 13px; color: var(--st-muted); }
.st-format small { font-size: 10.5px; color: var(--st-faint); }
.st-format.is-active { border-color: rgba(255,31,61,.55); background: rgba(255,31,61,.1); }
.st-format.is-active svg { stroke: var(--st-red); }
.st-format.is-active b { color: var(--st-text); }
.st-format.is-active small { color: var(--st-muted); }

/* ===================== Upload button (in the canvas toolbar) ===================== */
.st-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #ff2f4a, var(--st-red-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px -10px var(--st-red-glow), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .12s, box-shadow .15s;
}
.st-upload-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-upload-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px var(--st-red-glow); }

/* ===================== Toast ===================== */
.st-toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(14px);
  display: flex; align-items: center; gap: 10px;
  background: #16181d;
  border: 1px solid var(--st-line-2);
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 18px 44px -14px rgba(0,0,0,.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.st-toast:not([hidden]) { opacity: 1; transform: translateX(-50%) translateY(0); }
.st-toast svg { width: 18px; height: 18px; stroke: #2fd16b; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.st-toast.is-error svg { stroke: var(--st-red); }

/* ===================== Responsive ===================== */
@media (max-width: 1000px) {
  .st-main { grid-template-columns: 1fr; }
  .st-topbar { grid-template-columns: 1fr auto; }
  .st-tools { grid-column: 1 / -1; order: 3; justify-self: center; flex-wrap: wrap; }
  .st-pane-original img, .st-pane-result img { max-width: 90vw; max-height: 48vh; }
}

[hidden] { display: none !important; }
