/**
 * dopic.app - Native iOS Studio Stylesheet for [cutout]
 * Clean, lightweight, thumb-ergonomic single-stage mobile experience.
 */

/* Mobile App Header (Apple Frosted Glass) */
.m-header {
  background: rgba(255, 255, 255, 0.88) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.m-header-title {
  color: #0f172a !important;
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.01em;
}

.m-brand-badge {
  background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3) !important;
}

.m-lang-btn {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}

/* Compact Mobile Hero */
.m-cutout-hero {
  padding: 0.85rem 1rem 0.5rem 1rem;
  text-align: center;
}

.m-cutout-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #eef2ff;
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: #4f46e5;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 0.35rem;
}

.m-cutout-hero-title {
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  margin: 0 0 0.25rem 0 !important;
  line-height: 1.3 !important;
  letter-spacing: -0.02em;
}

.m-cutout-hero-sub {
  font-size: 0.78rem !important;
  color: #64748b !important;
  line-height: 1.4 !important;
  max-width: 440px;
  margin: 0 auto 0.75rem auto;
}

/* iOS Elevated Single Upload CTA Button (Below Canvas) */
.cutout-m-single-upload-wrap {
  width: 100%;
  margin: 0.25rem 0 0.85rem 0;
}

.btn-m-single-upload {
  width: 100%;
  height: 46px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-m-single-upload:active {
  background: #1e293b;
  transform: scale(0.99);
}

.btn-m-single-upload .btn-m-upload-sub,
.btn-m-single-upload .upload-sub {
  font-size: 0.74rem;
  color: #64748b;
  font-weight: 500;
}

/* iOS Bottom Action Sheet Modal for Unified Upload */
.m-type-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000 !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
}

.m-type-modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.m-type-modal-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.12);
  z-index: 10001 !important;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom, 20px)) 18px !important;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.m-type-modal-sheet.active {
  transform: translateY(0);
}

.m-modal-pull-bar {
  width: 36px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 4px;
  margin: 0 auto 12px auto;
}

.m-modal-header {
  text-align: center;
  margin-bottom: 14px;
}

.m-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 3px 0;
}

.m-modal-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
  letter-spacing: 0.5px;
  margin: 0;
}

.m-modal-actions-unified {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.m-modal-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.m-modal-upload-btn {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.m-modal-upload-btn:active {
  background: #f8fafc;
  transform: scale(0.99);
}

.m-modal-camera-btn {
  background: #f8fafc;
  color: #334155;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.m-modal-camera-btn:active {
  background: #f1f5f9;
  transform: scale(0.99);
}

.m-modal-cancel-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.m-modal-cancel-btn:active {
  background: #e2e8f0;
}

/* Main Workspace & Studio Card */
.m-workspace-wrap {
  padding: 0.5rem 1rem 1.25rem 1rem;
}

.m-studio-card {
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 30px -4px rgba(15, 23, 42, 0.06);
  padding: 0.85rem;
  margin-bottom: 1.25rem;
}

/* Interactive Before/After Split Comparison Slider (Mobile Viewport) */
.ba-slider-container {
  width: 100% !important;
  height: auto !important;
  max-height: 68vh !important;
  aspect-ratio: var(--slider-aspect, 1 / 1) !important;
  border-radius: 20px !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  background-color: #0b0f19;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04) !important;
  overflow: hidden !important;
  position: relative !important;
  margin: 0 auto !important;
  cursor: ew-resize !important;
  user-select: none !important;
  touch-action: pan-y !important;
}

.ba-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ba-after-layer {
  z-index: 1;
  background: transparent;
}

.ba-after-layer canvas,
.ba-after-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.ba-before-layer {
  z-index: 2;
  clip-path: inset(0 calc(100% - var(--slider-pos)) 0 0);
  background: transparent;
}

.ba-before-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

.ba-badge {
  position: absolute;
  top: 10px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  z-index: 5;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ba-badge-left {
  left: 10px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
}

.ba-badge-right {
  right: 10px;
  background: rgba(79, 70, 229, 0.88);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--slider-pos);
  width: 2.5px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
  z-index: 10;
  transform: translateX(-50%);
  pointer-events: none;
}

.ba-handle-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  color: #4f46e5;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.22);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #4f46e5;
}

.ba-hint-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 12px;
  border-radius: 20px;
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Controls Panel */
.m-controls-panel {
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* Row 1: Swatches Bar */
.m-palette-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.m-palette-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.m-swatches-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.m-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  box-sizing: border-box;
}

.m-swatch.active {
  border-color: #4f46e5 !important;
  transform: scale(1.18);
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.4);
}

