/* AI 图片高级编辑工作台 */
.advanced-hero .hero-glow.g2 {
    opacity: 0.75;
}

.editor-tabs {
    display: flex;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    padding: 5px;
    margin-bottom: 18px;
    border: 1px solid #ececf7;
    border-radius: 14px;
    background: #fff;
    overflow-x: auto;
}

.editor-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 15px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #6b6f8f;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}

.editor-tab.active {
    background: linear-gradient(135deg, #7c5cff, #5b4bd6);
    color: #fff;
    box-shadow: 0 10px 22px -14px rgba(91, 75, 214, 0.8);
}

.editor-mode[hidden] {
    display: none !important;
}

.editor-canvas {
    height: auto;
}

/* 图层卡片下方还有图层面板，避免 100% 高度把面板挤出列高 */
#layersMode .canvas-card {
    height: auto;
}

.editor-canvas .canvas-body {
    min-height: 620px;
}

.editor-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 8px;
}

.editor-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    touch-action: none;
}

.editor-image-wrap > img {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    user-select: none;
    -webkit-user-drag: none;
}

.editor-box-layer {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

.editor-box-layer.is-point {
    cursor: cell;
}

.editor-box {
    position: absolute;
    border: 2px solid #a896ff;
    border-radius: 4px;
    background: rgba(124, 92, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.editor-box.is-drawing {
    border-style: dashed;
}

.editor-box-del {
    position: absolute;
    right: -9px;
    top: -9px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #5b4bd6;
    font-size: 12px;
    line-height: 20px;
    box-shadow: 0 3px 10px rgba(20, 20, 50, 0.28);
    cursor: pointer;
    pointer-events: auto;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tool-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #c9cbe6;
    font-size: 0.68rem;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.tool-chip.active,
.tool-chip:hover {
    border-color: #8b7cf6;
    background: rgba(124, 92, 255, 0.24);
    color: #fff;
}

.box-count {
    font-size: 0.66rem;
    color: #8f94b8;
    white-space: nowrap;
}

.prompt-input {
    width: 100%;
    min-height: 88px;
    padding: 10px 12px;
    border: 1px solid #e5e4f2;
    border-radius: 12px;
    background: #fbfaff;
    color: #2a2b45;
    font-size: 0.8rem;
    line-height: 1.65;
    resize: vertical;
    outline: none;
}

.prompt-input:focus {
    border-color: #8b7cf6;
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}

.prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chip-btn {
    padding: 4px 9px;
    border: 1px solid #e7e5f8;
    border-radius: 999px;
    background: #f7f5ff;
    color: #5b4bd6;
    font-size: 0.68rem;
    cursor: pointer;
}

.chip-btn:hover {
    border-color: #bdb2ff;
    background: #efebff;
}

.toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #555a7a;
    font-size: 0.72rem;
    cursor: pointer;
}

.toggle input {
    width: 15px;
    height: 15px;
    accent-color: #6c5ce7;
}

.reference-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.reference-slot {
    position: relative;
    min-height: 92px;
    border: 1px dashed #dcd9f0;
    border-radius: 12px;
    background: #fbfaff;
    overflow: hidden;
}

.ref-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    height: 100%;
    min-height: 92px;
    padding: 8px;
    border: 0;
    background: transparent;
    color: #8b86ad;
    font-size: 0.68rem;
    cursor: pointer;
}

.ref-add i {
    font-size: 1rem;
}

.ref-preview {
    position: absolute;
    inset: 0;
}

.ref-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ref-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(20, 22, 40, 0.72);
    color: #fff;
    font-size: 13px;
    line-height: 20px;
    cursor: pointer;
}

.ref-label {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(20, 22, 40, 0.65);
    color: #fff;
    font-size: 0.6rem;
}

.mini-hint {
    margin: 9px 0 0;
    color: #9a9db7;
    font-size: 0.68rem;
    line-height: 1.6;
}

.history-panel {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid #ececf7;
    border-radius: 16px;
    background: #fff;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: #4a4b66;
    font-size: 0.74rem;
}

.history-head small {
    color: #9a9db7;
    font-size: 0.66rem;
}

.history-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.history-item {
    flex: 0 0 70px;
    padding: 0;
    border: 1px solid #e7e5f4;
    border-radius: 10px;
    background: #faf9ff;
    overflow: hidden;
    cursor: pointer;
}

.history-item img {
    display: block;
    width: 100%;
    height: 54px;
    object-fit: cover;
}

.history-item span {
    display: block;
    padding: 3px 0;
    color: #8a8ca8;
    font-size: 0.6rem;
    text-align: center;
}

.layer-size-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.layer-size-option {
    padding: 8px 4px;
    border: 1px solid #e7e5f4;
    border-radius: 11px;
    background: #fbfaff;
    color: #5b5e7d;
    text-align: center;
    cursor: pointer;
}

.layer-size-option strong {
    display: block;
    color: #2a2b45;
    font-size: 0.78rem;
}

.layer-size-option span {
    display: block;
    margin-top: 2px;
    font-size: 0.6rem;
}

.layer-size-option.active {
    border-color: #8b7cf6;
    background: #f1edff;
    box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.12);
}

