/*  =====  基础重置  =====  */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  overflow: hidden;
}

/*  =====  通用工具（原子类）  =====  */
.w-full { width: 100%; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-2 { margin-top: 8px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-gray-500 { color: #95a5a6; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/*  =====  按钮体系  =====  */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  display: inline-block;
}
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-primary {
  background: #3498db;
  color: #fff;
}
.btn-primary:hover { background: #2980b9; }
.btn-secondary {
  background: #34495e;
  color: #fff;
}
.btn-secondary:hover { background: #2c3e50; }
.btn-danger {
  background: #e74c3c;
  color: #fff;
}
.btn-danger:hover { background: #c0392b; }

/*  =====  应用框架  =====  */
.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.top-bar {
  background: #2c3e50;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
  flex: 0 0 auto;
}
.logo h1 { font-size: 24px; margin-bottom: 4px; }
.logo span { font-size: 14px; opacity: .8; }
.actions { display: flex; align-items: center; gap: 12px; }

/*  =====  主体三栏  =====  */
.main-content { flex: 1; display: flex; overflow: hidden; }

/*  -----  左侧面板  -----  */
.left-panel {
  width: 260px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.panel-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #2c3e50;
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tool-btn {
  padding: 16px;
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 24px;
  transition: all .2s;
}
.tool-btn:hover {
  border-color: #3498db;
  background: #f8f9fa;
}
.tool-btn.active {
  background: #34495e !important;
  color: #fff !important;
  border-color: #2c3e50 !important;
}
.template-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.template-item {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
}
.template-item:hover {
  border-color: #3498db;
  transform: translateY(-2px);
}
.template-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}
.template-item span {
  display: block;
  padding: 4px;
  font-size: 12px;
  text-align: center;
}
.asset-library {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.asset-item {
  width: 60px;
  height: 60px;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  transition: all .2s;
}
.asset-item:hover {
  border-color: #3498db;
  transform: scale(1.05);
}
.asset-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

/*  -----  画布区域  -----  */
.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ecf0f1;
  padding: 20px;
  overflow: hidden;
}
.canvas-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: auto;
}
#canvasOuter {
  position: relative;
  background: #f0f0f0;
  margin: 20px;
  pointer-events: none;
  border: 1px dashed #bdc3c7;
}
#canvasInner {
  position: absolute;
  top: 150px;
  left: 150px;
  box-shadow: 0 0 0 2px #3498db;
  z-index: 10;
  pointer-events: all;
}
.canvas-info {
  margin-top: 12px;
  font-size: 12px;
  color: #7f8c8d;
}

/*  -----  右侧面板  -----  */
.right-panel {
  width: 300px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  padding: 20px;
  overflow-y: auto;
}
.right-panel h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: #2c3e50;
  padding-bottom: 10px;
  border-bottom: 2px solid #3498db;
}
#propertiesPanel {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
}
.property-section {
  background: #fff;
  padding: 8px;
  border-radius: 4px;
}
.section-title {
  color: #3498db;
  font-weight: 700;
  font-size: 14px;
  display: block;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e0e0e0;
}
.property-row {
  margin-bottom: 12px;
}
.property-row:last-child { margin-bottom: 0; }
.property-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.property-row.two-cols > div {
  display: flex;
  flex-direction: column;
}
.property-row label {
  font-size: 12px;
  color: #7f8c8d;
  margin-bottom: 4px;
  font-weight: 500;
}
.property-row input,
.property-row select,
.property-row textarea {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  transition: border-color .2s;
}
.property-row input:focus,
.property-row select:focus,
.property-row textarea:focus {
  border-color: #3498db;
  outline: none;
}
.slider-row {
  margin-top: 8px;
}
.slider-row input[type="range"] {
  margin: 6px 0;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  background: #3498db;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.slider-row .value-display {
  float: right;
  font-size: 12px;
  color: #3498db;
  font-weight: 700;
}
#layersList {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.layer-item {
  padding: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  background: #fff;
  transition: all .2s;
}
.layer-item:hover { border-color: #bdc3c7; }
.layer-item.active {
  background: #e3f2fd;
  border-color: #3498db;
  box-shadow: 0 2px 4px rgba(52, 152, 219, .2);
}
.layer-controls { display: flex; gap: 4px; }
.layer-btn {
  padding: 2px 6px;
  border: none;
  background: #f5f5f5;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  transition: all .2s;
}
.layer-btn:hover {
  background: #3498db;
  color: #fff;
  transform: scale(1.1);
}
.align-controls.two-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.align-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.align-controls button {
  font-size: 18px;
  padding: 8px 12px;
  min-width: 40px;
}
.context-menu {
  position: absolute;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  z-index: 3000;
  min-width: 150px;
}
.menu-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f5f5f5;
  transition: background .2s;
}
.menu-item:hover { background: #f0f0f0; }
.menu-item:last-child { border-bottom: none; }
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h2 { margin-bottom: 16px; }
@media (max-width: 900px) {
  .left-panel { width: 220px; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .left-panel,
  .right-panel { display: none; }
  .canvas-container { padding: 10px; }
}