/* ---------- tool-specific styles (High-Contrast & Organized Edition) ---------- */
#bgrm-root { line-height: 1.5; text-align: left; }
#bgrm-root h1, #bgrm-root h2, #bgrm-root h3 { margin: 0; color: var(--heading); }
#bgrm-root button { font: inherit; color: inherit; cursor: pointer; }
#bgrm-root :focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }

/* layout */
#bgrm-root .bgrm-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 18px; align-items: start; }
#bgrm-root .bgrm-main { min-width: 0; }
@media (min-width: 1024px) {
  #bgrm-root .bgrm-grid { grid-template-columns: minmax(0,1fr) 370px; gap: 22px; }
  #bgrm-root .bgrm-side { position: sticky; top: 74px; }
}
#bgrm-root .bgrm-pcard { background: transparent; border: none; border-radius: 0; padding: 0; box-shadow: none; }
#bgrm-root .bgrm-stepwrap + .bgrm-stepwrap { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
#bgrm-root .bgrm-steptitle { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; font-size: 13.5px; font-weight: 800; color: var(--heading); flex-wrap: nowrap; }
#bgrm-root .bgrm-steptitle-left { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
#bgrm-root .bgrm-stepnum { width: 23px; height: 23px; border-radius: 50%; flex: none; background: var(--grad-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 800; font-family:'Space Grotesk',sans-serif; box-shadow: 0 2px 6px rgba(124,58,237,.4); }
#bgrm-root .bgrm-step-pill { font-size: 11px; font-weight: 700; color: var(--primary-light); background: color-mix(in srgb, var(--primary) 16%, var(--surface-soft)); border: 1px solid var(--border); padding: 3px 9px; border-radius: 50px; white-space: nowrap; }

/* Bright Illuminated Settings & API Button */
#bgrm-root .bgrm-gear-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border: 1.5px solid #c4b5fd; color: #ffffff !important;
  padding: 6px 13px; border-radius: 50px; font-size: 12px; font-weight: 700;
  box-shadow: 0 3px 12px rgba(124,58,237,.45);
  transition: transform .15s, box-shadow .15s, filter .15s; white-space: nowrap;
}
#bgrm-root .bgrm-gear-btn:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 6px 18px rgba(124,58,237,.6); }

/* Active Settings Summary Bar */
#bgrm-root .bgrm-settings-summary {
  margin-top: 11px; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--surface-soft); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s;
}
#bgrm-root .bgrm-settings-summary:hover { border-color: var(--primary-light); background: var(--surface-hover); color: var(--heading); }
#bgrm-root .bgrm-settings-summary strong { color: var(--heading); }
#bgrm-root .bgrm-settings-summary .bgrm-cust-link { color: var(--primary-light); font-weight: 800; white-space: nowrap; }

