body,
html {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f0f0f0;
}

#toolbar {
  height: 40px;
  background: #333;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  box-sizing: border-box;
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#toolbar .group {
  display: flex;
  align-items: center;
  gap: 10px;
}

#toolbar select,
#toolbar button {
  font-size: 12px;
  padding: 4px 10px;
  height: 28px;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: 4px;
  border: none;
  outline: none;
  background: #444;
  color: white;
  transition: all 0.2s;
}

#toolbar select:hover,
#toolbar button:hover,
#toolbar select:focus,
#toolbar button:focus {
  background: #555;
  outline: none;
}

#toolbar select {
  width: auto;
  min-width: 100px;
}

#rulerContainer {
  height: calc(100% - 40px);
  width: 100%;
  position: relative;
  display: flex;
  background: #e0e0e0;
  overflow: auto;
}

/* 独立窗口模式下，尺子本体始终保持 60px 宽度/高度 */
#rulerSvg {
  display: block;
  background-color: #dcb35c;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

/* 横向尺子样式 */
#rulerContainer.horizontal {
  align-items: flex-start;
  padding-top: 20px;
}
#rulerContainer.horizontal #rulerSvg {
  width: 100%;
  height: 60px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6 0.005' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 纵向尺子样式 */
#rulerContainer.vertical {
  justify-content: center;
  padding-left: 20px;
  flex-direction: row;
}
#rulerContainer.vertical #rulerSvg {
  width: 60px;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.005 0.6' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.25 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 模态框样式 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  width: min(90%, 700px);
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  color: #333;
}

.modal-content h3 {
  margin-top: 0;
  border-bottom: 1px solid #eee;
  padding-bottom: 15px;
  margin-bottom: 20px;
}

#calibrationBoxContainer {
  margin: 20px 0;
  border: 2px dashed #ddd;
  padding: 40px 0;
  display: flex;
  align-items: center;
  height: 250px;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  background: #f9f9f9;
}

#calibrationBoxTrack {
  min-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 40px;
}

#calibrationBox {
  flex: 0 0 auto;
  box-sizing: border-box;
  border: 2px solid #ff4757;
  background: rgba(255, 71, 87, 0.1);
  box-shadow: 0 0 15px rgba(255, 71, 87, 0.2);
}

/* 颜色选择器组件 */
.color-selector {
  position: relative;
}

.color-trigger {
  width: 120px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid #666;
  user-select: none;
  box-sizing: border-box;
  color: #000;
}

.color-options-list {
  position: absolute;
  top: 40px;
  width: 120px;
  display: none;
  flex-direction: column;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  border: 1px solid #555;
  z-index: 1000;
}

.color-opt {
  padding: 6px 10px;
  color: #000;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
}

.color-opt:hover {
  filter: brightness(0.9);
}

.step {
  margin-bottom: 20px;
  font-size: 14px;
}

.step select {
  margin-left: 10px;
  padding: 5px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}

#ppiSlider {
  flex: 1;
  cursor: pointer;
}

.ppi-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ppi-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f2f6;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  transition: all 0.2s;
  padding: 0;
}

.ppi-btn:hover {
  background: #e1e2e6;
  border-color: #ccc;
}

.ppi-btn:active {
  background: #d1d2d6;
  transform: translateY(1px);
}

.ppi-display {
  font-weight: bold;
  background: #f1f2f6;
  padding: 5px 12px;
  border-radius: 4px;
  min-width: 120px;
  text-align: center;
}

.actions {
  display: flex;
  gap: 15px;
  margin-top: 25px;
}

#saveCalibration {
  background: #2ed573;
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  flex: 2;
  transition: background 0.2s;
}

#saveCalibration:hover {
  background: #26af5f;
}

#closeModal {
  padding: 12px 25px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #ccc;
  background: white;
  flex: 1;
}
