/* =========================================================================
   dopic.app - 3D Physical Shadow Studio (iOS Mobile Styles)
   ========================================================================= */

.m-app-container {
  padding-bottom: 90px;
}

/* Header layout: prevent title text overflow on small screens */
.m-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  overflow: hidden !important;
}

.m-header-title {
  font-size: 0.95rem !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  margin: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  min-width: 0 !important;
  max-width: 190px !important;
}

/* Single-row Choice Groups for Mobile */
.choice-row-2 {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  gap: 6px !important;
}
.choice-row-2 .choice-btn {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  padding: 0.52rem 0.4rem !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  border-radius: 9px !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

.choice-row-4 {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
  gap: 5px !important;
}
.choice-row-4 .choice-btn {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  padding: 0.48rem 0.2rem !important;
  font-size: 0.76rem !important;
  font-weight: 700 !important;
  border-radius: 8px !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

.choice-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}
.choice-btn.active {
  background: #e0f2fe !important;
  border-color: #0284c7 !important;
  color: #0369a1 !important;
  font-weight: 800 !important;
}

/* Presets row */
.m-presets-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 1rem 0.6rem;
  -webkit-overflow-scrolling: touch;
}
.m-preset-pill {
  flex-shrink: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
}
.m-preset-pill.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.m-drag-hint-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.5rem 1rem;
  padding: 4px 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 0.72rem;
  color: #1e40af;
  font-weight: 600;
  gap: 6px;
}
.m-btn-reset-pos {
  flex-shrink: 0;
  padding: 2px 7px;
  background: #ffffff;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

/* Live Preview Stage */
.m-canvas-wrap {
  margin: 0 1rem 1rem;
  background: #f1f5f9;
  border: 1.5px dashed #94a3b8;
  border-radius: 16px;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 2rem);
  max-width: 440px;
  aspect-ratio: 1 / 1;
  position: relative;
  overflow: hidden;
  touch-action: none;
}

#canvasShadow {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  touch-action: none;
  cursor: grab;
}

/* High-Contrast Crisp Checkerboard for Transparent Canvas & Wrapper */
#canvasShadow.is-transparent,
.m-canvas-wrap.is-transparent {
  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;
  background-size: 16px 16px !important;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px !important;
  background-color: #ffffff !important;
}

/* Canvas Bottom Actions (Upload & Camera) */
.m-canvas-actions {
  display: flex;
  gap: 8px;
  margin: 0.75rem 1rem 1rem;
}
.m-btn-action {
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  padding: 0 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.m-btn-upload {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.m-btn-upload:active {
  background: #1e293b;
  transform: scale(0.99);
}
.m-btn-camera {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.m-btn-camera:active {
  background: #f8fafc;
  transform: scale(0.99);
}

/* Parameters iOS Card */
.m-config-card {
  margin: 0 1rem 1.25rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.m-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.m-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #334155;
}
.m-val-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #0284c7;
  background: #e0f2fe;
  padding: 1px 6px;
  border-radius: 5px;
}
.m-slider {
  width: 100%;
  accent-color: #0284c7;
  height: 6px;
}

/* AI Cutout Card */
.ai-cutout-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.btn-upload-cutout-main {
  width: 100%;
  padding: 0.65rem 0.5rem;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 800;
  border: none;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}
.cutout-status-text {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.cutout-status-text.active {
  color: #0284c7;
  font-weight: 700;
}

/* Bottom Export Bar */
.m-bottom-export-bar {
  margin: 0 1rem;
}
.m-btn-export-main {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
  cursor: pointer;
}

/* Mobile AI Scan Stage & Floating Upload */
.ai-scan-stage,
.m-canvas-wrap {
  position: relative;
  width: 100% !important;
  max-width: 350px !important;
  aspect-ratio: 1 / 1 !important;
  margin: 0 auto 0.75rem auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  user-select: none;
  background: #ffffff;
  cursor: pointer;
}

.ai-scan-clean-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #ffffff;
}

.ai-scan-clean-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ai-scan-text-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  animation: aiShadowWipe 5.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: clip-path, opacity;
}

.ai-scan-text-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.ai-scan-beam {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #ffffff;
  z-index: 5;
  pointer-events: none;
  animation: aiShadowBeamSweep 5.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  will-change: left, opacity;
}

.ai-scan-beam-glow {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 100%;
  width: 70px;
  background: linear-gradient(to left, rgba(2, 132, 199, 0.4), transparent);
  pointer-events: none;
}

@keyframes aiShadowWipe {
  0%, 15% { clip-path: inset(0 0 0 0); opacity: 1; }
  45% { clip-path: inset(0 0 0 100%); opacity: 1; }
  75% { clip-path: inset(0 0 0 100%); opacity: 1; }
  85% { clip-path: inset(0 0 0 100%); opacity: 0; }
  90% { clip-path: inset(0 0 0 0); opacity: 0; }
  96%, 100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

@keyframes aiShadowBeamSweep {
  0%, 14% { left: 0%; opacity: 0; }
  15% { left: 0%; opacity: 1; }
  45% { left: 100%; opacity: 1; }
  48%, 100% { left: 100%; opacity: 0; }
}

.canvas-floating-upload {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: auto;
  max-width: 86%;
  pointer-events: auto;
}

.btn-cutout-minimal {
  position: relative;
  overflow: hidden;
  padding: 7px 18px;
  border-radius: 9999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.16);
  width: auto;
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.upload-specs-hint {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.btn-upload-svg {
  width: 14px;
  height: 14px;
  stroke: #0284c7;
  flex-shrink: 0;
}

/* 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.75rem;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 1.25rem;
  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: #0284c7;
  border-radius: 50%;
  animation: shadowSpinnerSpin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

.processing-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.processing-tip {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  max-width: 260px;
  line-height: 1.4;
}

