.editor-container { max-width: 1200px; }
.editor-toolbar {
  margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.editor-toolbar button, .editor-toolbar select {
  padding: 6px 12px; font-size: 14px; border: 1px solid #ccc; border-radius: 4px; background: #f9f9f9; cursor: pointer;
}
.editor-toolbar button:hover { background: #e0e0e0; }
#btn-download { margin-left: auto; background: #4CAF50; color: #fff; border: none; }
.editor-workspace {
  display: flex; justify-content: center; align-items: center; padding: 10px; min-height: 300px; background: #f9f9f9; border-radius: 6px; margin-bottom: 20px;
}
#canvas-container {
  position: relative; display: inline-block; max-width: 100%; max-height: 70vh; overflow: hidden; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#main-canvas { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; }

/* 文字框 */
.text-overlay {
  position: absolute; top: 0; left: 0; padding: 4px;
  background: transparent !important; border: none !important; box-shadow: none !important;
  user-select: none; min-width: 40px; min-height: 20px; cursor: move;
}
.text-overlay.active { border: 1px dashed rgba(79,140,255,0.6) !important; }
.editable-text {
  outline: none; min-width: 50px; color: red; font-size: 30px; font-family: Arial; white-space: nowrap;
  background: transparent !important; box-shadow: none !important;
}
.editable-text:focus { background: transparent !important; outline: none; }

.resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; background: #4f8cff;
  border: 1px solid #fff; border-radius: 50%; cursor: nwse-resize; z-index: 5; display: none;
}
.text-overlay.active .resize-handle { display: block; }

.delete-text-btn {
  position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; background: #ff4444;
  color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 20px; text-align: center; z-index: 10;
  display: none;
}
.text-overlay.active .delete-text-btn { display: block; }

/* PC 裁剪工具栏（浮动在容器内底部） */
#canvas-container.cropping { cursor: grab; }
#canvas-container.cropping:active { cursor: grabbing; }
#canvas-container.cropping .crop-img { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; }
.crop-toolbar {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 20;
  background: rgba(255,255,255,0.9); padding: 6px 16px; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

/* 调整尺寸面板 */
#resize-panel { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 10px; }
#resize-panel input[type="number"] { width: 80px; padding: 4px; }
#resize-panel label { margin: 0; font-weight: normal; }

/* 文字设置面板 */
#text-settings {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px; background: #f0f2f5; border-radius: 6px; margin-bottom: 10px;
}
#text-settings label { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; }
#text-settings input[type="color"] { width: 30px; height: 28px; border: none; padding: 0; cursor: pointer; }
#text-settings input[type="range"] { width: 80px; cursor: pointer; }

/* 字体按钮组 */
.font-picker { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.font-btn {
  padding: 3px 8px; border: 1px solid #ccc; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; transition: all 0.2s;
}
.font-btn:hover { background: #e6f0ff; border-color: #4f8cff; }
.font-btn.active { background: #4f8cff; color: #fff; border-color: #4f8cff; }

.apply-btn {
  background-color: #4f8cff; color: #fff; border: none; padding: 4px 10px; border-radius: 4px; font-size: 13px; cursor: pointer; transition: background 0.2s;
}
.apply-btn:hover { background-color: #3a6fd8; }

/* 收藏卡片 */
.fav-grid-item { cursor: pointer; transition: transform 0.2s; }
.fav-grid-item:hover { transform: scale(1.02); }
.fav-grid-item .pro_title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
.fav-actions { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.compose-btn {
  background-color: #4f8cff; color: #fff; border: none; padding: 4px 10px; border-radius: 4px; font-size: 13px; cursor: pointer; transition: background 0.2s;
}
.compose-btn:hover { background-color: #3a6fd8; }
.fav-remove-btn {
  background: none; border: none; color: #999; cursor: pointer; font-size: 13px; padding: 2px 0; display: inline-flex; align-items: center; gap: 4px; position: relative; transition: color 0.2s;
}
.fav-remove-btn::after { content: ''; position: absolute; left: 0; bottom: 0; width: 0; height: 1px; background: #ff6b6b; transition: width 0.25s; }
.fav-remove-btn:hover { color: #ff6b6b; }
.fav-remove-btn:hover::after { width: 100%; }
.fav-remove-icon { width: 14px; height: 14px; stroke: #999; transition: stroke 0.2s; }
.fav-remove-btn:hover .fav-remove-icon { stroke: #ff6b6b; }

/* ========== 手机端优化 ========== */
@media screen and (max-width: 768px) {
  .editor-container { padding: 0 10px; }
  .editor-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .editor-toolbar button,
  .editor-toolbar select {
    width: 100%;
    padding: 8px 12px;
    font-size: 16px;
  }
  #btn-download {
    width: 100%;
    margin-left: 0;
  }

  /* 画布更大 */
  #canvas-container {
    max-height: 85vh !important;
    max-width: 100%;
  }
  #main-canvas {
    max-height: 85vh !important;
    max-width: 100%;
  }

  /* 文字设置面板竖向排列 */
  #text-settings {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #text-settings label {
    justify-content: space-between;
    font-size: 14px;
  }
  #text-settings input[type="color"] {
    width: 40px; height: 36px;
  }
  #text-settings input[type="range"] {
    width: 100%;
  }
  .font-picker {
    justify-content: flex-start;
  }

  /* 收藏列表两列显示 */
  .pro_list.col-lg-3 {
    width: 50%;
    padding: 0 5px;
  }

  /* ===== 裁剪工具栏移至画布下方（关键） ===== */
  #canvas-container.cropping {
    overflow: visible;
    margin-bottom: 70px;
  }
  .crop-toolbar {
    position: absolute;
    top: 100%;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    padding: 10px 24px;
    border-radius: 30px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 15px rgba(0,0,0,0.2);
    white-space: nowrap;
    gap: 12px;
    z-index: 25;
  }
  .crop-toolbar button {
    padding: 10px 20px;
    font-size: 16px;
    white-space: nowrap;
    border-radius: 8px;
    min-width: 80px;
  }
  #btn-crop-done,
  #btn-crop-cancel {
    margin: 0;
  }

  /* 缩放/删除控件加大 */
  .resize-handle {
    width: 20px; height: 20px;
    right: -8px; bottom: -8px;
  }
  .delete-text-btn {
    width: 24px; height: 24px;
    font-size: 14px;
    line-height: 24px;
    top: -12px; right: -12px;
  }
}

/* 确保容器清除浮动 */
.productList {
  overflow: hidden;
  clear: both;
}

/* 自定义网格：基础浮动 */
.fav-grid-item.pro_list {
  float: left;
  min-height: 1px;
  padding-left: 5px;
  padding-right: 5px;
  box-sizing: border-box;
  margin: 10px 0;
  width: 100%;
}

/* 手机端（<768px）：两列 */
@media (max-width: 767px) {
  .fav-grid-item.pro_list {
    width: 50%;
  }
}

/* 平板端（768px - 991px）：三列 */
@media (min-width: 768px) and (max-width: 991px) {
  .fav-grid-item.pro_list {
    width: 33.333%;
  }
}

/* PC端（≥992px）：五列 */
@media (min-width: 992px) {
  .fav-grid-item.pro_list {
    width: 20%;
  }
}

/* ========== 分类筛选样式（已修正换行） ========== */
.fav-filter-bar {
  margin-bottom: 20px;
  overflow: hidden;
}

.fav-filter-scroll {
  display: flex;
  flex-wrap: wrap;          /* 允许换行 */
  gap: 8px;
  justify-content: flex-start;
  padding-bottom: 4px;
}

.fav-filter-btn {
  display: inline-block;
  margin: 4px 6px;
  padding: 8px 18px;
  background: #f5f6fa;
  color: #666;
  border: 1px solid #e0e4e8;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
}
.fav-filter-btn:hover {
  background: #eef2ff;
  border-color: #4f8cff;
  color: #4f8cff;
}
.fav-filter-btn.active {
  background: #4f8cff;
  color: #fff;
  border-color: #4f8cff;
}


/* ========== 上传按钮区域 ========== */
.upload-section {
  text-align: center;
  margin: 0 0 15px 0;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  background: #fff;
  color: #4f8cff;
  border: 1.5px dashed #4f8cff;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8faff;
}
.upload-btn:hover {
  background: #4f8cff;
  color: #fff;
  border-style: solid;
}
.upload-btn:active {
  background: #3a6fd8;
  border-color: #3a6fd8;
}

/* 上传图片浮动标签（与之前相同，放在这里统一） */
.custom-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: #ff9800;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px 3px 5px;
  border-radius: 0 6px 6px 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
.custom-badge::before {
  content: "⬆";
  font-size: 11px;
  flex-shrink: 0;
}

/* 上传按钮和教程按钮并排容器 */
.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 0 0 15px 0;
  flex-wrap: wrap;
}

/* 教程按钮样式（与上传按钮协调） */
.guide-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  background: #f8faff;
  color: #666;
  border: 1.5px dashed #aaa;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}
.guide-btn:hover {
  border-color: #4f8cff;
  color: #4f8cff;
  background: #eef2ff;
}
.guide-btn:active {
  background: #dce6ff;
}

/* 教程面板样式 */
.guide-panel {
  background: #f9fafb;
  border: 1px solid #e0e4e8;
  border-radius: 8px;
  padding: 15px 20px;
  margin-bottom: 20px;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}
.guide-panel h4 {
  margin: 0 0 8px 0;
  color: #2764b3;
}
.guide-panel ol, .guide-panel ul {
  padding-left: 20px;
  margin: 5px 0;
}

/* 裁剪尺寸显示 */
#crop-dimensions {
  background: rgba(255,255,255,0.85);
  padding: 4px 12px;
  border-radius: 4px;
  display: inline-block;
}


/* Resize 面板的 Cancel 按钮改为灰蓝色 */
#btn-resize-cancel {
  background-color: #124470;   /* 灰蓝色 */
  color: #fff;
  border: none;
  border-radius: 4px;
  transition: background 0.2s;
}
#btn-resize-cancel:hover {
  background-color: #124470;   /* 深一点的灰蓝 */
}