/* 拼豆Pic 网页版 - 桌面端样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ========== 顶部导航 ========== */
.navbar {
  background: #fff;
  color: #333;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-bottom: 1px solid #e8e8e8;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 40px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: #1660AB;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.navbar-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1660AB, #1a73e8);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
}

.navbar-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  color: #555;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.nav-link:hover {
  background: #f0f5ff;
  color: #1660AB;
}

.nav-link.active {
  background: #e8f0fe;
  color: #1660AB;
  font-weight: 600;
}

.navbar-right {
  display: flex;
  align-items: center;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #e8e8e8;
  object-fit: cover;
}

.navbar-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1660AB;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.navbar-nickname {
  font-size: 14px;
  color: #333;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid #ddd;
  color: #666;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
  background: #fff2f0;
}

/* ========== 主内容区 ========== */
.page-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px;
  min-height: calc(100vh - 60px);
}

/* ========== 卡片 ========== */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border: 1px solid #f0f0f0;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #1a1a1a;
}

/* ========== 搜索栏 ========== */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  max-width: 500px;
}

.search-input {
  flex: 1;
  height: 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.1);
}

.search-btn {
  height: 40px;
  padding: 0 24px;
  background: #1660AB;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.search-btn:hover {
  background: #125094;
}

/* ========== 作品网格（桌面端自适应多列） ========== */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.work-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s;
}

.work-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  border-color: #d0e0ff;
}

.work-thumb-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.work-thumb {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.work-info {
  padding: 12px 14px;
}

.work-title {
  font-size: 14px;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  margin-bottom: 4px;
}

.work-author {
  font-size: 12px;
  color: #999;
}

.work-stats {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: #bbb;
}

/* ========== Tab切换 ========== */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.tab {
  padding: 8px 24px;
  font-size: 14px;
  cursor: pointer;
  color: #666;
  border: none;
  background: transparent;
  border-radius: 6px;
  transition: all 0.2s;
}

.tab.active {
  background: #fff;
  color: #1660AB;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ========== 统计数字 ========== */
.stats-row {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin: 24px 0;
}

.stat-item {
  text-align: center;
}

.stat-num {
  font-size: 32px;
  font-weight: 700;
  color: #1660AB;
}

.stat-label {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

/* ========== 个人中心头部 ========== */
.avatar-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 3px solid #e8f0fe;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1660AB;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
}

.avatar-fallback {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  display: none;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1a1a1a;
}

.profile-stats {
  display: flex;
  gap: 40px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: #1660AB;
  color: #fff;
}

.btn-primary:hover {
  background: #125094;
}

.btn-outline {
  background: transparent;
  color: #1660AB;
  border: 1.5px solid #1660AB;
}

.btn-outline:hover {
  background: rgba(22,96,171,0.06);
}

.btn-danger {
  background: #ff4d4f;
  color: #fff;
}

.btn-danger:hover {
  background: #e04345;
}

.btn-sm {
  padding: 5px 14px;
  font-size: 13px;
  border-radius: 4px;
}

.btn-block {
  width: 100%;
}

/* ========== 加载/空状态 ========== */
.loading {
  text-align: center;
  padding: 60px 0;
  color: #999;
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid #e8e8e8;
  border-top-color: #1660AB;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #bbb;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .empty-text {
  font-size: 14px;
}

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0 8px;
}

.page-btn:hover {
  border-color: #1660AB;
  color: #1660AB;
}

.page-btn.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== 详情页 ========== */
.detail-header {
  display: flex;
  gap: 28px;
}

.detail-thumb {
  width: 280px;
  height: 280px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f5f5f5;
  border: 1px solid #eee;
}

/* 详情页拼豆模式：双栏布局（左画布，右色卡） */
@media (min-width: 1100px) {
  .detail-pattern-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
  }
  .detail-pattern-canvas {
    flex: 1;
    min-width: 0;
  }
  .detail-pattern-side {
    flex: 0 0 180px;
  }
}

.detail-meta {
  flex: 1;
  min-width: 0;
}

.detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #1a1a1a;
}

.detail-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.detail-author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.detail-author-name {
  font-size: 15px;
  color: #333;
  font-weight: 500;
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: #bbb;
}

.action-btn.liked {
  color: #ff4d4f;
  border-color: #ff4d4f;
  background: #fff1f0;
}