.layer-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 8px;
}

.layer-canvas {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    border-radius: 10px;
    overflow: hidden;
    user-select: none;
}

.layer-canvas > img {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    width: auto;
    height: auto;
    border-radius: 10px;
    user-select: none;
    -webkit-user-drag: none;
}

.layer-nodes {
    position: absolute;
    inset: 0;
}

.layer-node {
    position: absolute;
    transform-origin: center center;
    cursor: move;
    touch-action: none;
    will-change: transform;
}

.layer-node > img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.layer-node-frame {
    position: absolute;
    inset: 0;
    border: 1px dashed transparent;
    border-radius: 4px;
    pointer-events: none;
}

.layer-node.is-selected .layer-node-frame {
    border-color: #a896ff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.layer-handle {
    display: none;
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid #8b7cf6;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(20, 20, 50, 0.25);
    transform: rotate(var(--handle-inverse-rotate, 0deg)) scale(var(--handle-inverse-scale, 1));
    transform-origin: center;
}

.layer-node.is-selected .layer-handle {
    display: block;
}

.layer-handle-scale {
    right: 3px;
    bottom: 3px;
    border-radius: 3px;
    cursor: nwse-resize;
}

.layer-handle-rotate {
    left: 50%;
    top: 3px;
    margin-left: -7px;
    cursor: grab;
}

.layer-node-del {
    display: none;
    position: absolute;
    right: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    transform: rotate(var(--handle-inverse-rotate, 0deg)) scale(var(--handle-inverse-scale, 1));
    transform-origin: center;
}

.layer-node.is-selected .layer-node-del {
    display: block;
}

.layer-actions {
    flex-wrap: wrap;
}

.layer-panel {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid #ececf7;
    border-radius: 16px;
    background: #fff;
}

.layer-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px;
    border: 1px solid #eceaf6;
    border-radius: 12px;
    background: #fbfaff;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.layer-item:hover {
    border-color: #d8d2f6;
}

.layer-item.is-active {
    border-color: #b9aaff;
    background: #f5f2ff;
    box-shadow: 0 0 0 2px rgba(124, 92, 255, 0.1);
}

.layer-item.is-hidden {
    opacity: 0.45;
}

.layer-thumb {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: #e9e7f5;
    object-fit: contain;
}

.layer-meta {
    flex: 1;
    min-width: 0;
}

.layer-meta strong {
    display: block;
    color: #2a2b45;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-meta span {
    display: block;
    margin-top: 2px;
    color: #9396b1;
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-check {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    accent-color: #6c5ce7;
}

.layer-remove {
    flex: 0 0 auto;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: #b0b2c8;
    font-size: 1rem;
    cursor: pointer;
}

.layer-empty {
    padding: 8px 0;
    color: #9a9db7;
    font-size: 0.72rem;
}

.layer-example-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 10px;
    aspect-ratio: 1 / 1;
    background: #f4f3fa;
}

.layer-example-grid figure {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 8px;
    background: #e8e7f2;
    overflow: hidden;
}

.layer-example-grid img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.layer-example-grid figcaption {
    position: absolute;
    left: 5px;
    bottom: 5px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(20, 22, 40, 0.62);
    color: #fff;
    font-size: 0.58rem;
}

.checkerboard,
.compare.checkerboard-wrap {
    background-color: #f4f3fa;
    background-image:
        linear-gradient(45deg, #d9d8e8 25%, transparent 25%),
        linear-gradient(-45deg, #d9d8e8 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d9d8e8 75%),
        linear-gradient(-45deg, transparent 75%, #d9d8e8 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

.checkerboard img,
.compare.checkerboard-wrap .compare-base,
.compare.checkerboard-wrap .compare-top {
    object-fit: contain;
}

@media (max-width: 991.98px) {
    .editor-canvas .canvas-body {
        min-height: 480px;
    }

    .layer-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .editor-tabs {
        width: 100%;
    }

    .editor-canvas .canvas-body {
        min-height: 380px;
    }

    .editor-toolbar {
        justify-content: flex-start;
        margin-top: 6px;
    }

    .canvas-top {
        flex-wrap: wrap;
    }

    .layer-size-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .layer-example-grid {
        aspect-ratio: 1.8 / 1;
    }

    .history-head small {
        display: none;
    }

    .canvas-actions {
        flex-wrap: wrap;
    }

    .canvas-actions .btn-ghost,
    .canvas-actions .btn-solid {
        flex: 1 1 auto;
        white-space: nowrap;
    }

    .layer-handle {
        width: 18px;
        height: 18px;
    }

    .layer-handle-scale {
        right: 4px;
        bottom: 4px;
    }

    .layer-handle-rotate {
        top: 4px;
        margin-left: -9px;
    }

    .layer-node-del {
        width: 22px;
        height: 22px;
        font-size: 14px;
        line-height: 22px;
    }
}
