* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== 顶部工具栏 ===== */
#top-toolbar {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  height: 52px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  z-index: 100;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: #e0e0e0;
  margin: 0 6px;
}

.toolbar-right {
  margin-left: auto;
}

#top-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: #1b1f23;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

#top-toolbar button:hover {
  background: #f0f0f0;
}

#top-toolbar button:active {
  background: #e0e0e0;
}

#btn-export-png,
#btn-export-svg {
  width: auto;
  padding: 0 12px;
  font-size: 12px;
}

/* ===== 绘图工具按钮（顶部横排） ===== */
.tool-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: #1b1f23;
  transition: background 0.15s, color 0.15s;
}

.shortcut-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  color: #868e96;
  background: rgba(255,255,255,0.85);
  border-radius: 3px;
  padding: 1px 3px;
  pointer-events: none;
}

.tool-btn.active .shortcut-badge {
  color: #5b57d1;
}

.tool-btn:hover {
  background: #f0f0f0;
}

.tool-btn.active {
  background: #eef0ff;
  color: #5b57d1;
}

/* ===== 右侧编辑面板 ===== */
#properties-panel {
  position: fixed;
  top: 64px;
  left: 12px;
  bottom: 12px;
  width: 220px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  transition: opacity 0.2s, transform 0.2s;
  overflow: hidden;
}

#properties-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-12px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  font-weight: 700;
  color: #1b1f23;
}

#btn-close-panel {
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

#btn-close-panel:hover {
  background: #f0f0f0;
  color: #1b1f23;
}

.panel-body {
  padding: 10px 14px 14px;
  overflow-y: auto;
  flex: 1;
}

.prop-section {
  margin-bottom: 14px;
}

.prop-section:last-child {
  margin-bottom: 0;
}

.prop-section label {
  display: block;
  font-size: 11px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.color-palette {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #5b57d1;
}

.stroke-width-btn,
.fill-style-btn,
.stroke-style-btn,
.roughness-btn {
  height: 30px;
  padding: 0 8px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  color: #1b1f23;
  transition: all 0.15s;
}

.stroke-width-btn:hover,
.fill-style-btn:hover,
.stroke-style-btn:hover,
.roughness-btn:hover {
  background: #f0f0f0;
}

.stroke-width-btn.active,
.fill-style-btn.active,
.stroke-style-btn.active,
.roughness-btn.active {
  background: #eef0ff;
  border-color: #5b57d1;
  color: #5b57d1;
}

.stroke-width-group,
.fill-style-group,
.stroke-style-group,
.roughness-group {
  display: flex;
  gap: 4px;
}

/* 不透明度滑块 */
.opacity-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opacity-group input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #e0e0e0;
  border-radius: 2px;
  outline: none;
}

.opacity-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5b57d1;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#opacity-value {
  font-size: 11px;
  color: #666;
  min-width: 32px;
  text-align: right;
}

/* 图层按钮 */
.layer-group {
  display: flex;
  gap: 4px;
}

.layer-btn {
  width: 36px;
  height: 30px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  color: #1b1f23;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.layer-btn:hover {
  background: #f0f0f0;
}

.layer-btn:active {
  background: #e0e0e0;
}

/* 删除按钮 */
#btn-delete-element {
  width: 100%;
  height: 32px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #fa5252;
  transition: all 0.15s;
}

#btn-delete-element:hover {
  background: #fff5f5;
  border-color: #fa5252;
}

/* ===== 画布 ===== */
#canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  z-index: 1;
}

/* ===== 缩放控制 ===== */
#zoom-controls {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#zoom-controls button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: #1b1f23;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#zoom-controls button:hover {
  background: #f0f0f0;
}

#zoom-level {
  font-size: 12px;
  color: #666;
  min-width: 48px;
  text-align: center;
  font-weight: 600;
}

/* ===== 文字输入框 ===== */
.text-input-overlay {
  position: fixed;
  z-index: 300;
  background: rgba(255,255,255,0.9);
  border: 2px solid #5b57d1;
  border-radius: 4px;
  outline: none;
  font-family: 'Architects Daughter', 'Long Cang', 'Segoe UI Emoji', sans-serif;
  font-size: 28px;
  color: #1b1f23;
  padding: 4px 6px;
  min-width: 100px;
  min-height: 30px;
  resize: none;
  overflow: hidden;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
}

/* ===== 光标样式 ===== */
.cursor-select { cursor: default !important; }
.cursor-crosshair { cursor: crosshair !important; }
.cursor-text { cursor: text !important; }
.cursor-grab { cursor: grab !important; }
.cursor-grabbing { cursor: grabbing !important; }
.cursor-eraser { cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="none" stroke="%23666" stroke-width="1.5"/></svg>') 12 12, auto !important; }