/* checkerboard */
#bgrm-root .bgrm-check {
  background-color: var(--check-a);
  background-image:
    linear-gradient(45deg, var(--check-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--check-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--check-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

/* dropzone */
#bgrm-root .bgrm-drop { display: block; width: 100%; font-family: inherit; color: inherit; border: 2px dashed var(--border); border-radius: var(--r-lg); padding: 30px 16px 24px; text-align: center; position: relative; transition: border-color .18s, transform .1s, background .18s; cursor: pointer; }
#bgrm-root .bgrm-drop:hover { border-color: var(--primary-light); background: color-mix(in srgb, var(--primary) 6%, transparent); }
#bgrm-root .bgrm-drop.bgrm-drag { border-color: var(--green-light); transform: scale(1.005); background: color-mix(in srgb, var(--green) 10%, transparent); }
#bgrm-root .bgrm-drop-icon { width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--primary) 22%, var(--surface-soft)); border: 1px solid var(--border); color: var(--primary-light); display: grid; place-items: center; margin: 0 auto 10px; box-shadow: var(--shadow); }
#bgrm-root .bgrm-drop-icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#bgrm-root .bgrm-drop .bgrm-dt { display: block; margin: 2px 0; font-size: 15px; font-weight: 700; color: var(--heading); }
#bgrm-root .bgrm-drop .bgrm-dim { display: block; margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
#bgrm-root input[type=file] { display: none; }
#bgrm-root .bgrm-file-count { margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--green-light); display: none; }
#bgrm-root .bgrm-file-count.bgrm-show { display: block; }

/* dropzone bottom bar: sample photos + paste */
#bgrm-root .bgrm-upload-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-soft); border: 1px solid var(--border); }
#bgrm-root .bgrm-samples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text); font-weight: 700; }
#bgrm-root .bgrm-sample-btn { border: 1.5px solid var(--border); background: var(--surface); color: var(--heading); border-radius: 50px; padding: 5px 11px; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; transition: border-color .15s, background .15s, transform .1s; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
#bgrm-root .bgrm-sample-btn:hover { border-color: var(--primary-light); background: var(--surface-hover); transform: translateY(-1px); }

/* progress + boxes */
#bgrm-root .bgrm-inst { display: none; margin-top: 10px; }
#bgrm-root .bgrm-inst.bgrm-show { display: block; }
#bgrm-root .bgrm-track { height: 6px; border-radius: 50px; background: var(--surface-hover); overflow: hidden; margin-top: 8px; }
#bgrm-root .bgrm-fill { height: 100%; width: 0%; border-radius: 50px; transition: width .18s; background: linear-gradient(90deg, var(--primary), var(--green-light)); }
#bgrm-root .bgrm-instsub { font-size: 12px; opacity: .9; margin-top: 6px; line-height: 1.45; }
#bgrm-root .bgrm-box { display: none; margin-top: 10px; font-size: 12px; line-height: 1.5; font-weight: 600; border-radius: var(--r-md); padding: 9px 12px; border: 1px solid var(--border); background: var(--surface-soft); }
#bgrm-root .bgrm-box.bgrm-show { display: block; }
#bgrm-root .bgrm-box.bgrm-ok { border-color: var(--green); color: var(--green-light); }
#bgrm-root .bgrm-box.bgrm-err { border-color: #ef4444; color: #f87171; }
#bgrm-root .bgrm-box.bgrm-warn { border-color: #d97706; color: #fbbf24; }
#bgrm-root .bgrm-progress { display: none; margin-top: 12px; }
#bgrm-root .bgrm-progress.bgrm-show { display: block; }
#bgrm-root .bgrm-progress-text { font-size: 12px; opacity: .9; margin-top: 6px; font-weight: 600; }

/* Primary Action Buttons (Start & ZIP) */
#bgrm-root .bgrm-btn { width: 100%; padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid rgba(255,255,255,.16); background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff !important; font-size: 13.5px; font-weight: 800; transition: all .18s; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px rgba(109,40,217,.35); margin-top: 10px; }
#bgrm-root .bgrm-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(124,58,237,.5); filter: brightness(1.06); }
#bgrm-root .bgrm-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
#bgrm-root .bgrm-btn.get { background: linear-gradient(135deg, #22c55e, #15803d); box-shadow: 0 4px 12px rgba(22,163,74,.35); }
#bgrm-root .bgrm-btn.get:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(22,163,74,.5); }

/* High-Contrast Option Cards (Background, Resolution, Format, Settings) */
#bgrm-root .bgrm-bgrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 4px; }
#bgrm-root .bgrm-bgopt {
  border: 1.5px solid var(--border); background: var(--surface-soft);
  border-radius: var(--r-sm); padding: 7px 3px; font-size: 11px; font-weight: 700;
  color: var(--heading); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; transition: all .15s; min-height: 44px;
  box-shadow: 0 2px 5px rgba(0,0,0,.18);
}
#bgrm-root .bgrm-bgopt:hover { border-color: var(--primary-light); background: var(--surface-hover); transform: translateY(-1px); }
#bgrm-root .bgrm-bgopt.bgrm-active {
  border-color: #c4b5fd;
  background: linear-gradient(135deg, rgba(139,92,246,.38), rgba(109,40,217,.26));
  box-shadow: 0 0 0 1px #a78bfa, 0 4px 12px rgba(124,58,237,.32);
  color: #ffffff;
}
html.light #bgrm-root .bgrm-bgopt.bgrm-active {
  border-color: #6d28d9;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #2e1065;
}
#bgrm-root .bgrm-sublabel { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; }
#bgrm-root .bgrm-sublabel::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
#bgrm-root .bgrm-alignrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
#bgrm-root .bgrm-alignrow2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
#bgrm-root .bgrm-sw { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: 12px; }
#bgrm-root .bgrm-sw.wh { background: #ffffff; border-color: #cbd5e1; }
#bgrm-root .bgrm-sw.col { background: conic-gradient(from 0deg, #ef4444, #eab308, #22c55e, #3b82f6, #a855f7, #ef4444); }
#bgrm-root .bgrm-sw.bl { background: radial-gradient(circle, #c4b5fd 25%, rgba(124,58,237,.25) 100%); }
#bgrm-root .bgrm-sw.im { background: color-mix(in srgb, var(--primary) 22%, var(--surface)); color: var(--primary-light); font-size: 13px; }
#bgrm-root .bgrm-extra { margin-top: 10px; display: none; padding: 10px; border-radius: var(--r-sm); background: var(--surface-soft); border: 1px solid var(--border); }
#bgrm-root .bgrm-extra.bgrm-show { display: block; }
#bgrm-root .bgrm-colorwrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#bgrm-root .bgrm-colorwrap input[type=color] { width: 38px; height: 32px; border: 1.5px solid var(--border); border-radius: 7px; background: var(--surface); padding: 2px; cursor: pointer; flex: none; }
#bgrm-root .bgrm-colorwrap span { font-size: 12px; color: var(--heading); font-family: monospace; font-weight: 700; min-width: 60px; }
#bgrm-root .bgrm-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#bgrm-root .bgrm-swatch { width: 25px; height: 25px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; transition: transform .12s, border-color .12s; }
#bgrm-root .bgrm-swatch:hover { transform: scale(1.15); border-color: #fff; }
#bgrm-root .bgrm-bgimg-btn { width: 100%; border: 1.5px dashed var(--primary-light); background: var(--surface); color: var(--heading); border-radius: var(--r-sm); padding: 9px; font-size: 12.5px; font-weight: 700; }
#bgrm-root .bgrm-bgimg-btn:hover { background: var(--surface-hover); }

/* Sidebar Custom Pixel Resolution Box */
#bgrm-root .bgrm-side-custompx {
  margin-top: 8px; padding: 10px; border-radius: var(--r-md);
  background: var(--surface-soft); border: 1.5px solid var(--border); display: none;
}
#bgrm-root .bgrm-side-custompx.bgrm-show { display: block; }
#bgrm-root .bgrm-px-inputs { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
#bgrm-root .bgrm-px-inputs label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; color: var(--heading); flex: 1; }
#bgrm-root .bgrm-px-inputs input { width: 100%; padding: 6px 8px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--bg); color: var(--heading); font: inherit; font-weight: 700; font-size: 12.5px; }
#bgrm-root .bgrm-px-chips { display: flex; flex-wrap: wrap; gap: 5px; }
#bgrm-root .bgrm-px-chip { font-size: 10.5px; font-weight: 700; padding: 5px 9px; border-radius: 50px; border: 1.5px solid var(--border); background: var(--surface); color: var(--heading); transition: all .15s; }
#bgrm-root .bgrm-px-chip:hover, #bgrm-root .bgrm-px-chip.bgrm-active { border-color: #c4b5fd; background: var(--grad-primary); color: #fff; }

