/* ===== 菜单栏 ===== */
.menu-bar {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 4px;
    font-size: var(--font-size-sm);
}

.menu-logo {
    padding: 0 12px 0 8px;
    font-weight: bold;
    font-size: var(--font-size-md);
    color: var(--accent-primary);
    letter-spacing: 0.5px;
}

.menu-item {
    position: relative;
    padding: 0 10px;
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.menu-item:hover,
.menu-item.open {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 1000;
}

.menu-item.open .menu-dropdown {
    display: block;
}

.menu-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.menu-dropdown-item:hover {
    background-color: var(--accent-primary);
    color: #fff;
}

.menu-dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.menu-dropdown-item:hover i {
    color: #fff;
}

.menu-dropdown-item span {
    flex: 1;
}

.menu-dropdown-item kbd {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-left: 20px;
}

.menu-dropdown-item:hover kbd {
    color: rgba(255,255,255,0.7);
}

.menu-dropdown-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

/* ===== 子菜单样式 ===== */
.menu-dropdown-item.has-submenu {
    position: relative;
}

.menu-dropdown-item.has-submenu .submenu-arrow {
    margin-left: auto;
    font-size: 10px;
}

.menu-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 160px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 1001;
}

.menu-dropdown-item.has-submenu:hover .menu-submenu {
    display: block;
}

/* ===== 顶部菜单用户信息 ===== */
.menu-spacer {
    flex: 1;
}

.menu-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.menu-user i {
    font-size: 12px;
}

.menu-user-logout {
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.menu-user-logout:hover {
    color: #f87171;
    border-color: #f87171;
}

.menu-divider {
    height: 1px;
    margin: 4px 8px;
    background-color: var(--border-color);
}

/* ===== 工具栏 ===== */
.toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    gap: 1px;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    position: relative;
}

.tool-btn i {
    font-size: 14px;
    margin-bottom: 1px;
}

.tool-btn span {
    font-size: 9px;
    line-height: 1;
}

.tool-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tool-btn.active {
    background-color: var(--bg-active);
    color: var(--accent-primary);
}

.tool-btn.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background-color: var(--accent-primary);
    border-radius: 0 2px 2px 0;
}

.tool-separator {
    width: 28px;
    height: 1px;
    margin: 4px 0;
    background-color: var(--border-color);
}

.tool-options {
    border-top: 1px solid var(--border-color);
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== 画布工作区 ===== */
.canvas-container {
    position: absolute;
    left: 0;
    top: 0;
    box-shadow: var(--shadow-lg);
}

#mainCanvas {
    display: block;
}

/* 画布空状态（无文档时显示） */
.canvas-empty {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    pointer-events: auto;
    user-select: none;
}

.canvas-empty.hidden {
    display: none;
}

.canvas-empty-icon {
    font-size: 80px;
    color: var(--border-color);
    margin-bottom: 20px;
}

.canvas-empty-title {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.canvas-empty-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.canvas-empty-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* 工具按钮禁用态 */
.tool-btn:disabled,
.tool-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tool-btn:disabled:hover,
.tool-btn.disabled:hover {
    background-color: transparent;
    color: var(--text-secondary);
}

.canvas-grid-bg {
    background-image:
        linear-gradient(45deg, var(--canvas-grid) 25%, transparent 25%),
        linear-gradient(-45deg, var(--canvas-grid) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--canvas-grid) 75%),
        linear-gradient(-45deg, transparent 75%, var(--canvas-grid) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: var(--canvas-grid-alt);
}

.canvas-ruler {
    position: absolute;
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    overflow: hidden;
}

.canvas-ruler-top {
    top: 0;
    left: 20px;
    right: 0;
    height: 20px;
    border-bottom: 1px solid var(--border-color);
}

.canvas-ruler-left {
    top: 20px;
    left: 0;
    bottom: 0;
    width: 20px;
    border-right: 1px solid var(--border-color);
}

/* ===== 图层/历史 Tab 面板 ===== */
.layer-history-panel {
    flex: 0 0 auto;
    height: 300px;
}

.layer-history-panel .panel-body {
    max-height: calc(100% - 60px);
    overflow-y: auto;
}

.layer-history-panel .tab-content {
    display: none;
}

.layer-history-panel .tab-content.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.layer-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast),
                margin-top 0.2s ease,
                margin-bottom 0.2s ease;
    position: relative;
}

