* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f5f7; color: #1c2127; }

.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 24px; background: #ffffff; border-bottom: 1px solid #e3e6ea; }
.topbar h1 { font-size: 18px; margin: 0; color: #1c2127; }
.size-control, .export-control { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.size-control label, .export-control label { display: flex; align-items: center; gap: 6px; color: #4a5360; }
.size-control input, .size-control select, .export-control select {
  width: 70px; padding: 5px 6px; background: #fff; border: 1px solid #d6dae0; color: #1c2127; border-radius: 4px;
}
.export-control select { width: auto; }
.size-control button, .export-control button {
  padding: 6px 14px; background: #3b82f6; border: none; color: #fff; border-radius: 4px; cursor: pointer; font-weight: 500;
}
.size-control button:hover, .export-control button:hover { background: #2563eb; }
.px-hint { color: #8a93a0; font-size: 12px; }

.layout { display: grid; grid-template-columns: 360px 1fr 300px; gap: 16px; padding: 16px 24px; align-items: start; }

.panels { display: flex; flex-direction: column; gap: 14px; }
.panel { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
.panel-style { border-left: 3px solid #8b5cf6; }
.panel-style #styleSaveBtn { background: #8b5cf6; }
.panel-style #styleSaveBtn:hover { background: #7c3aed; }

.swatch-row { display: flex; gap: 6px; margin: -2px 0 8px; min-height: 22px; }
.swatch-row:empty { margin: 0; }
.swatch-row .swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid #e3e6ea; }
.panel h2 { font-size: 14px; margin: 0 0 6px; color: #1c2127; }
.panel .hint { font-size: 12px; color: #8a93a0; margin: 0 0 10px; line-height: 1.5; }
.panel textarea {
  width: 100%; min-height: 60px; background: #f8f9fb; border: 1px solid #d6dae0; color: #1c2127;
  border-radius: 4px; padding: 8px; font-size: 13px; resize: vertical; margin-bottom: 8px;
}
.panel input[type=file][hidden] { display: none; }
.panel button {
  width: 100%; padding: 8px; background: #3b82f6; border: none; color: #fff; border-radius: 4px;
  cursor: pointer; margin-bottom: 6px; font-size: 13px; font-weight: 500;
}
.panel button:hover { background: #2563eb; }
.panel button:disabled { background: #cbd2da; cursor: not-allowed; }

.panel.paste-target { outline: 2px solid #3b82f6; outline-offset: 2px; }
.dropzone { border: 1px dashed #d6dae0; border-radius: 6px; padding: 8px; margin-bottom: 8px; background: #fafbfc; }
.dropzone button {
  margin-bottom: 0; width: auto; display: block; background: none; color: #8a93a0; font-weight: 400;
  border: 1px dashed #c3cad3; padding: 6px 10px; font-size: 12px;
}
.dropzone button:hover { background: #f0f2f5; color: #4a5360; border-color: #aab2bd; }
.thumb-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.thumb-wrap:empty { display: none; }
.thumb-item { position: relative; width: 56px; height: 56px; border-radius: 4px; overflow: hidden; border: 1px solid #e3e6ea; background: repeating-conic-gradient(#eee 0% 25%, #e2e2e2 0% 50%) 50% / 8px 8px; }
.thumb-item img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-item .remove-btn { position: absolute; top: 0; right: 0; width: 16px; height: 16px; line-height: 16px; text-align: center; background: rgba(0,0,0,0.55); color: #fff; font-size: 11px; cursor: pointer; border-radius: 0 0 0 4px; }

.preview-area { display: flex; flex-direction: column; align-items: center; }
.toggle-label { font-size: 12px; color: #4a5360; display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.preview-area h2 { font-size: 14px; align-self: flex-start; margin: 0 0 4px; }
.preview-area .hint { font-size: 12px; color: #8a93a0; align-self: flex-start; margin: 0 0 10px; line-height: 1.5; }

.canvas-wrapper { max-width: 100%; }
.canvas-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-bottom: 8px; }
.canvas-toolbar button {
  padding: 5px 12px; background: #fff; border: 1px solid #d6dae0; color: #4a5360; border-radius: 4px;
  cursor: pointer; font-size: 12px; font-weight: 500;
}
.canvas-toolbar button:hover { background: #f0f2f5; border-color: #aab2bd; }
#stage-container { background: repeating-conic-gradient(#e9e9e9 0% 25%, #f4f4f4 0% 50%) 50% / 20px 20px; border: 1px solid #e3e6ea; border-radius: 6px; max-width: 100%; max-height: 75vh; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.status { font-size: 12px; color: #8a93a0; min-height: 16px; }
.status.status-warning { color: #b45309; font-weight: 500; }

.history-panel { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 14px; max-height: 85vh; overflow-y: auto; }
.history-panel h2 { font-size: 14px; margin: 0 0 10px; }
.history-group { margin-bottom: 18px; }
.history-group h3 { font-size: 12px; color: #8a93a0; margin: 0 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.history-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hist-item { cursor: pointer; border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: #f8f9fb; aspect-ratio: 1; }
.hist-item img { width: 100%; height: 100%; object-fit: contain; display: block; background: repeating-conic-gradient(#eee 0% 25%, #e2e2e2 0% 50%) 50% / 8px 8px; }
.hist-item.active { border-color: #3b82f6; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}
