/* ==========================================================================
   StudioFlow Smart Skin Touch-Up Sandbox Lab (v1.0 Prototype)
   Clean-Room WebGL2 Portrait Engine · Mobile-First Darkroom Glass UI
   ========================================================================== */

.sf-sandbox-lab-bar {
  position: sticky;
  top: 0;
  z-index: 95;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 55%, #172554 100%);
  color: #f8fafc;
  border-bottom: 1px solid rgba(96, 165, 250, 0.32);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
}

.sf-sandbox-lab-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sf-sandbox-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.42);
}

.sf-sandbox-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
}

.sf-sandbox-sub {
  font-size: 12px;
  color: #94a3b8;
}

.sf-sandbox-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.24);
}

.sf-sbx-ico {
  flex-shrink: 0;
}

.sf-sbx-lbl {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  max-width: 180px;
  opacity: 1;
  transition:
    max-width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease,
    margin-left 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.sf-sbx-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    padding 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.sf-sbx-close {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sf-sbx-close:hover {
  color: #f8fafc;
  background: rgba(51, 65, 85, 0.8);
}

.sf-sbx-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(147, 197, 253, 0.65);
  transform: translateY(-1px);
}

.sf-sbx-btn.primary {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  border-color: rgba(147, 197, 253, 0.55);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.38);
}

.sf-sbx-btn.emerald {
  background: linear-gradient(135deg, #059669 0%, #0d9488 100%);
  border-color: rgba(110, 231, 183, 0.5);
}

/* Lightbox Trigger Pill */
.lb-pill.retouch-pill {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.92), rgba(124, 58, 237, 0.92));
  color: #ffffff !important;
  border: 1px solid rgba(191, 219, 254, 0.5) !important;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.38);
  font-weight: 600;
}

/* Full Retouch Studio Modal */
.retouch-studio-dialog {
  width: min(1120px, calc(100vw - 16px));
  max-width: 1120px;
  max-height: calc(100dvh - 16px);
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 20px;
  background: #0b1120;
  color: #f8fafc;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.72);
  overflow: hidden;
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
}

.retouch-studio-dialog::backdrop {
  background: rgba(2, 6, 23, 0.84);
  backdrop-filter: blur(8px);
}

.rt-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) 360px;
  height: min(840px, calc(100dvh - 18px));
}

.rt-viewport-col {
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 42%, #172033 0%, #070b14 100%);
  min-height: 320px;
  overflow: hidden;
}

.rt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.78);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  z-index: 4;
  flex-wrap: wrap;
}

.rt-telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  font-size: 11.5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.rt-tool-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rt-mini-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.85);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.rt-mini-btn.is-active {
  background: rgba(37, 99, 235, 0.88);
  border-color: #93c5fd;
  color: #ffffff;
}

.rt-stage-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  touch-action: none;
}

.rt-canvas-holder {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  will-change: transform;
}

#rtWebglCanvas {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 150px);
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.55);
}

/* Split-Wipe Divider Overlay */
.rt-split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 3;
}

.rt-split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #ffffff;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  cursor: ew-resize;
}

.rt-split-tag {
  position: absolute;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.rt-split-tag.before {
  left: 10px;
}

.rt-split-tag.after {
  right: 10px;
  background: rgba(37, 99, 235, 0.82);
}

.rt-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(11, 17, 32, 0.76);
  backdrop-filter: blur(4px);
  z-index: 6;
  font-size: 13.5px;
  color: #e2e8f0;
}

.rt-loading-overlay[hidden] {
  display: none !important;
}

/* Controls Right Column */
.rt-controls-col {
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border-left: 1px solid rgba(148, 163, 184, 0.16);
  overflow-y: auto;
  padding: 16px;
  gap: 14px;
}

.rt-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.rt-head-row h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: #f8fafc;
}

