/* Background Remover (bg-remove.js). Loaded after tool.css. */
/* small texts a step lighter than tool.css, for enough contrast on the panels */
.tk-note { color: var(--text-2); }
.br-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "top set" "files set"; grid-template-rows: auto 1fr; gap: 14px; align-items: start; align-content: start; }
.br-col { display: grid; gap: 14px; align-content: start; min-width: 0; }
.br-top { grid-area: top; }
.br-files { grid-area: files; }

/* ---------- adding photos ---------- */
.br-drop { position: relative; display: grid; justify-items: center; gap: 10px; padding: 34px 20px; border: 2px dashed var(--line-strong); border-radius: 16px; background: var(--panel); text-align: center; transition: border-color 0.15s, background 0.15s; }
.br-drop.is-over { border-color: var(--accent); background: var(--info-bg); }
.br-drop.is-small { grid-template-columns: auto minmax(0, 1fr) auto; justify-items: start; align-items: center; padding: 14px 16px; text-align: start; }
.br-art { width: 74px; height: 74px; display: grid; place-items: center; border-radius: 20px; background: var(--info-bg); color: var(--accent); }
.br-art svg { width: 42px; height: 42px; }
.br-drop.is-small .br-art { width: 44px; height: 44px; border-radius: 12px; }
.br-drop.is-small .br-art svg { width: 26px; height: 26px; }
.br-drop h2 { margin: 4px 0 0; font-size: 20px; font-weight: 650; }
.br-drop.is-small h2 { margin: 0; font-size: 15px; }
.br-drop p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.br-or { color: var(--text-2); font-size: 12.5px; }
.br-drop.is-small .br-or, .br-drop.is-small .br-formats { display: none; }
.br-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.br-drop.is-small .br-btns { justify-content: flex-end; }
.br-pick { position: relative; overflow: hidden; }
.br-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.br-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.br-formats { color: var(--text-2); font-size: 12px; }
.br-veil { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: rgba(8, 14, 24, 0.55); color: #fff; font-size: 22px; font-weight: 650; pointer-events: none; }
.br-veil.is-on { display: grid; }

/* ---------- the model ---------- */
.br-model { display: grid; gap: 8px; }
.br-model-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.br-model .tk-h { margin: 0; }
.br-engine { padding: 2px 10px; border-radius: 999px; background: var(--raised); color: var(--text-2); font-size: 12px; font-weight: 600; }
.br-engine[data-kind="gpu"] { background: var(--pass-bg, var(--info-bg)); color: var(--pass); }
.br-model p { margin: 0; }
.br-model p.is-err { color: var(--msg-error); }
.br-model-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.br-model-btns:empty { display: none; }

/* bars: the model, the whole list, each photo */
.br-bar { position: relative; height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; direction: ltr; }
.br-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--accent); transition: width 0.25s; }
.br-bar.is-done i { background: var(--pass); }
.br-bar.is-fail i { background: var(--fail); }
.br-bar.is-busy i { width: 100% !important; background: linear-gradient(90deg, var(--accent) 0 30%, transparent 30% 100%); background-size: 200% 100%; animation: br-busy 1.1s linear infinite; }
@keyframes br-busy { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- the list ---------- */
.br-head { display: grid; gap: 10px; }
.br-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.br-count { font-weight: 650; }
.br-count small { color: var(--text-2); font-weight: 400; margin-inline-start: 6px; font-size: 12px; }
.br-total { display: grid; gap: 4px; }
.br-total p { margin: 0; }
.br-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.br-card { display: grid; gap: 8px; align-content: start; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
.br-view { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--panel-2); }
/* the checks show only where the photo is see-through */
.br-view canvas { grid-area: 1 / 1; max-width: 100%; max-height: 100%; width: auto; height: auto; display: block;
  background: repeating-conic-gradient(#d9dee5 0 25%, #ffffff 0 50%) 0 0 / 14px 14px; }
.br-view .br-res { display: none; }
.br-card[data-st="done"] .br-res { display: block; }
.br-card[data-st="done"] .br-orig { display: none; }
.br-card.is-orig .br-res { display: none; }
.br-card.is-orig .br-orig { display: block; }
.br-card[data-st="wait"] .br-orig, .br-card[data-st="work"] .br-orig { opacity: 0.55; }
.br-spin { grid-area: 1 / 1; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.85); border-top-color: var(--accent); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); animation: br-spin 0.9s linear infinite; display: none; }
.br-card[data-st="work"] .br-spin { display: block; }
@keyframes br-spin { to { transform: rotate(360deg); } }
.br-info { display: grid; gap: 2px; min-width: 0; }
.br-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.br-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; color: var(--text-2); font-size: 12px; line-height: 1.4; }
.br-meta bdi { white-space: nowrap; }
.br-meta .err { color: var(--msg-error); }
.br-mini { height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; direction: ltr; }
.br-mini i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s linear; }
.br-card[data-st="done"] .br-mini i { background: var(--pass); }
.br-card[data-st="error"] .br-mini i { background: var(--fail); }
.br-card[data-st="wait"] .br-mini { visibility: hidden; }
.br-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.br-acts .tk-btn svg { width: 15px; height: 15px; }
.br-dl { margin-inline-start: auto; }
.br-cmp[aria-pressed="true"] { background: var(--raised-2); color: var(--text); }
.br-x { width: 30px; height: 30px; margin-inline-start: auto; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.br-dl:not([hidden]) + .br-x { margin-inline-start: 0; }
.br-x:hover { background: var(--hover); color: var(--fail); }
.br-x svg { width: 16px; height: 16px; }

/* ---------- settings ---------- */
.br-set { grid-area: set; position: sticky; top: 0; display: grid; gap: 14px; }
.br-set .tk-h { margin: 0; }
.br-field { display: grid; gap: 8px; }
.br-field > span, .br-field > label { color: var(--text-2); font-size: 13px; }
.br-field p { margin: 0; }
.br-set .tk-seg { display: flex; }
.br-set .tk-seg button { flex: 1; height: auto; min-height: 28px; padding: 4px 6px; line-height: 1.25; }
.br-color { display: flex; align-items: center; gap: 10px; }
.br-color input { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.br-q { display: flex; align-items: center; gap: 10px; }
.br-q input { flex: 1; }
.br-q output { min-width: 30px; text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.br-private { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-size: 12px; }
.br-private svg { width: 16px; height: 16px; flex: none; color: var(--pass); }

@media (max-width: 860px) {
  /* on a phone the settings come right after adding photos, before a long list */
  .br-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "set" "files"; }
  .br-set { position: static; }
}
@media (max-width: 520px) {
  .br-drop.is-small { grid-template-columns: auto minmax(0, 1fr); }
  .br-drop.is-small .br-btns { grid-column: 1 / -1; justify-content: flex-start; }
  .br-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .br-card { padding: 6px; }
  .br-cmp span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .br-spin, .br-bar.is-busy i { animation-duration: 3s; }
  .br-bar i, .br-mini i { transition: none; }
}
html.a11y-still .br-spin, html.a11y-still .br-bar.is-busy i { animation: none; }
@media (forced-colors: active) {
  .br-bar i, .br-mini i { background: Highlight; forced-color-adjust: none; }
}
