/* 全局样式 - 浅色主题 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
  padding-top: 44px;
  overflow-x: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 44px);
  padding: 12px;
  gap: 12px;
}

/* 步骤指示器 */
.step-indicator {
  display: flex;
  gap: 4px;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.step {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  background: #eee;
  color: #999;
  transition: all 0.2s;
}

.step.active {
  background: #4a90d9;
  color: #fff;
  font-weight: 600;
}

.step.completed {
  background: #d4edda;
  color: #28a745;
}

/* 主工作区 */
.workspace {
  display: flex;
  flex: 1;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

/* 画布容器 - 棋盘格背景便于观察 */
.canvas-container {
  flex: 1;
  min-width: 0;
  position: relative;
  background-image: linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.canvas-hint {
  position: fixed;
  bottom: 20px;
  left: 20px;
  font-size: 11px;
  color: #999;
  pointer-events: none;
}

#mainCanvas {
  display: block;
  margin: auto;
  border-radius: 4px;
  cursor: crosshair;
  transform-origin: 0 0;
}

/* 加载覆盖层 */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 8px;
  display: none;
  flex-direction: column;
}

.loading-overlay:not([hidden]) {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ddd;
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 工具栏 */
.toolbar {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tool-section {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 8px 10px;
}

.tool-section h3 {
  font-size: 12px;
  margin-bottom: 6px;
  color: #4a90d9;
}

.hint {
  font-size: 11px;
  color: #999;
  margin: 2px 0;
}

/* 按钮 */
.btn {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  color: #333;
  transition: all 0.2s;
  margin: 1px 0;
}

.btn[hidden] {
  display: none;
}

label.btn[hidden] {
  display: none;
}

.btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}

.btn-primary:hover {
  background: #3a7bc8;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-fg.active {
  background: #28a745;
  color: #fff;
  border-color: #28a745;
}

.btn-bg.active {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}

/* 参数控制 */
.param-control {
  margin: 4px 0;
}

.param-control label {
  display: block;
  font-size: 11px;
  margin-bottom: 2px;
  color: #666;
}

.param-control input[type="range"] {
  width: 100%;
  height: 16px;
}

/* 笔刷控制 */
.brush-controls {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

/* 按钮行 */
.btn-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 4px;
}

/* 背景选项 */
.bg-options {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.bg-options label {
  font-size: 12px;
  width: 100%;
  color: #666;
}

.bg-options .btn.selected {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}

.bg-status {
  font-size: 11px;
  color: #28a745;
  margin: 2px 0;
  font-weight: 600;
}

.bg-adjust {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #eee;
}

.bg-adjust label {
  display: block;
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}

.bg-adjust input[type="range"] {
  width: 100%;
  height: 16px;
}

.bg-options input[type="color"] {
  width: 32px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

/* 错误提示 */
.error-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc3545;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 1000;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 响应式布局 */
@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    overflow-y: visible;
    overflow-x: auto;
  }

  .tool-section {
    min-width: 200px;
    flex: 1;
  }

  .step-indicator {
    font-size: 11px;
  }

  .step {
    padding: 6px 8px;
  }
}
