/* 拼豆图纸 Demo —— 全部选择器都在 .pbs-root 下，直接扔进现有站点不会污染全局样式 */

.pbs-root {
    --pbs-paper: #efeae0;
    --pbs-card: #fbf9f4;
    --pbs-ink: #17150f;
    --pbs-ink-soft: #5d5749;
    --pbs-line: #17150f;
    --pbs-accent: #d9165e;
    --pbs-accent-soft: #fbe3ec;
    --pbs-ok: #2f6b4f;

    --pbs-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
    --pbs-sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;

    box-sizing: border-box;
    min-height: 100vh;
    padding: 28px 24px 40px;
    background-color: var(--pbs-paper);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(23, 21, 15, .13) 1px, transparent 0);
    background-size: 22px 22px;
    color: var(--pbs-ink);
    font-family: var(--pbs-sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.pbs-root *,
.pbs-root *::before,
.pbs-root *::after { box-sizing: border-box; }

/* display:flex 会盖掉 hidden 属性，这里统一兜住 */
.pbs-root [hidden] { display: none !important; }

.pbs-root :focus-visible {
    outline: 2px solid var(--pbs-accent);
    outline-offset: 2px;
}

/* ---------- 页头 ---------- */
.pbs-masthead {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 20px;
    max-width: 1320px;
    margin: 0 auto 22px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--pbs-ink);
}

.pbs-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--pbs-mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .16em;
}

.pbs-mark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--pbs-ink);
    border-radius: 50%;
    box-shadow: inset 0 0 0 3px var(--pbs-card), inset 0 0 0 5px var(--pbs-accent);
    background: var(--pbs-accent);
}

.pbs-tag {
    margin: 0;
    color: var(--pbs-ink-soft);
    font-size: 13px;
}

/* ---------- 布局 ---------- */
.pbs-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 22px;
    max-width: 1320px;
    margin: 0 auto;
    align-items: start;
}

@media (max-width: 900px) {
    .pbs-layout { grid-template-columns: minmax(0, 1fr); }
}

.pbs-panel {
    background: var(--pbs-card);
    border: 2px solid var(--pbs-line);
    border-radius: 3px;
    box-shadow: 5px 5px 0 rgba(23, 21, 15, .9);
}

/* ---------- 左栏 ---------- */
.pbs-controls {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
}

.pbs-drop {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 132px;
    padding: 12px;
    border: 2px dashed #9b9484;
    border-radius: 2px;
    background:
        repeating-linear-gradient(45deg, rgba(23,21,15,.035) 0 6px, transparent 6px 12px),
        #fffdf8;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.pbs-drop:hover,
.pbs-drop.is-over {
    border-color: var(--pbs-accent);
    background-color: var(--pbs-accent-soft);
}

.pbs-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.pbs-drop-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: none;
}

.pbs-drop-copy strong { font-size: 15px; }

.pbs-drop-copy span { color: var(--pbs-ink-soft); }

.pbs-drop-copy em {
    margin-top: 6px;
    font-family: var(--pbs-mono);
    font-size: 11px;
    font-style: normal;
    letter-spacing: .04em;
    color: #8b8474;
}

.pbs-drop.has-file {
    min-height: 0;
    padding: 9px 12px;
    border-style: solid;
    border-color: var(--pbs-ink);
    background: #fffdf8;
    justify-content: flex-start;
    text-align: left;
}

.pbs-drop.has-file .pbs-drop-copy { display: none; }

.pbs-filebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    pointer-events: none;
}

.pbs-filename {
    overflow: hidden;
    font-family: var(--pbs-mono);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pbs-filebar em {
    flex: none;
    font-size: 11px;
    font-style: normal;
    color: #8b8474;
}

/* ---------- 裁剪框 ---------- */
/* img 用 object-fit: contain 铺满定高框；选区按 JS 量出的可见图像矩形定位，
   所以竖图/全景图周围留白也不会让框和像素对不上 */
.pbs-cropper {
    position: relative;
    height: 230px;
    overflow: hidden;
    border: 2px solid var(--pbs-ink);
    border-radius: 2px;
    background: #f4f0e6;
    line-height: 0;
    touch-action: none;
    user-select: none;
}

.pbs-cropper img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 用超大投影遮住选区之外，比四个遮罩层省事 */
.pbs-cropbox {
    position: absolute;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 9999px rgba(23, 21, 15, .48);
    cursor: move;
}

.pbs-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--pbs-ink);
    background: #fff;
    box-shadow: 0 0 0 1.5px #fff;
}

