:root {
  --pink: #ff5a6e;
  --pink-2: #e23;
  --line: #ececec;
  --muted: #9aa0a6;
  --bg: #f7f8fa;
  --card: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, Arial, sans-serif; background: var(--bg); color: #222; }
.top { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line); z-index: 10; }
.brand { font-weight: 800; font-size: 17px; }
.brand small { font-weight: 600; color: var(--muted); font-size: 12px; margin-left: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: none; border-radius: 20px; padding: 9px 16px; font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.btn.primary { background: var(--pink); color: #fff; }
.btn.ghost { background: #f0f0f0; color: #333; }
.wrap { max-width: 920px; margin: 18px auto; padding: 0 16px 60px; }
.picker { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.picker select { flex: 1; max-width: 380px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #555; }
.field input[type=number], .field input[type=text], .field input[type=color], .field select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.field input[type=color] { height: 34px; padding: 2px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #333; margin-right: 14px; }
.toggle input { accent-color: var(--pink); width: 16px; height: 16px; }
.cat { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; }
.cat.d1 { margin-left: 0; }
.cat.d2 { margin-left: 30px; margin-top: 4px; border-left: 3px solid var(--pink); border-top-left-radius: 0; background: #fbfcfe; }
.cat.d2:before { content: "└"; color: var(--muted); font-size: 14px; position: absolute; left: -18px; top: 12px; }
.cat { position: relative; }
.cat-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 14px; padding: 4px 2px; user-select: none; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.cat.drop-before { box-shadow: 0 -3px 0 0 var(--pink); }
.cat.drop-after { box-shadow: 0 3px 0 0 var(--pink); }
.cat-cover { width: 64px; height: 72px; border-radius: 8px; border: 1px dashed var(--line); background: #f0f0f0 center/cover no-repeat; cursor: pointer; flex: 0 0 auto; }
.cat-cover.has { border: 2px solid var(--pink); }
.cat-head .cat-label { font-weight: 700; font-size: 13px; min-width: 90px; }
.cat-head input[type=text] { flex: 1; min-width: 140px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.mini { border: none; background: #f0f0f0; color: #333; border-radius: 12px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.mini.danger { background: #ffe9ec; color: var(--pink-2); }
.mini.add { background: #fff0f5; color: var(--pink); }
.tpl { display: grid; grid-template-columns: minmax(160px, 1fr) 116px 32px; gap: 8px; align-items: center; margin-top: 8px; padding: 6px 8px; background: #fafafa; border-radius: 10px; }
.tpl .nm { display: flex; flex-direction: column; gap: 2px; }
.tpl .nm input { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.tpl-img { display: flex; align-items: center; gap: 4px; }
.tpl-img-prev { width: 28px; height: 38px; border-radius: 6px; border: 1px solid var(--line); background: #f0f0f0 center/cover no-repeat; flex: 0 0 auto; }
.tpl-img-prev.has { border-color: var(--pink); }
.tpl-img .mini { padding: 4px 6px; font-size: 11px; }
.tpl .rm { background: none; border: none; color: var(--pink-2); font-size: 16px; cursor: pointer; }

/* 模板横向卡片 + “+”批量新增框 */
.tpl-strip { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-top: 10px; }
.tpl-card { width: 96px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fafafa; display: flex; flex-direction: column; gap: 5px; position: relative; }
.tpl-thumb { width: 100%; height: 112px; border-radius: 8px; border: 1px solid var(--line); background: #f0f0f0 center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.tpl-thumb.has { border-color: var(--pink); }
.tpl-card input { width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.tpl-del { position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; background: var(--pink); color: #fff; border: none; font-size: 12px; cursor: pointer; line-height: 1; }
.tpl-add { width: 96px; height: 152px; border: 2px dashed var(--pink); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--pink); background: #fff0f5; }
.tpl-add .plus { font-size: 26px; line-height: 1; }
.tpl-add .add-tip { font-size: 10px; text-align: center; color: var(--pink); }
.tpl-add.drag-over, .ast-add.drag-over { border-color: #1a7f37; background: #e6f7ee; color: #1a7f37; box-shadow: 0 0 0 3px rgba(26,127,55,.15); }

/* 素材库 */
.asset-card { background: var(--card); }
.ast-cat { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-top: 8px; }
.ast-cat .cat-head input[type=text] { flex: 1; min-width: 120px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.ast-strip { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 8px; }
.ast-card { width: 76px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fafafa; position: relative; }
.ast-thumb { width: 100%; height: 72px; border-radius: 6px; border: 1px solid var(--line); background: #f0f0f0 center/cover no-repeat; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.ast-name { display: block; width: 100%; background: rgba(255,255,255,.85); font-size: 10px; color: #444; padding: 2px 3px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ast-thumb { position: relative; }
.ast-ref { position: absolute; left: 3px; top: 3px; background: var(--pink); color: #fff; border-radius: 8px; padding: 1px 6px; font-size: 10px; font-weight: 700; line-height: 1.3; z-index: 2; }
.ast-del { position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--pink); color: #fff; border: none; font-size: 11px; cursor: pointer; line-height: 1; }
.ast-add { width: 76px; height: 88px; border: 2px dashed var(--pink); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; color: var(--pink); background: #fff0f5; }
.ast-add .plus { font-size: 22px; line-height: 1; }
.ast-add .add-tip { font-size: 9px; text-align: center; color: var(--pink); }

/* 从素材库选 弹层 */
.asset-picker-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: center; justify-content: center; }
.asset-picker { width: min(680px, 92vw); max-height: 82vh; background: #fff; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.asset-picker-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.asset-picker-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.asset-picker-grid { display: flex; flex-wrap: wrap; gap: 12px; overflow: auto; max-height: 50vh; align-content: flex-start; }
.asset-card.pick { width: 118px; border: 2px solid transparent; border-radius: 10px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); transition: border-color .15s, transform .1s; }
.asset-card.pick .asset-thumb { position: relative; width: 100%; height: 150px; border-radius: 8px; overflow: hidden; cursor: pointer; background: #f0f0f0 center/cover no-repeat; }
.asset-card.pick .asset-thumb::after { content: ""; position: absolute; inset: 0; background: rgba(233,15,115,.22); opacity: 0; transition: opacity .15s; pointer-events: none; }
.asset-card.pick.sel { border-color: var(--pink); }
.asset-card.pick.sel .asset-thumb::after { opacity: 1; }
.asset-card.pick:hover { border-color: var(--pink); transform: translateY(-1px); }
.asset-card.pick .asset-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 5px 4px; background: rgba(255,255,255,.92); font-size: 11px; line-height: 1.2; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.asset-picker-foot { display: flex; gap: 10px; align-items: center; }
.asset-picker-foot .btn { border-radius: 10px; padding: 8px 14px; font-size: 12px; }
.asset-picker-foot .btn.primary { background: var(--pink); color: #fff; border: 1px solid var(--pink); }
.asset-picker-foot .btn.primary:hover { background: #d10d63; }
.asset-picker-foot .btn.ghost { background: #fff; border: 1px solid var(--line); color: #333; }
.asset-picker-foot .btn.ghost:hover { border-color: var(--pink); color: var(--pink); }
.asset-picker-foot .btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 520px) { .asset-card.pick { width: 104px; } .asset-card.pick .asset-thumb { height: 132px; } }
.json summary { cursor: pointer; font-weight: 700; font-size: 13px; margin-bottom: 8px; }
#jsonArea { width: 100%; min-height: 260px; font-family: Consolas, monospace; font-size: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.json-btns { display: flex; gap: 8px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 11px; margin: 2px 0 6px; }

/* 文字模块编辑器：位置 / 颜色 / 字体 列表 */
.sub { font-weight: 700; font-size: 12px; color: #555; margin: 12px 0 6px; }
.rowline { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.rowline input[type=text], .rowline input[type=number], .rowline input[type=color], .rowline select {
  padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; font-size: 12px; }
.rowline input[type=number] { width: 70px; }
.rowline input[type=color] { width: 38px; height: 30px; padding: 2px; }
.rowline select { width: auto; }
.rowline .grow { flex: 1 1 120px; min-width: 120px; }
.rowline .mini-w { width: 60px; }
.rowline .mini { flex: 0 0 auto; }
.row-actions { margin: 6px 0 2px; }

/* 字体自定义下拉：每个选项用真实字体渲染 */
.font-dd { position: relative; flex: 1 1 150px; min-width: 150px; }
.font-dd-btn { width: 100%; display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; font-size: 12px; text-align: left; }
.font-dd-btn .font-swatch { font-size: 18px; line-height: 1; color: #222; flex: 0 0 auto; }
.font-dd-btn .font-name { flex: 1; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-dd-btn .font-caret { color: var(--muted); font-size: 10px; }
.font-dd-panel { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  min-width: 230px; max-width: 340px; max-height: 300px; overflow: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; }
.font-dd.open .font-dd-panel { display: block; }
.font-opt { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.font-opt:hover { background: #f5f5f5; }
.font-opt.sel { background: #fff0f5; }
.font-opt .fo-sample { font-size: 18px; line-height: 1; color: #222; flex: 0 0 auto; width: 30px; }
.font-opt .fo-name { color: #333; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #111; color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 13px; opacity: 0; transition: .2s; z-index: 40; pointer-events: none; }
.toast.show { opacity: 1; }

/* 双栏：左编辑 + 右实时预览 */
.wrap.layout { max-width: 1400px; display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .wrap.layout { grid-template-columns: 1fr; } }
.preview-col { position: sticky; top: 62px; }
.preview-card iframe { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: block; }
.preview-card .hint { margin: 0; }

/* 店匠商品 / 分类目录 */
.catalog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.catalog-head h3 { margin: 0; }
.catalog-card .catalog-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.catalog-split { display: grid; grid-template-columns: 1fr 1.6fr; gap: 14px; }
@media (max-width: 720px) { .catalog-split { grid-template-columns: 1fr; } }
.catalog-collections, .catalog-products { border: 1px dashed var(--line); border-radius: 12px; padding: 10px; background: #fbfcfe; }
.catalog-collections .sub, .catalog-products .sub { font-weight: 700; font-size: 12px; color: #555; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 5px 11px; font-size: 12px; cursor: pointer; color: #444; }
.chip .num { color: var(--muted); font-size: 10px; margin-left: 3px; }
.chip.active { background: var(--pink); border-color: var(--pink); color: #fff; }
.prods { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow: auto; }
.prod { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.prod.active { border-color: var(--pink); background: #fff6f8; }
.prod .t { font-size: 13px; font-weight: 700; }
.prod .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.badge.bound { background: #e6f7ee; color: #0a7d3f; }
.badge.unbound { background: #fff0f0; color: var(--pink-2); }
.catalog-bind { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.catalog-bind b { color: var(--pink-2); }
.catalog-bind select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.mini.primary { background: var(--pink); color: #fff; }
