/* ===== beforeafter.css ===== */
.ba-grid { display: grid; gap: 16px; }
@media (min-width: 860px) { .ba-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: start; gap: 24px; } }
.ba-preview { position: sticky; top: calc(var(--h-head) + env(safe-area-inset-top, 0px) + 8px); z-index: 5; background: var(--bg); padding-bottom: 4px; }
@media (min-width: 860px) { .ba-preview { top: calc(var(--h-head) + env(safe-area-inset-top, 0px) + 20px); } }
.ba-stage {
  min-height: 160px; display: grid; place-items: center; padding: 12px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 16px; background-color: #8a949b;
  background-image: linear-gradient(45deg, #7d878e 25%, transparent 25%, transparent 75%, #7d878e 75%), linear-gradient(45deg, #7d878e 25%, transparent 25%, transparent 75%, #7d878e 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.ba-stage canvas { display: block; max-width: 100%; }
.ba-empty { margin: 0; padding: 12px; text-align: center; font-size: 14px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.ba-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 4px 0; font-size: 13px; color: var(--fg2); min-height: 20px; }
.ba-meta p { margin: 0; }
@media (max-width: 859px) {
  .ba-stage { max-height: 34vh; max-height: 34dvh; }
  .ba-stage canvas { max-height: calc(34dvh - 26px); max-height: calc(34vh - 26px); width: auto; height: auto; }
}

.ba-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 2px; }
.ba-thumbs:empty { display: none; }
.ba-th { position: relative; flex: none; width: 56px; height: 56px; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; padding: 0; background: var(--card); cursor: pointer; }
.ba-th canvas { display: block; width: 100%; height: 100%; }
.ba-th[aria-selected="true"] { border-color: var(--accent); }
.ba-th .x { position: absolute; top: 0; inset-inline-start: 0; width: 22px; height: 22px; border-radius: 0 0 10px 0; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; line-height: 22px; text-align: center; }

.ba-controls .field:last-child { margin-bottom: 0; }
.ba-controls fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 4px; margin: 0 0 16px; min-width: 0; }
.ba-controls legend { padding: 0 8px; font-size: 14px; font-weight: 600; color: var(--accent); }
.ba-controls select, .ba-controls input[type="text"] { width: 100%; min-height: 44px; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font: inherit; font-size: 16px; }
.ba-controls .lbl { font-size: 14px; font-weight: 500; color: var(--fg2); }
.ba-row { display: grid; gap: 0 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 420px) { .ba-row { grid-template-columns: 1fr 1fr; } }
.ba-hint { margin: 6px 2px 10px; font-size: 12px; color: var(--fg3); line-height: 1.8; }
.ba-drop, .ba-logo-btn { display: grid; place-items: center; gap: 4px; text-align: center; cursor: pointer; min-height: 96px; padding: 16px; border: 2px dashed var(--line); border-radius: 14px; color: var(--fg2); font-size: 14px; }
.ba-logo-btn { min-height: 56px; padding: 8px 12px; }
.ba-drop strong { color: var(--fg); font-size: 15px; } .ba-drop small { color: var(--fg3); font-size: 12px; }
.ba-drop.over, .ba-drop:focus-visible, .ba-logo-btn:focus-visible { border-color: var(--accent); outline: none; background: var(--badge-bg); }
.ba-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 72px; text-align: center; cursor: pointer; min-height: 44px; display: grid; place-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9999px; font-size: 14px; font-weight: 500; color: var(--fg2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--badge-bg); color: var(--accent); border-color: var(--accent); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.ba-pos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; direction: ltr; }
.ba-pos label { cursor: pointer; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; }
.ba-pos label::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--fg3); }
.ba-pos input { position: absolute; opacity: 0; pointer-events: none; }
.ba-pos label:has(input:checked) { background: var(--badge-bg); border-color: var(--accent); }
.ba-pos label:has(input:checked)::after { background: var(--accent); width: 14px; height: 14px; }
.ba-pos label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ba-tile { margin-bottom: 12px; }

.ba-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.ba-actions .btn { flex: 1 1 140px; min-height: 44px; }
.ba-actions .btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.ba-result { margin-top: 12px; text-align: center; }
.ba-result .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.ba-result p { margin: 8px 0 0; font-size: 13px; color: var(--fg2); }
.ba-slots { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
.ba-slot { min-width: 0; }
.ba-slot .ba-drop { min-height: 84px; padding: 10px; }
.ba-slot .ba-nm { margin: 4px 2px 0; font-size: 12px; color: var(--fg3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ba-stage canvas.mv { cursor: grab; touch-action: none; }
.ba-slider { margin-top: 8px; }
.ba-slider input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--accent); }
.ba-slider[hidden] { display: none; }
.ba-sm { display: block; font-size: 12px; color: var(--fg3); }
.ba-result { margin-top: 12px; text-align: center; }
.ba-result img { max-width: 100%; border: 1px solid var(--line); border-radius: 12px; }
.ba-result p { margin: 8px 0 0; font-size: 13px; color: var(--fg2); }
.ba-controls label.lbl { display: block; margin-top: 6px; }