.pbs-handle[data-h="nw"] { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.pbs-handle[data-h="ne"] { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.pbs-handle[data-h="sw"] { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.pbs-handle[data-h="se"] { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }

.pbs-crop-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
    margin-top: -10px;
}

.pbs-ratios { display: flex; gap: 4px; }

.pbs-ratios button {
    padding: 3px 8px;
    border: 1.5px solid #c9c2b2;
    border-radius: 2px;
    background: #fffdf8;
    color: var(--pbs-ink-soft);
    font-family: var(--pbs-mono);
    font-size: 11px;
    cursor: pointer;
}

.pbs-ratios button:hover { border-color: var(--pbs-ink); color: var(--pbs-ink); }

.pbs-ratios button.is-on {
    border-color: var(--pbs-ink);
    background: var(--pbs-ink);
    color: #fdfaf3;
}

.pbs-crop-size {
    font-family: var(--pbs-mono);
    font-size: 11px;
    color: #8b8474;
}

/* 字段 */
.pbs-field {
    margin: 0;
    padding: 0;
    border: 0;
}

.pbs-field legend {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
}

.pbs-field legend span {
    font-weight: 400;
    font-size: 11.5px;
    color: #8b8474;
}

/* chips */
.pbs-chips {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}

.pbs-chips-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.pbs-chips-quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.pbs-chip { display: block; }

.pbs-chip input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pbs-chip span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 42px;
    padding: 4px 2px;
    border: 1.5px solid #c9c2b2;
    border-radius: 2px;
    background: #fffdf8;
    font-family: var(--pbs-mono);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    transition: all .12s ease-out;
    user-select: none;
}

.pbs-chip em {
    font-family: var(--pbs-sans);
    font-size: 10px;
    font-style: normal;
    font-weight: 400;
    color: #8b8474;
    white-space: nowrap;
}

.pbs-chip span:hover {
    border-color: var(--pbs-ink);
    transform: translateY(-1px);
}

.pbs-chip input:checked + span {
    border-color: var(--pbs-ink);
    background: var(--pbs-ink);
    color: #fdfaf3;
    box-shadow: 2px 2px 0 var(--pbs-accent);
}

.pbs-chip input:checked + span em { color: #cfc8b8; }

.pbs-chip input:disabled + span {
    opacity: .35;
    cursor: not-allowed;
    transform: none;
}

/* 数字输入 */
.pbs-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.pbs-inline label {
    font-size: 12px;
    color: var(--pbs-ink-soft);
    white-space: nowrap;
}

.pbs-inline input[type="number"] {
    width: 76px;
    height: 34px;
    padding: 0 8px;
    border: 1.5px solid #c9c2b2;
    border-radius: 2px;
    background: #fffdf8;
    color: var(--pbs-ink);
    font-family: var(--pbs-mono);
    font-size: 14px;
}

.pbs-inline input[type="number"]:focus { border-color: var(--pbs-ink); }

.pbs-unit { font-size: 11.5px; color: #8b8474; }

/* 抖动滑条 */
.pbs-field.is-off { opacity: .42; }
.pbs-field input[type="range"]:disabled { cursor: not-allowed; }

.pbs-field input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 6px;
    margin: 10px 0 6px;
    border: 1.5px solid var(--pbs-ink);
    border-radius: 4px;
    background: linear-gradient(90deg, #fffdf8 0%, var(--pbs-accent) 100%);
    cursor: pointer;
}

.pbs-field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--pbs-ink);
    border-radius: 50%;
    background: #fffdf8;
    box-shadow: 1px 1px 0 var(--pbs-ink);
}

.pbs-field input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 2px solid var(--pbs-ink);
    border-radius: 50%;
    background: #fffdf8;
}

.pbs-range-tags {
    display: flex;
    justify-content: space-between;
    font-family: var(--pbs-mono);
    font-size: 10.5px;
    color: #8b8474;
}

.pbs-range-tags #pbs-dither-val {
    font-weight: 700;
    color: var(--pbs-accent);
}

/* 复选框 */
.pbs-check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px;
    border: 1.5px solid #c9c2b2;
    border-radius: 2px;
    background: #fffdf8;
    cursor: pointer;
}

.pbs-check input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--pbs-accent);
}

.pbs-check span {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 600;
}

.pbs-check em {
    font-weight: 400;
    font-size: 11.5px;
    font-style: normal;
    color: #8b8474;
}

.pbs-check-inline {
    padding: 0;
    border: 0;
    background: none;
}