.layer-item:hover {
    background-color: var(--bg-hover);
}

.layer-item.active {
    background-color: var(--bg-active);
}

.layer-item.locked {
    opacity: 0.5;
}

.layer-item.dragging {
    opacity: 0.8;
    background-color: var(--bg-active);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: absolute;
    left: 0;
    right: 0;
}

.layer-item-placeholder {
    border-bottom: 1.5px dashed var(--accent-primary);
    margin: 0 8px;
}

.layer-item.drop-above {
    margin-top: 30px;
}

.layer-item.drop-above::before {
    content: '';
    position: absolute;
    top: -28px;
    left: 4px;
    right: 4px;
    height: 24px;
    background-color: var(--accent-primary);
    opacity: 0.08;
    border: 1.5px dashed var(--accent-primary);
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.layer-item.drop-below {
    margin-bottom: 30px;
}

.layer-item.drop-below::after {
    content: '';
    position: absolute;
    bottom: -28px;
    left: 4px;
    right: 4px;
    height: 24px;
    background-color: var(--accent-primary);
    opacity: 0.08;
    border: 1.5px dashed var(--accent-primary);
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.layer-drag-handle {
    width: 14px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.layer-item:hover .layer-drag-handle {
    opacity: 1;
}

.layer-drag-handle:hover {
    color: var(--text-secondary);
    cursor: grabbing;
}

.layer-drag-handle i {
    font-size: 12px;
}

.layer-thumb {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background-image:
        linear-gradient(45deg, var(--canvas-grid) 25%, transparent 25%),
        linear-gradient(-45deg, var(--canvas-grid) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--canvas-grid) 75%),
        linear-gradient(-45deg, transparent 75%, var(--canvas-grid) 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
    background-color: var(--canvas-grid-alt);
    flex-shrink: 0;
    overflow: hidden;
}

.layer-name {
    flex: 1;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.layer-actions .icon-btn {
    width: 18px;
    height: 18px;
    font-size: 10px;
}

/* ===== 属性面板 ===== */
.props-panel {
    flex-shrink: 0;
    margin-top: auto;
}

.props-panel .panel-body {
    max-height: 340px;
    overflow-y: auto;
}

.props-empty {
    padding: 16px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

.props-section {
    border-bottom: 1px solid var(--border-color);
}

.props-section-title {
    padding: 6px 8px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    cursor: pointer;
}

.props-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
}

.props-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    min-width: 50px;
    flex-shrink: 0;
}

.props-control {
    flex: 1;
    min-width: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 5px 12px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.history-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.history-item.current {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
}

.history-item i {
    width: 14px;
    margin-right: 6px;
    text-align: center;
}

.history-desc {
    flex: 1;
}

.history-empty {
    padding: 16px 12px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

/* ===== 项目面板 ===== */
.projects-panel {
    flex-shrink: 0;
}

.projects-panel .panel-body {
    max-height: 220px;
}

.projects-list {
    display: flex;
    flex-direction: column;
}

.project-item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    gap: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.project-item:hover {
    background-color: var(--bg-hover);
}

.project-item.active {
    background-color: var(--bg-tertiary);
    border-left: 2px solid var(--accent-primary);
}

.project-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.project-item.active .project-icon {
    color: var(--accent-primary);
}

.project-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.project-name {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-time {
    font-size: 10px;
    color: var(--text-muted);
}

.project-action {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    font-size: 11px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.project-item:hover .project-action {
    opacity: 1;
}

.projects-empty {
    padding: 24px 12px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
    line-height: 1.6;
}

.projects-empty-hint {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.7;
}

/* ===== 面板通用 ===== */
.panel-body {
    min-height: 80px;
}

.panel-title {
    justify-content: flex-start;
    gap: 4px;
}

.panel-title > span {
    flex-shrink: 0;
}

.panel-drag-handle {
    margin-right: 2px;
    color: var(--text-muted);
    cursor: grab;
    font-size: 10px;
    flex-shrink: 0;
}

.panel-dragging {
    opacity: 0.6;
}

/* Tab 切换 */
.panel-title-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.panel-title-actions {
    margin-left: auto;
}

.panel-tab {
    padding: 2px 8px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.panel-tab:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.panel-tab.active {
    color: var(--text-primary);
    background-color: var(--bg-active);
    border-color: var(--border-light);
}

/* 属性面板“文字属性/形状属性”按钮 */
.prop-type-btn {
    width: 100%;
}

/* 文字内容多行输入框（弹窗内） */
.tp-text-content {
    width: 100%;
    min-height: 60px;
    padding: 4px 6px;
    font-family: inherit;
    font-size: var(--font-size-xs);
    resize: vertical;
    line-height: 1.4;
}

/* 形状属性弹窗中的 checkbox + color 行内布局 */
.props-row .sp-shape-fill,
.props-row .sp-shape-stroke {
    margin-right: 6px;
    vertical-align: middle;
}

.props-row .sp-shape-fill + .color-picker,
.props-row .sp-shape-stroke + .color-picker {
    width: 32px;
    height: 22px;
    vertical-align: middle;
}

/* ===== 可拖动属性弹窗 ===== */
.floating-dialog {
    display: none;
    position: fixed;
    top: 100px;
    left: 100px;
    width: 240px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    overflow: hidden;
}

.floating-dialog.visible {
    display: block;
}

.floating-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: move;
}

.floating-dialog-title {
    font-size: var(--font-size-xs);
    font-weight: bold;
    color: var(--text-primary);
}

.floating-dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.floating-dialog-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.floating-dialog-body {
    padding: 10px;
    max-height: 360px;
    overflow-y: auto;
}

.floating-dialog-body .props-section:last-child {
    border-bottom: none;
}

/* ===== 状态栏 ===== */
.status-bar {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 8px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    gap: 16px;
}

.status-item {
    white-space: nowrap;
}

/* ===== 对话框 ===== */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.dialog-overlay.visible {
    display: flex;
}

.dialog {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 360px;
    max-width: 560px;
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: var(--font-size-lg);
    font-weight: bold;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.dialog-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.dialog-body {
    padding: 16px;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
}

/* ===== 裁剪覆盖层 ===== */
.crop-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: crosshair;
}

.crop-box {
    position: absolute;
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.crop-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #fff;
    border: 1px solid var(--accent-primary);
}

.crop-handle-nw { top: -4px; left: -4px; cursor: nw-resize; }
.crop-handle-ne { top: -4px; right: -4px; cursor: ne-resize; }
.crop-handle-sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.crop-handle-se { bottom: -4px; right: -4px; cursor: se-resize; }
.crop-handle-n { top: -4px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle-s { bottom: -4px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle-w { top: 50%; left: -4px; transform: translateY(-50%); cursor: w-resize; }
.crop-handle-e { top: 50%; right: -4px; transform: translateY(-50%); cursor: e-resize; }

/* ===== 滚动条（合并到统一声明） ===== */
.panel-body::-webkit-scrollbar,
.layer-list::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.projects-list::-webkit-scrollbar {
    width: 6px;
}

.panel-body::-webkit-scrollbar-track,
.layer-list::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.projects-list::-webkit-scrollbar-track {
    background: transparent;
}

.panel-body::-webkit-scrollbar-thumb,
.layer-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.projects-list::-webkit-scrollbar-thumb {
    background-color: var(--bg-active);
    border-radius: 3px;
}

.panel-body::-webkit-scrollbar-thumb:hover,
.layer-list::-webkit-scrollbar-thumb:hover,
.history-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--border-light);
}

.tool-option-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* 工具选项提示信息样式 */
.tool-option-hint {
    display: block;
    padding: 8px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== 工具选项浮动弹窗 ===== */
.tool-options-popup {
    position: fixed;
    z-index: 10000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    padding: 8px 6px;
    min-width: 140px;
    max-width: 280px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}
.tool-options-popup.visible {
    opacity: 1;
    visibility: visible;
}
.tool-options-popup .tool-option-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 4px 6px;
}
.tool-options-popup .tool-option-group:last-child {
    padding-bottom: 0;
}
.tool-options-popup .tool-option-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}
.tool-options-popup .tool-option-value {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 600;
}
.tool-options-popup .tool-option-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.tool-options-popup .tool-option-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}
.tool-options-popup .tool-option-hint {
    display: block;
    padding: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: nowrap;
}

/* 移动工具选项 */
.move-options {
    padding: 4px;
}

.move-option-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px;
}

.move-option-row label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}

.move-option-inputs {
    display: flex;
    gap: 8px;
}

.move-option-inputs span {
    font-size: 10px;
    color: var(--text-muted);
    align-self: center;
    min-width: 12px;
}

.move-option-input {
    width: 50px;
    padding: 3px 4px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    text-align: center;
    outline: none;
}

.move-option-input:focus {
    border-color: var(--accent-primary);
}

.move-option-input[readonly] {
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
}

/* 右键菜单样式 */
.context-menu-item {
    padding: 6px 12px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--transition-fast);
}

.context-menu-item:hover {
    background-color: var(--bg-hover);
}

.context-menu-item.disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.context-menu-item.disabled:hover {
    background-color: transparent;
}

.tool-option-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.tool-option-input,
.tool-option-select {
    width: 100%;
    padding: 3px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.tool-option-input:focus,
.tool-option-select:focus {
    border-color: var(--accent-primary);
}

.tool-option-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23888899' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
    cursor: pointer;
}

.tool-option-color {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    cursor: pointer;
}

.tool-option-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.tool-option-color::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* 样式按钮组（粗体/斜体/下划线等）水平排列 */
.tool-option-group:last-child {
    flex-direction: row;
    gap: 4px;
}

.tool-option-group:last-child .tool-option-label {
    width: 100%;
    margin-bottom: 2px;
}

.tool-option-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 24px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.tool-option-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tool-option-btn.active {
    background-color: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

/* 滑块容器（画笔大小/硬度等） */
.tool-option-group .slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-option-group .slider-wrap input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

.tool-option-group .slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    cursor: pointer;
    border: 1px solid var(--bg-primary);
}

.tool-option-value {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    min-width: 32px;
    text-align: right;
}

.tool-option-color-preview {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

/* 让带按钮的工具选项组（缩放工具的"适应窗口/100%"按钮）水平排列且按钮自适应宽度 */
.tool-option-group .tool-option-btn:only-child,
.tool-option-group > .tool-option-btn {
    width: auto;
    padding: 4px 10px;
    gap: 4px;
}

/* ===== 艺术字对话框 ===== */
.arttext-dialog {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.arttext-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.arttext-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}

.arttext-textarea {
    width: 100%;
    min-height: 50px;
    padding: 6px 8px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

.arttext-textarea:focus {
    border-color: var(--accent-primary);
}

.arttext-select {
    padding: 4px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23888899' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.arttext-select:focus {
    border-color: var(--accent-primary);
}

.arttext-number {
    width: 60px;
    padding: 3px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
}

.arttext-number:focus {
    border-color: var(--accent-primary);
}

/* 属性面板中的颜色选择器 — 正方形 */
.input.prop-color {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.input.prop-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.input.prop-color::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.arttext-color {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    cursor: pointer;
}

.arttext-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.arttext-color::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.arttext-style-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.arttext-style-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 4px;
    background-color: var(--bg-tertiary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.arttext-style-card:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-hover);
}

.arttext-style-card.active {
    border-color: var(--accent-primary);
    background-color: var(--bg-active);
}

.arttext-style-icon {
    font-size: 16px;
    margin-bottom: 2px;
}

.arttext-style-name {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
}

.arttext-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

.arttext-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    cursor: pointer;
}

.arttext-range-val {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    min-width: 24px;
    text-align: right;
}

.arttext-preview-area {
    flex-shrink: 0;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    height: 220px;
    overflow: hidden;
}

.arttext-settings {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.arttext-preview-box {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    overflow: hidden;
}

.arttext-preview-box svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    transition: opacity 0.15s ease;
}

/* ===== 标识选择浮动窗口 ===== */
.icon-picker-float {
    position: fixed;
    width: 320px;
    max-height: 480px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.icon-picker-float.hidden {
    display: none;
}

.icon-picker-float-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: move;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
}

.icon-picker-float-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
}

.icon-picker-float-close:hover {
    color: var(--text-primary);
}

.icon-picker-float-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.icon-picker-dialog {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.icon-picker-color-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    margin-bottom: 6px;
    border-top: 1px solid var(--border-light);
}

.icon-picker-color-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

.icon-picker-color-grid {
    display: flex;
    gap: 4px;
    flex: 1;
}

.icon-picker-color-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.icon-picker-color-btn:hover {
    transform: scale(1.1);
}

.icon-picker-color-btn.active {
    border-color: var(--text-primary);
}

.icon-picker-color-input {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.icon-picker-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.icon-picker-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.icon-picker-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.icon-picker-tab {
    padding: 4px 12px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.icon-picker-tab:hover {
    color: var(--text-primary);
}

.icon-picker-tab.active {
    color: #ffffff;
    background-color: var(--accent-primary);
}

.icon-picker-content {
    overflow-y: auto;
}

.icon-picker-content.hidden {
    display: none;
}

.icon-picker-category {
    margin-bottom: 8px;
}

.icon-picker-category-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    padding-left: 2px;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.icon-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.icon-picker-item:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-active);
}

.icon-picker-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.icon-picker-icon svg {
    width: 18px;
    height: 18px;
}

.icon-picker-name {
    font-size: 8px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 1px;
    line-height: 1.2;
}

.icon-picker-upload {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.icon-picker-upload-tip {
    font-size: 8px;
    color: var(--text-muted);
}

.icon-picker-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 12px;
    font-size: var(--font-size-xs);
}

.icon-picker-my-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.icon-picker-my-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.icon-picker-my-item:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-active);
}

