/* ==========================================================
   请柬在线编辑器样式 · gallery 主题版（基于 default 换色：紫主色 + 冷灰中性色，警示态保留红色）
   ========================================================== */
:root {
    --ed-brand: #534AB7;
    --ed-brand-d: #443B9E;
    --ed-gold: #D99A3D;
    --ed-danger: #D0453F;   /* 删除 / 出错等警示态（与全站 --red 一致） */
    --ed-line: #E8E4F0;
    --ed-ink: #1A1922;
    --ed-ink2: #55516A;
    --ed-bg: #F3F0F9;
    --ed-head: 54px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.editor-page {
    font: 14px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    background: var(--ed-bg);
    color: var(--ed-ink);
    overflow: hidden;
    height: 100vh;
}

/* -------- 顶栏 -------- */
.ed-head {
    height: var(--ed-head); display: flex; align-items: center; gap: 12px;
    padding: 0 14px; background: #fff; border-bottom: 1px solid var(--ed-line);
    position: relative; z-index: 80;
}
/* 返回按钮：锚点元素，复用 .ed-btn 按钮外观（可与 .primary 组合成主色实心） */
.ed-back { color: var(--ed-ink2); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; text-decoration: none; }
.ed-back:hover { color: var(--ed-brand); }
.ed-btn.ed-back.primary,
.ed-btn.ed-back.primary:hover { color: #fff; border-color: var(--ed-brand); }
.ed-title { font-size: 15px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 标题 + 模板编号两行（编号行只在电脑端显示，见文件末尾手机端适配：触屏设备隐藏） */
.ed-titlebox { min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.4; }
.ed-titlebox .ed-title { line-height: 1.4; }
.ed-code { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ed-brand); line-height: 1.3; margin-top: 2px; }
.ed-code code {
    font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700;
    background: #EEEDFE; border: 1px solid #D8D5F5; border-radius: 5px; padding: 0 6px;
}
/* 分辨率：接在模板编号后面同一行，样式与编号一致但整体降一档颜色（灰），避免抢编号的视觉 */
.ed-code .ed-size { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; color: var(--ed-ink2); }
.ed-code .ed-size code { background: #f4f4f5; border-color: #e2e2e5; }
.ed-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ed-btn {
    border: 1px solid var(--ed-line); background: #fff; border-radius: 9px;
    padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--ed-ink2);
    white-space: nowrap;
}
.ed-btn:hover { border-color: var(--ed-brand); color: var(--ed-brand); }
.ed-btn.primary {
    background: linear-gradient(145deg, var(--ed-brand), #443B9E);
    border-color: var(--ed-brand); color: #fff; font-weight: 600;
}
.ed-btn.gold { background: linear-gradient(145deg, #EBCF9C, var(--ed-gold)); border-color: var(--ed-gold); color: #4A3810; font-weight: 700; }
.ed-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 撤销 / 重做：顶栏里的小图标按钮组（白色药丸容器 + 两枚 32px 图标按钮）。
 * 与「重置 / 导出图片」并排，因此做成同高的紧凑形态；
 * 无可撤销/重做时按钮置灰（对应 :disabled 的淡灰描边效果）。 */
.ed-undo {
    display: inline-flex; align-items: center; gap: 2px; flex: 0 0 auto;
    padding: 2px; margin-right: 2px;
    background: #fff; border: 1px solid var(--ed-line); border-radius: 9px;
}
.ed-undo button {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; border: 0; background: none;
    border-radius: 7px; cursor: pointer; color: var(--ed-ink2);
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, color .15s ease;
}
.ed-undo button svg {
    width: 17px; height: 17px;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.ed-undo button:not(:disabled):hover { background: #f2f3f5; color: var(--ed-ink); }
.ed-undo button:not(:disabled):active { background: #e8eaee; }
.ed-undo button:disabled { opacity: .3; cursor: default; background: none; }
.ed-undo button:focus-visible { outline: 2px solid var(--ed-brand); outline-offset: 1px; }

/* -------- 三栏布局 -------- */
.ed-wrap {
    display: grid;
    grid-template-columns: 232px 1fr 322px;
    height: calc(100vh - var(--ed-head));
}

/* 左侧文字列表 */
.ed-left { background: #fff; border-right: 1px solid var(--ed-line); display: flex; flex-direction: column; overflow: hidden; }
.ed-left-head { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--ed-line); font-size: 14px; }
.ed-left-head small { display: block; font-weight: 400; color: #8A85A0; font-size: 12px; margin-top: 2px; }
.text-list { list-style: none; margin: 0; padding: 8px; overflow: auto; flex: 1; }
.tl-item {
    display: flex; gap: 8px; align-items: flex-start; padding: 9px 10px; border-radius: 10px;
    cursor: pointer; border: 1px solid transparent; margin-bottom: 6px; background: #F7F6FB;
}
.tl-item:hover { border-color: #DDD9EE; }
.tl-item.active { background: #EEEDFE; border-color: var(--ed-brand); }
/* 多选集合里的非主元素：弱一档的高亮，与主元素（.active）区分 */
.tl-item.picked { background: #FEF8E8; border-color: #E8C67A; }
.tl-item.picked .tl-idx { background: #E8C67A; color: #fff; }
.tl-idx {
    width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; background: #efe7d9;
    color: #75709A; font-size: 11px; text-align: center; line-height: 20px; margin-top: 2px;
}
.tl-item.active .tl-idx { background: var(--ed-brand); color: #fff; }
.tl-body { min-width: 0; flex: 1; }
.tl-body b { display: block; font-size: 13px; }
.tl-body i { display: block; font-style: normal; color: #8A85A0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-tools { display: flex; gap: 3px; }
.tl-tools button {
    width: 22px; height: 22px; padding: 0; border-radius: 6px; border: 1px solid var(--ed-line);
    background: #fff; cursor: pointer; color: var(--ed-ink2); font-size: 12px; line-height: 1;
}
.tl-tools button.danger:hover { background: #FDEDEC; color: var(--ed-danger); border-color: var(--ed-danger); }
.tl-add { padding: 4px; display: flex; gap: 6px; }
.tl-add button { flex: 1; padding: 9px; border-radius: 10px; border: 1px dashed #C5C1E0; background: #FAF9F6; cursor: pointer; color: #75709A; }
.tl-add button:hover { border-color: var(--ed-brand); color: var(--ed-brand); }
.ed-tip { margin: 0; padding: 10px 14px; border-top: 1px solid var(--ed-line); color: #8A85A0; font-size: 12px; line-height: 1.6; }

/* 中间画布：纵向靠上下两个弹性垫片（::before/::after）居中——空间足够时均分、
 * 模板严格居中；空间不足时垫片各收回 10px，仍保证上下各有一段缝隙且可滚动。
 * 横向交给 .stage-outer 的 margin:auto（放得下居中、放不下靠左可右滑），
 * 避免 flex 溢出居中导致「左侧内容滚不到」。 */
.ed-center { position: relative; overflow: auto; padding: 22px; display: flex; flex-direction: column; align-items: flex-start; }
.ed-center::before, .ed-center::after { content: ""; flex: 1 0 10px; }
.stage-outer {
    position: relative; width: var(--stage-w, 300px); height: var(--stage-h, 640px);
    flex: 0 0 auto; align-self: flex-start; margin: auto;
    box-shadow: 0 10px 34px rgba(60, 52, 120, .18); border-radius: 4px;
    touch-action: none; cursor: default;
}
.stage-outer.dragging { cursor: move; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage canvas { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; }

/* -------- 首屏加载占位：正在加载中 --------
 * 模板背景图是原图（可能几 MB），网络慢时不能立刻解码出来，这段时间画布是空白的，
 * 用户会以为页面坏了。占位层直接写进 HTML（不等 JS），打开页面立刻可见；
 * 首次渲染完成（背景图 + 素材图就绪）后由 editor.js 淡出移除。
 * 挂在 .stage-outer 内、不参与 .stage 的 transform 缩放，任何缩放档位都铺满画布区。 */
.stage-loading {
    position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: linear-gradient(160deg, #F7F5FC 0%, #ECE9F8 100%);
    border-radius: 4px; color: var(--ed-ink2);
    transition: opacity .28s ease, visibility 0s .28s linear;
}
.stage-loading.hide { opacity: 0; visibility: hidden; }
.sl-spin {
    width: 34px; height: 34px; border-radius: 50%; box-sizing: border-box;
    border: 3px solid rgba(83, 74, 183, .16); border-top-color: var(--ed-brand);
    animation: qjSpin .8s linear infinite;
}
@keyframes qjSpin { to { transform: rotate(360deg); } }
.sl-text { font-size: 13px; letter-spacing: .5px; }
/* 加载失败：停止转圈，警示色提示（不自动消失，让用户看清原因） */
.stage-loading.err .sl-spin { display: none; }
.stage-loading.err .sl-text { color: var(--ed-danger); max-width: 80%; text-align: center; line-height: 1.7; }
.sel-box {
    position: absolute; display: none; pointer-events: none;
    border: 1px dashed rgba(255, 255, 255, .95);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 0 0 3px rgba(255, 255, 255, .18);
    border-radius: 3px;
}

/* -------- 多选（电脑端按住 Shift 点选）--------
 * 主元素仍用 .sel-box 的虚线框；其余成员由 editor.js 在 .stage-outer 里画 .sel-ghost，
 * 坐标已乘过缩放比，所以边框恒为 1 物理像素，放大缩小画布都不会变粗。
 * 多选时四角圆点隐藏 —— 拖它只缩放主元素，容易让人误以为整组缩放。 */
.sel-multi-layer {
    position: absolute; left: 0; top: 0; right: 0; bottom: 0;
    display: none; pointer-events: none; z-index: 5;
}
.sel-ghost {
    position: absolute; box-sizing: border-box; display: block;
    border: 1px dashed #ffcf5c; border-radius: 3px;
    background: rgba(255, 207, 92, .08);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .3);
    transform-origin: center center;
}
.sel-box.multi {
    border-color: #ffcf5c;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 0 3px rgba(255, 207, 92, .3);
}
/* Shift 连点左侧列表时，避免浏览器把列表文字一并拖成蓝色选区 */
.text-list { -webkit-user-select: none; user-select: none; }

/* -------- 打开编辑器时的「哪些文字能改」提示 --------
 * 首次渲染完成后，把所有文字元素的包围盒描边闪一下（约 1 秒后自动移除），
 * 让用户一眼看出画布上哪些文字点一下就能编辑。
 * 挂在 .stage 内（与 .sel-box 同一坐标系），随画布缩放；纯提示、不可点击。 */
.hint-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.hint-box {
    position: absolute; box-sizing: border-box; display: block;
    border: 2px dashed #ffd76a; border-radius: 5px;
    background: rgba(255, 215, 106, .1);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .28), 0 0 12px rgba(255, 215, 106, .55);
    animation: qjHintFlash 1000ms ease-out forwards;
}
@keyframes qjHintFlash {
    0%   { opacity: 0; }
    10%  { opacity: 1; }
    35%  { opacity: .45; }
    55%  { opacity: 1; }
    75%  { opacity: .5; }
    100% { opacity: 0; }
}
.edit-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: none; }
.edit-box { outline: none; caret-color: transparent; }   /* 原生光标隐藏，用 .edit-caret 自绘加粗光标 */

/* 自绘打字光标：2px 加粗（原生光标只有 1px 且无法用 CSS 调粗），
 * 颜色跟随文字色由 JS 设置；位置由 selectionchange / 输入 / 布局变化时同步 */
.edit-caret {
    position: absolute; width: 2px; pointer-events: none;
    animation: qjCaretBlink 1.06s steps(1) infinite;
}
@keyframes qjCaretBlink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

/* -------- 选中框四角缩放圆点（同取景器手柄手感） --------
 * 挂在 .stage-outer 上（不在 .stage 的 transform 层里），
 * 因此任何画布缩放档位下都是 16px 视觉圆点 + 32px 命中区；坐标由 JS 乘缩放比换算。
 * 拖任意一角：文字等比改字号（换行宽度同步），图片等比改宽高。 */
.sel-dot-layer {
    position: absolute; left: 0; top: 0; right: 0; bottom: 0;
    display: none; pointer-events: none; z-index: 7;
}
.sel-dot {
    position: absolute; left: 0; top: 0; width: 32px; height: 32px;
    margin: -16px 0 0 -16px;            /* 圆点中心正压在角的顶点上 */
    box-sizing: border-box; touch-action: none; pointer-events: auto;
}
.sel-dot[data-corner="nw"], .sel-dot[data-corner="se"] { cursor: nwse-resize; }
.sel-dot[data-corner="ne"], .sel-dot[data-corner="sw"] { cursor: nesw-resize; }
.sel-dot::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 16px; height: 16px; margin: -8px 0 0 -8px; box-sizing: border-box;
    background: #fff; border: 2px solid rgba(20, 18, 35, .4); border-radius: 50%;
    box-shadow: 0 1px 5px rgba(0, 0, 0, .55);
}

/* -------- 对齐辅助线（拖拽时临时渲染，松手即消失） --------
 * 挂在 .stage-outer 上（不在 .stage 的 transform 层里），
 * 因此线宽恒为 1px、间距数字不受画布缩放影响；坐标由 JS 乘缩放比换算。 */
.guide-layer {
    position: absolute; left: 0; top: 0; right: 0; bottom: 0;
    display: none; pointer-events: none; z-index: 6;
}
.qj-guide, .qj-gap {
    position: absolute; display: block;
    background: var(--qj-guide-c, rgba(255, 45, 120, .9));
    /* 1px 粉线 + 半透明白描边：深色 / 浅色背景上都看得清 */
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
}
.qj-guide--v { width: 1px; }
.qj-guide--h { height: 1px; }
/* 等间距标记：在两段间隔上各画一条带端点刻度的短线 */
.qj-gap--v { width: 1px; }
.qj-gap--h { height: 1px; }
.qj-gap--v::before, .qj-gap--v::after {
    content: ''; position: absolute; left: -4px; width: 9px; height: 1px;
    background: inherit;
}
.qj-gap--v::before { top: 0; }
.qj-gap--v::after  { bottom: 0; }
.qj-gap--h::before, .qj-gap--h::after {
    content: ''; position: absolute; top: -4px; width: 1px; height: 9px;
    background: inherit;
}
.qj-gap--h::before { left: 0; }
.qj-gap--h::after  { right: 0; }
.qj-guide-tag {
    position: absolute; transform: translate(-50%, -50%);
    padding: 0 4px; border-radius: 3px;
    background: rgba(255, 45, 120, .92); color: #fff;
    font: 500 10px/14px -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: .2px; white-space: nowrap; pointer-events: none;
}

/* -------- 画布缩放控件（− / ＋ / 百分比） -------- */
.ed-zoom {
    position: absolute; right: 16px; bottom: 16px; z-index: 40;
    display: flex; align-items: center; gap: 2px;
    background: #fff; border: 1px solid #E8E4F0; border-radius: 12px; padding: 4px;
    box-shadow: 0 6px 20px rgba(60, 52, 120, .12), 0 1px 2px rgba(60, 52, 120, .06);
    font-size: 13px; color: #3F3B55;
    user-select: none; -webkit-user-select: none;
}
.ed-zoom button {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    height: 32px; min-width: 32px; padding: 0; border: 0; background: none;
    border-radius: 8px; cursor: pointer; color: #3F3B55;
    font: inherit; -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, color .15s ease;
}
.ed-zoom button:hover { background: #f2f3f5; color: #1A1922; }
.ed-zoom button:active { background: #e8eaee; }
.ed-zoom button:disabled { opacity: .32; cursor: default; background: none; }
.ed-zoom button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* 百分比按钮 */
.ed-zoom-val { min-width: 58px; padding: 0 5px; gap: 2px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ed-zoom-val svg { width: 13px; height: 13px; stroke-width: 2.4; transition: transform .18s ease; }
.ed-zoom-val[aria-expanded="true"] svg { transform: rotate(180deg); }

/* 比例下拉菜单 */
.ed-zoom-menu {
    position: absolute; right: 0; bottom: calc(100% + 10px);
    min-width: 128px; margin: 0; padding: 5px; list-style: none;
    background: #fff; border: 1px solid #E8E4F0; border-radius: 11px;
    box-shadow: 0 12px 30px rgba(60, 52, 120, .18);
    display: none; z-index: 8;
}
.ed-zoom-menu.show { display: block; }
.ed-zoom-menu li { margin: 0; }
.ed-zoom-menu button {
    width: 100%; height: 32px; padding: 0 10px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 13px; border-radius: 7px; color: #3F3B55;
}
.ed-zoom-menu button em { font-style: normal; color: #8A85A0; font-size: 12px; }
.ed-zoom-menu button.on { color: var(--ed-brand); font-weight: 700; }
.ed-zoom-menu button.on em { color: var(--ed-brand); opacity: .7; }

/* 悬停提示气泡：黑底白字 + 小三角 */
.ed-zoom [data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 11px);
    transform: translateX(-50%) translateY(3px);
    padding: 9px 12px; border-radius: 9px;
    background: rgba(26, 25, 34, .93); color: #fff;
    font-size: 13px; line-height: 1; white-space: nowrap;
    opacity: 0; pointer-events: none; z-index: 7;
    transition: opacity .16s ease, transform .16s ease;
}
.ed-zoom [data-tip]::before {
    content: ''; position: absolute; left: 50%; bottom: calc(100% + 6px);
    transform: translateX(-50%);
    border: 5px solid transparent; border-top: 5px solid rgba(26, 25, 34, .93); border-bottom: 0;
    opacity: 0; pointer-events: none; z-index: 7;
    transition: opacity .16s ease;
}
.ed-zoom [data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
.ed-zoom [data-tip]:hover::before { opacity: 1; }
/* 比例菜单展开时隐藏提示气泡，避免二者互相遮挡 */
.ed-zoom.__menu-open [data-tip]::after,
.ed-zoom.__menu-open [data-tip]::before { opacity: 0; transition: none; }

/* -------- 右侧样式面板 -------- */
.ed-right { background: #fff; border-left: 1px solid var(--ed-line); overflow: auto; padding: 0 0 20px; }
.sheet-head { display: none; }
.pnl { padding: 12px 14px 4px; border-bottom: 1px solid #F2EFF8; }
/* 面板与元素类型不匹配时隐藏（文字面板 / 图片面板按需显示） */
.pnl--off { display: none !important; }
.pnl h4 { margin: 0 0 10px; font-size: 13.5px; display: flex; align-items: center; gap: 6px; color: var(--ed-ink); }
.pnl h4 svg { width: 16px; height: 16px; fill: none; stroke: var(--ed-brand); stroke-width: 1.9; stroke-linecap: round; }
.field { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.field > label { width: 52px; flex: 0 0 52px; font-size: 12.5px; color: var(--ed-ink2); }
.field .val { width: 46px; text-align: right; font-size: 12.5px; color: #75709A; }
.field select, .field textarea, .field input[type="number"], .field input[type="text"] {
    flex: 1; min-width: 0; border: 1px solid var(--ed-line); border-radius: 8px;
    padding: 7px 9px; font-size: 13.5px; font-family: inherit; color: var(--ed-ink); background: #FBFAFE;
}
.pnl textarea { width: 100%; resize: vertical; line-height: 1.6; }
.field input[type="range"] { flex: 1; min-width: 0; accent-color: var(--ed-brand); }
/* 字号数字框（滑块右侧精调）：固定宽度，不挤占滑块 */
.field .size-in { flex: 0 0 58px; width: 58px; text-align: right; padding: 6px 7px; }
/* 原生 <input type="color"> 已弃用（其内置面板带 HEX/RGB/HSL 模式切换，无法裁剪），
   颜色统一走自绘取色器 .csw + .cpick，只提供 HEX */
.field input[type="color"] { width: 38px; height: 30px; padding: 0; border: 1px solid var(--ed-line); border-radius: 7px; background: #fff; }
/* 自定义颜色入口按钮（外框 + 内色片） */
.csw {
    flex: 0 0 auto; width: 38px; height: 30px; padding: 0; background: #fff;
    border: 1px solid var(--ed-line); border-radius: 7px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.csw.sm { width: 32px; height: 28px; }
.csw i {
    display: block; width: 24px; height: 18px; border-radius: 4px;
    background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
}
.csw.sm i { width: 20px; height: 16px; }
.csw:hover { border-color: #B9B4E3; }
.csw.on { border-color: var(--ed-brand); box-shadow: 0 0 0 2px rgba(83, 74, 183, .12); }
/* 「自定义」右侧：用过的自定义颜色，点一下即可复用 */
.color-field { align-items: center; }
.recents { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; min-width: 0; }
.rec {
    width: 22px; height: 22px; padding: 0; cursor: pointer;
    border: 1px solid rgba(0, 0, 0, .12); border-radius: 6px;
}
.rec:hover { transform: scale(1.12); }

/* ---- 自绘取色器（内联展开，只提供 HEX） ---- */
.cpick {
    margin: -2px 0 10px; padding: 10px; background: #fff;
    border: 1px solid var(--ed-line); border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}
.cpick[hidden] { display: none; }
.cpick-sv {
    position: relative; height: 132px; border-radius: 8px;
    cursor: crosshair; touch-action: none;
    background: linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
                linear-gradient(to right, #fff, #f00);
}
.cpick-sv i {
    position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px;
    border-radius: 50%; border: 2px solid #fff; pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.cpick-hue {
    position: relative; height: 14px; margin-top: 10px; border-radius: 7px;
    cursor: pointer; touch-action: none;
    background: linear-gradient(90deg, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cpick-hue i {
    position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
    border-radius: 50%; border: 2px solid #fff; pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.cpick-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cpick-eye {
    flex: 0 0 auto; width: 32px; height: 30px; padding: 0; background: #fff;
    border: 1px solid var(--ed-line); border-radius: 7px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.cpick-eye svg { width: 16px; height: 16px; fill: none; stroke: var(--ed-ink2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cpick-eye:hover { border-color: var(--ed-brand); }
.cpick-prev { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--ed-line); }
.cpick-hex {
    flex: 1; min-width: 0; width: auto; padding: 7px 9px; background: #fff;
    border: 1px solid var(--ed-line); border-radius: 7px;
    font-size: 13px; letter-spacing: .6px; text-transform: uppercase;
}
.cpick-hex.err { border-color: var(--ed-danger); background: #FDF5F5; }
.cpick-tip { margin: 8px 0 0; font-size: 11.5px; line-height: 1.55; color: #8A85A0; }
.field .num { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ed-ink2); }
.field .num input { width: 62px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btns button {
    border: 1px solid var(--ed-line); background: #fff; border-radius: 8px; padding: 6px 11px;
    cursor: pointer; font-size: 13px; color: var(--ed-ink2);
}
.btns button.on { background: #EEEDFE; border-color: var(--ed-brand); color: var(--ed-brand); font-weight: 600; }
.btns button.wide { width: 100%; }
/* 面板里的「删除这个文字」按钮：与恢复原始样式同宽，警示红 */
.btns button.wide.danger {
    background: #FDEDEC; border-color: #F2C6C9; color: var(--ed-danger); font-weight: 600;
}
.del-field { margin: 4px 0 2px; }
.sw-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.sw { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(0, 0, 0, .12); cursor: pointer; padding: 0; }
.sw:hover { transform: scale(1.08); }
/* 字体为原生下拉框（楷体/宋体/黑体/行楷，均为全平台通用的内置 Web 字体）。
 * option 预览样式用系统字体栈渲染（避免打开页面就触发 Web 字体全量下载） */
.pnl[data-pnl="font"] select { padding: 9px 10px; border: 1px solid var(--ed-line); border-radius: 8px; background: #fff; font-size: 14px; }
.tip { margin: 0 0 10px; font-size: 12px; color: #8A85A0; line-height: 1.6; }
.pnl [disabled] { opacity: .45; }

/* -------- 手机端底部工具栏 -------- */
.m-toolbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    display: none; grid-template-columns: repeat(5, 1fr);
    background: #fff; border-top: 1px solid var(--ed-line);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(110%); transition: transform .22s ease;
    box-shadow: 0 -4px 18px rgba(60, 52, 120, .10);
}
.m-toolbar.show { transform: none; }
.m-toolbar button {
    border: 0; background: none; padding: 8px 2px 7px; display: flex; flex-direction: column;
    align-items: center; gap: 3px; cursor: pointer; color: var(--ed-ink2); font-size: 12px;
}
.m-toolbar button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.m-toolbar button.on { color: var(--ed-brand); }
/* 手机端「＋ 添加文字」悬浮按钮：左下角，与右下角缩放胶囊对称，
 * 随底部遮挡（工具栏/面板/键盘，--ed-occupied）整体上移 */
.m-add {
    position: fixed; left: 10px;
    bottom: calc(14px + var(--ed-occupied, 0px));
    z-index: 45;
    display: none; align-items: center; justify-content: center; gap: 4px;
    height: 38px; padding: 0 15px;
    background: #fff; border: 1px solid #E8E4F0; border-radius: 999px;
    box-shadow: 0 6px 20px rgba(60, 52, 120, .12), 0 1px 2px rgba(60, 52, 120, .06);
    color: #3F3B55; font-size: 14px; font-family: inherit; line-height: 1;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    user-select: none; -webkit-user-select: none;
    transition: opacity .18s ease, visibility .18s ease;
}
.m-add:active { background: #f2f3f5; }
/* 「＋ 添加图片」：叠在「＋ 添加文字」上方一档，避免与右侧缩放胶囊抢位置 */
.m-add.m-add-img { bottom: calc(58px + var(--ed-occupied, 0px)); }
.sheet-mask {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 65;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-mask.show { opacity: 1; pointer-events: auto; }
.edit-done {
    position: fixed; right: 16px; top: calc(var(--ed-head) + 12px); z-index: 75;
    display: none; padding: 9px 18px; border-radius: 999px; border: 0;
    background: var(--ed-brand); color: #fff; font-size: 14px; box-shadow: 0 6px 18px rgba(83, 74, 183, .35);
}
.edit-done.show { display: block; }

/* -------- 导出弹窗 --------
 * 注意：遮罩必须可滚动、弹窗用 margin:auto 居中 —— 不能用 align-items:center 硬居中。
 * 硬居中在「内容超过一屏」（如导出结果带预览图）时会把顶部和底部同时顶出屏幕外，
 * 用户既看不到标题也看不到客服微信；margin:auto 在放得下时居中、放不下时自动贴顶并滚动。 */
.qj-mask {
    position: fixed; inset: 0; background: rgba(20, 18, 32, .5); z-index: 100;
    display: none; padding: 18px;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.qj-mask.show { display: flex; }
.qj-modal { position: relative; background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 420px; margin: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.qj-modal h3 { margin: 0 0 6px; font-size: 18px; padding-right: 34px; }
/* 右上角关闭（X）：视觉 30px、命中区 34px，与弹窗内「关闭」按钮同一个 data-act */
.qj-modal-close {
    position: absolute; right: 12px; top: 12px; width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; border: 0; border-radius: 50%; background: transparent;
    color: #8A85A0; cursor: pointer; transition: background .15s, color .15s;
}
.qj-modal-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; }
.qj-modal-close:hover { background: #EEEDFE; color: var(--ed-brand); }
.qj-modal-close:focus-visible { outline: 2px solid var(--ed-brand); outline-offset: 1px; }
.qj-modal .desc { color: var(--ed-ink2); font-size: 13px; margin: 0 0 14px; }
.qj-modal .row { display: flex; gap: 8px; margin-bottom: 10px; }
.qj-modal input {
    flex: 1; min-width: 0; border: 1px solid var(--ed-line); border-radius: 10px;
    padding: 11px 12px; font-size: 16px; letter-spacing: 2px; text-transform: uppercase;
    font-family: inherit;
}
.qj-modal .row.actions { margin: 16px 0 4px; }
.qj-modal .row.actions button { flex: 1; }

/* -------- 两档导出：「免费带水印」直接可用 + 「我有提取码」折叠解锁无水印 -------- */
.qj-modal .desc b { color: var(--ed-brand); font-weight: 600; }
.qj-modal .free-note { margin: -2px 0 4px; text-align: center; font-size: 12px; color: var(--ed-ink2); }
.code-fold { margin: 12px 0 4px; border: 1px solid var(--ed-line); border-radius: 12px; overflow: hidden; }
.code-fold-head {
    display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
    padding: 11px 12px; border: 0; background: #F7F6FB; cursor: pointer; text-align: left;
    font-family: inherit; font-size: 13.5px; color: var(--ed-ink); transition: background .15s;
}
.code-fold-head:hover { background: #F1EFF9; }
.code-fold-head:focus-visible { outline: 2px solid var(--ed-brand); outline-offset: -2px; }
.code-fold-head .cf-ico { font-size: 14px; line-height: 1; }
.code-fold-head .cf-text { flex: 1; min-width: 0; }
.code-fold-head .cf-arrow { color: var(--ed-ink2); transition: transform .18s; }
.code-fold.open .code-fold-head { border-bottom: 1px solid var(--ed-line); }
.code-fold.open .cf-arrow { transform: rotate(180deg); }
.code-body { padding: 12px 12px 2px; }
.code-body .row { margin-bottom: 8px; }
.code-body .row.actions { margin: 10px 0 6px; }
.code-info { font-size: 13px; min-height: 20px; color: var(--ed-ink2); }
.code-info.ok { color: #1e7a3c; }
.code-info.err { color: var(--ed-danger); }

/* -------- 购买提取码入口 --------
 * 紧跟在「我有提取码」折叠条之后：用户发现自己没有码时，不用退出弹窗去别处找。
 * 后台「购买提取码」关闭时整块不渲染（PHP 判断），所以这里不用写隐藏态。 */
.qj-modal .ed-buy {
    display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;
    margin: 12px 0 2px; padding: 11px 14px; cursor: pointer; text-align: left;
    font-family: inherit; font-size: 13.5px; border-radius: 12px;
    border: 1px solid rgba(83, 74, 183, .35);
    background: linear-gradient(145deg, #EEEDFE, #E4E2FB);
    color: var(--ed-ink); text-decoration: none;
    transition: border-color .15s, background .15s, transform .1s;
}
.qj-modal .ed-buy:hover { border-color: var(--ed-brand); background: linear-gradient(145deg, #E4E2FB, #D5D2F4); }
.qj-modal .ed-buy:active { transform: scale(.99); }
.qj-modal .ed-buy:focus-visible { outline: 2px solid var(--ed-brand); outline-offset: 2px; }
.qj-modal .ed-buy .eb-ico {
    flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(145deg, var(--ed-brand), #443B9E); color: #fff; font-size: 15px; line-height: 1;
}
.qj-modal .ed-buy .eb-txt { flex: 1; min-width: 0; }
.qj-modal .ed-buy .eb-txt em { display: block; font-style: normal; font-size: 11.5px; color: #8A85A0; letter-spacing: 1px; }
.qj-modal .ed-buy .eb-txt b { display: block; font-size: 14.5px; font-weight: 700; color: var(--ed-brand); }
.qj-modal .ed-buy .eb-arrow { flex: none; color: var(--ed-brand); font-size: 16px; }

/* -------- 弹窗底部客服微信：整条可点即复制微信号 --------
 * 提取码是联系客服拿的，所以联系方式直接摆在弹窗里，省掉用户去页脚找的那一步。 */
.qj-modal .modal-wx {
    display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;
    margin: 10px 0 0; padding: 9px 12px; cursor: pointer; text-align: left;
    font-family: inherit; border-radius: 12px;
    border: 1px solid rgba(217, 154, 61, .42);
    background: linear-gradient(145deg, rgba(235, 207, 156, .22), rgba(217, 154, 61, .07));
    transition: border-color .15s, background .15s, transform .1s;
}
.qj-modal .modal-wx:hover { border-color: rgba(217, 154, 61, .72); background: linear-gradient(145deg, rgba(235, 207, 156, .36), rgba(217, 154, 61, .14)); }
.qj-modal .modal-wx:active { transform: scale(.99); }
.qj-modal .modal-wx:focus-visible { outline: 2px solid var(--ed-brand); outline-offset: 2px; }
.qj-modal .modal-wx .mw-ico {
    flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(145deg, #EBCF9C, var(--ed-gold)); color: #4A3810;
    font-size: 14px; font-weight: 700; line-height: 1;
}
.qj-modal .modal-wx .mw-txt { flex: 1; min-width: 0; }
.qj-modal .modal-wx .mw-txt em { display: block; font-style: normal; font-size: 11.5px; color: #8A85A0; letter-spacing: 1px; }
/* 微信号本体：加大加粗 + 深金，弹窗里的视觉重心 */
.qj-modal .modal-wx .mw-txt b { display: block; font-size: 17px; font-weight: 700; color: #8A6414; letter-spacing: .6px; word-break: break-all; }
.qj-modal .modal-wx .mw-copy {
    flex: none; font-size: 12px; padding: 5px 11px; border-radius: 999px;
    color: #8A6414; border: 1px solid rgba(217, 154, 61, .5); background: rgba(255, 255, 255, .72);
    transition: .15s;
}
.qj-modal .modal-wx:hover .mw-copy { background: #fff; }
.qj-modal .modal-wx.copied { border-color: rgba(60, 160, 100, .5); background: rgba(90, 190, 120, .12); }
.qj-modal .modal-wx.copied .mw-copy { color: #1e7a3c; border-color: rgba(60, 160, 100, .55); background: #fff; }
#exportResult p { margin: 6px 0; font-size: 13px; }
#exportResult .ok { color: #1e7a3c; }
#exportResult .err { color: var(--ed-danger); }
#exportResult .dl {
    display: block; text-align: center; background: var(--ed-brand); color: #fff;
    padding: 11px; border-radius: 10px; margin: 10px 0 6px; font-weight: 600;
    border: 0; cursor: pointer; font-size: 14px; width: 100%;
}
#exportResult .dl[disabled] { opacity: .6; }
/* 导出成功后的图片预览：微信等不支持分享面板的环境里，用户长按它「保存到相册」 */
#exportResult .export-preview {
    display: block; max-width: 78%; max-height: 34vh; width: auto; height: auto;
    margin: 8px auto 2px; border-radius: 10px; box-shadow: 0 6px 18px rgba(60, 52, 120, .16);
}
/* 预览图占位：原图很大（最长边 3840px），解码完之前只显示「正在生成图片中…」，
   否则浏览器边解边画会「空白一片」或「只画出上半截」 */
#exportResult .export-shot {
    position: relative; display: flex; align-items: center; justify-content: center;
    min-height: 132px;
}
#exportResult .export-shot .shot-tip {
    position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0 10px; color: #8A85A0; font-size: 13px; text-align: center;
}
#exportResult .export-shot .shot-spin {
    flex: 0 0 14px; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid rgba(83, 74, 183, .22); border-top-color: var(--ed-brand);
    animation: qjShotSpin .8s linear infinite;
}
@keyframes qjShotSpin { to { transform: rotate(360deg); } }
#exportResult .export-shot .export-preview { opacity: 0; }
#exportResult .export-shot.loaded .shot-tip { display: none; }
#exportResult .export-shot.loaded .export-preview { opacity: 1; transition: opacity .18s; }
#exportResult .export-shot.failed .shot-spin { display: none; }
#exportResult .export-shot.failed .shot-tip { color: var(--ed-brand); }
/* 手机端屏幕小：预览图再压一档，让「下载按钮 + 说明 + 客服微信」尽量少滚动就能看到 */
@media (max-width: 900px) and (pointer: coarse) {
    #exportResult .export-preview { max-height: 26vh; }
    #exportResult .export-shot { min-height: 108px; }
}
.toast {
    position: fixed; left: 50%; top: 74px; transform: translate(-50%, -12px);
    background: rgba(26, 25, 34, .92); color: #fff; padding: 9px 16px; border-radius: 10px;
    font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; z-index: 120;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(208, 69, 63, .94); }

/* -------- 通用选择弹窗（如替换图片时比例不一致的处理方式） -------- */
.qj-dialog-mask {
    position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 200;
    background: rgba(20, 18, 35, .45);
    display: flex; align-items: center; justify-content: center;
    padding: 18px;
}
.qj-dialog {
    width: 100%; max-width: 360px;
    background: #FAF9F6; border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    padding: 18px 16px 10px;
    max-height: 86vh; overflow: auto;
}
.qj-dialog h3 { margin: 0 0 6px; font-size: 16px; color: var(--ed-ink); }
.qj-dialog p  { margin: 0 0 12px; font-size: 13px; color: var(--ed-ink2); line-height: 1.6; }
.qj-dialog-btns { display: flex; flex-direction: column; gap: 8px; }
.qj-dialog-btns button {
    text-align: left; border: 1px solid var(--ed-line); background: #fff;
    border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--ed-ink);
    font-family: inherit;
}
/* 第一项（推荐项）用品牌色描边突出 */
.qj-dialog-btns button:first-child { border-color: var(--ed-brand); background: #F7F6FE; }
.qj-dialog-btns button:active { background: #F1EFF9; }
.qj-dialog-btns b { display: block; font-size: 14px; font-weight: 700; }
.qj-dialog-btns i {
    display: block; font-style: normal; font-size: 12px; color: var(--ed-ink2);
    margin-top: 3px; line-height: 1.5;
}
.qj-dialog-cancel {
    display: block; width: 100%; margin-top: 8px; padding: 10px;
    border: 0; background: none; color: var(--ed-ink2); font-size: 14px;
    cursor: pointer; font-family: inherit;
}

/* -------- 可视化取景器（等比裁剪：直接拖框选择保留范围）-------- */
.qj-crop-mask { padding: 12px; }
.qj-crop {
    width: 100%; max-width: 440px; max-height: 92vh; overflow: auto;
    background: #FAF9F6; border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
    padding: 16px 16px 12px;
}
.qj-crop h3 { margin: 0 0 6px; font-size: 16px; color: var(--ed-ink); }
.qj-crop > p { margin: 0 0 12px; font-size: 12.5px; color: var(--ed-ink2); line-height: 1.6; }
/* 图片区：深底衬着，方便看清裁掉的部分 */
.qj-crop-stage {
    display: flex; align-items: center; justify-content: center;
    background: #211F2E; border-radius: 12px; padding: 10px;
}
.qj-crop-canvas {
    position: relative; line-height: 0; overflow: hidden;
    border-radius: 6px; touch-action: none;
    /* 关键：容器必须收缩到与图片完全等大。
     * 竖版图片受 max-height 限制显示得比弹窗窄，若容器仍占满整行，
     * 取景框（相对容器定位）就会和实际裁剪窗口错位，预览对不上 */
    width: fit-content; max-width: 100%; margin: 0 auto;
}
.qj-crop-canvas img {
    display: block; max-width: 100%; max-height: 40vh; border-radius: 6px;
    -webkit-user-drag: none; user-select: none;
}
/* 取景框：框外压暗（用超大 box-shadow 盖住，被 .qj-crop-canvas 的 overflow 裁掉） */
.qj-crop-frame {
    position: absolute; left: 0; top: 0; box-sizing: border-box;
    border: 2px solid #fff; border-radius: 2px;
    box-shadow: 0 0 0 2000px rgba(12, 10, 25, .55);
    cursor: move; touch-action: none;
}
/* 三分参考线 */
.qj-crop-frame::before,
.qj-crop-frame::after {
    content: ''; position: absolute; background: rgba(255, 255, 255, .3);
}
.qj-crop-frame::before { left: 0; right: 0; top: 33.33%; height: 1px; }
.qj-crop-frame::after  { top: 0; bottom: 0; left: 33.33%; width: 1px; }
.qj-crop-frame.locked { border-style: dashed; cursor: default; }
/* 四角白色圆点手柄：拖动任意一角可放大 / 缩小取景范围（等比，不变形）。
 * 圆点视觉 16px，命中区 32px（手机上也好按） */
.qj-crop-grip {
    position: absolute; width: 32px; height: 32px;
    margin: -16px 0 0 -16px;            /* 圆点中心正压在角的顶点上 */
    touch-action: none; z-index: 2;
}
.qj-crop-grip[data-corner="nw"] { left: 0;    top: 0;    cursor: nwse-resize; }
.qj-crop-grip[data-corner="ne"] { left: 100%; top: 0;    cursor: nesw-resize; }
.qj-crop-grip[data-corner="sw"] { left: 0;    top: 100%; cursor: nesw-resize; }
.qj-crop-grip[data-corner="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.qj-crop-grip::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 16px; height: 16px; margin: -8px 0 0 -8px; box-sizing: border-box;
    background: #fff; border: 2px solid rgba(20, 18, 35, .4); border-radius: 50%;
    box-shadow: 0 1px 5px rgba(0, 0, 0, .55);
}
.qj-crop-mask.resizing .qj-crop-grip::before { background: var(--ed-brand); border-color: #fff; }
.qj-crop-mask.resizing, .qj-crop-mask.resizing .qj-crop-grip { cursor: nwse-resize; }
.qj-crop-mask.dragging { cursor: grabbing; }
.qj-crop-mask.dragging .qj-crop-frame { border-color: var(--ed-brand); }

.qj-crop-side { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; }
.qj-crop-prev { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.qj-crop-prev canvas {
    display: block; border-radius: 8px; border: 1px solid var(--ed-line);
    background: #F2EFF8; box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.qj-crop-prev span { font-size: 11px; color: var(--ed-ink2); }
.qj-crop-info { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ed-ink2); }
.qj-crop-acts { display: flex; gap: 8px; margin-top: 12px; }
.qj-crop-acts button {
    flex: 1 1 0; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--ed-line); background: #fff; color: var(--ed-ink);
    font-size: 14px; font-family: inherit; cursor: pointer;
}
.qj-crop-acts button.primary {
    background: var(--ed-brand); border-color: var(--ed-brand); color: #fff; font-weight: 700;
}
.qj-crop-acts button:active { transform: scale(.98); }
@media (max-width: 380px) {
    .qj-crop-side { flex-direction: column; align-items: flex-start; }
}


/* -------- 触摸设备：不要 hover 提示气泡 --------
 * 手机浏览器点按后会「粘住」:hover，于是点一次缩放就残留一个气泡，
 * 而且提示文案（Ctrl 滚轮）本身就是电脑端操作，触摸设备上完全不适用 */
@media (pointer: coarse) {
    .ed-zoom [data-tip]::after,
    .ed-zoom [data-tip]::before { display: none; content: none; }
}

/* -------- 电脑端窄视口（浏览器放大导致）--------
 * 保持三栏画面，但收窄左右两栏，避免整体横向溢出 */
@media (max-width: 1000px) and (pointer: fine) {
    .ed-wrap { grid-template-columns: 188px 1fr 262px; }
    .ed-left-head small { display: none; }
}

/* 电脑端放大到极致（视口 <640px）时收起左侧文字列表，保住「画布 + 样式」两栏 */
@media (max-width: 640px) and (pointer: fine) {
    .ed-wrap { grid-template-columns: 1fr 248px; }
    .ed-left { display: none; }
}

/* -------- 移动端 --------
 * 仅触摸设备（pointer: coarse）进入手机布局；
 * 电脑端浏览器放大（Ctrl+加号）导致视口变窄时，保持电脑端三栏画面。 */
@media (max-width: 900px) and (pointer: coarse) {
    /* 页面本身不可滚动：手机端软键盘弹出时，浏览器会滚动文档去露出输入框，
     * 顶栏（返回首页/导出图片）会被顶出屏幕、点不到。position:fixed 让页面彻底不可滚 */
    body.editor-page {
        position: fixed; inset: 0; width: 100%; height: 100%;
        overflow: hidden; overscroll-behavior: none;
    }
    /* 顶栏固定：即使发生视觉视口位移，返回/导出始终留在原位可点 */
    .ed-head {
        position: fixed; top: 0; left: 0; right: 0; z-index: 90;
        padding: 0 10px; gap: 8px;
    }
    /* 标题弹性收缩（flex:1 + min-width:0 才会真正让位给按钮），
     * 按钮组 nowrap，避免窄屏把「返回首页」挤成两行 */
    .ed-title { font-size: 14px; }
    /* 编号行只在电脑端显示：手机顶栏本来就挤，标题要优先让位给按钮 */
    .ed-code { display: none; }
    /* 标题外面套了一层 .ed-titlebox（为了放编号行），弹性收缩改由它承担 */
    .ed-titlebox { flex: 1 1 auto; }
    .ed-actions { flex: 0 0 auto; gap: 6px; }
    .ed-btn { padding: 7px 11px; font-size: 13px; }
    /* 撤销 / 重做：窄屏再收一点，避免顶栏按钮组把标题挤没 */
    .ed-undo { padding: 1px; margin-right: 0; }
    .ed-undo button { width: 30px; height: 30px; }
    .ed-undo button svg { width: 16px; height: 16px; }
    /* 后台排版编辑器顶栏比前台多一个「模板设置」、再加撤销/重做后共 5 个控件，
     * 390px 宽的手机上按前台的字号排会横向溢出：按钮收紧 + 标题让位
     * （标题在浏览器标签页与「模板设置」弹窗里都能看到，此处最不重要）。 */
    .ed-head-admin .ed-title { display: none; }
    .ed-head-admin .ed-titlebox { display: none; }
    .ed-head-admin .ed-btn { padding: 6px 9px; font-size: 12.5px; }
    /* 顶栏脱流后由 .ed-wrap 自己补出高度（含 padding-top 占位）。
     * 高度必须用 100%（body 在本断点内是 fixed+inset:0，跟随真实可视区），
     * 不能写 100vh —— iOS Safari 的 100vh 是「地址栏收起后的大视口」，
     * 比可见区域高出底栏几十 px，画布会在这块看不见的高度里居中，
     * 表现为顶上缝大、底下缝被浏览器栏吃掉。 */
    .ed-wrap { grid-template-columns: 1fr; height: 100%; padding-top: var(--ed-head); }
    .ed-left { display: none; }
    /* --ed-occupied 由 JS 实时写入 = 软键盘 + 底部工具栏 + 样式面板的实际遮挡高度。
     * padding-bottom 用它兜出底部空间：画布缩到能完整显示时，stage（margin:auto 垂直居中）
     * 就会居中在「顶栏以下、菜单/键盘以上」的安全区里，而不是被面板盖住下半截 */
    /* 上下 padding 对称（14/14）：居中垫片之外不再有额外偏差；
     * --ed-occupied 只在面板/键盘弹出时撑大底部，属功能性避让 */
    .ed-center { padding: 14px 8px calc(14px + var(--ed-occupied, 0px)); }
    /* 缩放控件：改用 fixed 定位（原来绝对定位在滚动容器里，会随内容滚走、
     * 也会被底部工具栏压住），并整体抬到「工具栏 + 面板 + 键盘」之上 */
    .ed-zoom {
        position: fixed; right: 10px;
        bottom: calc(14px + var(--ed-occupied, 0px));
        z-index: 45;
        transition: opacity .18s ease, visibility .18s ease;
    }
    /* 样式面板占住下半屏时收起缩放控件（此时遮罩在上层，点它只会关面板） */
    body.editor-page.sheet-open .ed-zoom { opacity: 0; visibility: hidden; }
    /* 「添加文字」按钮：仅手机端显示；面板打开时同样收起 */
    .m-add { display: inline-flex; }
    body.editor-page.sheet-open .m-add { opacity: 0; visibility: hidden; }
    /* --ed-kb 由 JS 按 visualViewport 写入：软键盘弹起的高度。
     * 底部工具栏与面板整体抬到键盘上方，保证「一边打字一边切面板」也能点 */
    .m-toolbar { display: grid; bottom: var(--ed-kb, 0px); }
    .ed-right {
        position: fixed; left: 0; right: 0;
        bottom: calc(var(--ed-tb-h, 61px) + var(--ed-kb, 0px)); z-index: 68;
        max-height: 60vh; border-left: 0; border-radius: 18px 18px 0 0;
        box-shadow: 0 -10px 30px rgba(60, 52, 120, .18);
        /* 同时用 visibility 兜底：内容高度很小时，仅靠 translateY 百分比会把面板露出来。
         * visibility 不参与时长过渡——打开时立即可见（否则同一次点击里同步
         * focus 面板输入框会因「此刻仍不可见」而静默失败，手机端无法直接弹键盘），
         * 关闭时延迟 .24s 隐藏，等滑出动画放完再消失 */
        transform: translateY(115%); visibility: hidden;
        transition: transform .24s ease, visibility 0s .24s linear;
        padding-bottom: 14px; overflow: auto;
    }
    .ed-right.open {
        transform: none; visibility: visible;
        transition: transform .24s ease, visibility 0s;
    }
    .sheet-head {
        display: flex; align-items: center; justify-content: space-between;
        position: sticky; top: 0; background: #fff; padding: 12px 14px 8px;
        border-bottom: 1px solid #F2EFF8; z-index: 2;
    }
    .sheet-head b { font-size: 15px; }
    .sheet-close {
        border: 0; background: #EEEDFE; color: var(--ed-brand); border-radius: 999px;
        padding: 6px 14px; font-size: 13px; cursor: pointer;
    }
    .ed-right .pnl { display: none; border-bottom: 0; padding: 14px 16px 6px; }
    .ed-right.open .pnl.active { display: block; }
    .pnl textarea { font-size: 16px; }
}