.action-btn.collected {
  color: #faad14;
  border-color: #faad14;
  background: #fffbe6;
}

/* ========== 拼豆查看器 ========== */
.viewer-container {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid #f0f0f0;
  text-align: center;
}

.viewer-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #f0e8d8;
  margin: 0 auto;
}

.viewer-canvas {
  display: block;
  image-rendering: pixelated;
  border-radius: 4px;
}

.viewer-info {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 14px;
  font-size: 13px;
  color: #888;
}

/* ========== 发布表单 ========== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  font-size: 14px;
  color: #555;
  font-weight: 500;
  display: block;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.form-input:focus {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.1);
}

.form-textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-textarea:focus {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.1);
}

.form-textarea.mono {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  background: #fafafa;
}

.form-hint {
  font-size: 12px;
  color: #bbb;
  margin-top: 4px;
}

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ed 100%);
  padding: 20px;
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 48px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.login-title {
  font-size: 22px;
  margin-bottom: 4px;
  color: #1a1a1a;
}

.login-subtitle {
  color: #999;
  font-size: 14px;
  margin-bottom: 28px;
}

.login-hint {
  color: #bbb;
  font-size: 12px;
  margin-top: 20px;
}

.qr-container {
  margin: 20px 0;
  display: flex;
  justify-content: center;
}

#qrImg {
  border-radius: 8px;
  border: 2px solid #eee;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.78);
  color: #fff;
  padding: 10px 28px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 9999;
  animation: fadeInOut 2s forwards;
  pointer-events: none;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ========== 工具类 ========== */
.hidden { display: none !important; }

.text-center { text-align: center; }
.text-muted { color: #999; font-size: 13px; }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

@media (max-width: 640px) {
  .works-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-container {
    padding: 16px;
  }
  .navbar {
    padding: 0 16px;
  }
  .navbar-links {
    display: none;
  }
  .pattern-layout {
    flex-direction: column !important;
  }
  .pattern-left, .pattern-right {
    width: 100% !important;
  }
  .ai-layout {
    flex-direction: column !important;
  }
  .ai-left, .ai-right {
    width: 100% !important;
  }
}

/* ========== AI 卡通页面 ========== */
.ai-page { width: 100%; }

/* AI 双栏布局：左创建+任务列表，右任务详情 */
.ai-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.ai-left { flex: 0 0 420px; }
.ai-right { flex: 1; min-width: 0; }

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
}

.ai-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.ai-beans {
  background: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
}