.pbs-check-inline span { font-weight: 400; }

/* 规格预估条 */
.pbs-plan {
    padding: 9px 11px;
    border-left: 3px solid var(--pbs-ink);
    background: #f2eee3;
    font-family: var(--pbs-mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--pbs-ink-soft);
    word-break: break-all;
}

.pbs-plan b {
    color: var(--pbs-ink);
    font-weight: 700;
}

.pbs-problem {
    margin: 0;
    padding: 9px 11px;
    border-left: 3px solid var(--pbs-accent);
    background: var(--pbs-accent-soft);
    font-size: 12.5px;
    color: #a30f42;
}

/* 软提示：能继续做，只是不划算 */
.pbs-note {
    margin: 0;
    padding: 9px 11px;
    border-left: 3px solid #8b8474;
    background: #f2eee3;
    font-size: 12.5px;
    color: var(--pbs-ink-soft);
}

/* 高级设置（常驻展开，不再折叠） */
.pbs-adv {
    padding-top: 12px;
    border-top: 1.5px dashed #c9c2b2;
}

.pbs-adv-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
}

.pbs-adv-title span {
    font-weight: 400;
    font-size: 11.5px;
    color: #8b8474;
}

.pbs-adv > .pbs-field,
.pbs-adv > .pbs-check { margin-top: 14px; }

/* 主按钮 */
.pbs-go {
    position: relative;
    width: 100%;
    height: 48px;
    border: 2px solid var(--pbs-ink);
    border-radius: 2px;
    background: var(--pbs-accent);
    color: #fff;
    font-family: var(--pbs-sans);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .08em;
    cursor: pointer;
    box-shadow: 3px 3px 0 var(--pbs-ink);
    transition: transform .1s, box-shadow .1s, background-color .15s;
}

.pbs-go:hover:not(:disabled) { background: #c2104f; }

.pbs-go:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--pbs-ink);
}

.pbs-go:disabled {
    background: #d5cfc0;
    color: #7d7666;
    box-shadow: 3px 3px 0 #b3ab98;
    cursor: not-allowed;
}

.pbs-go .pbs-go-busy { display: none; }

.pbs-go.is-busy .pbs-go-text { display: none; }

.pbs-go.is-busy .pbs-go-busy {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.pbs-go.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 132px;
    height: 20px;
    margin: -10px 0 0 -66px;
    border-radius: 2px;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 10px, transparent 10px 20px);
    animation: pbs-slide .7s linear infinite;
    pointer-events: none;
}

.pbs-go.is-busy .pbs-go-busy { position: relative; z-index: 1; }

@keyframes pbs-slide {
    from { background-position: 0 0; }
    to { background-position: 20px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .pbs-go.is-busy::after { animation: none; }
    .pbs-chip span:hover { transform: none; }
}

.pbs-fine {
    margin: -6px 0 0;
    font-size: 11px;
    color: #8b8474;
}

/* ---------- 右栏 ---------- */
.pbs-output {
    position: relative;
    min-height: 480px;
    padding: 18px;
}

/* 重新生成时的遮罩：旧结果压暗 + 明确的进行中提示，避免用户以为没刷新 */
.pbs-loading {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 234, 224, .82);
}

.pbs-loading[hidden] { display: none; }

.pbs-loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    width: 208px;
    padding: 22px 20px 20px;
    border: 2px solid var(--pbs-ink);
    background: var(--pbs-card);
    box-shadow: 6px 6px 0 rgba(23, 21, 15, .85);
    text-align: center;
}

.pbs-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #d8d1c0;
    border-top-color: var(--pbs-accent);
    border-radius: 50%;
    animation: pbs-spin .8s linear infinite;
}

@keyframes pbs-spin { to { transform: rotate(360deg); } }

.pbs-loading-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--pbs-ink);
}

.pbs-loading-time {
    font-family: var(--pbs-mono);
    font-size: 11.5px;
    color: var(--pbs-ink-soft);
}

.pbs-loading-bar {
    position: relative;
    display: block;
    width: 100%;
    height: 4px;
    margin-top: 2px;
    background: #e4ded0;
    overflow: hidden;
}

.pbs-loading-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: var(--pbs-accent);
    animation: pbs-slide 1.1s ease-in-out infinite;
}

@keyframes pbs-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
    .pbs-spinner, .pbs-loading-bar::after { animation: none; }
    .pbs-loading-bar::after { width: 100%; }
}