/* results grid */
#bgrm-root .bgrm-results { margin-top: 18px; display: none; }
#bgrm-root .bgrm-results.bgrm-show { display: block; }
#bgrm-root .bgrm-results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding-top: 16px; border-top: 1px solid var(--border); }
#bgrm-root .bgrm-results-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 7px; }
#bgrm-root .bgrm-mini-btn { border: 1.5px solid var(--border); background: var(--surface-soft); color: var(--heading); border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; transition: all .15s; }
#bgrm-root .bgrm-mini-btn:hover { border-color: var(--primary-light); background: var(--surface-hover); }
#bgrm-root .bgrm-listtitle { font-size: 12px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: var(--heading); }
#bgrm-root .bgrm-gridimgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px,1fr)); gap: 16px; }
@media (max-width: 520px) { #bgrm-root .bgrm-gridimgs { grid-template-columns: repeat(auto-fill, minmax(158px,1fr)); gap: 12px; } }
#bgrm-root .bgrm-card { border-radius: var(--r-md); overflow: hidden; background: var(--surface-soft); border: 1.5px solid var(--border); padding: 8px; transition: transform .18s, box-shadow .18s, border-color .18s; display: flex; flex-direction: column; }
#bgrm-root .bgrm-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.25); border-color: var(--primary-light); }
#bgrm-root .bgrm-card-thumb { position: relative; display: block; line-height: 0; border-radius: var(--r-sm); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); min-height: 140px; display: grid; place-items: center; }
#bgrm-root .bgrm-card-thumb img { display: block; width: 100%; height: auto; max-height: 210px; object-fit: contain; }
#bgrm-root .bgrm-card-thumb.bgrm-zoomable { cursor: zoom-in; }
#bgrm-root .bgrm-res-badge { position: absolute; bottom: 7px; left: 7px; z-index: 3; background: rgba(15,12,29,.84); color: #fff; border: 1px solid rgba(196,181,253,.35); font-size: 10px; font-weight: 700; padding: 3px 7px; border-radius: 5px; line-height: 1.2; pointer-events: none; backdrop-filter: blur(4px); }
#bgrm-root .bgrm-card-tools { position: absolute; top: 8px; right: 8px; z-index: 4; display: flex; gap: 5px; opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s; }
#bgrm-root .bgrm-card-thumb:hover .bgrm-card-tools, #bgrm-root .bgrm-card-tools:focus-within { opacity: 1; transform: none; }
#bgrm-root .bgrm-card-toolbtn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(255,255,255,.22); background: rgba(20,17,42,.85); color: #fff; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: grid; place-items: center; font-size: 13px; cursor: pointer; transition: background .15s; }
#bgrm-root .bgrm-card-toolbtn:hover { background: var(--primary); }
@media (hover: none) { #bgrm-root .bgrm-card-tools { opacity: 1; transform: none; } }
#bgrm-root .bgrm-card-body { padding: 9px 2px 1px; margin-top: auto; }
#bgrm-root .bgrm-card-name { font-size: 11px; color: var(--muted); margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bgrm-root .bgrm-card-dl { display: flex; gap: 6px; }
#bgrm-root .bgrm-card-dl:empty { display: none; }
#bgrm-root .bgrm-card-editbtn { flex: 1; font-size: 11.5px; font-weight: 700; border: 1.5px solid var(--border); background: var(--surface-hover); color: var(--heading); border-radius: 7px; padding: 8px 4px; cursor: pointer; transition: border-color .15s, background .15s; min-height: 36px; }
#bgrm-root .bgrm-card-editbtn:hover { border-color: var(--primary-light); background: color-mix(in srgb, var(--primary) 22%, var(--surface-hover)); }
#bgrm-root .bgrm-card-dl button.bgrm-dl-main { flex: 1.5; font-size: 11.5px; font-weight: 800; border: none; background: linear-gradient(135deg, #22c55e, #15803d); color: #fff; border-radius: 7px; padding: 8px 6px; transition: transform .15s, box-shadow .18s, filter .18s; min-height: 36px; }
#bgrm-root .bgrm-card-dl button.bgrm-dl-main:hover { filter: brightness(1.06); box-shadow: 0 4px 12px rgba(22,163,74,.4); }
#bgrm-root .bgrm-card-remove { position: absolute; top: 8px; left: 8px; z-index: 4; width: 28px; height: 28px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(20,17,42,.82); color: #fff; display: grid; place-items: center; font-size: 12px; cursor: pointer; opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s, background .15s; }
#bgrm-root .bgrm-card-thumb:hover .bgrm-card-remove, #bgrm-root .bgrm-card-remove:focus-visible { opacity: 1; transform: none; }
#bgrm-root .bgrm-card-remove:hover { background: #ef4444; }
@media (hover: none) { #bgrm-root .bgrm-card-remove { opacity: 1; transform: none; } }

/* SETTINGS MODAL (⚙️ Studio & API Settings — High-Contrast Visual Cards) */
#bgrm-root .bgrm-settings-modal { position: fixed; inset: 0; background: rgba(8,6,15,.88); display: none; align-items: center; justify-content: center; z-index: 999999; padding: 14px; backdrop-filter: blur(5px); }
#bgrm-root .bgrm-settings-modal.bgrm-show { display: flex; }
#bgrm-root .bgrm-sm-inner { width: min(96vw, 700px); max-height: 92vh; background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.7); display: flex; flex-direction: column; }
#bgrm-root .bgrm-sm-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
#bgrm-root .bgrm-sm-title { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 16px; color: var(--heading); display: flex; align-items: center; gap: 8px; }
#bgrm-root .bgrm-sm-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-soft); padding: 6px; gap: 6px; border-bottom: 1px solid var(--border); }
#bgrm-root .bgrm-sm-tab { border: 1.5px solid transparent; background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; padding: 10px 8px; border-radius: 10px; transition: all .15s; text-align: center; }
#bgrm-root .bgrm-sm-tab:hover { color: var(--heading); background: var(--surface); }
#bgrm-root .bgrm-sm-tab.bgrm-active { color: #fff; background: var(--grad-primary); border-color: #c4b5fd; box-shadow: 0 3px 10px rgba(124,58,237,.35); }
#bgrm-root .bgrm-sm-body { padding: 16px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
#bgrm-root .bgrm-sm-pane { display: none; flex-direction: column; gap: 14px; }
#bgrm-root .bgrm-sm-pane.bgrm-active { display: flex; }
#bgrm-root .bgrm-sm-group { background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
#bgrm-root .bgrm-sm-gtitle { font-size: 13px; font-weight: 800; color: var(--heading); margin: 0 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#bgrm-root .bgrm-sm-gdesc { font-size: 12px; color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
#bgrm-root .bgrm-sm-check { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; color: var(--text); cursor: pointer; user-select: none; }
#bgrm-root .bgrm-sm-check + .bgrm-sm-check { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
#bgrm-root .bgrm-sm-check input { width: 18px; height: 18px; accent-color: var(--primary); margin-top: 2px; flex: none; cursor: pointer; }

/* Visual API Engine Selector Cards inside Settings */
#bgrm-root .bgrm-prov-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
@media (max-width: 560px) { #bgrm-root .bgrm-prov-grid { grid-template-columns: repeat(2, 1fr); } }
#bgrm-root .bgrm-prov-card {
  border: 1.5px solid var(--border); background: var(--surface-soft);
  border-radius: 10px; padding: 10px 8px; text-align: left;
  display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: all .15s; position: relative;
}
#bgrm-root .bgrm-prov-card:hover { border-color: var(--primary-light); background: var(--surface-hover); transform: translateY(-1px); }
#bgrm-root .bgrm-prov-card.bgrm-active {
  border-color: #4ade80;
  background: linear-gradient(135deg, rgba(124,58,237,.32), rgba(22,163,74,.22));
  box-shadow: 0 0 0 1px #4ade80, 0 4px 12px rgba(22,163,74,.25);
}
html.light #bgrm-root .bgrm-prov-card.bgrm-active {
  border-color: #16a34a; background: linear-gradient(135deg, #f0fdf4, #ede9fe);
}
#bgrm-root .bgrm-prov-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 12px; font-weight: 800; color: var(--heading); }
#bgrm-root .bgrm-prov-sub { font-size: 10.5px; color: var(--muted); line-height: 1.3; font-weight: 600; }
#bgrm-root .bgrm-prov-card.bgrm-active .bgrm-prov-sub { color: var(--text); }
#bgrm-root .bgrm-prov-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
#bgrm-root .bgrm-prov-card.bgrm-active .bgrm-prov-dot { background: #4ade80; box-shadow: 0 0 8px #4ade80; }

/* API Key Input Box */
#bgrm-root .bgrm-api-fields { display: none; flex-direction: column; gap: 9px; margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--surface-soft); border: 1.5px solid var(--primary-light); }
#bgrm-root .bgrm-api-fields.bgrm-show { display: flex; }
#bgrm-root .bgrm-api-input-row { display: flex; gap: 7px; align-items: center; }
#bgrm-root .bgrm-api-input.bgrm-masked { -webkit-text-security: disc; }
#bgrm-root .bgrm-api-input { flex: 1; width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--bg); color: var(--heading); font-family: monospace; font-size: 13px; font-weight: 700; }
#bgrm-root .bgrm-api-input:focus { border-color: #4ade80; outline: none; }
#bgrm-root .bgrm-api-eye { border: 1.5px solid var(--border); background: var(--surface); color: var(--heading); border-radius: 8px; padding: 8px 11px; font-size: 12px; font-weight: 700; white-space: nowrap; }
#bgrm-root .bgrm-api-eye:hover { border-color: var(--primary-light); background: var(--surface-hover); }
#bgrm-root .bgrm-api-help { font-size: 11.5px; color: var(--text); line-height: 1.45; }
#bgrm-root .bgrm-sm-footer { padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* pre-process edit & select modal */
#bgrm-root .bgrm-preedit { position: fixed; inset: 0; background: rgba(10,8,16,.9); display: none; align-items: center; justify-content: center; z-index: 999999; padding: 16px; }
#bgrm-root .bgrm-preedit.bgrm-show { display: flex; }
#bgrm-root .bgrm-pe-inner { position: relative; display: flex; flex-direction: column; width: min(96vw, 900px); max-height: 92vh; background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
#bgrm-root .bgrm-pe-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
#bgrm-root .bgrm-pe-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 14px; color: var(--heading); }
#bgrm-root .bgrm-pe-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#bgrm-root .bgrm-pe-wrap { position: relative; display: inline-block; line-height: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.5); touch-action: none; }
#bgrm-root .bgrm-pe-wrap canvas { display: block; max-width: 100%; max-height: 66vh; cursor: crosshair; }
#bgrm-root .bgrm-pe-box { position: absolute; border: 2px solid var(--primary-light); background: color-mix(in srgb, var(--primary) 16%, transparent); box-shadow: 0 0 0 9999px rgba(10,8,16,.45); pointer-events: none; }
#bgrm-root .bgrm-pe-box[hidden] { display: none; }
#bgrm-root .bgrm-pe-controls { flex: none; border-top: 1px solid var(--border); background: var(--surface); padding: 12px 15px; display: flex; flex-direction: column; gap: 10px; }
#bgrm-root .bgrm-pe-hint { font-size: 12px; color: var(--muted); text-align: center; }
#bgrm-root .bgrm-pe-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

#bgrm-root .bgrm-status-badge { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 11px; color: #fff; text-align: center; padding: 8px; line-height: 1.4; background: rgba(12,10,20,.58); backdrop-filter: blur(1.5px); }
#bgrm-root .bgrm-status-text { text-shadow: 0 1px 3px rgba(0,0,0,.5); font-weight: 600; }
#bgrm-root .bgrm-status-badge.bgrm-idle { display: none; }
#bgrm-root .bgrm-card.bgrm-error .bgrm-status-badge { color: #fecaca; }
#bgrm-root .bgrm-error-detail { font-size: 10px; opacity: .9; word-break: break-word; line-height: 1.4; max-height: 5.6em; overflow-y: auto; }
#bgrm-root .bgrm-chase { display: flex; gap: 5px; }
#bgrm-root .bgrm-chase span { width: 8px; height: 8px; border-radius: 2px; background: var(--primary); animation: bgrm-chase 1s ease-in-out infinite; }
#bgrm-root .bgrm-chase span:nth-child(2) { animation-delay: .12s; background: var(--green); }
#bgrm-root .bgrm-chase span:nth-child(3) { animation-delay: .24s; }
#bgrm-root .bgrm-chase span:nth-child(4) { animation-delay: .36s; background: var(--green); }
@keyframes bgrm-chase { 0%,100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* lightbox preview + side-by-side layer & touch-up studio */
#bgrm-root .bgrm-lightbox {
  position: fixed; inset: 0;
  background: rgba(7, 6, 14, 0.92);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 999999; padding: 12px;
}
#bgrm-root .bgrm-lightbox.bgrm-show { display: flex; }

#bgrm-root .bgrm-lb-inner {
  position: relative; display: flex; flex-direction: column;
  width: min(96vw, 960px); max-height: 94vh;
  background: var(--bg-2); border: 1.5px solid var(--border);
  border-radius: 18px; overflow: hidden;
  box-shadow: 0 32px 90px rgba(0,0,0,.75);
  transition: width .2s ease, height .2s ease;
}
#bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-inner {
  width: min(97vw, 1280px);
  height: min(93vh, 840px);
}