/* Row 2: Samples Row */
.m-samples-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 0.65rem;
  border-top: 1px dashed #e2e8f0;
}

.m-samples-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #64748b;
  margin-right: 2px;
}

.m-samples-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.m-sample-pill {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.m-sample-pill:active {
  background: #e2e8f0;
}

.m-sample-pill.active {
  background: #0f172a !important;
  color: #ffffff !important;
  border-color: #0f172a !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25) !important;
}

/* Row 3: Action Buttons Deck */
.m-actions-deck {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0.15rem;
}

.btn-m-action {
  width: 100%;
  border: none;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.btn-m-primary {
  min-height: 48px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
}

.btn-m-primary:active {
  transform: scale(0.985);
}

.btn-m-secondary {
  min-height: 44px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  font-size: 0.92rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.btn-m-secondary:active {
  transform: scale(0.985);
}

.m-sub-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.btn-m-tool {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.btn-m-tool:active {
  background: #e2e8f0;
}

.m-upload-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 2px;
}

/* In-Place Processing Indicator */
.m-processing-box {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #f8fafc;
  border-radius: 16px;
  border: 1px dashed #cbd5e1;
  margin-bottom: 1rem;
}

.m-processing-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: mSpinner 0.8s linear infinite;
  margin: 0 auto 0.75rem auto;
}

@keyframes mSpinner {
  to { transform: rotate(360deg); }
}

.m-processing-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.m-processing-tip {
  font-size: 0.8rem;
  color: #64748b;
}

/* Side by Side Mode Overrides (if toggled) */
.preview-split {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.preview-card {
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.m-app-container #sideBySideContainer .preview-card-raw {
  display: none !important;
}

.btn-done-header {
  background: #10b981 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  border: none !important;
}

.preview-header-bar {
  background: #f1f5f9;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-scan-stage {
  width: 100% !important;
  max-width: 350px !important;
  aspect-ratio: 1 / 1 !important;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  margin: 0 auto 0.75rem auto;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

/* In-Canvas Processing Overlay (覆盖在画布正上方) */
.canvas-processing-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 1rem;
  text-align: center;
  border-radius: inherit;
  pointer-events: auto;
  user-select: none;
}
.processing-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: cutoutSpinnerSpin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes cutoutSpinnerSpin {
  to { transform: rotate(360deg); }
}
.processing-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.processing-tip {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  max-width: 260px;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.canvas-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: auto;
  max-height: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  position: relative;
}

.canvas-container img,
.canvas-container canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Clean white transparent checkerboard (Photoshop / Canva industry standard) */
.checkerboard-pattern,
.ai-scan-stage.checkerboard-pattern,
.ai-scan-clean-layer.checkerboard-pattern,
.ba-slider-container.checkerboard-pattern,
.canvas-container.checkerboard-pattern {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%) !important;
  background-size: 20px 20px !important;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px !important;
}

.m-swatch.checkerboard-pattern {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%) !important;
  background-size: 10px 10px !important;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px !important;
}

/* Unified Mobile Container & Section Proportions */
.m-app-container {
  overflow-x: hidden !important;
  background: #f8fafc !important;
}

.m-workspace-wrap {
  padding: 0.5rem 1rem calc(75px + env(safe-area-inset-bottom, 20px)) 1rem !important;
}

.m-studio-card {
  background: #ffffff !important;
  border-radius: 18px !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05) !important;
  padding: 0.85rem !important;
  margin-bottom: 0.75rem !important;
}

.m-toolbox-sec {
  padding: 0 1rem 1.5rem 1rem !important;
  margin-top: 0.25rem !important;
}

