/* ==================== 在线海报制作（对象化画布） ==================== */
.pst-card { overflow: hidden; }

.pst-head {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start;
    justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.pst-head-text { flex: 1 1 380px; min-width: 0; }
.pst-head-text .seo-h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.pst-head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* 画布在左（1fr）、操作栏在右（420px）；DOM 顺序仍是面板在前，用 order 交换 */
.pst-shell { display: grid; grid-template-columns: minmax(0, 1fr) 420px; min-height: 640px; }
.pst-preview { order: 1; }
.pst-panel { order: 2; }
@media (max-width: 900px) { .pst-shell { grid-template-columns: 1fr; } }

/* ---------- 右侧操作栏 ---------- */
.pst-panel {
    border-left: 1px solid var(--border); background: #fcfcfd; padding: 4px 16px 20px;
    max-height: 78vh; overflow-y: auto;
    scrollbar-gutter: stable; /* 预留滚动条槽位，滚动条出现/消失不引起横向抖动 */
}
@media (max-width: 900px) { .pst-panel { border-left: 0; border-top: 1px solid var(--border); max-height: none; } }

.pst-sec { padding: 14px 0; border-bottom: 1px solid var(--border); }
.pst-sec:last-child { border-bottom: 0; }
.pst-sec-title { font-size: .92rem; font-weight: 700; color: var(--text); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }

.pst-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 34px; }
.pst-row:first-of-type { margin-top: 0; }
.pst-row > label:first-child { flex: 0 0 58px; font-size: .82rem; color: var(--text-dim); margin: 0; }
.pst-row .form-select, .pst-row .form-control { flex: 1 1 auto; min-width: 0; font-size: .82rem; }
.pst-row input[type="range"] { flex: 1 1 auto; min-width: 70px; accent-color: var(--accent); height: 22px; }
.pst-row-inline .form-control { flex: 1 1 70px; }
.pst-unit { flex: 0 0 auto; font-size: .76rem; color: var(--text-dim); white-space: nowrap; min-width: 30px; }
.pst-row textarea { resize: vertical; font-size: .82rem; }
.pst-color {
    flex: 0 0 40px; width: 40px; height: 30px; padding: 2px; border: 1px solid var(--field-border);
    border-radius: 6px; background: #fff; cursor: pointer;
}
.pst-checks { display: flex; gap: 10px; align-items: center; flex: 0 0 auto; }
.pst-checks label { white-space: nowrap; margin: 0; display: inline-flex; align-items: center; gap: 3px; }
.pst-mini-tip { margin: 8px 0 0; font-size: .72rem; color: var(--text-dim); line-height: 1.5; }

/* ---------- 背景类型切换 ---------- */
.pst-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.pst-tab {
    flex: 1 1 0; padding: 5px 4px; font-size: .8rem; border: 1px solid var(--border);
    background: #fff; color: var(--text-dim); border-radius: 6px; cursor: pointer;
}
.pst-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pst-pane { display: none; }
.pst-pane.active { display: block; }

