.container {
  display: flex;
  padding: 20px;
  gap: 20px;
  height: 100vh;
  box-sizing: border-box;
  flex-direction: column;
}

.tools {
  width: 200px;
  height: calc(100vh - 40px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

.tools::-webkit-scrollbar {
  width: 6px;
}

.tools::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.tools::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.tools::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.color-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 10px;
  padding-bottom: 20px;
}

.color-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 5px;
  background-color: white;
  position: relative;
}

.color-item:hover {
  background-color: #f0f0f0;
}

.color-item.active {
  border-color: #333;
}

.color-preview {
  width: 30px;
  height: 30px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-right: 10px;
}

#canvas {
  border: 1px solid #ccc;
  width: 800px;
  height: calc(100vh - 40px);
  background-color: white;
  object-fit: contain;
}

path {
  stroke: #000;
  stroke-width: 1;
  cursor: pointer;
  fill: transparent;
  transition: fill 0.3s ease;
}

path.highlight {
  stroke: #000;
  stroke-width: 2;
  cursor: pointer;
}

path:hover {
  opacity: 0.8;
}

.color-number {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  color: #666;
  font-family: monospace;
  margin-right: 8px;
}

.canvas-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.canvas-controls {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 5px;
}

.zoom-btn {
  padding: 8px 16px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.zoom-btn:hover {
  background: #f0f0f0;
}

.canvas-wrapper {
  position: relative;
  overflow: hidden;
  flex: 1;
  border: 1px solid #ccc;
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

#canvas {
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease;
  cursor: grab;
  object-fit: contain;
  transform-origin: center center;
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  preserveaspectratio: xMidYMid meet;
}

#canvas:active {
  cursor: grabbing;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ff4444;
  color: white;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

path.shake {
  animation: shake 0.5s ease-in-out infinite;
}

.progress-info {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress {
  font-size: 14px;
  color: #666;
  font-family: monospace;
}

.checkmark {
  color: #4caf50;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.color-item.completed .checkmark {
  opacity: 1;
}

.color-item.completed {
  background-color: #f8fff8;
}

.color-item.completed .progress {
  color: #4caf50;
}

.mode-switch {
  display: flex;
  align-items: center;
  padding: 10px;
  margin-bottom: 10px;
  background: #f5f5f5;
  border-radius: 5px;
}

.mode-label {
  margin-left: 10px;
  font-size: 14px;
  color: #666;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4caf50;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.color-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 70px;
}

.color-code {
  font-size: 12px;
  color: #666;
  font-family: monospace;
}

.path-label {
  font-size: 14px;
  font-family: monospace;
  fill: #666;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.3s ease;
}

/* 移除之前的白色文本样式 */
path[fill]:not([fill="transparent"]) + text.path-label {
  opacity: 0;
}

@keyframes hint-flash {
  0%,
  100% {
    stroke-width: 2;
    stroke: #000;
    fill: rgba(255, 68, 68, 0);
    transform: scale(1);
  }
  50% {
    stroke-width: 4;
    stroke: #ff4444;
    fill: rgba(255, 68, 68, 0.2);
    transform: scale(1.05);
  }
}

path.hint-flash {
  animation: hint-flash 0.8s ease-in-out infinite;
  transform-origin: center;
  transform-box: fill-box;
}

/* 添加文本闪烁效果 */
@keyframes text-flash {
  0%,
  100% {
    fill: #666;
    font-size: 14px;
  }
  50% {
    fill: #ff4444;
    font-size: 18px;
  }
}

text.path-label.hint-flash {
  animation: text-flash 0.8s ease-in-out infinite;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
  .container {
    flex-direction: column;
    height: 100vh;
    margin: 0;
    padding: 0;
    gap: 0;
  }

  .tools {
    width: 100%;
    height: 200px;
    flex-shrink: 0;
    padding: 10px;
  }

  .canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    width: 100%;
  }

  .canvas-controls {
    flex-wrap: wrap;
    justify-content: center;
    padding: 5px;
  }

  .canvas-wrapper {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
  }

  #canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    touch-action: none;
    transform-origin: center center;
    preserveaspectratio: xMidYMid meet;
  }

  /* 调整其他元素大小 */
  .zoom-btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .color-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding: 10px;
    gap: 8px;
    overflow-y: auto;
  }
}
