.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    background: var(--ut-color-surface-muted);
}

/* 顶部工具栏 */
.editor-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--ut-color-surface);
    border-bottom: 1px solid var(--ut-color-border);
    flex-shrink: 0;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    border-radius: var(--ut-radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--ut-color-text);
    transition: var(--ut-transition-fast);
}

.topbar-btn:hover:not(:disabled) {
    background: var(--ut-color-surface-muted);
}

.topbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.topbar-divider {
    width: 1px;
    height: 20px;
    background: var(--ut-color-border);
    margin: 0 4px;
}

.topbar-label {
    font-weight: 500;
}

/* 编辑器主体 */
.editor-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* 左侧工具面板 */
.editor-tools {
    display: flex;
    flex-direction: column;
    width: 64px;
    background: var(--ut-color-surface);
    border-right: 1px solid var(--ut-color-border);
    padding: 8px 4px;
    gap: 2px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border: none;
    background: transparent;
    border-radius: var(--ut-radius-sm);
    cursor: pointer;
    font-size: 0.65rem;
    color: var(--ut-color-text-muted);
    transition: var(--ut-transition-fast);
}

.tool-btn i {
    font-size: 1rem;
}

.tool-btn:hover {
    background: var(--ut-color-surface-muted);
    color: var(--ut-color-text);
}

.tool-btn.active {
    background: var(--ut-color-primary-500);
    color: #fff;
}

/* 主画布区域 */
.editor-canvas-area {
    flex: 1;
    display: flex;
    overflow: auto;
    position: relative;
    min-width: 0;
    padding: 20px;
}

.editor-placeholder {
    text-align: center;
    color: var(--ut-color-text-muted);
    padding: 40px;
    margin: auto;
}

.editor-placeholder i {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 16px;
}

.canvas-wrapper {
    position: relative;
    margin: auto;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.canvas-wrapper canvas {
    display: block;
}

#overlayCanvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
}

/* 裁剪遮罩 */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.crop-box {
    position: absolute;
    border: 2px dashed #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    cursor: move;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--ut-color-primary-500);
    border-radius: 2px;
}

.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }

/* 贴纸容器 */
.stickers-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* 浮动文字元素 */
.text-float-item {
    position: absolute;
    cursor: move;
    pointer-events: auto;
    user-select: none;
    padding: 4px 6px;
    border: 1px dashed transparent;
    border-radius: 3px;
    transition: border-color 0.15s, box-shadow 0.15s;
    z-index: 6;
}

.text-float-item:hover {
    border-color: var(--ut-color-primary-500);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.text-float-item.text-float-active {
    border-color: var(--ut-color-primary-500);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.35);
}

.text-float-item.text-float-committed {
    border-color: transparent;
    box-shadow: none;
    cursor: pointer;
}

.text-float-item.text-float-committed:hover {
    border-color: var(--ut-color-primary-300, #a0b4f0);
    box-shadow: none;
}

.text-float-item .sticker-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.6rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.text-float-item:hover .sticker-delete,
.text-float-item.text-float-active .sticker-delete {
    display: flex;
}

.text-float-content {
    line-height: 1.3;
}

.text-float-editable {
    outline: none;
    cursor: text;
    min-width: 20px;
    min-height: 1em;
    user-select: text;
}

.sticker-item {
    position: absolute;
    cursor: move;
    pointer-events: auto;
    user-select: none;
    font-size: 48px;
    line-height: 1;
    transition: outline 0.1s;
}

.sticker-item:hover {
    outline: 2px dashed var(--ut-color-primary-500);
}

.sticker-item .sticker-delete {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #ff4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.6rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.sticker-item:hover .sticker-delete {
    display: flex;
}

.sticker-resize {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: var(--ut-color-primary-500);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: se-resize;
    display: none;
}

.sticker-item:hover .sticker-resize {
    display: block;
}

/* 右侧属性面板 */
.editor-props {
    width: 220px;
    background: var(--ut-color-surface);
    border-left: 1px solid var(--ut-color-border);
    overflow-y: auto;
    flex-shrink: 0;
}

.props-content {
    padding: 12px;
}

.props-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ut-color-border);
    color: var(--ut-color-text);
}

.prop-group {
    margin-bottom: 12px;
}

.prop-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--ut-color-text-muted);
    margin-bottom: 4px;
}

.prop-color-input {
    width: 100%;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--ut-color-border);
    border-radius: var(--ut-radius-sm);
    cursor: pointer;
}

.prop-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--ut-color-border);
    outline: none;
}

.prop-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ut-color-primary-500);
    cursor: pointer;
}

/* 裁剪比例按钮 */
.crop-ratios {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.crop-ratio-btn {
    padding: 4px 8px;
    border: 1px solid var(--ut-color-border);
    border-radius: var(--ut-radius-sm);
    background: var(--ut-color-surface);
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--ut-transition-fast);
}

.crop-ratio-btn:hover {
    border-color: var(--ut-color-primary-500);
}

.crop-ratio-btn.active {
    background: var(--ut-color-primary-500);
    color: #fff;
    border-color: var(--ut-color-primary-500);
}

/* 旋转按钮 */
.rotate-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rotate-btns .btn {
    text-align: left;
}

/* AI状态（编辑器内） */
.editor-container .ai-status {
    margin: 8px 0;
    font-size: 0.75rem;
    text-align: center;
}

.editor-container .ai-status-loading {
    color: var(--ut-color-warning, #f0ad4e);
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(240, 173, 78, 0.1);
    border-radius: 16px;
}

.editor-container .ai-status-ready {
    color: var(--ut-color-success, #5cb85c);
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(92, 184, 92, 0.1);
    border-radius: 16px;
}

/* 贴纸面板 */
.sticker-categories {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.sticker-cat-btn {
    padding: 3px 8px;
    border: 1px solid var(--ut-color-border);
    border-radius: 12px;
    background: var(--ut-color-surface);
    font-size: 0.7rem;
    cursor: pointer;
    transition: var(--ut-transition-fast);
}

.sticker-cat-btn:hover {
    border-color: var(--ut-color-primary-500);
}

.sticker-cat-btn.active {
    background: var(--ut-color-primary-500);
    color: #fff;
    border-color: var(--ut-color-primary-500);
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.sticker-grid-item {
    font-size: 1.5rem;
    text-align: center;
    padding: 6px;
    cursor: pointer;
    border-radius: var(--ut-radius-sm);
    transition: var(--ut-transition-fast);
}

.sticker-grid-item:hover {
    background: var(--ut-color-surface-muted);
    transform: scale(1.2);
}

/* hidden class */
.hidden {
    display: none !important;
}

/* 响应式 */
@media (max-width: 768px) {
    .editor-body {
        flex-direction: column;
    }

    .editor-tools {
        flex-direction: row;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--ut-color-border);
        overflow-x: auto;
    }

    .tool-btn {
        flex-direction: row;
        gap: 4px;
        padding: 6px 10px;
    }

    .tool-btn span {
        display: none;
    }

    .editor-props {
        width: 100%;
        max-height: 200px;
        border-left: none;
        border-top: 1px solid var(--ut-color-border);
    }

    .topbar-label {
        display: none;
    }
}
