.ms-generator-canvas {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background:
        radial-gradient(circle at top center, rgba(255, 121, 26, 0.05), transparent 26%),
        radial-gradient(circle at 18% 22%, rgba(125, 92, 255, 0.06), transparent 22%),
        linear-gradient(180deg, #050505 0%, #000 100%);
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.ms-generator-canvas-ambient,
.ms-generator-canvas-noise {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ms-generator-canvas-ambient {
    background:
        radial-gradient(circle at 80% 30%, rgba(255, 122, 26, 0.05), transparent 18%),
        radial-gradient(circle at 30% 75%, rgba(116, 78, 255, 0.05), transparent 24%);
    filter: blur(28px);
}

.ms-generator-canvas-noise {
    opacity: 0.04;
    background-image:
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 3px 3px, 3px 3px;
    mix-blend-mode: soft-light;
}

.ms-generator-stage {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 4px 8px 6px;
}

.ms-generator-result {
    width: 100%;
    max-width: none;
    align-self: stretch;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.ms-generator-result-media {
    flex: 1 1 0;
    min-height: 0;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.05);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
}

.ms-generator-hero-video-wrap {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
}

.ms-generator-hero-video {
    position: absolute;
    inset: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    object-fit: cover;
    object-position: center;
    filter: saturate(1.05) contrast(1.02);
}

.ms-generator-hero-video-noise {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: 0.24;
    mix-blend-mode: overlay;
    background-image:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(110deg, transparent 0 6px, rgba(255, 255, 255, 0.02) 6px 7px);
    background-size: 100% 100%, 100% 100%, 200% 200%;
    animation: ms-generator-hero-noise-drift 0.45s steps(4) infinite;
}

@keyframes ms-generator-hero-noise-drift {
    0% {
        opacity: 0.2;
        transform: translate(0, 0);
        background-position: 0 0, 0 0, 0 0;
    }
    33% {
        opacity: 0.3;
        transform: translate(-0.35%, 0.2%);
        background-position: 1px 0, 0 1px, 4px 2px;
    }
    66% {
        opacity: 0.22;
        transform: translate(0.25%, -0.15%);
        background-position: 0 2px, 2px 0, -3px 4px;
    }
    100% {
        opacity: 0.24;
        transform: translate(0, 0);
        background-position: 0 0, 0 0, 0 0;
    }
}

.ms-generator-result-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ms-generator-ref-slots-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px 12px;
    pointer-events: auto;
    align-items: flex-start;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0.2) 70%, transparent 100%);
}

.ms-generator-result-media.is-generating .ms-generator-ref-slots-wrap,
.ms-generator-result-media.is-generating #generatorReferenceSlots {
    display: none !important;
}

.ms-generator-ref-slot {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 120px;
    max-width: 200px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
}

.ms-generator-ref-slot-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.ms-generator-ref-slot-preview {
    min-height: 48px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ms-generator-ref-slot-placeholder {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
}

.ms-generator-ref-thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.ms-generator-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ms-generator-ref-slot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ms-generator-ref-slot-btn {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.88);
    cursor: pointer;
}

.ms-generator-ref-slot-btn-ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
}

.ms-generator-processing-badges {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    pointer-events: none;
    max-width: calc(100% - 28px);
}

.ms-generator-result-grid > .ms-generator-processing-badges.is-grid-progress-slot {
    position: relative;
    top: auto;
    left: auto;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    max-width: none;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 12px;
    box-sizing: border-box;
    aspect-ratio: 1;
    min-height: 210px;
    border-radius: 12px;
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.06);
    align-self: start;
}

.ms-generator-processing-badges .generation-progress {
    width: 300px;
    max-width: 300px;
    flex: 0 0 auto;
    margin: 0;
    border-radius: 12px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.38);
    border: none;
    box-sizing: border-box;
}

.ms-generator-result-grid > .ms-generator-processing-badges.is-grid-progress-slot .generation-progress {
    width: 100%;
    max-width: none;
    flex: 0 1 auto;
}

.ms-generator-processing-badges .generation-progress .progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ms-generator-processing-badges .generation-progress .progress-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.ms-generator-processing-badges .generation-progress .progress-percentage {
    color: #5ee4ff;
    font-weight: 600;
    font-size: 13px;
}