.pbs-empty {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 420px;
    padding: 30px;
    border: 1.5px dashed #c9c2b2;
    text-align: center;
    overflow: hidden;
}

.pbs-empty-grid {
    width: 168px;
    height: 168px;
    margin-bottom: 14px;
    border: 2px solid var(--pbs-ink);
    background-image:
        linear-gradient(rgba(23,21,15,.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23,21,15,.16) 1px, transparent 1px);
    background-size: 21px 21px;
    background-position: -1px -1px;
    box-shadow: 6px 6px 0 var(--pbs-accent);
}

.pbs-empty p {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.pbs-empty small {
    max-width: 340px;
    color: var(--pbs-ink-soft);
    font-size: 12.5px;
}

/* 统计 */
.pbs-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

@media (max-width: 1180px) {
    .pbs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.pbs-stat {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    border: 1.5px solid #d8d1c0;
    border-radius: 2px;
    background: #fffdf8;
}

.pbs-stat-v {
    font-family: var(--pbs-mono);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.pbs-stat-v b { font: inherit; }

.pbs-stat-v i {
    margin-left: 2px;
    font-family: var(--pbs-mono);
    font-size: 10.5px;
    font-style: normal;
    font-weight: 600;
    color: #8b8474;
}

.pbs-stat label {
    margin-top: 2px;
    font-size: 10.5px;
    letter-spacing: .06em;
    color: #8b8474;
}

.pbs-stat-hero {
    border-color: var(--pbs-ink);
    background: var(--pbs-ink);
    color: #fdfaf3;
}

.pbs-stat-hero .pbs-stat-v { color: #fff; }
.pbs-stat-hero i, .pbs-stat-hero label { color: #cfc8b8; }

/* 警告 */
.pbs-warn {
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pbs-warn li {
    padding: 8px 11px;
    border-left: 3px solid var(--pbs-accent);
    background: var(--pbs-accent-soft);
    font-size: 12.5px;
    line-height: 1.5;
}

/* 标签页 */
.pbs-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--pbs-ink);
}

.pbs-tabs button {
    margin-bottom: -2px;
    padding: 7px 14px;
    border: 2px solid transparent;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
    background: none;
    color: var(--pbs-ink-soft);
    font-family: var(--pbs-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.pbs-tabs button:hover { color: var(--pbs-ink); }

.pbs-tabs button.is-on {
    border-color: var(--pbs-ink);
    background: var(--pbs-ink);
    color: #fdfaf3;
}

/* 舞台 */
.pbs-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 14px;
    border: 1.5px solid #d8d1c0;
    background:
        repeating-conic-gradient(#f4f0e6 0% 25%, #eae5d8 0% 50%) 50% / 18px 18px;
    overflow: auto;
}

.pbs-stage img {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    image-rendering: auto;
    transition: filter .2s;
}

/* 图纸是原尺寸大图：滚轮缩放、按住左键拖动，双击回到适配大小 */
.pbs-stage-chart {
    position: relative;
    display: block;
    height: 68vh;
    min-height: 340px;
    padding: 0;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.pbs-stage-chart.is-dragging { cursor: grabbing; }

.pbs-stage-chart img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    max-height: none;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
}

.pbs-stage img.is-squint { filter: blur(3.2px) saturate(.92); }

.pbs-stage-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 14px;
    padding: 9px 2px 2px;
}

.pbs-hintline {
    font-size: 11.5px;
    color: #8b8474;
}

.pbs-link {
    font-family: var(--pbs-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--pbs-accent);
    text-decoration: none;
    border-bottom: 2px solid var(--pbs-accent);
}

.pbs-link:hover { color: var(--pbs-ink); border-bottom-color: var(--pbs-ink); }

/* 色号表 */
.pbs-bom {
    width: 100%;
    max-height: 460px;
    border-collapse: collapse;
    font-size: 12.5px;
}

.pbs-bom thead th {
    position: sticky;
    top: 0;
    padding: 7px 8px;
    border-bottom: 2px solid var(--pbs-ink);
    background: #f2eee3;
    font-size: 10.5px;
    letter-spacing: .06em;
    text-align: left;
    color: #8b8474;
    z-index: 1;
}

.pbs-bom tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid #e4dece;
    font-family: var(--pbs-mono);
}

.pbs-bom tbody tr:hover td { background: #fff; }

.pbs-bom .pbs-swatch {
    display: inline-block;
    width: 26px;
    height: 14px;
    border: 1px solid rgba(23,21,15,.35);
    border-radius: 1px;
    vertical-align: middle;
}

.pbs-bom .pbs-num { text-align: right; }

/* 页脚 */
.pbs-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 18px;
    max-width: 1320px;
    margin: 26px auto 0;
    font-family: var(--pbs-mono);
    font-size: 10.5px;
    letter-spacing: .04em;
    color: #8b8474;
}
/* ---------- 通用下拉 ---------- */
.pbs-select {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1.5px solid var(--pbs-ink);
    border-radius: 2px;
    background: #fff;
    color: var(--pbs-ink);
    font-family: var(--pbs-sans);
    font-size: 13.5px;
}

/* ---------- 画板 ---------- */
.pbs-ed-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 22px;
    max-width: 1320px;
    margin: 0 auto;
    align-items: start;
}

@media (max-width: 900px) {
    .pbs-ed-layout { grid-template-columns: minmax(0, 1fr); }
}

.pbs-ed-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
}

.pbs-ed-drop { min-height: 84px; }

.pbs-ed-meta {
    padding: 10px 12px;
    border: 1.5px dashed #cfc7b4;
    font-size: 12.5px;
    color: var(--pbs-ink-soft);
}

.pbs-ed-meta p { margin: 0; }

.pbs-ed-name {
    font-family: var(--pbs-mono);
    font-weight: 700;
    color: var(--pbs-ink);
    word-break: break-all;
}

.pbs-ed-current {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-family: var(--pbs-mono);
    color: var(--pbs-ink-soft);
}

.pbs-ed-current::after { content: attr(data-code); }

.pbs-ed-current i {
    display: inline-block;
    width: 42px;
    height: 20px;
    border: 1.5px solid var(--pbs-ink);
    border-radius: 1px;
}

.pbs-ed-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 340px;
    overflow: auto;
    padding: 2px;
}

.pbs-ed-color {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border: 1.5px solid #d8d1c0;
    border-radius: 2px;
    background: #fff;
    color: var(--pbs-ink);
    font-family: var(--pbs-mono);
    font-size: 11.5px;
    cursor: pointer;
}

.pbs-ed-color:hover { border-color: var(--pbs-ink); }

.pbs-ed-color.is-on {
    border-color: var(--pbs-accent);
    box-shadow: 0 0 0 2px var(--pbs-accent-soft);
}

.pbs-ed-color .pbs-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(23,21,15,.35);
    border-radius: 1px;
}

