/* css/style.css */
:root {
  /* 主色调 */
  --primary: #ff9800;
  --primary-light: #ffc107;
  --primary-dark: #f57c00;

  /* 强调色 */
  --accent: #f44336;
  --accent-light: #ff5722;

  /* 辅助色 */
  --success: #4caf50;
  --info: #2196f3;
  --warning: #ffc107;

  /* 背景 */
  --bg-gradient: linear-gradient(135deg, #fff9c4, #ffccbc);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);

  /* 阴影 */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);
  --shadow-primary: 0 4px 12px rgba(255, 152, 0, 0.4);

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 字体 */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: #333;
  min-height: 100vh;
}

.app { max-width: 1280px; margin: 0 auto; padding: 24px; }

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  position: relative;
  z-index: 10;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 36px;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-dark);
}

.subtitle {
  color: #bf360c;
  margin-top: 4px;
  font-size: 16px;
}

/* 步骤引导 */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  transition: all 0.3s;
  opacity: 0.5;
}

.step.active {
  opacity: 1;
  background: rgba(255, 152, 0, 0.1);
}

.step.completed {
  opacity: 0.8;
}

.step-icon {
  font-size: 32px;
}

.step-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}

.step-arrow {
  font-size: 24px;
  color: var(--primary);
}

.main {
  display: grid;
  grid-template-columns: 320px 1fr auto;
  gap: 32px;
  align-items: start;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-section {
  margin-bottom: 20px;
}

.drop-zone {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px dashed rgba(255, 152, 0, 0.3);
  border-radius: var(--radius-lg);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.drop-zone img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
}

#upload-hint {
  text-align: center;
  color: #666;
}

.upload-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.upload-hint-small {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
  display: block;
}

.change-img-btn {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--primary-dark);
  cursor: pointer;
  transition: all 0.2s;
}

.change-img-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.size-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.preview-section h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary-dark);
}

.size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.size-label {
  width: 40px;
  font-size: 14px;
  color: #666;
}
.size-value {
  font-size: 16px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}
.size-unit {
  font-size: 13px;
  color: #888;
}

.stepper {
  display: flex;
  align-items: center;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}
.stepper-btn {
  width: 36px; height: 36px;
  border: none; background: #f0f0f0;
  font-size: 18px; cursor: pointer;
  color: #333;
  transition: background .2s;
  line-height: 1;
}
.stepper-btn:hover { background: #e0e0e0; }
.stepper-btn:active { background: #d0d0d0; }
.stepper-input {
  width: 64px; height: 36px;
  border: none;
  border-left: 2px solid #e0e0e0;
  border-right: 2px solid #e0e0e0;
  text-align: center;
  font-size: 16px; font-weight: 600;
  outline: none;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-inner-spin-button,
.stepper-input::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}

/* 通用按钮样式 */
.btn {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

/* 主要按钮 */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 次要按钮 */
.btn-secondary {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-md);
}

/* 成功按钮 */
.btn-success {
  background: linear-gradient(135deg, var(--success), #66bb6a);
  color: white;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-success:hover {
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

/* 危险按钮 */
.btn-danger {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.btn-danger:hover {
  box-shadow: 0 6px 16px rgba(244, 67, 54, 0.5);
}

.download-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.download-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.preview-container {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
  max-height: 70vh;
  position: relative;
  box-shadow: var(--shadow-md);
  transition: all 0.3s;
}

.preview-container:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.preview-container canvas {
  display: block;
  margin: 0 auto;
}

#overlay-canvas {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.sidebar {
  grid-column: 1;
  grid-row: 1;
}

.preview-section {
  grid-column: 2;
  grid-row: 1;
}

.bill-of-materials {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
}

.download-btn {
  grid-column: 1;
  grid-row: 2;
  align-self: start;
}

.bom-active {
  outline: 2px solid var(--primary, #ff9800);
  outline-offset: 1px;
  border-radius: 4px;
  background: rgba(255, 152, 0, 0.08);
}

.bill-of-materials {
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 2;
  box-shadow: var(--shadow-sm);
  min-width: 180px;
  max-width: 220px;
}

.color-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid #ddd;
  vertical-align: middle;
  margin-right: 4px;
}

.bead-tooltip {
  display: none;
  position: fixed;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  align-items: center;
  gap: 8px;
}

.bead-tooltip-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.3);
  vertical-align: middle;
}

/* 裁剪模态框 */
.crop-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.crop-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
}

.crop-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
  flex-shrink: 0;
}

.crop-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
  transition: all 0.2s;
}

.crop-modal-close:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.crop-modal-body {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 0;
  flex: 1;
}

.crop-viewport {
  position: relative;
  user-select: none;
  cursor: default;
}

.crop-image {
  display: block;
  pointer-events: none;
}

.crop-mask {
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.crop-mask-top { top: 0; left: 0; width: 100%; }
.crop-mask-bottom { left: 0; width: 100%; }

.crop-box {
  position: absolute;
  border: 1px dashed #fff;
  cursor: move;
  box-sizing: border-box;
}

.crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid #4a90d9;
  border-radius: 50%;
  box-sizing: border-box;
}

/* 角手柄 */
.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }

/* 边手柄 */
.crop-handle-n { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.crop-handle-s { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.crop-handle-e { top: 50%; right: -6px; margin-top: -6px; cursor: e-resize; }
.crop-handle-w { top: 50%; left: -6px; margin-top: -6px; cursor: w-resize; }

.crop-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 152, 0, 0.1);
  gap: 16px;
  flex-shrink: 0;
}

.crop-ratio-group {
  display: flex;
  gap: 8px;
}

.crop-ratio-btn {
  padding: 8px 16px;
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark);
}

.crop-ratio-btn:hover {
  border-color: var(--primary);
  background: rgba(255, 152, 0, 0.1);
}