.ms-generator-processing-badges .generation-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.ms-generator-processing-badges .generation-progress .progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.3s ease;
    background: linear-gradient(90deg, #00d4ff, #667eea);
}

.ms-generator-processing-badges .generation-progress .progress-text {
    margin: 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
}

.ms-generator-result-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 85% 65% at 50% 45%, rgba(255, 255, 255, 0.045) 0%, transparent 55%),
        rgba(0, 0, 0, 0.34);
    z-index: 0;
}

.ms-generator-result-media::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.28) 100%);
    pointer-events: none;
}

.ms-generator-result-media.has-media::after {
    display: none;
}

.ms-generator-result-grid {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
    overflow: auto;
    align-content: start;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.ms-generator-result-grid-cell {
    position: relative;
    aspect-ratio: 1;
    min-height: 210px;
    min-width: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-generator-result-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 12;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    max-width: calc(100% - 16px);
    pointer-events: auto;
}

.ms-generator-result-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.55);
    color: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.ms-generator-result-action-btn:hover {
    background: rgba(30, 30, 30, 0.75);
    border-color: rgba(220, 198, 120, 0.45);
    color: #f5e6b8;
}

.ms-generator-result-action-btn--danger:hover {
    border-color: rgba(248, 113, 113, 0.5);
    color: #fecaca;
}

.ms-generator-result-action-btn--asset-type .ms-generator-result-type-badge-label {
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ms-generator-result-action-btn i {
    font-size: 12px;
    opacity: 0.9;
}

.ms-generator-result-grid-cell:has(video.ms-generator-result-asset) .ms-generator-result-actions {
    bottom: 44px;
}

.ms-generator-result-asset-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: inherit;
}

.ms-generator-result-asset-wrap[data-ms-media-id] {
    cursor: pointer;
}

.ms-generator-result-asset-wrap[data-ms-media-id]:focus-visible {
    outline: 2px solid rgba(232, 197, 120, 0.85);
    outline-offset: -2px;
}

.ms-generator-result-asset-wrap .ms-generator-result-asset:is(img, video) {
    pointer-events: none;
}

.ms-generator-result-audio-thumb-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    pointer-events: none;
    text-align: center;
    padding: 12px;
}

.ms-generator-result-audio-thumb-inner i {
    font-size: 28px;
    opacity: 0.88;
}

.ms-generator-result-model-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
    max-width: calc(100% - 16px);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #e8c578;
    background: rgba(0, 0, 0, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.14);
    pointer-events: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.ms-generator-result-grid-cell:has(.ms-generator-result-asset--audio-thumb) {
    aspect-ratio: auto;
    min-height: 150px;
}

.ms-generator-result-grid-cell .ms-generator-result-asset:is(img, video) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    object-fit: cover;
    display: block;
    background: #0a0a0a;
}

.ms-generator-result-grid-cell .ms-generator-result-asset--audio-thumb {
    position: absolute;
    inset: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #141218, #0a0a0c);
    box-sizing: border-box;
}

.ms-generator-result-grid-cell audio.ms-generator-result-asset {
    position: relative;
    width: 100%;
    height: auto;
    max-height: none;
    padding: 12px 14px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.ms-generator-result-asset {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 360px;
    max-height: none;
    object-fit: contain;
    background: #0a0a0a;
}

.ms-generator-result-media audio.ms-generator-result-asset {
    width: 100%;
    height: auto;
    max-height: none;
    padding: 24px;
    box-sizing: border-box;
}

.ms-generator-result-media .ms-generator-result-grid-cell audio.ms-generator-result-asset {
    padding: 12px 14px;
}

.ms-generator-result-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    padding: 26px;
    background-size: cover;
    background-position: center;
}

.ms-generator-result-placeholder--hero {
    background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 42%, rgba(0, 0, 0, 0.65) 100%);
}

.ms-generator-result-placeholder span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(0,0,0,0.36);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    color: rgba(255,255,255,0.82);
    backdrop-filter: blur(12px);
}

@media (max-width: 900px) {
    .ms-generator-stage {
        padding: 10px 10px 12px;
        flex: 1 1 auto;
        min-height: min(420px, 52dvh);
    }

    .ms-generator-result-media {
        min-height: min(360px, 40dvh);
    }
}