/* Top Studio Header Bar */
#bgrm-root .bgrm-lb-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex: none; z-index: 10;
}
#bgrm-root .bgrm-lb-title {
  font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 14.5px;
  color: var(--heading); display: inline-flex; align-items: center; gap: 9px; min-width: 0;
}
#bgrm-root .bgrm-studio-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px;
  background: linear-gradient(135deg, rgba(124,58,237,.25), rgba(37,99,235,.25));
  border: 1px solid rgba(167,139,250,.4); color: #c4b5fd;
}
#bgrm-root .bgrm-cmp-pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 50px;
  background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--primary-light);
  white-space: nowrap;
}
#bgrm-root .bgrm-lb-bar-center {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: nowrap;
}
#bgrm-root .bgrm-lb-bar-right {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
}
#bgrm-root .bgrm-lightbox-close {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--surface-soft); color: var(--heading);
  border: 1.5px solid var(--border); display: grid; place-items: center;
  font-size: 14px; cursor: pointer; flex: none; font-weight: 800;
}
#bgrm-root .bgrm-lightbox-close:hover { border-color: #f87171; background: rgba(239,68,68,.15); color: #fca5a5; }

/* Main Studio Workspace: Side-by-Side on Desktop, Stacked App Layout on Mobile */
#bgrm-root .bgrm-studio-workspace {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}
#bgrm-root #bgrmLightbox.bgrm-editing .bgrm-studio-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Left / Center Interactive Canvas Stage */
#bgrm-root .bgrm-lb-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow: hidden;
  background: radial-gradient(circle at center, #171429 0%, #0b0914 100%);
}
#bgrm-root .bgrm-preview {
  position: relative; display: inline-block; border-radius: 12px;
  overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.55); line-height: 0;
}
#bgrm-root .bgrm-preview img {
  display: block; max-width: 100%; max-height: 68vh; width: auto; height: auto;
}
#bgrm-root .bgrm-editview {
  overflow: auto; max-width: 100%; max-height: 100%;
  border-radius: 12px; box-shadow: 0 22px 65px rgba(0,0,0,.65);
  border: 1px solid rgba(255,255,255,.1);
  scrollbar-width: thin; scrollbar-color: rgba(167,139,250,.3) transparent; scrollbar-color: rgba(167,139,250,.4) transparent;
}
#bgrm-root .bgrm-editview.bgrm-fit-zoom {
  overflow: hidden !important;
}
#bgrm-root .bgrm-editwrap { position: relative; display: inline-block; line-height: 0; }
#bgrm-root .bgrm-editwrap.bgrm-check-light {
  background-color: #f8fafc !important;
  background-image: linear-gradient(45deg, #cbd5e1 25%, transparent 25%), linear-gradient(-45deg, #cbd5e1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #cbd5e1 75%), linear-gradient(-45deg, transparent 75%, #cbd5e1 75%) !important;
}
#bgrm-root .bgrm-editwrap canvas { display: block; cursor: crosshair; touch-action: none; }

