* { box-sizing: border-box; margin: 0; padding: 0; }
:root { --sideW: 372px; } /* 侧栏宽 = 预览区最小宽 */
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: #2b2e33; color: #e8e8e8; display: flex; flex-direction: column;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: #202329; border-bottom: 1px solid #3a3e46;
  flex: 0 0 auto; gap: 12px; flex-wrap: wrap;
}
header h1 { font-size: 17px; font-weight: 700; letter-spacing: 1px; color: #f5d76e; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
button {
  background: #3a3f47; color: #e8e8e8; border: 1px solid #555b64; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
}
button:hover { background: #4a505a; }
button.primary { background: #7ca43f; border-color: #94c054; color: #fff; font-weight: 700; }
button.primary:hover { background: #8db84c; }
button.mini { padding: 2px 8px; font-size: 12px; border-radius: 4px; }
button.danger:hover { background: #a4433f; border-color: #c05a56; }
select, input[type="text"] {
  background: #33373d; color: #eee; border: 1px solid #555b64; border-radius: 5px;
  padding: 5px 8px; font-size: 13px; font-family: inherit;
}
input[type="number"] {
  background: #33373d; color: #eee; border: 1px solid #555b64; border-radius: 5px;
  padding: 4px 6px; font-size: 12.5px; font-family: inherit; width: 46px;
  appearance: textfield; -moz-appearance: textfield; /* 隐藏加减号 */
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="color"] { width: 34px; height: 26px; padding: 1px 2px; border: 1px solid #555b64; border-radius: 5px; background: #33373d; cursor: pointer; }
input[type="range"] { width: 110px; accent-color: #7ca43f; }
input[type="checkbox"] { accent-color: #7ca43f; }
.scale-label { font-size: 13px; display: flex; align-items: center; gap: 6px; }

main { flex: 1 1 auto; display: flex; min-height: 0; overflow-x: auto; }
#sidebar {
  flex: 0 0 var(--sideW); overflow-y: auto; background: #26292e; border-right: 1px solid #3a3e46;
  padding: 14px; display: flex; flex-direction: column; gap: 14px;
}
#previewWrap {
  flex: 1 1 auto; min-width: var(--sideW); overflow: auto; padding: 0 22px 22px; display: block;
  background: repeating-conic-gradient(#33363c 0% 25%, #2b2e33 0% 50%) 0 0 / 22px 22px;
}
#zoomBar {
  position: sticky; top: 0; z-index: 6; width: max-content; margin: 0 auto 16px;
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: rgba(32,35,41,.95); border: 1px solid #3a3e46; border-top: none;
  border-radius: 0 0 8px 8px;
}
#zPct { min-width: 46px; text-align: center; font-size: 12px; color: #c9cdd3; }
#canvasBox { width: max-content; margin: 0 auto; position: relative; }
#preview { display: block; box-shadow: 0 6px 30px rgba(0,0,0,.5); border-radius: 4px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.drag-ghost {
  position: absolute; z-index: 9; pointer-events: none; display: none;
  opacity: .85; border-radius: 8px; box-shadow: 0 10px 26px rgba(0,0,0,.55); border: 2px solid #fff;
}
.drop-hl {
  position: absolute; z-index: 8; pointer-events: none; display: none;
  outline: 3px solid #9fd06a; outline-offset: 2px; border-radius: 10px;
  background: rgba(159,208,106,.15);
}

.group { background: #2e3238; border: 1px solid #3d424a; border-radius: 8px; padding: 12px; }
.group > h3 { font-size: 13px; color: #f5d76e; margin-bottom: 10px; letter-spacing: 1px; }
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.row:last-child { margin-bottom: 0; }
.row label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #c9cdd3; }
.row input[type="text"] { flex: 1 1 auto; min-width: 60px; }
.row .grow { flex: 1 1 auto; }

.sec { background: #2e3238; border: 1px solid #3d424a; border-radius: 8px; padding: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sec-head b { font-size: 13px; color: #9fd06a; }
.sec-head .ops { display: flex; gap: 5px; }
.thumb {
  width: 62px; height: 46px; object-fit: cover; border-radius: 5px;
  border: 1px solid #555b64; background: #22252a;
}
.thumb.sq { width: 46px; height: 46px; }
.cards-box { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-item { position: relative; width: 58px; }
.card-item img { width: 58px; height: 80px; object-fit: cover; border-radius: 5px; border: 1px solid #555b64; display: block; user-select: none; }
.card-item .c-ops { display: flex; justify-content: center; gap: 2px; margin-top: 2px; }
.card-item .c-ops button { padding: 0 4px; font-size: 11px; border-radius: 3px; }
.extra-box { border-left: 3px solid #7ca43f; padding-left: 8px; margin: 6px 0 8px 2px; }
.hint { font-size: 11.5px; color: #8b919b; line-height: 1.6; }
#sidebar::-webkit-scrollbar, #previewWrap::-webkit-scrollbar { width: 9px; height: 9px; }
#sidebar::-webkit-scrollbar-thumb, #previewWrap::-webkit-scrollbar-thumb { background: #4a4f57; border-radius: 5px; }

/* 拖拽排序 */
.card-item[draggable="true"] { cursor: grab; }
.card-item.drag-over img { outline: 2px solid #9fd06a; outline-offset: 1px; }