.icon-picker-my-item:hover .icon-picker-my-delete {
    opacity: 1;
}

.icon-picker-my-preview {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
}

.icon-picker-my-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.icon-picker-my-name {
    font-size: 8px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-picker-my-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    font-size: 8px;
}

.icon-picker-my-delete:hover {
    background-color: var(--accent-danger);
}

/* ===== 模板对话框 ===== */
.template-dialog {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.template-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.template-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 600;
}

.template-input {
    width: 100%;
    padding: 6px 8px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.template-input:focus {
    border-color: var(--accent-primary);
}

.template-select {
    padding: 4px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23888899' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.template-select:focus {
    border-color: var(--accent-primary);
}

.template-textarea {
    width: 100%;
    min-height: 60px;
    padding: 6px 8px;
    font-family: inherit;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

.template-textarea:focus {
    border-color: var(--accent-primary);
}

.template-search {
    flex-shrink: 0;
    margin-bottom: 12px;
}

.template-search-input {
    width: 100%;
    padding: 6px 12px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-fast);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888899' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 8px center;
    padding-left: 28px;
}

.template-search-input:focus {
    border-color: var(--accent-primary);
}

.template-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 8px;
}

.template-empty i {
    font-size: 32px;
    opacity: 0.5;
}

.template-card {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.template-card:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-hover);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.template-card-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.template-card-category {
    font-size: 10px;
    padding: 2px 6px;
    background-color: var(--accent-primary);
    color: #fff;
    border-radius: 4px;
}