/* Transform Bounding Box & Handles */
#bgrm-root .bgrm-tf { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: none; pointer-events: none; }
#bgrm-root #bgrmLightbox.bgrm-tool-move .bgrm-tf { display: block; }
#bgrm-root .bgrm-tf-box { fill: none; stroke: #a78bfa; stroke-width: 2; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
#bgrm-root .bgrm-tf-arm { stroke: #a78bfa; stroke-width: 2; vector-effect: non-scaling-stroke; }
#bgrm-root .bgrm-tf-h { fill: #ffffff; stroke: #7c3aed; stroke-width: 2.2; rx: 2; vector-effect: non-scaling-stroke; }
#bgrm-root .bgrm-tf-rot { fill: #22c55e; stroke: #ffffff; stroke-width: 2; vector-effect: non-scaling-stroke; }

/* Brush Cursor */
#bgrm-root .bgrm-brush-cursor {
  position: absolute; top: 0; left: 0; z-index: 5;
  border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%);
  border: 1.8px solid #22c55e;
  box-shadow: 0 0 0 1px rgba(0,0,0,.75), 0 0 0 1px rgba(0,0,0,.75) inset, 0 0 8px rgba(0,0,0,.4);
  display: none;
}
#bgrm-root .bgrm-brush-cursor::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 3px; height: 3px;
  margin: -1.5px 0 0 -1.5px; border-radius: 50%; background: #22c55e;
}
#bgrm-root .bgrm-brush-cursor.bgrm-mode-erase { border-color: #ef4444; }
#bgrm-root .bgrm-brush-cursor.bgrm-mode-erase::after { background: #ef4444; }
#bgrm-root .bgrm-brush-cursor.bgrm-show { display: block; }

/* Floating Canvas HUD Overlays */
#bgrm-root .bgrm-stage-hud-top {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none; z-index: 6; gap: 8px;
}
#bgrm-root .bgrm-stage-hud-top > * { pointer-events: auto; }
#bgrm-root .bgrm-hud-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(19, 16, 34, 0.86); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.14); border-radius: 10px;
  padding: 4px 6px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
#bgrm-root .bgrm-lb-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(15, 13, 28, 0.88); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12); border-radius: 50px;
  padding: 5px 14px; color: rgba(255,255,255,.9); font-size: 11.5px; font-weight: 600;
  white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; z-index: 6;
}