.crop-ratio-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-primary);
}

.crop-actions {
  display: flex;
  gap: 10px;
}

.crop-btn {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.crop-btn-cancel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #666;
}

.crop-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.9);
}

.crop-btn-confirm {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  box-shadow: var(--shadow-primary);
}

.crop-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

/* 工具栏 */
.toolbar {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 工具按钮 */
.remove-noise-btn,
.replace-btn,
.highlight-btn,
.palette-btn,
.merge-btn,
.mirror-btn,
.preview-bead-btn {
  width: 100%;
  padding: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark);
}

.remove-noise-btn:hover,
.replace-btn:hover,
.highlight-btn:hover,
.mirror-btn:hover,
.preview-bead-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--primary);
  color: var(--primary);
}

.remove-noise-btn.active,
.replace-btn.active,
.highlight-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-primary);
}

.palette-btn:hover {
  border-color: #9c27b0;
  color: #9c27b0;
}

.merge-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}


.highlight-info {
  font-size: 13px;
  color: var(--primary-dark);
  text-align: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 188, 212, 0.1);
  border: 1px solid rgba(0, 188, 212, 0.2);
  min-height: 20px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
}

.zoom-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(0, 188, 212, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  font-weight: 700;
  color: #00bcd4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.zoom-btn:hover {
  background: rgba(0, 188, 212, 0.1);
  border-color: #00bcd4;
}

.zoom-level {
  font-size: 14px;
  font-weight: 600;
  color: #00bcd4;
  min-width: 40px;
  text-align: center;
}

/* 提示框样式 */
.remove-hint,
.replace-hint {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.remove-hint {
  background: rgba(255, 193, 7, 0.2);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: #f57c00;
}

.replace-hint {
  background: rgba(33, 150, 243, 0.2);
  border: 1px solid rgba(33, 150, 243, 0.3);
  color: #1565c0;
}

/* 操作按钮组 */
.remove-actions,
.replace-actions {
  display: flex;
  gap: 8px;
}

.undo-btn,
.done-remove-btn,
.do-replace-btn,
.cancel-replace-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.undo-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--primary-dark);
}

.undo-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

.done-remove-btn,
.do-replace-btn {
  background: linear-gradient(135deg, var(--success), #66bb6a);
  color: white;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.done-remove-btn:hover,
.do-replace-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

.cancel-replace-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: #666;
}

.cancel-replace-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* 色板编辑和合并颜色按钮 */

/* Palette editor modal */
.palette-overlay, .merge-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.palette-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 720px;
  max-width: 90vw;
  max-height: 85vh;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.palette-count {
  font-size: 14px;
  font-weight: 400;
  color: #888;
}

.palette-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
  transition: all 0.2s;
}

.palette-close:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.palette-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
  flex-wrap: wrap;
}

.palette-tool-btn {
  padding: 8px 16px;
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark);
}

.palette-tool-btn:hover {
  border-color: var(--primary);
  background: rgba(255, 152, 0, 0.1);
}

.palette-tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.palette-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.palette-series {
  margin-bottom: 20px;
}

.palette-series-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.palette-series-count {
  font-size: 13px;
  font-weight: 400;
  color: #888;
  margin-left: auto;
}

.palette-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0;
}

.palette-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 152, 0, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  background: rgba(255, 255, 255, 0.5);
}

.palette-color-item:hover {
  border-color: var(--primary);
  background: rgba(255, 152, 0, 0.1);
  transform: translateY(-2px);
}

.palette-color-item.disabled {
  opacity: 0.3;
}

.palette-color-item.disabled .palette-code {
  text-decoration: line-through;
}

.palette-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.palette-code {
  font-size: 12px;
  color: #333;
  min-width: 36px;
}

.palette-color-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.palette-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 152, 0, 0.1);
}

.palette-btn-reset {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: #666;
  transition: all 0.2s;
}

.palette-btn-reset:hover {
  background: rgba(255, 255, 255, 0.9);
}

.palette-btn-confirm {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
  color: #fff;
  box-shadow: 0 4px 12px rgba(156, 39, 176, 0.4);
  transition: all 0.2s;
}

.palette-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(156, 39, 176, 0.5);
}

/* Color merge modal */
.merge-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 640px;
  max-width: 90vw;
  max-height: 85vh;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
}

.merge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.merge-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
  transition: all 0.2s;
}

.merge-close:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.merge-stats {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.merge-stats-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.merge-stats-list {
  max-height: 200px;
  overflow-y: auto;
}

.merge-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.merge-stat-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #ddd;
  flex-shrink: 0;
}

.merge-stat-label {
  font-size: 13px;
  min-width: 40px;
  color: #333;
}

.merge-stat-bar {
  flex: 1;
  height: 12px;
  background: rgba(255, 152, 0, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.merge-stat-bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s;
}

.merge-stat-count {
  font-size: 12px;
  color: #888;
  min-width: 40px;
  text-align: right;
}

.merge-threshold {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.merge-threshold-label {
  font-size: 14px;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.merge-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 152, 0, 0.1);
  border-radius: 4px;
  outline: none;
}

.merge-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
}

.merge-threshold-hint {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

.merge-preview {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
}

.merge-preview-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 12px;
}

.merge-preview-list {
  max-height: 200px;
  overflow-y: auto;
}

.merge-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.merge-preview-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.merge-preview-arrow {
  color: #888;
  font-size: 14px;
}

.merge-preview-dist {
  color: #888;
  font-size: 11px;
  margin-left: auto;
}

.merge-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 152, 0, 0.1);
}

.merge-btn-cancel {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: #666;
  transition: all 0.2s;
}

.merge-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.9);
}

.merge-btn-confirm {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--primary), #f57c00);
  color: #fff;
  box-shadow: var(--shadow-primary);
  transition: all 0.2s;
}

.merge-btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