.m-sec-header {
  padding: 0.4rem 0.15rem 0.5rem 0.15rem !important;
}

.m-sec-title {
  font-size: 0.95rem !important;
  font-weight: 800 !important;
  color: #0f172a !important;
}

.m-tools-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 0.65rem !important;
}

.m-tool-pill {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 14px !important;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03) !important;
  padding: 0.5rem 0.65rem !important;
  height: 56px !important;
  min-height: 56px !important;
}



/* =========================================================================
   Pixel-Perfect Before/After Alignment & Absolute Image/Canvas Lock
   ========================================================================= */
.ba-slider-container {
  width: 100% !important;
  aspect-ratio: var(--slider-aspect, 1 / 1) !important;
  height: auto !important;
  max-height: 68vh !important;
  border-radius: 16px !important;
  border: 1px solid rgba(226, 232, 240, 0.9) !important;
  background-color: #0b0f19;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06) !important;
  overflow: hidden !important;
  position: relative !important;
  margin: 0 auto !important;
  cursor: ew-resize !important;
  user-select: none !important;
  touch-action: pan-y !important;
}

.ba-slider-container .ba-layer,
#sliderBeforeLayer,
#sliderAfterLayer {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

#sliderBeforeLayer {
  z-index: 2 !important;
  background: transparent !important;
  clip-path: inset(0 calc(100% - var(--slider-pos)) 0 0) !important;
}

#sliderAfterLayer {
  z-index: 1 !important;
  background: transparent !important;
}

/* Force both canvas and img to have identical box model, geometry & fit */
.m-workspace-wrap .ba-slider-container canvas,
.m-workspace-wrap .ba-slider-container img,
.ba-slider-container .ba-layer canvas,
.ba-slider-container .ba-layer img,
#sliderResultCanvas,
#sliderSourceImg {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  object-fit: contain !important;
  object-position: center center !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: block !important;
  pointer-events: none !important;
}

/* Direct Finished Product Display Mode (No slider, full cutout) */
.ba-slider-container.finished-mode,
.ba-slider-stage.finished-mode,
#baSliderContainer.finished-mode {
  cursor: default !important;
  touch-action: auto !important;
}
.ba-slider-container.finished-mode #sliderBeforeLayer,
.ba-slider-container.finished-mode #baHandle,
.ba-slider-container.finished-mode .ba-handle,
.ba-slider-container.finished-mode #baHandleLine,
.ba-slider-container.finished-mode .ba-handle-line,
.ba-slider-container.finished-mode #baHandleBtn,
.ba-slider-container.finished-mode .ba-handle-btn,
.ba-slider-container.finished-mode .ba-badge,
.ba-slider-container.finished-mode .ba-hint-bar,
.ba-slider-stage.finished-mode #sliderBeforeLayer,
.ba-slider-stage.finished-mode #baHandleLine,
.ba-slider-stage.finished-mode .ba-handle-line,
.ba-slider-stage.finished-mode #baHandleBtn,
.ba-slider-stage.finished-mode .ba-handle-btn,
#baSliderContainer.finished-mode #sliderBeforeLayer,
#baSliderContainer.finished-mode #baHandleLine,
#baSliderContainer.finished-mode .ba-handle-line,
#baSliderContainer.finished-mode #baHandleBtn,
#baSliderContainer.finished-mode .ba-handle-btn {
  display: none !important;
}
.ba-slider-container.finished-mode #sliderAfterLayer,
.ba-slider-stage.finished-mode #sliderAfterLayer,
#baSliderContainer.finished-mode #sliderAfterLayer {
  clip-path: none !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 1 !important;
}

/* Mobile Sub-Tool Universal Upload Dropzone (No Dog Slider) */
.sub-dropzone-box {
  background: #ffffff;
  border: 2px dashed #93c5fd;
  border-radius: 14px;
  padding: 2.25rem 1rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.05);
  transition: all 0.2s ease;
  user-select: none;
}
.sub-dropzone-box:active {
  background: #eff6ff;
  border-color: #2563eb;
  transform: scale(0.99);
}