.ai-beans strong { color: #1660AB; }

.free-badge {
  background: linear-gradient(135deg, #faad14, #ffc53d);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.free-badge.used {
  background: #d9d9d9;
  color: #888;
}

.ai-create-card { text-align: center; }

.ai-upload-area {
  border: 2px dashed #d0d0d0;
  border-radius: 10px;
  padding: 40px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-upload-area:hover, .ai-upload-area.drag-over {
  border-color: #1660AB;
  background: #f0f5ff;
}

.upload-placeholder {
  text-align: center;
  color: #999;
}

.upload-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.upload-placeholder p {
  font-size: 14px;
  margin-top: 4px;
}

.upload-hint {
  font-size: 12px !important;
  color: #bbb !important;
}

.upload-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

.ai-create-actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.remove-bg-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  user-select: none;
}

.remove-bg-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* AI 任务列表 */
.ai-tasks-section { margin-top: 20px; }

.ai-tasks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

.ai-tasks-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.ai-task-card {
  padding: 16px;
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.task-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.status-pending { background: #f0f0f0; color: #888; }
.status-processing { background: #e6f7ff; color: #1890ff; }
.status-done { background: #f6ffed; color: #52c41a; }
.status-fail { background: #fff2f0; color: #ff4d4f; }

.task-time {
  font-size: 12px;
  color: #bbb;
}

.task-images {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.task-img-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f5f5;
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-img-wrap.processing .spinner {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

.task-img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 2px 0;
}

.task-failed {
  padding: 20px;
  text-align: center;
  color: #ff4d4f;
  font-size: 14px;
}

.task-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ========== 图片转图纸页面 ========== */
.pattern-page { width: 100%; }

/* Pattern 双栏布局：左侧源图+参数，右侧结果 */
.pattern-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.pattern-left { flex: 0 0 380px; position: sticky; top: 80px; }
.pattern-right { flex: 1; min-width: 0; }

.pattern-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.pattern-source {
  display: flex;
  gap: 16px;
  align-items: center;
}

.pattern-source-img img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 8px;
  border: 1px solid #eee;
}

.pattern-source-info {
  flex: 1;
}

.pattern-params { margin-top: 20px; }

.param-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.param-btn {
  padding: 6px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  transition: all 0.2s;
}

.param-btn:hover {
  border-color: #1660AB;
  color: #1660AB;
}

.param-btn.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

.custom-grid {
  margin-top: 12px;
}

.slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  margin-top: 6px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1660AB;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1660AB;
  cursor: pointer;
  border: none;
}

/* 图纸结果 */
.pattern-result { }

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.result-info {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: #888;
}

.pattern-canvas-wrap {
  text-align: center;
  margin-bottom: 20px;
  overflow: auto;
}

#patternCanvas {
  border: 1px solid #eee;
  border-radius: 8px;
  image-rendering: pixelated;
  max-width: 100%;
}

.color-list-section {
  border-top: 1px solid #f0f0f0;
  padding-top: 16px;
}

.color-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.color-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #fafafa;
  border-radius: 6px;
  border: 1px solid #f0f0f0;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.color-code {
  font-size: 12px;
  color: #333;
  font-weight: 500;
}

.color-count {
  font-size: 12px;
  color: #888;
  margin-left: auto;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* ========== 图纸编辑器 ========== */
.editor-page {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 60px);
  width: 100%;
  overflow: hidden;
}

/* 左侧：工具栏 + 画布 */
.editor-main {
  order: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* 右侧面板：当前颜色 + 色卡 */
.editor-sidebar {
  order: 1;
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid #e8e8e8;
  padding: 10px 10px 6px;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 当编辑器激活时，page-container 去掉内边距和宽度限制，填满导航栏下方 */
.page-container:has(.editor-page) {
  max-width: none !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* 编辑器模式下全局样式 */
body.editor-mode .navbar {
  padding: 0 12px !important;
}

body.editor-mode {
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-radius: 8px 8px 0 0;
  border: 1px solid #e8e8e8;
  border-bottom: none;
  gap: 4px;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  gap: 2px;
}

.tool-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: #555;
}

.tool-btn:hover {
  border-color: #1660AB;
  background: #f0f5ff;
}

.tool-btn.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

.editor-canvas-area {
  flex: 1;
  overflow: hidden;
  background: #e8e8e8;
  border-left: 1px solid #e8e8e8;
  border-right: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
  position: relative;
  cursor: grab;
}

.editor-canvas-area:active {
  cursor: grabbing;
}

.editor-canvas-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#editorCanvas {
  display: block;
  position: relative;
  transform-origin: 0 0;
  image-rendering: pixelated;
  cursor: crosshair;
}

.editor-zoom-badge {
  position: absolute;
  bottom: 8px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  pointer-events: none;
}
.canvas-size-label {
  position: absolute;
  bottom: 8px;
  left: 12px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  pointer-events: none;
  font-weight: 600;
}

/* 侧边栏色卡筛选栏 */
.palette-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.palette-filter-btn {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  color: #666;
  transition: all 0.1s;
}

.palette-filter-btn:hover {
  border-color: #1660AB;
  color: #1660AB;
}

.palette-filter-btn.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}
.editor-sidebar .current-color-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

/* 侧边栏色卡：竖向排列 */
.editor-sidebar .palette-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.editor-sidebar .palette-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 2px 0;
}

.current-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid #ddd;
}

.current-color-code {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  min-width: 30px;
}

/* 详情页色卡滚动区（竖向） */
.detail-pattern-layout .palette-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

/* 详情页色卡列表（横向折行） */
.detail-pattern-layout .palette-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 2px 0;
}

.palette-item {
  width: 38px;
  height: 38px;
  border-radius: 5px;
  border: 1.5px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.1s;
  position: relative;
  overflow: hidden;
}

.palette-swatch {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.palette-code {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #222;
  background: rgba(255,255,255,0.85);
  line-height: 1.4;
  pointer-events: none;
}

.palette-count {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 8px;
  font-weight: 700;
  color: #fff;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  padding: 0 3px;
  line-height: 1.4;
  pointer-events: none;
}

.palette-item:hover {
  transform: scale(1.15);
  border-color: #1660AB;
}

.palette-item.active {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.3);
  transform: scale(1.1);
}

/* 详情页色卡 - 紧凑网格 */
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 600px;
  overflow-y: auto;
  padding: 4px 0;
}