.rt-head-row p {
  margin: 3px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

.rt-scope-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rt-scope-caption {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.02em;
}

.rt-scope-bar {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: 5px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.rt-scope-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  border-radius: 9px;
  padding: 7px 6px;
  font-family: inherit;
  font-size: 11.4px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.16s ease;
}

.rt-scope-btn.is-active {
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  border-color: rgba(147, 197, 253, 0.65);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.rt-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.rt-preset-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(30, 41, 59, 0.72);
  color: #e2e8f0;
  border-radius: 11px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.14s ease;
}

.rt-preset-btn small {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: #94a3b8;
  margin-top: 2px;
}

.rt-preset-btn.is-active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.34), rgba(79, 70, 229, 0.34));
  border-color: #60a5fa;
  color: #ffffff;
}

.rt-sliders-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.rt-slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rt-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 500;
  color: #e2e8f0;
}

.rt-slider-label strong {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: #93c5fd;
}

.rt-range {
  width: 100%;
  accent-color: #3b82f6;
  height: 6px;
  cursor: pointer;
}

.rt-face-status-box {
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.18);
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.45;
}

.rt-save-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rt-save-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
}

.rt-save-primary {
  appearance: none;
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.42);
  transition: background 0.18s ease, transform 0.12s ease;
}

.rt-save-primary.is-saved-done {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.38);
}

.rt-save-primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

.rt-folder-pick-btn {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(30, 41, 59, 0.88);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.rt-folder-pick-btn.has-folder {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(6, 78, 59, 0.65);
  color: #a7f3d0;
}

.rt-folder-pick-btn[hidden] {
  display: none !important;
}

.rt-https-bridge-box {
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(120, 53, 15, 0.45);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fef3c7;
  font-size: 11.8px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rt-https-bridge-box[hidden] {
  display: none !important;
}

.rt-https-bridge-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 9px;
  padding: 8px 12px;
  background: #f59e0b;
  color: #0f172a;
  font-weight: 700;
  font-size: 12.5px;
}

@media (max-width: 860px) {
  .rt-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(235px, 45dvh) minmax(0, 1fr);
    height: calc(100dvh - 10px);
  }
  #rtWebglCanvas {
    max-height: calc(45dvh - 58px);
  }
  .rt-controls-col {
    border-left: none;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    padding: 10px 14px 12px;
    gap: 8px;
  }
  .rt-sliders-box {
    gap: 8px;
    padding: 9px 11px;
  }
  .rt-save-actions {
    position: sticky;
    bottom: 0;
    padding-top: 6px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, #0f172a 24%);
  }
  .rt-scope-caption {
    display: none;
  }
  .rt-scope-btn {
    padding: 6px 8px;
    font-size: 11.8px;
  }
  .rt-preset-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }
  .rt-preset-btn {
    padding: 6px 7px;
    font-size: 11.5px;
    text-align: center;
  }
  .rt-preset-btn small {
    display: none;
  }
  .sf-sandbox-lab-bar {
    position: relative;
    flex-wrap: nowrap;
    padding: 6px 10px;
    gap: 8px;
  }
  .sf-sandbox-sub,
  .sf-sandbox-title {
    display: none;
  }
  .sf-sandbox-badge {
    padding: 4px 9px;
    font-size: 11px;
    white-space: nowrap;
  }
  .sf-sandbox-actions {
    width: auto;
    max-width: 100%;
    overflow: hidden;
    flex-wrap: nowrap;
    gap: 4px;
    padding: 3px;
  }
  /* Kongbeng Morphing Capsule on Mobile: Icon-only until tapped/expanded! */
  .sf-sbx-btn {
    min-width: 34px;
    min-height: 32px;
    padding: 5px 9px;
    gap: 0;
    font-size: 11.5px;
  }
  .sf-sbx-btn:not(.is-expanded) {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: #cbd5e1;
  }
  .sf-sbx-btn .sf-sbx-lbl {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
  }
  .sf-sbx-btn.is-expanded {
    padding: 5px 11px;
  }
  .sf-sbx-btn.is-expanded .sf-sbx-lbl {
    max-width: 120px;
    opacity: 1;
    margin-left: 5px;
  }
}