/* Right Side-by-Side Software Inspector Panel */
#bgrm-root .bgrm-lb-controls {
  flex: none; border-top: 1px solid var(--border);
  background: var(--surface); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
#bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-controls {
  border-top: none; border-left: 1.5px solid var(--border);
  height: 100%; max-height: none; overflow: hidden;
  padding: 0; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--surface);
}

/* Studio Inspector Category Tabs (Great for Mobile & Quick Filtering on Desktop) */
#bgrm-root .bgrm-studio-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  padding: 10px 12px 8px; background: var(--surface-soft);
  border-bottom: 1px solid var(--border); flex: none;
}
#bgrm-root .bgrm-stab {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 11.5px; font-weight: 800; padding: 7px 6px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
#bgrm-root .bgrm-stab:hover { color: var(--heading); border-color: var(--primary-light); }
#bgrm-root .bgrm-stab.bgrm-active {
  background: var(--grad-primary); color: #fff; border-color: #c4b5fd;
  box-shadow: 0 4px 12px rgba(124,58,237,.3);
}

/* Scrollable Inspector Body */
#bgrm-root .bgrm-studio-scroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(167,139,250,.3) transparent;
}

/* Inspector Cards / Layer Blocks */
#bgrm-root .bgrm-insp-card {
  background: var(--surface-soft); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
}
#bgrm-root .bgrm-insp-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
#bgrm-root .bgrm-insp-head b { color: var(--heading); font-size: 11.5px; }

/* Layer-by-Layer Stack Items */
#bgrm-root .bgrm-layer-list { display: flex; flex-direction: column; gap: 7px; }
#bgrm-root .bgrm-layer-item {
  display: flex; flex-direction: column; gap: 7px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--surface); border: 1.5px solid var(--border);
  transition: all .15s; cursor: pointer;
}
#bgrm-root .bgrm-layer-item:hover { border-color: rgba(167,139,250,.5); }
#bgrm-root .bgrm-layer-item.bgrm-layer-active {
  border-color: #a78bfa;
  background: linear-gradient(135deg, rgba(124,58,237,.12), rgba(37,99,235,.08));
  box-shadow: 0 4px 14px rgba(124,58,237,.15);
}
#bgrm-root .bgrm-layer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
#bgrm-root .bgrm-layer-info {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0;
}
#bgrm-root .bgrm-layer-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--surface-soft); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 14px; flex: none;
}
#bgrm-root .bgrm-layer-name {
  font-size: 12.5px; font-weight: 800; color: var(--heading); line-height: 1.2;
}
#bgrm-root .bgrm-layer-meta {
  font-size: 10.5px; font-weight: 600; color: var(--muted); display: block;
}
#bgrm-root .bgrm-layer-actions {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
}
#bgrm-root .bgrm-mini-btn {
  font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-soft);
  color: var(--heading); cursor: pointer; transition: all .15s;
}
#bgrm-root .bgrm-mini-btn:hover { border-color: var(--primary-light); background: var(--surface-hover); }
#bgrm-root .bgrm-mini-btn.bgrm-active { background: var(--grad-primary); color: #fff; border-color: #c4b5fd; }

/* Tool Mode Switcher (3-column grid inside Tool card) */
#bgrm-root .bgrm-tool-grid3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
#bgrm-root .bgrm-tool-grid3 .bgrm-tb-btn {
  justify-content: center; padding: 9px 6px; font-size: 12px; width: 100%;
}

/* Sliders & Rows inside Inspector */
#bgrm-root .bgrm-ctrl-row {
  display: flex; flex-direction: column; gap: 5px;
}
#bgrm-root .bgrm-ctrl-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 700; color: var(--heading);
}
#bgrm-root .bgrm-ctrl-label span:last-child {
  font-size: 11px; font-weight: 800; color: var(--primary-light);
  background: rgba(124,58,237,.14); padding: 1px 7px; border-radius: 50px;
}
#bgrm-root .bgrm-ctrl-row input[type=range] {
  width: 100%; accent-color: var(--primary); cursor: pointer;
}
#bgrm-root .bgrm-quick-grid4 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}

/* Swatches inside Studio Background Layer */
#bgrm-root .bgrm-studio-swatches {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 2px;
}
#bgrm-root .bgrm-st-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.22); cursor: pointer;
  transition: transform .12s, border-color .12s; padding: 0;
}
#bgrm-root .bgrm-st-swatch:hover, #bgrm-root .bgrm-st-swatch.bgrm-active {
  transform: scale(1.14); border-color: #fff; box-shadow: 0 0 0 2px var(--primary);
}

/* Toolbar & Buttons */
#bgrm-root .bgrm-tb-zoom { display: inline-flex; align-items: center; gap: 3px; }
#bgrm-root .bgrm-tb-zoom .bgrm-zlabel { font-size: 11.5px; font-weight: 800; color: var(--heading); min-width: 42px; text-align: center; }
#bgrm-root .bgrm-tb-icon { width: 30px; height: 30px; padding: 0; justify-content: center; font-size: 14px; }
#bgrm-root .bgrm-lb-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px; padding: 9px 10px;
}
#bgrm-root .bgrm-tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--heading);
  cursor: pointer; transition: all .15s;
}
#bgrm-root .bgrm-tb-btn:hover { border-color: var(--primary-light); background: var(--surface-hover); }
#bgrm-root .bgrm-tb-btn.bgrm-tb-active { background: var(--grad-primary); border-color: #c4b5fd; color: #fff; }
#bgrm-root .bgrm-tb-btn.bgrm-tb-primary {
  background: linear-gradient(135deg, #22c55e, #15803d);
  border: 1px solid #4ade80; color: #fff; font-weight: 800;
}
#bgrm-root .bgrm-tb-btn.bgrm-tb-primary:hover { filter: brightness(1.07); }
#bgrm-root .bgrm-tb-btn:disabled { opacity: .42; cursor: default; }