/* 用户栏 */
.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-btn {
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn-login {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--primary-dark);
}

.auth-btn-login:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.auth-btn-register {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  color: white;
  box-shadow: var(--shadow-primary);
}

.auth-btn-register:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

.user-info {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
}

.user-info:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

.user-info::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}

.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  z-index: 999;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

.user-info:hover .user-menu {
  display: block;
}
.user-info.user-menu-open .user-menu {
  display: block !important;
}

.user-menu-item {
  padding: 12px 16px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu-item:hover {
  background: rgba(255, 152, 0, 0.1);
  color: var(--primary-dark);
}

/* 认证模态框 */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.auth-modal {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.auth-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
  transition: all 0.2s;
}

.auth-modal-close:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.auth-modal-body {
  padding: 20px;
}

.auth-form-group {
  margin-bottom: 16px;
}

.auth-form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 6px;
}

.auth-form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.8);
}

.auth-form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.1);
}

.auth-form-group input:disabled {
  background: #f5f5f5;
  color: #888;
}

.auth-error {
  color: var(--accent);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 12px;
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-primary);
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 152, 0, 0.5);
}

.auth-submit-btn-secondary {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.auth-submit-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-md);
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: #666;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-divider {
  height: 1px;
  background: rgba(255, 152, 0, 0.1);
  margin: 20px 0;
}

/* Modal common styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
  line-height: 1;
  transition: all 0.2s;
}

.modal-close:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 152, 0, 0.1);
}

/* Loading animation */
.loading-bar {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.progress-bar {
  height: 16px;
  background: rgba(255, 152, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    #f44336,
    #ff9800,
    #ffc107,
    #4caf50,
    #2196f3,
    #9c27b0
  );
  background-size: 200% 100%;
  animation: rainbow 2s linear infinite;
  border-radius: 8px;
  transition: width 0.3s;
}

@keyframes rainbow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.loading-text {
  text-align: center;
  margin-top: 12px;
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* ===== 豆仓管理 ===== */
.inv-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
  animation: fadeIn 0.3s ease-out;
}

.inv-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inv-tool-section {
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-lg, 16px);
  padding: 16px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
}

.inv-tool-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary-dark, #e65100);
}

.inv-card-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--glass-border, rgba(255,152,0,0.2));
  border-radius: var(--radius-sm, 8px);
  background: var(--glass-bg, rgba(255,255,255,0.85));
  font-size: 14px;
  color: #333;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.inv-card-select:focus {
  border-color: var(--accent, #ff9800);
}

.inv-series-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inv-series-tab {
  padding: 6px 12px;
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark, #e65100);
}

