Files
it-tools-pro/src/tools/ai-gen/img-editor.vue
T
jinghui 7b6513c7de feat(ai-gen): 图片编辑器 — 文字发光/旋转、图片叠加、拖角改大小
- 新增 img-editor.vue(670行): 文字图层(大小/发光/旋转/拖动) + 图片图层(叠加/缩放)
- ai-gen.vue 生成结果增加「编辑图片」入口, 1024×1024 导出
2026-11-15 01:56:28 +08:00

671 lines
23 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { getMachineId, licenseHeaders } from '@/tools/license/license';
import { authHdr } from '@/tools/img-hist/img-hist';
// AI 生图结果编辑器:底图=生成图(锁定),叠加文字/图片图层
// 坐标系=底图原始像素,显示按 scale 缩放 → 导出即原图分辨率所见即所得
// 与海报编辑器的差异:拖右下角手柄直接改大小(文字改字号、图片等比),发光+旋转
const props = defineProps<{ src: string; prompt?: string }>();
const emit = defineEmits<{ close: []; saved: [url: string] }>();
const FONT_STACK = '"Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif';
type L = any; // 图层运行时对象(text / image 联合,编辑期动态增删)
const stageEl = ref<HTMLElement | null>(null);
const natW = ref(0);
const natH = ref(0);
const scale = ref(1);
const layers = ref<L[]>([]);
const selId = ref('');
const exporting = ref(false);
const edError = ref('');
const fileEl = ref<HTMLInputElement | null>(null);
let fileMode: 'add' | 'replace' = 'add';
let uid = 0;
let bgImg: HTMLImageElement | null = null;
const sel = computed(() => layers.value.find((l) => l.id === selId.value) || null);
// ---------- 底图加载 / 自适应缩放 ----------
function loadBg() {
const i = new Image();
i.onload = () => {
bgImg = i;
natW.value = i.naturalWidth;
natH.value = i.naturalHeight;
fit();
};
i.onerror = () => { edError.value = '底图加载失败'; };
i.src = props.src;
}
function fit() {
const el = stageEl.value;
if (!el || !natW.value) return;
const w = Math.max(el.clientWidth - 24, 120);
const h = Math.max(el.clientHeight - 24, 120);
scale.value = Math.max(Math.min(w / natW.value, h / natH.value), 0.05);
}
const handleStyle = computed(() => {
const s = scale.value || 1;
const sz = Math.max(14 / s, 10);
return { width: sz + 'px', height: sz + 'px', right: -sz / 2 + 'px', bottom: -sz / 2 + 'px', borderWidth: Math.max(2 / s, 1.5) + 'px' };
});
// ---------- 文字排版(预览与导出共用,保证换行一致) ----------
const mc = document.createElement('canvas');
const mctx = mc.getContext('2d')!;
const wrapCache = new Map<string, string[]>();
const CLOSE_PUNCT = ',。、!?:;)】」』,.!?;:)';
function fontStr(l: L) { return `${l.weight ?? 700} ${l.size}px ${FONT_STACK}`; }
function linesOf(l: L): string[] {
const key = `${l.text}|${l.w}|${fontStr(l)}`;
const hit = wrapCache.get(key);
if (hit) return hit;
mctx.font = fontStr(l);
const out: string[] = [];
for (const para of String(l.text ?? '').split('\n')) {
if (!para) { out.push(''); continue; }
let line = '';
for (const ch of para) {
const test = line + ch;
if (line && mctx.measureText(test).width > l.w && !CLOSE_PUNCT.includes(ch)) {
out.push(line); line = ch;
} else line = test;
}
out.push(line);
}
const res = out.length ? out : [''];
wrapCache.set(key, res);
return res;
}
const maxFontSize = computed(() => Math.max(80, Math.round((natW.value || 1024) * 0.25)));
// ---------- 样式 ----------
function boxStyle(l: L) {
return {
left: l.x + 'px', top: l.y + 'px', width: l.w + 'px',
height: l.type === 'text' ? 'auto' : l.h + 'px',
transform: l.rot ? `rotate(${l.rot}deg)` : undefined,
};
}
function fontStyle(l: L) {
return {
fontFamily: FONT_STACK,
fontSize: l.size + 'px',
fontWeight: String(l.weight ?? 700),
color: l.color,
textAlign: 'center' as const,
lineHeight: l.size * (l.lineHeight ?? 1.25) + 'px',
textShadow: l.glow ? `0 0 ${l.glowBlur ?? 14}px ${l.glowColor ?? '#000000'}` : 'none',
};
}
// ---------- 选中 / 拖动移动 ----------
let drag: { l: L; sx: number; sy: number; lx: number; ly: number } | null = null;
function onDown(e: PointerEvent, l: L) {
selId.value = l.id;
drag = { l, sx: e.clientX, sy: e.clientY, lx: l.x, ly: l.y };
window.addEventListener('pointermove', onMove);
window.addEventListener('pointerup', onUp);
e.preventDefault();
}
function onMove(e: PointerEvent) {
if (!drag) return;
const s = scale.value || 1;
const l = drag.l;
const nx = drag.lx + (e.clientX - drag.sx) / s;
const ny = drag.ly + (e.clientY - drag.sy) / s;
const estH = l.type === 'text' ? linesOf(l).length * l.size * (l.lineHeight ?? 1.25) : l.h;
l.x = Math.min(Math.max(nx, 0), Math.max(natW.value - l.w, 0));
l.y = Math.min(Math.max(ny, 0), Math.max(natH.value - estH, 0));
}
function onUp() {
drag = null;
window.removeEventListener('pointermove', onMove);
window.removeEventListener('pointerup', onUp);
}
// ---------- 拖右下角手柄改大小(位移旋转到图层局部轴,旋转后拖拽方向依然正确) ----------
let rz: { l: L; sx: number; sy: number; w0: number; h0: number; size0: number; rot: number } | null = null;
function onRzDown(e: PointerEvent, l: L) {
selId.value = l.id;
rz = { l, sx: e.clientX, sy: e.clientY, w0: l.w, h0: l.h ?? 0, size0: l.size ?? 48, rot: l.rot ?? 0 };
window.addEventListener('pointermove', onRzMove);
window.addEventListener('pointerup', onRzUp);
e.preventDefault();
e.stopPropagation();
}
function onRzMove(e: PointerEvent) {
if (!rz) return;
const s = scale.value || 1;
const dx = (e.clientX - rz.sx) / s;
const dy = (e.clientY - rz.sy) / s;
const rad = (-rz.rot * Math.PI) / 180;
const ldx = dx * Math.cos(rad) - dy * Math.sin(rad);
const ldy = dx * Math.sin(rad) + dy * Math.cos(rad);
const l = rz.l;
if (l.type === 'image') {
// 拖横向/纵向取位移大的轴驱动,等比缩放(以左上角为锚)
const delta = Math.abs(ldx) >= Math.abs(ldy) ? ldx : ldy;
const nw = Math.max(24, rz.w0 + delta);
const ratio = nw / rz.w0;
l.w = nw;
l.h = Math.max(24, rz.h0 * ratio);
} else {
// 文字:水平拖动改字号,换行宽度同步缩放保持排版比例
const ns = Math.min(Math.max(rz.size0 + ldx, 8), maxFontSize.value);
const ratio = ns / Math.max(1, rz.size0);
l.size = Math.round(ns);
l.w = Math.max(40, Math.round(rz.w0 * ratio));
}
}
function onRzUp() {
rz = null;
window.removeEventListener('pointermove', onRzMove);
window.removeEventListener('pointerup', onRzUp);
}
// ---------- 图层增删 ----------
function addText() {
const w = Math.round(natW.value * 0.8);
const l = {
id: 'l' + ++uid, type: 'text', text: '双击右侧修改文字',
x: Math.round((natW.value - w) / 2), y: Math.round(natH.value * 0.42), w,
size: Math.round(natW.value * 0.07) || 64, color: '#ffffff', weight: 700, lineHeight: 1.25,
glow: true, glowColor: '#000000', glowBlur: 14, rot: 0,
};
layers.value.push(l);
selId.value = l.id;
}
function pickImage() { fileMode = 'add'; fileEl.value?.click(); }
function replaceImage() { fileMode = 'replace'; fileEl.value?.click(); }
function onFile(e: Event) {
const f = (e.target as HTMLInputElement).files?.[0];
const input = e.target as HTMLInputElement;
input.value = '';
if (!f) return;
const url = URL.createObjectURL(f);
const probe = new Image();
probe.onload = () => {
if (fileMode === 'replace') {
const l = sel.value;
if (l && l.type === 'image') l.src = url;
return;
}
const w = Math.round(natW.value * 0.4) || 400;
const h = Math.round((w * probe.naturalHeight) / Math.max(1, probe.naturalWidth));
const l = {
id: 'l' + ++uid, type: 'image', src: url,
x: Math.round((natW.value - w) / 2), y: Math.round((natH.value - h) / 2),
w, h, rot: 0,
};
layers.value.push(l);
selId.value = l.id;
};
probe.src = url;
}
function delSel() {
const i = layers.value.findIndex((l) => l.id === selId.value);
if (i >= 0) layers.value.splice(i, 1);
selId.value = '';
}
function moveLayer(dz: number) {
const i = layers.value.findIndex((l) => l.id === selId.value);
const j = i + dz;
if (i < 0 || j < 0 || j >= layers.value.length) return;
const [l] = layers.value.splice(i, 1);
layers.value.splice(j, 0, l);
}
const selName = computed(() => {
const l = sel.value;
if (!l) return '';
return l.type === 'text' ? String(l.text || '文字').slice(0, 12) : '图片';
});
// ---------- 导出原分辨率 PNG:下载 + 落盘历史(失败不阻断下载) ----------
function loadImg(src: string): Promise<HTMLImageElement | null> {
return new Promise((res) => {
const i = new Image();
i.onload = () => res(i);
i.onerror = () => res(null);
i.src = src;
});
}
function rotAround(ctx: CanvasRenderingContext2D, cx: number, cy: number, deg: number) {
ctx.translate(cx, cy);
ctx.rotate((deg * Math.PI) / 180);
ctx.translate(-cx, -cy);
}
async function drawLayer(ctx: CanvasRenderingContext2D, l: L) {
if (l.type === 'image') {
const img = l.src ? await loadImg(l.src) : null;
if (!img || !img.naturalWidth) return;
ctx.save();
if (l.rot) rotAround(ctx, l.x + l.w / 2, l.y + l.h / 2, l.rot);
ctx.drawImage(img, l.x, l.y, l.w, l.h);
ctx.restore();
return;
}
// 文字
ctx.font = fontStr(l);
ctx.fillStyle = l.color;
const lh = l.size * (l.lineHeight ?? 1.25);
const m = ctx.measureText('字');
const asc = (m as any).fontBoundingBoxAscent ?? l.size * 0.8;
const desc = (m as any).fontBoundingBoxDescent ?? l.size * 0.2;
const lines = linesOf(l);
ctx.save();
if (l.rot) rotAround(ctx, l.x + l.w / 2, l.y + (lines.length * lh) / 2, l.rot);
ctx.textAlign = 'center';
const tx = l.x + l.w / 2;
for (let i = 0; i < lines.length; i++) {
const y = l.y + i * lh + (lh - (asc + desc)) / 2 + asc;
if (l.glow) {
ctx.shadowColor = l.glowColor ?? '#000000';
ctx.shadowBlur = l.glowBlur ?? 14;
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
} else {
ctx.shadowColor = 'transparent';
ctx.shadowBlur = 0;
}
ctx.fillText(lines[i], tx, y);
}
ctx.restore();
}
async function exportPng() {
if (!natW.value || !bgImg) return;
exporting.value = true;
edError.value = '';
try {
const c = document.createElement('canvas');
c.width = natW.value;
c.height = natH.value;
const ctx = c.getContext('2d')!;
ctx.drawImage(bgImg, 0, 0, natW.value, natH.value);
for (const l of layers.value) await drawLayer(ctx, l);
const blob: Blob | null = await new Promise((res) => c.toBlob(res, 'image/png'));
if (!blob) throw new Error('画布导出失败');
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = 'AI生图-编辑.png';
a.click();
setTimeout(() => URL.revokeObjectURL(a.href), 8000);
// 同步保存到图片历史(kind=gen → 出现在本工具右栏),失败不阻断下载
try {
const b64 = await new Promise<string>((res, rej) => {
const fr = new FileReader();
fr.onload = () => res(String(fr.result || ''));
fr.onerror = () => rej(new Error('读取失败'));
fr.readAsDataURL(blob);
});
const res = await fetch('/relay/ai/img-save', {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...licenseHeaders('ai-gen'), ...authHdr() },
body: JSON.stringify({
machine: getMachineId(), b64, tool: 'ai-gen', kind: 'gen',
model: 'AI生图', prompt: String(props.prompt || '').slice(0, 200) || '图片编辑导出',
}),
});
const j = await res.json().catch(() => ({}) as any);
if (res.ok && j.code === 200) emit('saved', j.data?.img_url || '');
} catch { /* 保存失败不影响本地下载 */ }
} catch (err: any) {
const msg = String(err?.message || err);
edError.value = msg.includes('SecurityError') || msg.includes('tainted')
? '该图片来自外链,浏览器禁止导出(跨域)。请先下载图片,再用「+图片」上传后编辑'
: '导出失败:' + msg;
} finally {
exporting.value = false;
}
}
function onKey(e: KeyboardEvent) {
if (e.key === 'Escape') emit('close');
const t = e.target as HTMLElement | null;
const typing = !!t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA');
if (!typing && (e.key === 'Delete' || e.key === 'Backspace') && selId.value) {
e.preventDefault();
delSel();
}
}
let ro: ResizeObserver | null = null;
onMounted(() => {
loadBg();
window.addEventListener('keydown', onKey);
window.addEventListener('resize', fit);
ro = new ResizeObserver(fit);
if (stageEl.value) ro.observe(stageEl.value);
});
onBeforeUnmount(() => {
ro?.disconnect();
window.removeEventListener('keydown', onKey);
window.removeEventListener('resize', fit);
onUp();
onRzUp();
layers.value.forEach((l) => { if (l.type === 'image' && l.src?.startsWith('blob:')) URL.revokeObjectURL(l.src); });
});
</script>
<template>
<div class="ed-root">
<div class="ed-top">
<span class="ed-title">✏️ 编辑图片</span>
<span class="ed-hint">拖动图层移动 · 拖右下角圆点改大小 · Delete 删除 · Esc 关闭</span>
<div class="ed-acts">
<button class="ed-btn" @click="addText">+ 文字</button>
<button class="ed-btn" @click="pickImage">+ 图片</button>
<button class="ed-btn primary" :disabled="exporting" @click="exportPng">
{{ exporting ? '导出中…' : '⬇ 导出 PNG' }}
</button>
<button class="ed-btn ghost" @click="emit('close')">✕ 关闭</button>
</div>
</div>
<div v-if="edError" class="ed-error">⚠️ {{ edError }}</div>
<div class="ed-main">
<section ref="stageEl" class="ed-stage" @click.self="selId = ''">
<div
v-if="natW"
class="ed-frame"
:style="{ width: natW * scale + 'px', height: natH * scale + 'px' }"
>
<div
class="ed-canvas"
:style="{ width: natW + 'px', height: natH + 'px', transform: `scale(${scale})` }"
@click.self="selId = ''"
>
<img class="ed-bg" :src="src" alt="" draggable="false">
<div
v-for="l in layers"
:key="l.id"
class="ed-layer"
:class="{ sel: selId === l.id }"
:style="boxStyle(l)"
@pointerdown.stop="onDown($event, l)"
>
<div v-if="l.type === 'text'" :style="fontStyle(l)">
<div v-for="(ln, i) in linesOf(l)" :key="i">{{ ln || '\u00a0' }}</div>
</div>
<img v-else-if="l.src" class="ed-img" :src="l.src" alt="" draggable="false">
<i
v-if="selId === l.id"
class="ed-rh"
:style="handleStyle"
@pointerdown.stop="onRzDown($event, l)"
></i>
</div>
</div>
</div>
<div v-else class="ed-empty"><n-spin size="large" /><p>底图加载中…</p></div>
</section>
<aside class="ed-panel">
<div class="ed-sec">
<div class="ed-sec-title">图层(上层在前)</div>
<div v-if="!layers.length" class="ed-tip">点上方「+ 文字」「+ 图片」开始编辑,文字可发光、可旋转,拖右下角圆点改大小</div>
<div
v-for="l in [...layers].reverse()"
:key="l.id"
class="ed-li"
:class="{ on: selId === l.id }"
@click="selId = l.id"
>
<span class="ed-li-ico">{{ l.type === 'text' ? 'T' : '🖼' }}</span>
<span class="ed-li-name">{{ l.type === 'text' ? String(l.text || '文字').slice(0, 10) : '图片' }}</span>
<span class="ed-li-ops">
<button title="上移" @click.stop="selId = l.id; moveLayer(1)">▲</button>
<button title="下移" @click.stop="selId = l.id; moveLayer(-1)">▼</button>
<button title="删除" @click.stop="selId = l.id; delSel()">✕</button>
</span>
</div>
</div>
<template v-if="sel && sel.type === 'text'">
<div class="ed-sec">
<div class="ed-sec-title">文字「{{ selName }}」</div>
<textarea v-model="sel.text" class="ed-textarea" rows="3" placeholder="输入文字内容"></textarea>
<label class="ed-row">
<span>字号</span>
<input v-model.number="sel.size" type="range" min="8" :max="maxFontSize">
<em>{{ sel.size }}</em>
</label>
<label class="ed-row">
<span>颜色</span>
<input v-model="sel.color" type="color" class="ed-color">
<span class="ed-flex"></span>
<span>旋转</span>
<input v-model.number="sel.rot" type="range" min="-180" max="180">
<em>{{ sel.rot ?? 0 }}°</em>
<button class="ed-mini" @click="sel.rot = 0">复位</button>
</label>
<label class="ed-row">
<span>发光</span>
<input v-model="sel.glow" type="checkbox">
<input v-if="sel.glow" v-model="sel.glowColor" type="color" class="ed-color">
<template v-if="sel.glow">
<span>强度</span>
<input v-model.number="sel.glowBlur" type="range" min="2" max="60">
<em>{{ sel.glowBlur ?? 14 }}</em>
</template>
</label>
<div class="ed-tip">拖右下角圆点直接改字号;发光为文字外光晕,颜色强度可调</div>
</div>
</template>
<template v-if="sel && sel.type === 'image'">
<div class="ed-sec">
<div class="ed-sec-title">图片</div>
<label class="ed-row">
<span>旋转</span>
<input v-model.number="sel.rot" type="range" min="-180" max="180">
<em>{{ sel.rot ?? 0 }}°</em>
<button class="ed-mini" @click="sel.rot = 0">复位</button>
</label>
<button class="ed-btn wide" @click="replaceImage">替换图片</button>
<div class="ed-tip">拖右下角圆点等比改大小;拖动图层移动位置</div>
</div>
</template>
<div class="ed-sec">
<div class="ed-sec-title">说明</div>
<div class="ed-tip">导出为底图原始分辨率 PNG,同时保存到右侧历史(按你的账号隔离)。底图本身锁定不可删。</div>
</div>
</aside>
</div>
<input ref="fileEl" type="file" accept="image/*" class="ed-hidden" @change="onFile">
</div>
</template>
<style scoped lang="less">
.ed-root {
position: fixed;
inset: 0;
z-index: 5000;
background: rgba(14, 16, 18, 0.97);
display: flex;
flex-direction: column;
color: #e8e8e8;
}
.ed-top {
display: flex;
align-items: center;
gap: 14px;
padding: 12px 18px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
flex-shrink: 0;
flex-wrap: wrap;
}
.ed-title { font-size: 16px; font-weight: 700; }
.ed-hint { font-size: 12px; opacity: 0.55; flex: 1; min-width: 160px; }
.ed-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-btn {
padding: 8px 16px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.18);
background: rgba(255, 255, 255, 0.08);
color: #e8e8e8;
font-size: 14px;
font-weight: 600;
cursor: pointer;
&:hover { background: rgba(255, 255, 255, 0.16); }
&:disabled { opacity: 0.55; cursor: wait; }
&.primary { background: #0ea5a0; border-color: #0ea5a0; color: #fff; }
&.primary:hover { background: #0c8f8a; }
&.ghost { background: transparent; }
&.wide { width: 100%; margin-top: 6px; }
}
.ed-error {
padding: 8px 18px;
font-size: 13px;
color: #ffb4a2;
background: rgba(255, 120, 100, 0.1);
flex-shrink: 0;
}
.ed-main { flex: 1; min-height: 0; display: flex; }
.ed-stage {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
padding: 12px;
}
.ed-empty { text-align: center; opacity: 0.6; font-size: 13.5px; p { margin-top: 12px; } }
.ed-frame {
position: relative;
flex-shrink: 0;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
border-radius: 4px;
overflow: hidden;
}
.ed-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.ed-bg {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: fill;
pointer-events: none;
user-select: none;
-webkit-user-drag: none;
}
.ed-layer {
position: absolute;
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
touch-action: none;
cursor: move;
}
.ed-layer.sel { outline: 3px dashed #38bdf8; outline-offset: 2px; }
.ed-img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }
.ed-rh {
position: absolute;
box-sizing: border-box;
background: #38bdf8;
border: 2px solid #fff;
border-radius: 50%;
cursor: nwse-resize;
z-index: 5;
touch-action: none;
}
.ed-panel {
width: 320px;
flex-shrink: 0;
min-height: 0;
overflow-y: auto;
border-left: 1px solid rgba(255, 255, 255, 0.1);
padding: 14px;
display: flex;
flex-direction: column;
gap: 14px;
}
.ed-sec { display: flex; flex-direction: column; gap: 8px; }
.ed-sec-title { font-size: 13px; font-weight: 700; opacity: 0.85; }
.ed-tip { font-size: 12.5px; opacity: 0.6; line-height: 1.7; }
.ed-li {
display: flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border-radius: 6px;
border: 1px solid transparent;
cursor: pointer;
font-size: 13px;
background: rgba(255, 255, 255, 0.06);
&:hover { background: rgba(255, 255, 255, 0.1); }
&.on { border-color: #38bdf8; background: rgba(56, 189, 248, 0.14); }
}
.ed-li-ico { width: 18px; text-align: center; opacity: 0.8; }
.ed-li-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-li-ops { display: inline-flex; gap: 2px; }
.ed-li-ops button {
border: none;
background: transparent;
cursor: pointer;
color: inherit;
padding: 2px 5px;
font-size: 12px;
border-radius: 4px;
&:hover { background: rgba(255, 255, 255, 0.16); }
}
.ed-textarea {
width: 100%;
box-sizing: border-box;
resize: vertical;
min-height: 64px;
background: rgba(255, 255, 255, 0.07);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 8px;
color: inherit;
padding: 8px 10px;
font-size: 13.5px;
font-family: inherit;
&:focus { outline: none; border-color: #38bdf8; }
}
.ed-row {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
opacity: 0.92;
input[type='range'] { flex: 1; min-width: 60px; accent-color: #38bdf8; }
input[type='checkbox'] { accent-color: #38bdf8; width: 16px; height: 16px; }
em { font-style: normal; min-width: 40px; text-align: right; opacity: 0.75; font-size: 12.5px; }
}
.ed-flex { flex: 1; }
.ed-color {
width: 42px;
height: 26px;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 6px;
background: transparent;
cursor: pointer;
}
.ed-mini {
padding: 3px 8px;
border-radius: 6px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.08);
color: inherit;
font-size: 12px;
cursor: pointer;
&:hover { background: rgba(255, 255, 255, 0.16); }
}
.ed-hidden { display: none; }
@media (max-width: 900px) {
.ed-main { flex-direction: column; overflow-y: auto; }
.ed-stage { flex: none; height: 48vh; }
.ed-panel { width: 100%; border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.1); overflow: visible; }
.ed-hint { display: none; }
}
</style>