/* Custom Pixel Size Panel inside Inspector */
#bgrm-root .bgrm-resize-panel {
  width: auto; margin-top: 0; background: var(--surface-soft);
  border: 1.5px solid var(--border); border-radius: 12px; padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
}
#bgrm-root .bgrm-resize-head {
  display: flex; align-items: center; justify-content: space-between; gap: 7px;
  font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0;
}
#bgrm-root .bgrm-resize-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
#bgrm-root .bgrm-resize-field { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; color: var(--heading); flex: 1; }
#bgrm-root .bgrm-resize-field input {
  width: 100%; min-width: 62px; padding: 6px 8px; border-radius: 8px;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--heading);
  font: inherit; font-weight: 800; font-size: 12.5px; text-align: center;
}
#bgrm-root .bgrm-resize-x { color: var(--muted); font-weight: 700; }
#bgrm-root .bgrm-resize-unit { font-size: 11px; color: var(--muted); }
#bgrm-root .bgrm-resize-presets {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; margin: 2px 0;
}
#bgrm-root .bgrm-preset-chip {
  font-size: 10.5px; font-weight: 700; padding: 6px 8px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--heading);
  transition: all .15s; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#bgrm-root .bgrm-preset-chip:hover { border-color: var(--primary-light); background: var(--grad-primary); color: #fff; }

/* Pinned Bottom Action Footer in Right Sidebar */
#bgrm-root .bgrm-studio-footer {
  padding: 10px 14px; border-top: 1px solid var(--border);
  background: var(--surface-soft); display: grid; grid-template-columns: 1fr 1.25fr; gap: 8px; flex: none;
}
#bgrm-root .bgrm-studio-footer .bgrm-tb-btn {
  justify-content: center; padding: 10px 10px; font-size: 12.5px; width: 100%;
}

/* Mode visibility rules */
#bgrm-root #bgrmLightbox:not(.bgrm-editing) .bgrm-edit-only { display: none !important; }
#bgrm-root #bgrmLightbox.bgrm-tool-move .bgrm-brush-only { display: none !important; }
#bgrm-root #bgrmLightbox:not(.bgrm-tool-move) .bgrm-move-only { display: none !important; }
#bgrm-root #bgrmLightbox.bgrm-editing .bgrm-view-only { display: none !important; }
#bgrm-root #bgrmLightbox.bgrm-editing #bgrmPreview { display: none !important; }
#bgrm-root #bgrmLightbox:not(.bgrm-editing) #bgrmEditView { display: none !important; }

/* Responsive Mobile Layout (<= 880px) */
@media (max-width: 880px) {
  #bgrm-root .bgrm-lightbox { padding: 0; }
  #bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-inner {
    width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none;
  }
  #bgrm-root #bgrmLightbox.bgrm-editing .bgrm-studio-workspace {
    display: flex; flex-direction: column; flex: 1; min-height: 0;
  }
  #bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-stage {
    flex: none; height: 44dvh; min-height: 210px; padding: 10px;
  }
  #bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-controls {
    flex: 1; min-height: 0; border-left: none; border-top: 1.5px solid var(--border);
  }
  #bgrm-root .bgrm-lb-bar { padding: 8px 10px; }
  #bgrm-root .bgrm-lb-title { font-size: 13px; }
  #bgrm-root .bgrm-studio-badge { display: none; }
  /* On mobile, filter inspector sections by active tab so user never has to scroll a long list */
  #bgrm-root #bgrmLightbox.bgrm-editing[data-stab="tools"] .bgrm-stab-panel:not([data-panel="tools"]) { display: none !important; }
  #bgrm-root #bgrmLightbox.bgrm-editing[data-stab="layers"] .bgrm-stab-panel:not([data-panel="layers"]) { display: none !important; }
  #bgrm-root #bgrmLightbox.bgrm-editing[data-stab="resize"] .bgrm-stab-panel:not([data-panel="resize"]) { display: none !important; }
}

/* tool panel = app window */
#bgrm-root .bgrm-appwin { max-width: 1180px; margin: 0 auto; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
#bgrm-root .bgrm-appbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-soft); border-radius: var(--r-xl) var(--r-xl) 0 0; flex-wrap: nowrap; }
#bgrm-root .bgrm-appbar-left { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
#bgrm-root .bgrm-appbar .dots { display: flex; gap: 6px; flex: none; }
#bgrm-root .bgrm-appbar .dots span { width: 11px; height: 11px; border-radius: 50%; }
#bgrm-root .bgrm-appbar .dots span:nth-child(1){ background:#ff5f57; } #bgrm-root .bgrm-appbar .dots span:nth-child(2){ background:#febc2e; } #bgrm-root .bgrm-appbar .dots span:nth-child(3){ background:#28c840; }
#bgrm-root .bgrm-appbar .bgrm-apptitle { font-family:'Space Grotesk',sans-serif; font-weight: 800; font-size: 13.5px; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bgrm-root .bgrm-appbar-right { display: inline-flex; align-items: center; gap: 10px; flex: none; }
#bgrm-root .bgrm-appbar .bgrm-apptag { font-size: 11.5px; font-weight: 700; color: var(--green-light); background: rgba(22,163,74,.14); border: 1px solid rgba(74,222,128,.35); padding: 4px 10px; border-radius: 50px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#bgrm-root .bgrm-appbody { padding: 18px 20px; }
@media (max-width: 640px){
  #bgrm-root .bgrm-appbar { padding: 9px 12px; }
  #bgrm-root .bgrm-appbar .dots { display: none; }
  #bgrm-root .bgrm-appbar .bgrm-apptag { display: none; }
  #bgrm-root .bgrm-appbody { padding: 13px; }
  #bgrm-root .bgrm-drop { padding: 22px 12px 18px; }
  #bgrm-root .bgrm-upload-footer { flex-direction: column; align-items: stretch; }
  #bgrm-root .bgrm-samples { justify-content: center; }
  #bgrm-root #bgrmPasteBtn { width: 100%; justify-content: center; padding: 7px 12px; }
}