.pbs-ed-color em {
    font-style: normal;
    color: #8b8474;
}

.pbs-ed-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-top: 12px;
    border-top: 1.5px solid #e4dece;
}

.pbs-ed-actions .pbs-link {
    background: none;
    border: 0;
    border-bottom: 2px solid var(--pbs-accent);
    cursor: pointer;
    padding: 0;
}

.pbs-go-small {
    height: 40px;
    font-size: 13px;
    margin-top: 10px;
}

.pbs-ed-main {
    padding: 14px;
    min-height: 480px;
}

.pbs-ed-stage {
    display: flex;
    align-items: flex-start;
    /* safe center：放大到超出容器时仍然能从左上角滚到 */
    justify-content: safe center;
    padding: 12px;
    border: 1.5px solid #d8d1c0;
    background:
        repeating-conic-gradient(#f4f0e6 0% 25%, #eae5d8 0% 50%) 50% / 18px 18px;
    overflow: auto;
    max-height: calc(100vh - 160px);
}

.pbs-ed-canvas-wrap {
    position: relative;
    flex: none;
}

.pbs-ed-stage canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
    image-rendering: pixelated;
    box-shadow: 0 2px 10px rgba(23,21,15,.18);
}

/* 悬停高亮画在叠层上，不重绘整张图 */
.pbs-ed-stage canvas.pbs-ed-hover {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: none;
}

.pbs-ed-zoombar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px 0;
    font-family: var(--pbs-mono);
    font-size: 11.5px;
    color: #8b8474;
}

.pbs-ed-zoombar b {
    min-width: 46px;
    padding: 1px 6px;
    border: 1.5px solid #d8d1c0;
    border-radius: 2px;
    background: #fff;
    color: var(--pbs-ink);
    text-align: center;
}

.pbs-ed-empty {
    padding: 90px 20px;
    text-align: center;
    color: var(--pbs-ink-soft);
}

.pbs-ed-empty p {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--pbs-ink);
}

.pbs-ed-empty small { font-size: 12px; }

.pbs-ed-foot {
    margin: 10px 2px 0;
    font-size: 12px;
    color: var(--pbs-ink-soft);
}
