/* 分享设计弹窗 v2 - 对齐用户中心风格，无遮罩，工作区居中 */
#shareDesignModal.sd-v2 {
  position: fixed !important;
  inset: 0 !important;
  display: none !important;
  background: transparent !important;
  pointer-events: none !important;
  z-index: 10050 !important;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

#shareDesignModal.sd-v2.is-open {
  display: block !important;
  pointer-events: none !important;
}

#shareDesignModal.sd-v2 .sd-modal {
  pointer-events: none;
  position: fixed !important;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  max-width: min(440px, calc(100vw - 32px));
  max-height: min(86vh, 720px);
  margin: 0 !important;
  box-sizing: border-box;
  overflow: auto;
  color: #e2e8f0;
  background: linear-gradient(160deg, #131836 0%, #0d1228 50%, #0a0f1f 100%);
  border-radius: 16px;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.35),
    0 0 50px rgba(139, 92, 246, 0.28),
    0 0 100px rgba(99, 102, 241, 0.16),
    0 25px 50px rgba(0, 0, 0, 0.5);
  padding: 18px 18px 16px;
}

#shareDesignModal.sd-v2.is-open .sd-modal {
  pointer-events: auto !important;
  animation: sdModalEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes sdModalEnter {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#shareDesignModal .sd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

#shareDesignModal .sd-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#shareDesignModal .sd-theme-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.28), rgba(99, 102, 241, 0.22));
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #c4b5fd;
}

#shareDesignModal .sd-theme-icon svg {
  width: 20px;
  height: 20px;
}

#shareDesignModal .sd-title-wrap {
  min-width: 0;
}

#shareDesignModal .sd-title-wrap h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.3;
}

#shareDesignModal .sd-title-wrap .sd-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

#shareDesignModal .sd-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}

#shareDesignModal .sd-close:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fda4af;
}

#shareDesignModal .sd-preview {
  position: relative;
  width: 100%;
  height: 180px;
  max-height: 180px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 14px;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(15, 23, 42, 0.6)),
    repeating-conic-gradient(from 0deg, rgba(255,255,255,0.03) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* 关键：预览图必须限制在预览框内，否则会按原图尺寸撑满屏幕 */
#shareDesignModal .sd-preview img,
#shareDesignModal #sdPreviewImg {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 auto;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: default !important;
  pointer-events: none !important;
}

#shareDesignModal .sd-preview-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.25);
  backdrop-filter: blur(6px);
  z-index: 1;
  pointer-events: none;
}

#shareDesignModal .sd-field {
  margin-bottom: 14px;
}

#shareDesignModal .sd-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #94a3b8;
}

#shareDesignModal .sd-label strong {
  color: #e2e8f0;
  font-weight: 600;
}

#shareDesignModal .sd-count {
  font-size: 11px;
  color: #64748b;
}

#shareDesignModal .sd-textarea {
  width: 100%;
  min-height: 96px;
  max-height: 180px;
  resize: vertical;
  box-sizing: border-box;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
  padding: 12px 12px;
  font-size: 13px;
  line-height: 1.55;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  font-family: inherit;
}

#shareDesignModal .sd-textarea::placeholder {
  color: #64748b;
}

#shareDesignModal .sd-textarea:focus {
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
  background: rgba(15, 23, 42, 0.72);
}

#shareDesignModal .sd-hint {
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
  line-height: 1.45;
}

#shareDesignModal .sd-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

#shareDesignModal .sd-btn {
  min-width: 88px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}

#shareDesignModal .sd-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

#shareDesignModal .sd-btn.primary {
  border-color: rgba(139, 92, 246, 0.45);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(99, 102, 241, 0.88));
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.28);
}

#shareDesignModal .sd-btn.primary:hover {
  filter: brightness(1.06);
}

#shareDesignModal .sd-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

#shareDesignModal .sd-btn.primary.loading {
  position: relative;
  color: transparent;
}

#shareDesignModal .sd-btn.primary.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: sdSpin 0.7s linear infinite;
}

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