#bgrm-root .bgrm-upload-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin: 10px auto 6px; padding: 11px 22px; border-radius: 50px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border: 1.5px solid #c4b5fd; color: #ffffff !important;
  font-size: 14px; font-weight: 800; box-shadow: 0 4px 16px rgba(124,58,237,.45);
  transition: transform .15s, box-shadow .15s, filter .15s; cursor: pointer;
}
#bgrm-root .bgrm-drop:hover .bgrm-upload-cta { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 6px 22px rgba(124,58,237,.6); }
#bgrm-root .bgrm-toast {
  margin-top: 10px; padding: 9px 12px; border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-soft));
  border: 1.5px solid var(--primary-light); color: var(--heading);
  font-size: 12px; font-weight: 700; display: none; align-items: center; justify-content: space-between; gap: 8px;
}
#bgrm-root .bgrm-toast.bgrm-show { display: flex; }


#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-drop {
  padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; text-align: left;
}
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-drop-icon,
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-dim,
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-upload-footer { display: none; }
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-upload-cta { margin: 0; padding: 6px 14px; font-size: 12px; }
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-dt { font-size: 12px; margin: 0; opacity: .85; }
#bgrm-root #bgrmStepUpload.bgrm-has-items .bgrm-file-count { margin: 0 0 0 auto; font-size: 12px; }
#bgrm-root .bgrm-results { margin-top: 12px; }
#bgrm-root .bgrm-results-head { margin-bottom: 10px; padding-top: 10px; }


#bgrm-root .bgrm-grid:has(> :only-child) .bgrm-card-thumb { max-height: 290px !important; }


/* Zero white scrollbars & clean tab switching on both Desktop and Mobile */
body:has(#bgrmLightbox.bgrm-show) { overflow: hidden !important; }
#bgrm-root .bgrm-studio-scroll::-webkit-scrollbar,
#bgrm-root .bgrm-editview::-webkit-scrollbar { width: 5px; height: 5px; }
#bgrm-root .bgrm-studio-scroll::-webkit-scrollbar-track,
#bgrm-root .bgrm-editview::-webkit-scrollbar-track { background: transparent; }
#bgrm-root .bgrm-studio-scroll::-webkit-scrollbar-thumb,
#bgrm-root .bgrm-editview::-webkit-scrollbar-thumb { background: rgba(167,139,250,.32); border-radius: 99px; }

/* Stage padding so HUD and Hint pill never overlap the canvas */
#bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-stage {
  padding: 54px 24px 48px !important;
}

/* Tab filtering on BOTH Desktop and Mobile so the active panel fits 100% with zero scrollbar */
#bgrm-root #bgrmLightbox.bgrm-editing[data-stab="tools"] .bgrm-stab-panel:not([data-panel="tools"]) { display: none !important; }
#bgrm-root #bgrmLightbox.bgrm-editing[data-stab="layers"] .bgrm-stab-panel:not([data-panel="layers"]) { display: none !important; }
#bgrm-root #bgrmLightbox.bgrm-editing[data-stab="resize"] .bgrm-stab-panel:not([data-panel="resize"]) { display: none !important; }

/* Pinned Interactive Layer Strip inside Tools tab so user always sees the 3 layers even on Tools tab */
#bgrm-root .bgrm-mini-layer-strip {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-soft); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
#bgrm-root .bgrm-mls-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 9px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--border); font-size: 11.5px; font-weight: 700; color: var(--heading);
  cursor: pointer; transition: all .15s;
}
#bgrm-root .bgrm-mls-row:hover { border-color: #a78bfa; background: var(--surface-hover); }
#bgrm-root .bgrm-mls-row.bgrm-mls-active {
  border-color: #a78bfa; background: linear-gradient(135deg, rgba(124,58,237,.16), rgba(37,99,235,.1));
}
#bgrm-root .bgrm-mls-left { display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
#bgrm-root .bgrm-mls-tag { font-size: 10px; font-weight: 800; color: var(--primary-light); background: rgba(124,58,237,.16); padding: 2px 7px; border-radius: 50px; white-space: nowrap; }

@media (max-width: 880px) {
  #bgrm-root #bgrmLightbox.bgrm-editing .bgrm-lb-stage {
    height: 45dvh !important; min-height: 220px !important;
    padding: 46px 10px 38px !important;
  }
  #bgrm-root .bgrm-lb-title .bgrm-edit-only:first-of-type {
    white-space: nowrap; font-size: 12.5px;
  }
  #bgrm-root .bgrm-lb-bar { padding: 7px 10px !important; gap: 6px !important; }
  #bgrm-root .bgrm-lb-bar .bgrm-tb-btn { padding: 5px 9px !important; font-size: 11px !important; }
}


@media (max-width: 880px) {
  #bgrm-root .bgrm-studio-scroll { padding: 8px 10px !important; gap: 8px !important; }
  #bgrm-root .bgrm-insp-card, #bgrm-root .bgrm-resize-panel { padding: 9px 10px !important; gap: 7px !important; }
  #bgrm-root .bgrm-layer-list { gap: 5px !important; }
  #bgrm-root .bgrm-layer-item { padding: 6px 8px !important; gap: 5px !important; }
  #bgrm-root .bgrm-studio-tabs { padding: 7px 10px 6px !important; }
  #bgrm-root .bgrm-studio-footer { padding: 8px 10px !important; }
}

body.bgrm-modal-open{overflow:hidden}#bgrm-root .bgrm-api-input{font-family:inherit}#bgrm-root button:focus-visible,#bgrm-root [role="button"]:focus-visible{outline:3px solid #a78bfa;outline-offset:3px}

/* v2.2 usability/performance additions */
#bgrm-root .bgrm-privacy-note{
  display:inline-flex;align-items:center;gap:6px;margin-top:8px;padding:5px 9px;
  border:1px solid color-mix(in srgb,var(--green) 40%,var(--border));border-radius:999px;
  background:color-mix(in srgb,var(--green) 9%,transparent);color:var(--text);
  font-size:11.5px;font-weight:700;line-height:1.35;
}
#main-content > .section{content-visibility:auto;contain-intrinsic-size:520px;}
@media (prefers-reduced-motion: reduce){
  #bgrm-root *,#bgrm-root *::before,#bgrm-root *::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;}
}