/* ---------- 渐变 / 样例图 / 图标选择 ---------- */
.pst-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.pst-swatch {
    position: relative; aspect-ratio: 1.45 / 1; border-radius: 6px; border: 2px solid transparent;
    cursor: pointer; padding: 0; overflow: hidden; background: #eee;
}
.pst-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 1px #fff inset; }
.pst-swatch .pst-swatch-ico { width: 100%; height: 100%; display: block; }
.pst-samples { grid-template-columns: repeat(3, 1fr); }
.pst-samples .pst-swatch { aspect-ratio: 1.6 / 1; }
.pst-samples .pst-swatch img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- 背景上传 ---------- */
.pst-drop {
    border: 1px dashed var(--field-border); border-radius: 8px; padding: 12px 10px; text-align: center;
    background: #fff; cursor: pointer; margin-top: 10px; transition: border-color .15s, background .15s;
}
.pst-drop:hover, .pst-drop.dragover { border-color: var(--accent); background: #fff8f5; }
.pst-drop.has-image { border-style: solid; }
.pst-drop-title { margin: 0; font-size: .8rem; color: var(--text); }
.pst-drop-sub { margin: 2px 0 0; font-size: .72rem; color: var(--text-dim); }

/* ---------- 遮罩颜色 ---------- */
.pst-mask-colors-wrap { margin-top: 8px; }
.pst-mask-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.pst-mask-color {
    width: 28px; height: 28px; border: 1px solid rgba(0,0,0,.18); border-radius: 50%; cursor: pointer;
    background: var(--c); display: inline-flex; align-items: center; justify-content: center;
    padding: 0; flex: 0 0 auto; box-sizing: border-box;
}
.pst-mask-color[data-color="#ffffff"] { border-color: #c8cdd4; }
.pst-mask-color.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pst-mask-custom { position: relative; cursor: pointer; }
.pst-mask-custom-plus { color: #fff; font-size: 16px; font-weight: 600; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; }
/* 取色器锚点放在圆点右侧：点击圆点由 label 转发到 input，原生色卡即在右侧弹出 */
.pst-mask-custom input { position: absolute; left: calc(100% + 4px); top: 0; width: 28px; height: 28px; opacity: 0; cursor: pointer; }

/* ---------- 添加元素 ---------- */
.pst-add-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pst-add-row .btn { font-size: .78rem; }
.pst-sel-tag { font-size: .72rem; font-weight: 500; color: var(--accent); }
.pst-nosel { font-size: .78rem; color: var(--text-dim); padding: 10px; text-align: center; background: #fff; border: 1px dashed var(--field-border); border-radius: 6px; }

/* ---------- 对象列表 ---------- */
.pst-objlist { display: flex; flex-direction: column; gap: 5px; }
.pst-objitem {
    display: flex; align-items: center; gap: 8px; padding: 6px 9px; background: #fff;
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .78rem;
}
.pst-objitem:hover { border-color: var(--field-border-hover); }
.pst-objitem.active { border-color: var(--accent); background: #fff8f5; }
.pst-objitem .pst-obj-ico { width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-dim); }
.pst-objitem .pst-obj-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; }
.pst-objitem .pst-obj-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pst-objitem .pst-obj-del { border: 0; background: transparent; color: #c0392b; cursor: pointer; font-size: .9rem; padding: 0 2px; }

/* ---------- 左侧预览 ---------- */
.pst-preview { padding: 18px 20px 24px; min-width: 0; display: flex; flex-direction: column; }
.pst-preview-head { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--text-dim); margin-bottom: 8px; }
.pst-status { color: var(--accent); font-weight: 600; }
.pst-zoom-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.pst-zoom-bar .btn { font-size: .76rem; }
.pst-lock-btn { display: inline-flex; align-items: center; gap: 5px; }
.pst-lock-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pst-lock-btn .pst-lock-closed { display: none; }
.pst-lock-btn.is-locked { border-color: var(--accent); color: var(--accent); background: #fff1ec; }
.pst-lock-btn.is-locked .pst-lock-open { display: none; }
.pst-lock-btn.is-locked .pst-lock-closed { display: block; }
.pst-zoom-sep { flex: 0 0 1px; height: 20px; background: var(--border); margin: 0 2px; }
.pst-zoom-val { font-size: .78rem; color: var(--text); min-width: 46px; text-align: center; font-weight: 600; }
.pst-canvas-wrap {
    flex: 1 1 auto; display: flex; align-items: safe center; justify-content: safe center;
    background: #f1f3f5; border: 1px solid var(--border); border-radius: 8px; padding: 16px; min-height: 380px;
    overflow: auto; scrollbar-gutter: stable;
}
.pst-canvas-wrap canvas {
    display: block; width: 960px; height: 1200px; flex: 0 0 auto;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .16); background: #fff; touch-action: none; cursor: default;
}
.pst-canvas-wrap.pst-dragging canvas { cursor: grabbing; }
.pst-canvas-wrap.pst-locked canvas { cursor: default !important; }
.pst-tip { margin: 12px 0 0; font-size: .74rem; color: var(--text-dim); }

/* ---------- 图标库弹窗 ---------- */
.pst-lib-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.pst-lib-tools #pstLibSet { flex: 0 0 160px; }
.pst-lib-tools #pstLibSearch { flex: 1 1 180px; }
.pst-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; min-height: 200px; }
.pst-lib-cell {
    border: 1px solid var(--border); border-radius: 8px; padding: 10px 6px; text-align: center;
    cursor: pointer; background: #fff; transition: border-color .15s;
}
.pst-lib-cell:hover { border-color: var(--accent); background: #fff8f5; }
.pst-lib-cell svg { width: 34px; height: 34px; display: block; margin: 0 auto 4px; }
.pst-lib-cell .pst-lib-name { font-size: .7rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pst-lib-empty { grid-column: 1 / -1; text-align: center; color: var(--text-dim); padding: 40px 0; font-size: .82rem; }

@media (max-width: 520px) {
    .pst-head { padding: 14px; }
    .pst-preview { padding: 14px; }
    .pst-panel { padding: 4px 12px 16px; }
    .pst-swatches { grid-template-columns: repeat(4, 1fr); }
}