.detail-palette-swatch:hover {
  transform: scale(1.15);
  border-color: #1660AB;
}

.detail-palette-swatch-active {
  border-color: #1660AB;
  box-shadow: 0 0 0 2px rgba(22,96,171,0.3);
  transform: scale(1.1);
}

/* ========== Modal ========== */
.modal-overlay,
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content,
.dialog {
  background: #fff;
  border-radius: 12px;
  max-width: 420px;
  width: 88%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dialog h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 20px 24px 16px;
  color: #1a1a1a;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
}

.dialog .form-group {
  padding: 0 24px 12px;
}

.dialog .form-group label {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
  display: block;
}

.dialog .dialog-body {
  padding: 0 24px 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.needs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.needs-table th {
  background: #f7f9fc;
  font-weight: 600;
  color: #555;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #e8e8e8;
}

.needs-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.needs-table tr:last-child td {
  border-bottom: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-close:hover {
  background: #f5f5f5;
  color: #333;
}

.modal-body {
  padding: 24px;
}

/* AI 详情弹窗 */
.ai-detail-modal .modal-body { padding: 0; }

.detail-images {
  display: flex;
  gap: 16px;
  padding: 24px;
  justify-content: center;
}

.detail-img-item {
  text-align: center;
}

.detail-img-item img {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #eee;
}

.detail-img-item p {
  font-size: 13px;
  color: #888;
  margin-top: 6px;
}

.detail-info {
  padding: 0 24px 24px;
  font-size: 13px;
  color: #666;
}

.detail-info p {
  margin-bottom: 4px;
}

/* ========= 编辑器参考图 ========= */
.ref-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}
.ref-image-overlay img {
  position: absolute;
  opacity: 0.5;
  border: 2px dashed #1660AB;
  cursor: move;
  /* pointer-events 由 JS 动态控制（锁定/解锁） */
}
.ref-image-handles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ref-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #1660AB;
  border: 2px solid #fff;
  border-radius: 2px;
  pointer-events: auto;
  cursor: nwse-resize;
}
.ref-handle-br {
  right: -6px;
  bottom: -6px;
  cursor: nwse-resize;
}
.ref-image-overlay.dragging img {
  opacity: 0.7;
}

/* ========= 参考图/对称控制面板 ========= */
.ref-controls {
  position: absolute;
  top: 52px;
  right: 12px;
  width: 220px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 14px;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

.sym-controls {
  position: absolute;
  top: 52px;
  left: 12px;
  width: 180px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 14px;
  z-index: 20;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.ref-controls-title,
.sym-controls-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 10px;
}
.ref-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  color: #555;
}
.ref-slider-row input[type="range"] {
  flex: 1;
  height: 4px;
}
.ref-slider-row span {
  width: 40px;
  text-align: right;
  color: #888;
  font-size: 12px;
}
.ref-controls .btn,
.sym-controls .btn {
  margin-top: 6px;
  width: 100%;
}
.sym-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #444;
  cursor: pointer;
}
.sym-controls select {
  flex: 1;
  padding: 3px 6px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff;
}

/* 魔术棒操作栏 */
.magic-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 13px;
  color: #333;
  max-width: 92%;
}
.magic-bar.hidden { display: none; }
.magic-bar .magic-info { white-space: nowrap; }
.magic-bar .magic-info b { color: #1660AB; }
.magic-region {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}
.magic-bar .btn { margin: 0; width: auto; }

/* 色号 HTML overlay（屏幕绝对坐标定位，原生文字渲染，无 transform 缩放白边） */
/* 画布大小设置弹窗 */
.canvas-size-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.canvas-size-overlay.hidden { display: none; }

/* 覆盖父级 user-select:none，确保输入框可输入 */
.canvas-size-overlay,
.canvas-size-overlay * {
  user-select: auto !important;
  -webkit-user-select: auto !important;
}
.canvas-size-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.canvas-size-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
  color: #1a1a1a;
}
.canvas-size-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.canvas-size-row label {
  font-size: 13px;
  color: #555;
  min-width: 85px;
}
.canvas-size-row .form-input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}
.canvas-size-hint {
  font-size: 12px;
  color: #ff4d4f;
  margin-bottom: 18px;
  padding: 8px 10px;
  background: #fff1f0;
  border-radius: 6px;
}
.canvas-size-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.canvas-size-custom {
  /* 无预设按钮时不需要分隔线 */
}
.canvas-size-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.canvas-size-row label {
  font-size: 13px;
  color: #555;
  min-width: 85px;
}
.canvas-size-row .form-input {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}
.canvas-size-unit {
  font-size: 13px;
  color: #555;
}
.canvas-size-hint {
  font-size: 12px;
  color: #ff4d4f;
  margin-bottom: 18px;
  padding: 8px 10px;
  background: #fff1f0;
  border-radius: 6px;
}