.template-card-body {
    margin-bottom: 10px;
}

.template-card-desc {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.4;
}

.template-card-info {
    display: flex;
    gap: 16px;
    font-size: 10px;
    color: var(--text-muted);
}

.template-card-info i {
    margin-right: 3px;
}

.template-card-actions {
    display: flex;
    gap: 8px;
}

.template-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: var(--font-size-xs);
    border-radius: 2px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.template-btn-open {
    background-color: var(--accent-primary);
    color: #fff;
}

.template-btn-open:hover {
    background-color: var(--accent-hover);
}

.template-btn-delete {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.template-btn-delete:hover {
    background-color: #ffeaea;
    color: #dc3545;
    border-color: #dc3545;
}

/* 新建画布 - 平台尺寸预设按钮 */
.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
}
.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    font-size: var(--font-size-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    min-width: 80px;
    line-height: 1.3;
    transition: background-color .15s, border-color .15s, color .15s;
}
.preset-btn:hover {
    border-color: var(--accent-color, #4a90e2);
    color: var(--accent-color, #4a90e2);
}
.preset-btn.active {
    border-color: var(--accent-color, #4a90e2);
    background-color: rgba(74, 144, 226, 0.08);
    color: var(--accent-color, #4a90e2);
}
.preset-btn .preset-size {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}
.preset-btn.active .preset-size {
    color: var(--accent-color, #4a90e2);
}