.inv-series-tab:hover {
  border-color: var(--primary, #ff9800);
}

.inv-series-tab.active {
  background: linear-gradient(135deg, var(--primary, #ff9800), var(--accent, #f44336));
  border-color: transparent;
  color: white;
}

.inv-summary {
  display: flex;
  gap: 16px;
}

.inv-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.inv-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark, #e65100);
}

.inv-stat-label {
  font-size: 12px;
  color: #888;
}

.inv-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inv-grid-section {
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-lg, 16px);
  padding: 20px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
}

.inv-batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.inv-batch-label {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.inv-batch-qty {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--glass-border, rgba(255,152,0,0.2));
  border-radius: var(--radius-sm, 8px);
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.inv-batch-qty:focus {
  border-color: var(--accent, #ff9800);
}

.inv-batch-btn {
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.inv-batch-btn.active {
  background: var(--accent, #ff9800);
  color: #fff;
  border-color: var(--accent, #ff9800);
}

.inv-batch-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  flex-wrap: wrap;
}

.inv-batch-action-bar .inv-batch-qty {
  width: 90px;
}

#inv-batch-count {
  font-size: 14px;
  font-weight: 600;
  color: #e65100;
}

.inv-card.selected {
  outline: 3px solid var(--accent, #ff9800);
  outline-offset: -2px;
}

.inv-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.inv-card {
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.inv-card.inv-zero { background: #f5f5f5; }
.inv-card.inv-low { background: #fff8e1; border-color: #ffc107; }
.inv-card.inv-ok { background: #e8f5e9; }
.inv-card.inv-full { background: #e8f5e9; border-color: #4caf50; }

.inv-swatch {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  margin: 0 auto 6px;
  border: 1px solid rgba(0,0,0,0.1);
}

.inv-code {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.inv-qty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.inv-qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  color: #666;
  padding: 0;
}

.inv-qty-btn:hover {
  background: var(--primary, #ff9800);
  color: white;
  border-color: var(--primary, #ff9800);
}

.inv-qty-input {
  width: 52px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  -moz-appearance: textfield;
}

.inv-qty-input::-webkit-inner-spin-button,
.inv-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.inv-qty-input:focus {
  border-color: var(--primary, #ff9800);
}

/* 变动记录面板 */
.inv-logs-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.inv-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.inv-logs-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.inv-logs-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inv-logs-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

.inv-logs-empty {
  text-align: center;
  color: #999;
  padding: 40px 0;
}

.inv-log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.inv-log-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.inv-log-code {
  font-weight: 600;
  min-width: 32px;
}

.inv-log-delta {
  font-weight: 600;
  min-width: 48px;
}

.inv-log-add { color: #4caf50; }
.inv-log-sub { color: #f44336; }

.inv-log-reason {
  color: #888;
  font-size: 12px;
}

.inv-log-time {
  color: #aaa;
  font-size: 12px;
  margin-left: auto;
}

.inv-logs-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #eee;
}

.inv-pager-btn {
  padding: 6px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.inv-pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.inv-pager-info {
  font-size: 13px;
  color: #888;
}

/* 缺料弹窗 */
.inv-shortage-list {
  margin-bottom: 16px;
  max-height: 50vh;
  overflow-y: auto;
}

.inv-shortage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.inv-shortage-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

.inv-shortage-code {
  font-weight: 600;
  min-width: 36px;
}

.inv-shortage-diff {
  color: #f44336;
  font-weight: 600;
  margin-left: auto;
}

.inv-shortage-total {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #f44336;
  margin-bottom: 16px;
}

.inv-shortage-actions {
  display: flex;
  gap: 12px;
}

.inv-shortage-actions .auth-submit-btn {
  flex: 1;
}

/* Toast */
.inv-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 9999;
  pointer-events: none;
}

.inv-shortage-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  max-width: 90vw;
  max-height: 120px;
  overflow-y: auto;
  opacity: 0;
  transition: all 0.3s;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.inv-shortage-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.inv-shortage-toast-icon {
  margin-right: 6px;
}

.inv-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 开关 */
.inv-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.inv-toggle-checkbox {
  display: none;
}

.inv-toggle-track {
  width: 40px;
  height: 22px;
  background: #ccc;
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.inv-toggle-thumb {
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.inv-toggle-checkbox:checked + .inv-toggle-track {
  background: var(--primary, #ff9800);
}

.inv-toggle-checkbox:checked + .inv-toggle-track .inv-toggle-thumb {
  transform: translateX(18px);
}

.inv-toggle-text {
  font-size: 14px;
  color: #333;
}

.inv-toggle-desc {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
  line-height: 1.4;
}

/* Responsive design */
@media (max-width: 768px) {
  .app {
    padding: 16px;
  }

  .header {
    margin-bottom: 12px;
  }

  .header h1 {
    font-size: 20px;
  }

  .header-brand {
    gap: 8px;
  }

  .brand-icon {
    font-size: 24px;
  }

  .subtitle {
    display: none;
  }

  .steps {
    gap: 6px;
    padding: 10px 8px;
  }

  .step {
    padding: 6px 10px;
    gap: 4px;
  }

  .step-icon {
    font-size: 22px;
  }

  .step-text {
    font-size: 11px;
  }

  .step-arrow {
    font-size: 16px;
  }

  .main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 1;
    grid-column: auto;
    grid-row: auto;
  }

  .download-btn {
    order: 2;
    grid-column: auto;
    grid-row: auto;
  }

  .preview-section {
    order: 3;
    grid-column: auto;
    grid-row: auto;
  }

  .bill-of-materials {
    order: 4;
    grid-column: auto;
    grid-row: auto;
    max-width: none;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .bill-of-materials > span {
    display: inline-flex;
    align-items: center;
    margin-right: 12px;
    flex-shrink: 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .toolbar-section {
    grid-column: 1 / -1;
  }

  .remove-noise-btn,
  .replace-btn,
  .highlight-btn,
  .palette-btn,
  .merge-btn,
  .mirror-btn,
  .preview-bead-btn {
    padding: 10px 8px;
    font-size: 13px;
  }

  .drop-zone {
    min-height: 180px;
  }

  .preview-container {
    max-height: 50vh;
  }

  /* Modal adaptations */
  .auth-modal,
  .palette-modal,
  .merge-modal,
  .crop-modal {
    max-width: 95vw;
    max-height: 95vh;
  }

  .crop-modal-footer {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  .crop-modal-body {
    padding: 12px;
  }

  .crop-handle {
    width: 20px;
    height: 20px;
  }

  .crop-handle-nw { top: -10px; left: -10px; }
  .crop-handle-ne { top: -10px; right: -10px; }
  .crop-handle-sw { bottom: -10px; left: -10px; }
  .crop-handle-se { bottom: -10px; right: -10px; }
  .crop-handle-n { top: -10px; margin-left: -10px; }
  .crop-handle-s { bottom: -10px; margin-left: -10px; }
  .crop-handle-e { right: -10px; margin-top: -10px; }
  .crop-handle-w { left: -10px; margin-top: -10px; }

  .palette-color-grid {
    gap: 8px;
  }

  .palette-color-item {
    padding: 4px 8px;
  }

  .palette-swatch {
    width: 24px;
    height: 24px;
  }

  /* Touch target enlargement (≥44px) */
  .stepper-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
  .stepper-input {
    height: 44px;
  }
  .zoom-btn {
    width: 44px;
    height: 44px;
  }
  .draw-color-swatch {
    width: 44px;
    height: 44px;
  }
  .auth-modal-close {
    padding: 8px 12px;
    font-size: 28px;
  }
  .palette-tool-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .header-top {
    flex-direction: column;
    gap: 12px;
  }

  .user-bar {
    width: 100%;
    justify-content: center;
  }

  .steps {
    gap: 4px;
    padding: 8px 6px;
  }

  .step {
    padding: 4px 6px;
    gap: 2px;
  }

  .step-icon {
    font-size: 18px;
  }

  .step-text {
    font-size: 10px;
  }

  .step-arrow {
    font-size: 14px;
  }
}

/* ===== 支付相关样式 ===== */

/* 套餐卡片 */
.package-card,
.pkg-card {
  background: white;
  transition: all 0.2s;
}
.package-card:hover,
.pkg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 豆币余额标签 */
.bean-balance-btn {
  transition: all 0.2s;
  user-select: none;
}
.bean-balance-btn:hover {
  background: rgba(255, 152, 0, 0.2) !important;
  transform: scale(1.05);
}

/* VIP 徽章 */
.vip-badge {
  animation: vipPulse 2s infinite;
}
@keyframes vipPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* 支付方式按钮 */
#pay-wechat, #pay-alipay {
  transition: all 0.2s;
}
#pay-wechat:hover, #pay-alipay:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 响应式 */
@media (max-width: 480px) {
  .modal {
    max-width: 90vw !important;
    margin: 6px;
    max-height: 78vh;
    overflow-y: auto;
    font-size: 13px;
  }
  .modal-body {
    padding: 8px !important;
  }
  .modal-header {
    padding: 8px 10px;
  }
  .modal-header h2 {
    font-size: 15px;
  }
  .pkg-card {
    padding: 10px !important;
  }
}

/* ===== 首页 ===== */
.landing-page {
  text-align: center;
  padding: 80px 24px 40px;
  animation: fadeIn 0.5s ease-out;
  position: relative;
}

.landing-top-bar {
  position: absolute;
  top: 48px;
  right: 16px;
  z-index: 10;
}

.landing-brand {
  margin-bottom: 48px;
}

.landing-brand .brand-icon {
  font-size: 64px;
  display: block;
  margin-bottom: 16px;
}

.landing-brand h1 {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary-dark, #e65100);
}

.landing-subtitle {
  font-size: 18px;
  color: #bf360c;
  margin-top: 8px;
}

.landing-cards {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
}

.landing-card {
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-lg, 16px);
  padding: 40px 32px;
  width: 260px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
  position: relative;
}

.landing-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,0.12));
  border-color: var(--primary, #ff9800);
}

.landing-card-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.bean-icon, .bean-icon-sm {
  display: inline-block;
  vertical-align: -0.15em;
  line-height: 0;
}
.bean-icon { width: 1em; height: 1em; }
.bean-icon-sm { width: 0.85em; height: 0.85em; vertical-align: -0.1em; }
.bean-icon svg, .bean-icon-sm svg { width: 100%; height: 100%; }

.landing-card h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark, #e65100);
  margin-bottom: 8px;
}

.landing-card p {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
}

.landing-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.landing-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, #ff9800, #f44336);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.coming-soon-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--primary, #ff9800);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.back-to-home-btn {
  padding: 8px 20px;
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-md, 12px);
  font-size: 14px;
  color: var(--primary-dark, #e65100);
  cursor: pointer;
  transition: all 0.2s;
  margin-right: auto;
  flex-shrink: 0;
}

.back-to-home-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
}

/* ===== 画拼豆 — 尺寸选择页 ===== */
.draw-setup {
  text-align: center;
  padding: 48px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.draw-setup h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-dark, #e65100);
  margin-bottom: 24px;
}

.draw-size-presets {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.draw-preset-btn {
  padding: 12px 24px;
  border: 2px solid rgba(255, 152, 0, 0.2);
  border-radius: var(--radius-md, 12px);
  background: var(--glass-bg, rgba(255,255,255,0.7));
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark, #e65100);
}

.draw-preset-btn:hover {
  border-color: var(--primary, #ff9800);
  background: rgba(255, 152, 0, 0.1);
}

.draw-preset-btn.active {
  background: linear-gradient(135deg, var(--primary, #ff9800), var(--accent, #f44336));
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-primary, 0 4px 16px rgba(255, 152, 0, 0.3));
}

.draw-custom-size {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
}

.draw-start-btn {
  padding: 16px 48px;
  font-size: 18px;
}

/* ===== 画拼豆 — 创作页 ===== */
.draw-main {
  display: grid;
  grid-template-columns: 280px 1fr 200px;
  gap: 24px;
  align-items: start;
  animation: fadeIn 0.3s ease-out;
}

.draw-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 画拼豆中间预览区 */
.draw-preview-section {
  min-height: 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

/* 画拼豆色号表：横排 */
.draw-preview-section .bill-of-materials {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  min-width: 0;
  max-width: none;
  max-height: 180px;
  overflow-y: auto;
  line-height: 1.6;
}

.draw-preview-section .bill-of-materials > span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.draw-preview-section .bill-of-materials > div {
  width: 100%;
  flex-basis: 100%;
}

.draw-tool-section {
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-lg, 16px);
  padding: 16px;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.06));
}

.draw-tool-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary-dark, #e65100);
}

.draw-current-color {
  display: flex;
  align-items: center;
  gap: 12px;
}

.draw-swatch-large {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 2px solid #ddd;
  background: #f0f0f0;
  transition: all 0.2s;
}

.draw-color-label {
  font-size: 14px;
  color: #666;
}

.draw-series-label {
  font-size: 13px;
  font-weight: 400;
  color: #888;
}

.draw-series-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.draw-series-tab {
  padding: 6px 12px;
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark, #e65100);
}

.draw-series-tab:hover {
  border-color: var(--primary, #ff9800);
}

.draw-series-tab.active {
  background: linear-gradient(135deg, var(--primary, #ff9800), var(--accent, #f44336));
  border-color: transparent;
  color: white;
}

.draw-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}

.draw-color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.draw-color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--primary, #ff9800);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.draw-color-swatch.active {
  border-color: #333;
  box-shadow: 0 0 0 3px var(--primary, #ff9800), 0 2px 8px rgba(0, 0, 0, 0.2);
}

.draw-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draw-eraser-btn.active,
#draw-noise-btn.active,
#draw-replace-btn.active,
#draw-eyedropper-btn.active {
  background: linear-gradient(135deg, var(--primary, #ff9800), var(--accent, #f44336));
  color: white;
  border-color: transparent;
}

.draw-hint {
  font-size: 12px;
  color: #888;
  padding: 4px 8px;
  background: #fffbe6;
  border-radius: 6px;
  border: 1px solid #ffe58f;
  text-align: center;
}

.draw-sub-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.draw-sub-actions .btn {
  font-size: 12px;
  padding: 4px 10px;
  flex: 1;
  min-width: 0;
}

.draw-preview-container {
  position: relative;
  background: var(--glass-bg, rgba(255,255,255,0.7));
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.3));
  border-radius: var(--radius-lg, 16px);
  padding: 20px;
  overflow: hidden;
  max-height: 70vh;
  box-shadow: var(--shadow-md, 0 4px 16px rgba(0,0,0,0.08));
}

.draw-selection-box {
  position: absolute;
  border: 2px dashed #4a90d9;
  background: rgba(74, 144, 217, 0.15);
  pointer-events: none;
  display: none;
  z-index: 10;
}

.draw-preview-container canvas {
  display: block;
  margin: 0 auto;
  cursor: crosshair;
  touch-action: none;
}

/* ===== 画布堆叠容器 ===== */
.draw-canvas-stack {
  position: relative;
  display: inline-block;
}

.draw-canvas-stack .layer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* ===== 画布尺寸调整 ===== */
.draw-grid-size-section {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin-bottom: 8px;
}

.draw-section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--primary-dark, #f57c00);
}

.draw-grid-size-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 4px;
  color: #333;
}

.draw-size-btn {
  width: 24px;
  height: 24px;
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.draw-size-btn:hover {
  background: #f0f0f0;
  border-color: #999;
}

.draw-size-val {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  width: 48px;
  text-align: center;
  font-family: monospace;
  font-size: 12px;
  color: #333;
  border: 1px solid #ccc;
  outline: none;
  -moz-appearance: textfield;
}
.draw-size-val::-webkit-outer-spin-button,
.draw-size-val::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.draw-size-val:focus {
  border-color: var(--primary-dark, #f57c00);
  background: #fff;
}

/* ===== 图层管理 ===== */
.draw-layer-section {
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin-bottom: 8px;
}

.draw-layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.draw-layer-item {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: #333;
}

.draw-layer-item.draw-layer-main {
  background: rgba(255, 152, 0, 0.1);
  border-color: var(--primary, #ff9800);
}

.draw-layer-item.draw-layer-active {
  border-color: var(--primary, #ff9800);
  box-shadow: 0 0 0 1px var(--primary, #ff9800);
}

.draw-layer-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.draw-layer-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.draw-layer-name {
  flex: 1;
  max-width: 100px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.draw-layer-delete-btn {
  font-size: 14px;
  color: #999;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 2px;
  line-height: 1;
}
.draw-layer-delete-btn:hover {
  color: #e53935;
}

.draw-layer-visibility {
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  user-select: none;
}

.draw-layer-opacity {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.draw-layer-opacity-label {
  color: #666;
  min-width: 30px;
}

.draw-layer-opacity-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  border-radius: 2px;
  outline: none;
}

.draw-layer-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--primary, #ff9800);
  border-radius: 50%;
  cursor: pointer;
}

.draw-layer-opacity-val {
  min-width: 28px;
  text-align: right;
  color: #666;
  font-family: monospace;
}

.draw-layer-actions {
  margin-top: 4px;
  display: flex;
  gap: 4px;
}

.draw-layer-action-btn {
  background: #f5f5f5;
  color: #555;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 10px;
}

.draw-layer-action-btn:hover {
  background: #e8e8e8;
}

.draw-layer-action-btn.active {
  background: var(--primary, #ff9800);
  border-color: var(--primary-dark, #f57c00);
  color: #fff;
}

.draw-layer-action-btn.draw-layer-delete {
  color: #e53935;
  border-color: #e5393544;
}

.draw-layer-action-btn.draw-layer-delete:hover {
  background: #e5393515;
}

.draw-add-layer-btn {
  width: 100%;
  font-size: 12px;
  padding: 6px 12px;
}

/* ===== 画拼豆 — 响应式 ===== */
@media (max-width: 768px) {
  .landing-page {
    padding: 40px 16px 24px;
  }

  .landing-brand .brand-icon {
    font-size: 48px;
  }

  .landing-brand h1 {
    font-size: 28px;
  }

  .landing-cards {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }

  .landing-card {
    width: 100%;
    max-width: 320px;
    padding: 28px 24px;
  }

  .draw-main {
    grid-template-columns: 1fr;
  }

  .draw-sidebar-left {
    order: 2;
  }

  .draw-preview-section {
    order: 1;
  }

  .draw-sidebar-right {
    order: 3;
  }

  .draw-custom-size {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }

  .draw-preview-container {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .landing-page {
    padding: 16px 12px 12px;
  }

  .landing-top-bar {
    position: static;
    text-align: right;
    margin-bottom: 8px;
  }

  .landing-brand {
    margin-bottom: 12px;
  }

  .landing-brand .brand-icon {
    font-size: 36px;
    margin-bottom: 8px;
  }

  .landing-brand h1 {
    font-size: 22px;
  }

  .landing-subtitle {
    font-size: 13px;
    margin-top: 4px;
  }

  .landing-cards {
    gap: 8px;
  }

  .landing-card {
    padding: 12px 14px;
  }

  .landing-card-icon {
    font-size: 28px;
    margin-bottom: 6px;
  }

  .landing-card h3 {
    font-size: 15px;
    margin-bottom: 4px;
  }

  .landing-card p {
    font-size: 12px;
    margin: 0;
  }

  .draw-setup {
    padding: 24px 12px;
  }

  .draw-setup h3 {
    font-size: 18px;
  }

  .draw-preset-btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .draw-tool-section {
    padding: 12px;
  }

  .draw-color-grid {
    max-height: 200px;
    gap: 4px;
  }

  .draw-color-swatch {
    width: 36px;
    height: 36px;
  }

  .draw-actions .btn {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* ===== 拼豆图提取 ===== */

.extract-setup {
  max-width: 480px;
  margin: 40px auto;
  padding: 0 20px;
  text-align: center;
}

.extract-setup h3 {
  margin-bottom: 20px;
}

.extract-setup-desc {
  color: var(--text-secondary, #999);
  font-size: 14px;
  margin-bottom: 24px;
}

.extract-size-controls {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 28px;
}

.extract-upload {
  max-width: 480px;
  margin: 40px auto;
  padding: 0 20px;
  text-align: center;
}

.extract-upload h3 {
  margin-bottom: 20px;
}

.extract-upload-hint {
  color: var(--text-secondary, #999);
  font-size: 13px;
  margin-top: 16px;
  line-height: 1.5;
}

.extract-preset-btn {
  padding: 8px 18px;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  color: var(--text, #fff);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.extract-preset-btn.active {
  background: var(--accent-alpha, #f9731633);
  border-color: var(--accent, #f97316);
  color: var(--accent, #f97316);
}

.extract-upload-zone {
  margin-top: 24px;
  min-height: 160px;
}

/* 对齐阶段 */
.extract-align-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 120px);
  padding: 16px;
}

.extract-canvas-area {
  flex: 1;
  background: #111;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.extract-canvas-area canvas {
  position: absolute;
  top: 0;
  left: 0;
}

.extract-align-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}

.extract-align-sidebar {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.extract-info-card {
  background: var(--bg-card, #1a1a2e);
  border-radius: 10px;
  padding: 14px;
}

.extract-info-label {
  font-size: 12px;
  opacity: 0.5;
  margin-bottom: 6px;
}

.extract-info-value {
  font-size: 20px;
  font-weight: 700;
}

.extract-zoom-slider {
  width: 100%;
  margin: 8px 0;
}

.extract-zoom-value {
  font-size: 12px;
  text-align: center;
  opacity: 0.5;
}

.extract-fine-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.extract-fine-btn {
  padding: 4px 10px;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  color: var(--text, #fff);
  font-size: 12px;
  cursor: pointer;
  min-width: 44px;
  text-align: center;
}

.extract-fine-btn:hover {
  border-color: var(--accent, #f97316);
  color: var(--accent, #f97316);
}

.extract-fine-value {
  font-size: 13px;
  font-weight: 600;
  min-width: 36px;
  text-align: center;
}

.extract-fine-pos {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}

.extract-fine-pos-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.extract-fine-pos-center {
  width: 44px;
  text-align: center;
  color: var(--text-secondary, #666);
}

.extract-align-spacer {
  flex: 1;
}

.extract-action-btn {
  width: 100%;
}

/* 结果阶段 */
.extract-result {
  max-width: 600px;
  margin: 24px auto;
  padding: 0 20px;
}

.extract-progress {
  margin-bottom: 24px;
}

.extract-progress-bar {
  height: 6px;
  background: var(--bg-card, #1a1a2e);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.extract-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f97316, #22c55e);
  border-radius: 3px;
  transition: width 0.3s;
}

.extract-progress-text {
  font-size: 13px;
  opacity: 0.7;
  text-align: center;
}

.extract-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.extract-stat-card {
  flex: 1;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.extract-stat-ok {
  background: #16a34a22;
  border: 1px solid #16a34a44;
}

.extract-stat-conflict {
  background: #dc262622;
  border: 1px solid #dc262644;
}

.extract-stat-fail {
  background: #6b728022;
  border: 1px solid #6b728044;
}

.extract-stat-num {
  font-size: 28px;
  font-weight: 700;
}

.extract-stat-ok .extract-stat-num { color: #22c55e; }
.extract-stat-conflict .extract-stat-num { color: #ef4444; }
.extract-stat-fail .extract-stat-num { color: #9ca3af; }

.extract-stat-label {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
}

.extract-conflicts {
  background: #dc262610;
  border: 1px solid #dc262633;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.extract-conflicts-title {
  font-size: 14px;
  font-weight: 600;
  color: #ef4444;
  margin-bottom: 12px;
}

.extract-conflicts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.extract-conflict-item {
  background: var(--bg-card, #1a1a2e);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid #dc262644;
}

.extract-conflict-pos {
  font-size: 11px;
  opacity: 0.4;
  margin-bottom: 6px;
}

.extract-conflict-options {
  display: flex;
  gap: 6px;
}

.extract-conflict-opt {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.extract-conflict-opt.color-channel {
  background: #16a34a33;
  color: #22c55e;
  border-color: #22c55e44;
}

.extract-conflict-opt.ocr-channel {
  background: #3b82f633;
  color: #60a5fa;
  border-color: #3b82f644;
}

.extract-conflict-opt.selected {
  outline: 2px solid #f97316;
  outline-offset: 1px;
}

.extract-conflict-opt.fail-channel {
  background: #6b728033;
  color: #9ca3af;
  border-color: #6b728044;
  cursor: default;
}

.extract-result-actions {
  display: flex;
  gap: 12px;
}

.extract-result-actions .extract-action-btn {
  flex: 1;
}

/* ===== 动漫拼豆图 ===== */

.anime-config-body {
  max-width: 600px;
  margin: 20px auto;
  padding: 0 16px;
}

.anime-preview-wrap {
  text-align: center;
  margin-bottom: 20px;
}

.anime-preview-wrap canvas {
  max-width: 100%;
  max-height: 300px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.anime-options {
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 20px;
}

.anime-option-group {
  margin-bottom: 16px;
}

.anime-option-label {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 10px;
  display: block;
}

.anime-btn-group {
  display: flex;
  gap: 10px;
}

.anime-opt-btn {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid rgba(255,152,0,0.2);
  border-radius: 12px;
  background: rgba(255,255,255,0.8);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--primary-dark);
}

.anime-opt-btn:hover {
  border-color: var(--primary);
  background: rgba(255,152,0,0.1);
}

.anime-opt-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.anime-generating-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 24px;
}

.anime-loading {
  position: relative;
  width: 100px;
  height: 100px;
}

.anime-loading-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid rgba(255,152,0,0.15);
  border-top-color: var(--primary);
  border-right-color: var(--accent);
  animation: animeSpin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.anime-loading-inner {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,152,0,0.08), rgba(244,67,54,0.08));
  display: flex;
  align-items: center;
  justify-content: center;
}

.anime-loading-icon {
  font-size: 32px;
  animation: animePulse 1.5s ease-in-out infinite;
}

@keyframes animeSpin {
  to { transform: rotate(360deg); }
}

@keyframes animePulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
}

.anime-loading-text {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.anime-loading-hint {
  font-size: 13px;
  color: #999;
}

.anime-result-body {
  max-width: 1000px;
  margin: 20px auto;
  padding: 0 16px;
}

.anime-result-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.anime-result-left {
  flex: 0 0 auto;
  max-width: 50%;
}

.anime-result-right {
  flex: 1;
  min-width: 0;
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 20px;
}

.anime-result-canvas-wrap {
  margin-bottom: 0;
}

.anime-result-canvas-wrap canvas {
  max-width: 100%;
  max-height: 500px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.anime-result-right p {
  margin: 8px 0;
  font-size: 15px;
}

.anime-color-list {
  max-height: 260px;
  overflow-y: auto;
  margin: 12px 0;
}

.anime-grid-stats {
  display: flex;
  gap: 16px;
  margin: 12px 0;
}

.anime-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  background: #f5f5f5;
  border-radius: 8px;
}

.anime-stat-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.anime-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #333;
}

.anime-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

.anime-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #ddd;
  flex-shrink: 0;
}

.anime-color-code {
  width: 40px;
  font-weight: 600;
}

.anime-color-bar {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.anime-color-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.anime-color-count {
  width: 45px;
  text-align: right;
  color: #999;
  font-size: 12px;
}

.anime-result-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.anime-result-actions .btn {
  flex: 1;
}

.anime-grid-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  flex-wrap: wrap;
}

.anime-grid-edit label {
  font-size: 14px;
  color: #666;
}

.anime-grid-edit input {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
}

/* 动漫结果页响应式 */
@media (max-width: 768px) {
  .anime-result-layout {
    flex-direction: column;
  }
  .anime-result-left {
    max-width: 100%;
  }
  .anime-result-right {
    max-height: none;
  }
}

/* 动漫示例预览 */
.anime-showcase {
  margin-top: 32px;
  text-align: center;
}
.anime-showcase-title {
  font-size: 15px;
  color: #999;
  margin-bottom: 16px;
}
.anime-showcase-cats {
  display: flex;
  justify-content: center;
  gap: 20px;
}
.anime-showcase-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 32px;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.anime-showcase-cat:hover {
  border-color: #ff9800;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255,152,0,0.2);
}
.anime-showcase-cat-icon {
  font-size: 36px;
}
.anime-showcase-cat-label {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

/* 示例浮层 */
.anime-showcase-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.anime-showcase-modal {
  background: white;
  border-radius: 16px;
  max-width: 800px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.anime-showcase-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  font-size: 18px;
  font-weight: 600;
}
.anime-showcase-modal-body {
  padding: 20px;
}
.anime-showcase-pair {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}
.anime-showcase-pair:last-child {
  margin-bottom: 0;
}
.anime-showcase-pair img {
  flex: 1;
  max-width: 50%;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.anime-showcase-arrow {
  font-size: 24px;
  color: #ff9800;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .anime-showcase-cat {
    padding: 16px 24px;
  }
  .anime-showcase-cat-icon {
    font-size: 28px;
  }
  .anime-showcase-pair {
    flex-direction: column;
  }
  .anime-showcase-pair img {
    max-width: 100%;
  }
  .anime-showcase-arrow {
    transform: rotate(90deg);
  }
}

/* ===== 提取页面响应式 ===== */

@media (max-width: 768px) {
  .extract-align-layout {
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - 120px);
    padding: 8px;
  }

  .extract-canvas-area {
    min-height: 50vh;
    flex: none;
  }

  .extract-align-sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .extract-align-sidebar .extract-info-card {
    flex: 1;
    min-width: 140px;
  }

  .extract-align-sidebar .extract-info-card:first-child {
    flex-basis: 100%;
  }

  .extract-align-hint {
    font-size: 11px;
    padding: 4px 12px;
  }

  .extract-fine-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .extract-fine-pos .extract-fine-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
  }

  .extract-size-controls {
    flex-direction: column;
    gap: 16px;
  }

  .extract-stats {
    flex-direction: column;
  }

  .extract-conflicts-list {
    grid-template-columns: 1fr;
  }

  .extract-result-actions {
    flex-direction: column;
  }

  .extract-result-actions .extract-action-btn {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .extract-setup {
    padding: 0 12px;
    margin: 20px auto;
  }

  .extract-upload {
    padding: 0 12px;
    margin: 20px auto;
  }
}

/* ===== 豆仓管理 — 响应式 ===== */
@media (max-width: 768px) {
  .inv-main {
    grid-template-columns: 1fr;
  }

  .inv-sidebar {
    order: -1;
  }

  .inv-series-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .inv-series-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .inv-summary {
    justify-content: center;
  }

  .inv-actions {
    flex-direction: row;
  }

  .inv-actions .btn {
    flex: 1;
  }

  .inv-color-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .inv-logs-panel {
    width: 100vw;
  }
}

/* BeadEditor 独立编辑器挂载点 */
.bead-editor-mount {
  width: 100%;
  height: calc(100vh - 60px);
}

/* 成品预览弹窗 */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.preview-modal {
  background: var(--glass-bg, #fff);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border, rgba(255,255,255,0.2));
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: var(--shadow-lg, 0 20px 60px rgba(0,0,0,0.3));
  animation: modalIn 0.3s ease-out;
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-dark, #333);
  border-bottom: 1px solid rgba(255, 152, 0, 0.1);
  flex-shrink: 0;
}

.preview-modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-export-btn {
  padding: 6px 16px;
  background: linear-gradient(135deg, #FF9800, #F57C00);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.preview-export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.preview-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0 4px;
  line-height: 1;
}

.preview-modal-close:hover {
  color: #333;
}

.preview-modal-body {
  padding: 20px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-result-canvas {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