/* ========= 去杂色开关 ========= */
.denoise-section {
  padding: 16px 0 8px;
  border-top: 1px solid #f0f0f0;
  margin-top: 8px;
}

.denoise-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.denoise-row .form-label {
  margin-bottom: 0;
}

.toggle-switch {
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #ddd;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch.active .toggle-track {
  background: #1660AB;
}

.toggle-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.active .toggle-thumb {
  left: 22px;
}

.max-colors-row {
  margin-top: 14px;
  padding-left: 4px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

.slider-row .slider {
  flex: 1;
}

.slider-value {
  font-size: 14px;
  font-weight: 600;
  color: #1660AB;
  min-width: 32px;
  text-align: center;
}

.selection-box {
  position: absolute;
  border: 2px dashed #1660AB;
  background: rgba(22,96,171,0.10);
  pointer-events: none;
  z-index: 4;
}

.selection-box.hidden {
  display: none;
}

.paste-anchor {
  position: absolute;
  border: 2px solid #ff6b00;
  background: rgba(255,107,0,0.18);
  pointer-events: none;
  z-index: 5;
  border-radius: 3px;
  transition: left 0.05s, top 0.05s;
}

.paste-anchor.hidden {
  display: none;
}

/* ========= 保存名称弹窗 ========= */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  min-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 16px;
}
.modal-field {
  margin-bottom: 14px;
}
.modal-field label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 5px;
}
.modal-field input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.modal-field input:focus {
  border-color: #1660AB;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ========= 快捷键提示 ========= */
.shortcut-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.72);
  color: #fff;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.shortcut-hint.show {
  opacity: 1;
}

/* ========= 对称指示线 ========= */
.sym-line {
  position: absolute;
  background: rgba(22,96,171,0.18);
  pointer-events: none;
  z-index: 3;
}

/* ========= 字体 Tab 切换 ========= */
.font-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.font-tab {
  flex: 1;
  padding: 6px 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.font-tab.active {
  background: #1660AB;
  color: #fff;
  border-color: #1660AB;
}

/* ========= 高级取色器 ========= */
.color-picker-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.color-picker-overlay.hidden {
  display: none;
}
.color-picker-panel {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 320px;
  max-width: 95vw;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
}
.color-picker-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #333;
}
.cp-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.cp-preview-swatch {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid #ddd;
}
.cp-preview-hex {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  font-family: monospace;
}

/* 色相条 */
.cp-hue-bar-wrap {
  position: relative;
  margin-bottom: 14px;
  height: 20px;
}
.cp-hue-bar {
  width: 100%;
  height: 16px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}
.cp-hue-thumb {
  position: absolute;
  top: 1px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #555;
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* 深浅变体 */
.cp-shades {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}
.cp-shade-item {
  flex: 1;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.cp-shade-item.active {
  border-color: #333;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

/* 预设色卡 */
.cp-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 14px;
}
.cp-preset-item {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.cp-preset-item.active {
  border-color: #333;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #333;
}

/* HEX 输入 */
.cp-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.cp-input-label {
  font-size: 12px;
  font-weight: 600;
  color: #999;
}
.cp-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: monospace;
  outline: none;
}
.cp-input:focus {
  border-color: #1660AB;
}

/* 取色器按钮行 */
.cp-btns {
  display: flex;
  gap: 10px;
}
.cp-btns .btn {
  flex: 1;
}

/* + 号取色器触发按钮 */
.picker-trigger:hover {
  background: #e8f0ff !important;
  border-color: #1660AB !important;
}

