/* Stage 样式 */
#stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}


/* 变换容器：包裹Canvas */
.transform-box {
    position: absolute;
    transform-origin: center center;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 默认不显示边框 */
}

/* SVG 样式 (替代原来的 Canvas) */
.transform-box svg {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    /* 让鼠标事件穿透给 box 处理拖拽 */
    overflow: visible;
    /* 允许部分特效溢出 */
}

/* 选中状态 UI */
.selection-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px dashed #1890ff;
    display: none;
    pointer-events: none;
}

.transform-box.active .selection-ui {
    display: block;
}

.transform-box.active {
    z-index: 100;
    cursor: move;
}

/* 手柄样式 */
.handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid #1890ff;
    border-radius: 50%;
    pointer-events: auto;
    z-index: 101;
}

.handle.tl {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.handle.tr {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.handle.bl {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.handle.br {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.handle.rotator {
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #1890ff;
    cursor: grab;
}

.rotator-stick {
    position: absolute;
    top: -40px;
    left: 50%;
    height: 40px;
    width: 1px;
    background: #1890ff;
    display: none;
}

.transform-box.active .rotator-stick {
    display: block;
}

/* 颜色面板 */
.color-panel {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-top: 20px;
    padding: 8px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    pointer-events: auto;
    align-items: center;
    gap: 10px;
    z-index: 30;
    white-space: nowrap;
}

.transform-box.active .color-panel {
    display: flex;
    gap: 5px;
}

/* --- 工具栏 (Toolbar) --- */
.toolbar {
    position: absolute;
    /* 定位在对象正上方 */
    top: 100%;
    left: 50%;
    margin-bottom: 15px;
    /* 留出一点距离 */

    background: white;
    border-radius: 50px;
    /* 圆角胶囊形状 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 5px 10px;
    display: none;
    /* 默认隐藏 */
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: auto;
}

.transform-box.active .toolbar {
    display: flex;
}

/* 工具栏内的按钮 */
.tool-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #333;
    transition: background 0.2s;
}

.tool-btn:hover {
    background-color: #f5f5f5;
}

/* 字体触发器按钮 (带下拉箭头) */
.font-trigger {
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 5px 12px;
    min-width: 80px;
    justify-content: space-between;
    font-weight: bold;
}

/* 颜色触发器 (显示当前颜色) */
.color-trigger-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
}

/* 分割线 */
.divider {
    width: 1px;
    height: 20px;
    background-color: #eee;
}

/* --- 二级弹出面板 (通用) --- */
.popup-panel {
    position: absolute;
    top: calc(100% + 10px);
    /* 在工具栏下方 */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    padding: 10px;
    z-index: 110;
    display: none;
    /* 默认隐藏 */
}

/* 显示状态 */
.popup-panel.show {
    display: block;
}

/* --- 字体网格布局 --- */
.font-grid-container {
    width: 340px;
    max-height: 250px;
    overflow-y: auto;
}

.font-grid-child-object {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* 3列布局 */
    gap: 10px;
}

/* 字体预览文字的大小 */
.font-preview-text {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* --- 颜色网格 (复用之前的逻辑，放进弹出层) --- */
.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    width: max-content;
}