html, body {
    --app-primary: #1a56ff;
    --app-primary-mid: #4d7aff;
    --app-secondary: #7c5cfc;
    --app-surface: #ffffff;
    --app-panel: #f9faff;
    --app-selected-panel: #eef2ff;
    --app-border: #dde5ff;
    --app-border-faint: #edf0ff;
    --app-text-primary: #0c1033;
    --app-text-subtle: #4a5580;
    --app-text-muted: #8e9ac4;
    --app-danger: #f43f5e;
    --app-radius-dialog: 24px;
    --app-shadow-dialog: 0 20px 64px rgba(12, 16, 51, .24), 0 4px 18px rgba(26, 86, 255, .12);
    --app-font-family: "DM Sans", Inter, "Segoe UI", Arial, sans-serif;
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
}

html,
body {
    background: #f5f8ff;
}

#viewport-backdrop,
#compose-root {
    position: fixed;
    inset: 0;
    width: 100dvw;
    height: 100dvh;
}

#viewport-backdrop {
    pointer-events: none;
    z-index: 2;
    background: transparent;
    mix-blend-mode: multiply;
}

#viewport-backdrop:not(.is-active) {
    visibility: hidden;
}

#compose-root {
    overflow: hidden;
    z-index: 1;
}

#compose-root canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}

.animated-gradient-background {
    --gradient-base: #f5f8ff;
    --gradient-cloud-1: 91, 139, 255;
    --gradient-cloud-2: 82, 190, 255;
    --gradient-cloud-3: 139, 105, 255;
    --gradient-cloud-4: 190, 132, 255;
    position: fixed;
    inset: 0;
    overflow: hidden;
    contain: strict;
    isolation: isolate;
    background: var(--gradient-base);
}

.palette-start-page {
    --gradient-base: #f5f8ff;
    --gradient-cloud-1: 91, 139, 255;
    --gradient-cloud-2: 82, 190, 255;
    --gradient-cloud-3: 139, 105, 255;
    --gradient-cloud-4: 190, 132, 255;
}

.gradient-blob {
    --blob-color: var(--gradient-cloud-1);
    position: absolute;
    width: min(71.3vw, 85.1vh);
    height: min(71.3vw, 85.1vh);
    border-radius: 50%;
    opacity: .94;
    filter: blur(clamp(14px, 1.6vw, 28px));
    background: radial-gradient(
        circle,
        rgba(var(--blob-color), .62) 0%,
        rgba(var(--blob-color), .57) 20%,
        rgba(var(--blob-color), .45) 42%,
        rgba(var(--blob-color), .24) 62%,
        rgba(var(--blob-color), .08) 78%,
        rgba(var(--blob-color), .015) 89%,
        rgba(var(--blob-color), 0) 100%
    );
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    animation-play-state: paused;
    will-change: transform, opacity;
}

#viewport-backdrop::after {
    content: "";
    position: absolute;
    inset: 26% 32%;
    z-index: 1;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, .48) 0%,
        rgba(255, 255, 255, .28) 20%,
        rgba(255, 255, 255, .08) 38%,
        rgba(255, 255, 255, 0) 56%
    );
}

#viewport-backdrop.has-auth-card-bounds::after {
    inset: auto;
    left: var(--auth-card-left);
    top: var(--auth-card-top);
    width: var(--auth-card-width);
    height: var(--auth-card-height);
    border-radius: 22px;
    background: #ffffff;
}

.is-active .gradient-blob {
    animation-play-state: running;
}

.blob-1 {
    --blob-color: var(--gradient-cloud-1);
    top: -24%;
    left: -14%;
    animation-name: gradient-drift-a;
    animation-duration: 19s;
    animation-delay: -5s;
}

.blob-2 {
    --blob-color: var(--gradient-cloud-2);
    top: -14%;
    right: -18%;
    animation-name: gradient-drift-b;
    animation-duration: 24s;
    animation-delay: -13s;
}

.blob-3 {
    --blob-color: var(--gradient-cloud-3);
    bottom: -27%;
    left: 7%;
    animation-name: gradient-drift-c;
    animation-duration: 30s;
    animation-delay: -21s;
}

.blob-4 {
    --blob-color: var(--gradient-cloud-4);
    right: -10%;
    bottom: -21%;
    animation-name: gradient-drift-d;
    animation-duration: 36s;
    animation-delay: -9s;
}

.blob-5 {
    --blob-color: var(--gradient-cloud-1);
    top: 2%;
    left: 27%;
    width: min(49.5vw, 59.8vh);
    height: min(49.5vw, 59.8vh);
    animation-name: gradient-drift-e;
    animation-duration: 21s;
    animation-delay: -14s;
}

.blob-6 {
    --blob-color: var(--gradient-cloud-2);
    top: 23%;
    right: -8%;
    width: min(55.2vw, 66.7vh);
    height: min(55.2vw, 66.7vh);
    animation-name: gradient-drift-f;
    animation-duration: 27s;
    animation-delay: -8s;
}

.blob-7 {
    --blob-color: var(--gradient-cloud-3);
    top: 42%;
    left: -9%;
    width: min(44.9vw, 55.2vh);
    height: min(44.9vw, 55.2vh);
    animation-name: gradient-drift-a;
    animation-duration: 32s;
    animation-delay: -25s;
}

.blob-8 {
    --blob-color: var(--gradient-cloud-1);
    bottom: -12%;
    left: 31%;
    width: min(52.9vw, 64.4vh);
    height: min(52.9vw, 64.4vh);
    animation-name: gradient-drift-b;
    animation-duration: 23s;
    animation-delay: -17s;
}

.blob-9 {
    --blob-color: var(--gradient-cloud-4);
    top: 38%;
    right: 19%;
    width: min(42.6vw, 52.9vh);
    height: min(42.6vw, 52.9vh);
    animation-name: gradient-drift-e;
    animation-duration: 29s;
    animation-delay: -4s;
}

.blob-10 {
    --blob-color: var(--gradient-cloud-2);
    right: -7%;
    bottom: 8%;
    width: min(48.3vw, 58.7vh);
    height: min(48.3vw, 58.7vh);
    animation-name: gradient-drift-f;
    animation-duration: 34s;
    animation-delay: -21s;
}

.blob-11 {
    --blob-color: var(--gradient-cloud-3);
    top: 10%;
    left: 7%;
    width: min(45vw, 54vh);
    height: min(45vw, 54vh);
    animation-name: gradient-drift-c;
    animation-duration: 26s;
    animation-delay: -18s;
}

.blob-12 {
    --blob-color: var(--gradient-cloud-4);
    top: 53%;
    left: 43%;
    width: min(48vw, 58vh);
    height: min(48vw, 58vh);
    animation-name: gradient-drift-d;
    animation-duration: 31s;
    animation-delay: -6s;
}

.blob-13 {
    --blob-color: var(--gradient-cloud-1);
    bottom: 13%;
    left: 11%;
    width: min(42vw, 51vh);
    height: min(42vw, 51vh);
    animation-name: gradient-drift-e;
    animation-duration: 22s;
    animation-delay: -9s;
}

@keyframes gradient-drift-a {
    0%, 100% { transform: translate3d(-9.2%, 3.5%, 0) scale(1.05); opacity: .82; }
    25% { transform: translate3d(16.1%, -11.5%, 0) scale(1.2); opacity: 1; }
    50% { transform: translate3d(20.7%, 13.8%, 0) scale(1.09); opacity: .88; }
    75% { transform: translate3d(-13.8%, 17.3%, 0) scale(1.22); opacity: .98; }
}

@keyframes gradient-drift-b {
    0%, 100% { transform: translate3d(10.4%, -8.1%, 0) scale(1.16); opacity: .94; }
    25% { transform: translate3d(-15%, 13.8%, 0) scale(1.07); opacity: .8; }
    50% { transform: translate3d(-20.7%, -10.4%, 0) scale(1.21); opacity: 1; }
    75% { transform: translate3d(13.8%, 18.4%, 0) scale(1.1); opacity: .88; }
}

@keyframes gradient-drift-c {
    0%, 100% { transform: translate3d(-5.8%, 13.8%, 0) scale(1.12); opacity: .82; }
    25% { transform: translate3d(19.6%, 4.6%, 0) scale(1.23); opacity: .98; }
    50% { transform: translate3d(9.2%, -18.4%, 0) scale(1.06); opacity: .88; }
    75% { transform: translate3d(-17.3%, -8.1%, 0) scale(1.19); opacity: 1; }
}

@keyframes gradient-drift-d {
    0%, 100% { transform: translate3d(13.8%, 9.2%, 0) scale(1.08); opacity: .9; }
    25% { transform: translate3d(3.5%, -19.6%, 0) scale(1.2); opacity: 1; }
    50% { transform: translate3d(-17.3%, 6.9%, 0) scale(1.13); opacity: .82; }
    75% { transform: translate3d(18.4%, 16.1%, 0) scale(1.23); opacity: .96; }
}

@keyframes gradient-drift-e {
    0%, 100% { transform: translate3d(-15%, -11.5%, 0) scale(1.04); opacity: .76; }
    25% { transform: translate3d(20.7%, 8.1%, 0) scale(1.18); opacity: .96; }
    50% { transform: translate3d(-4.6%, 21.9%, 0) scale(1.09); opacity: .84; }
    75% { transform: translate3d(-21.9%, 3.5%, 0) scale(1.2); opacity: .94; }
}

@keyframes gradient-drift-f {
    0%, 100% { transform: translate3d(17.3%, -9.2%, 0) scale(1.12); opacity: .9; }
    25% { transform: translate3d(-8.1%, 20.7%, 0) scale(1.03); opacity: .76; }
    50% { transform: translate3d(-20.7%, -5.8%, 0) scale(1.19); opacity: .96; }
    75% { transform: translate3d(9.2%, -21.9%, 0) scale(1.08); opacity: .82; }
}

@media (max-width: 640px) {
    .gradient-blob {
        width: 80.5vw;
        height: 80.5vw;
        filter: blur(14px);
    }

    #viewport-backdrop::after {
        inset: 31% 15%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gradient-blob {
        animation: none;
        will-change: auto;
    }
}

dialog.aivideo-modal-host {
    position: fixed;
    inset: 0;
    width: fit-content;
    height: fit-content;
    max-width: calc(100dvw - 24px);
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 0;
    border: 0;
    outline: none;
    overflow: visible;
    color: var(--app-text-primary);
    background: transparent;
    box-shadow: none;
    font-family: var(--app-font-family);
}

dialog.aivideo-modal-host:focus,
dialog.aivideo-modal-host:focus-visible {
    outline: none;
}

dialog.aivideo-modal-host::backdrop {
    background: rgba(12, 16, 51, .38);
    backdrop-filter: blur(6px);
}

.aivideo-popover-host {
    position: fixed;
    inset: auto;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: visible;
    color: var(--app-text-primary);
    background: transparent;
    font-family: var(--app-font-family);
    pointer-events: auto;
    z-index: 2147483000;
}

.aivideo-popover-host > * {
    max-width: 100%;
}

.aivideo-model-popover {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    border-radius: 18px;
    color: var(--app-text-primary);
    background: var(--app-surface);
    box-shadow: var(--app-shadow-dialog);
}

.aivideo-model-option {
    width: 100%;
    min-height: 62px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    overflow: hidden;
    clip-path: inset(0 round 14px);
    padding: 10px;
    border: 1px solid var(--app-border-faint);
    border-radius: 14px;
    color: var(--app-text-primary);
    background: var(--app-surface);
    background-clip: padding-box;
    text-align: left;
    font-family: var(--app-font-family);
    appearance: none;
    cursor: pointer;
}

.aivideo-model-option:hover:not(.is-disabled),
.aivideo-model-option:focus-visible:not(.is-disabled) {
    border-color: var(--app-primary);
    outline: none;
}

.aivideo-model-option.is-selected {
    border-color: var(--app-primary);
    background: var(--app-selected-panel);
}

.aivideo-model-option.is-disabled {
    border-color: var(--app-border-faint);
    color: var(--app-text-muted);
    background: var(--app-panel);
    cursor: not-allowed;
}

.aivideo-model-option.is-disabled .aivideo-model-icon {
    color: var(--app-text-muted);
    background: var(--app-border-faint);
}

.aivideo-model-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 10px;
    color: #16a34a;
    background: rgba(22, 163, 74, .14);
}

.aivideo-model-icon svg {
    width: 19px;
    height: 19px;
    stroke-width: 1.5;
}

.aivideo-model-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aivideo-model-copy strong,
.aivideo-model-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
}

.aivideo-model-copy strong {
    font-size: 14px;
    font-weight: 700;
    line-height: 19px;
}

.aivideo-model-copy small {
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 15px;
}

.aivideo-model-selected {
    width: 20px;
    flex: 0 0 20px;
    color: var(--app-primary);
    font-size: 16px;
    font-weight: 800;
    text-align: center;
    visibility: hidden;
}

.aivideo-model-option.is-selected .aivideo-model-selected { visibility: visible; }

.aivideo-create-character-modal {
    width: min(680px, calc(100dvw - 32px));
    max-height: min(820px, calc(100dvh - 32px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-dialog);
    background: var(--app-surface);
    box-shadow: var(--app-shadow-dialog);
}

.aivideo-character-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
}

.aivideo-character-modal-heading {
    min-width: 0;
    flex: 1 1 auto;
}

.aivideo-character-modal-title,
.aivideo-character-modal-subtitle,
.aivideo-character-section-title,
.aivideo-character-section-hint,
.aivideo-character-empty-message {
    margin: 0;
}

.aivideo-character-modal-title {
    color: var(--app-text-primary);
    font-size: 20px;
    font-weight: 700;
    line-height: 24px;
}

.aivideo-character-modal-subtitle {
    margin-top: 2px;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
}

.aivideo-character-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    color: var(--app-primary);
    background: transparent;
    font: 600 14px/20px var(--app-font-family);
    cursor: pointer;
    transition: background-color .15s ease, transform .1s ease;
}

.aivideo-character-close:hover,
.aivideo-character-close:focus-visible {
    background: var(--app-selected-panel);
}

.aivideo-character-close:active {
    transform: scale(.98);
}

.aivideo-character-modal-scroll {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 22px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c8d4ff transparent;
}

.aivideo-character-modal-scroll::-webkit-scrollbar {
    width: 5px;
}

.aivideo-character-modal-scroll::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: #c8d4ff;
}

.aivideo-character-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aivideo-character-field-label {
    color: var(--app-text-subtle);
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
}

.aivideo-character-input {
    width: 100%;
    min-height: 54px;
    box-sizing: border-box;
    padding: 14px 16px;
    border: 1.5px solid var(--app-border);
    border-radius: 16px;
    outline: none;
    color: var(--app-text-primary);
    background: var(--app-surface);
    font: 400 16px/24px var(--app-font-family);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.aivideo-character-input:hover {
    border-color: #c8d4ff;
}

.aivideo-character-input:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 255, .12);
}

.aivideo-character-input.is-error {
    border-color: var(--app-danger);
}

.aivideo-character-field-error {
    color: var(--app-danger);
    font-size: 12px;
    line-height: 18px;
}

.aivideo-character-field-error[hidden] {
    display: none;
}

.aivideo-character-textarea {
    min-height: 82px;
    resize: vertical;
}

.aivideo-character-section-title {
    color: var(--app-text-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.aivideo-character-section-hint,
.aivideo-character-empty-message {
    color: var(--app-text-muted);
    font-size: 12px;
    line-height: 18px;
}

.aivideo-character-selected-assets,
.aivideo-character-available-assets {
    display: grid;
    gap: 10px;
    min-width: 0;
    overflow: visible;
    padding: 1px 1px 5px;
    scrollbar-width: thin;
    scrollbar-color: #c8d4ff transparent;
}

.aivideo-character-selected-assets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.aivideo-character-selected-tile,
.aivideo-character-uploading-slot,
.aivideo-character-empty-slot {
    position: relative;
    width: 100%;
    min-width: 0;
    height: auto;
    aspect-ratio: 3 / 4;
    box-sizing: border-box;
    overflow: hidden;
    border: 1.5px solid var(--app-border);
    border-radius: 16px;
    background: var(--app-panel);
}

.aivideo-character-selected-tile:first-child,
.aivideo-character-uploading-slot.is-required,
.aivideo-character-empty-slot.is-required {
    border-color: var(--app-primary);
}

.aivideo-character-uploading-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--app-primary);
    background: var(--app-panel);
}

.aivideo-character-uploading-slot > .aivideo-character-asset-image,
.aivideo-character-uploading-slot > .aivideo-character-image-placeholder {
    position: absolute;
    inset: 0;
    opacity: .35;
}

.aivideo-character-uploading-slot > .aivideo-modal-spinner,
.aivideo-character-uploading-label {
    position: relative;
    z-index: 1;
}

.aivideo-character-uploading-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 14px;
}

.aivideo-character-asset-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.aivideo-character-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--app-primary-mid);
    background: var(--app-selected-panel);
}

.aivideo-character-tile-controls {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.aivideo-character-remove-asset,
.aivideo-character-replace-asset {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(12, 16, 51, .12);
    cursor: pointer;
}

.aivideo-character-remove-asset { color: var(--app-danger); }
.aivideo-character-replace-asset { color: var(--app-primary); }

.aivideo-character-main-badge {
    position: absolute;
    inset: auto 0 0;
    padding: 5px 8px;
    color: #fff;
    background: rgba(26, 86, 255, .84);
    font-size: 10px;
    font-weight: 600;
    line-height: 14px;
}

.aivideo-character-empty-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 6px;
    border-style: dashed;
    font-family: var(--app-font-family);
    color: var(--app-text-muted);
    cursor: pointer;
}

.aivideo-character-empty-slot.is-required {
    color: var(--app-primary);
    background: rgba(26, 86, 255, .04);
}

.aivideo-character-empty-slot:hover,
.aivideo-character-empty-slot:focus-visible {
    border-color: var(--app-primary);
    background: var(--app-selected-panel);
    outline: none;
}

.aivideo-character-empty-icon {
    height: 22px;
    color: #93b8ff;
}

.aivideo-character-empty-label,
.aivideo-character-required {
    font-size: 11px;
    font-weight: 600;
    line-height: 14px;
}

.aivideo-character-required {
    color: var(--app-primary);
}

.aivideo-character-assets-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.aivideo-character-image-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}

.aivideo-character-secondary-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    box-sizing: border-box;
    padding: 8px 14px;
    border: 1.5px solid var(--app-border);
    border-radius: 16px;
    color: var(--app-primary);
    background: var(--app-surface);
    font: 600 14px/20px var(--app-font-family);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}

.aivideo-character-cancel {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    box-sizing: border-box;
    padding: 8px 14px;
    border: 0;
    border-radius: 12px;
    color: var(--app-text-subtle);
    background: transparent;
    font: 600 13px/18px var(--app-font-family);
    cursor: pointer;
}

.aivideo-character-cancel:hover,
.aivideo-character-cancel:focus-visible {
    color: var(--app-primary);
    background: var(--app-selected-panel);
    outline: none;
}

.aivideo-character-secondary-button:hover:not(:disabled),
.aivideo-character-secondary-button:focus-visible:not(:disabled) {
    border-color: var(--app-primary);
    background: var(--app-selected-panel);
}

.aivideo-character-secondary-button:active:not(:disabled) {
    transform: scale(.98);
}

.aivideo-character-secondary-button:disabled {
    border-color: var(--app-border);
    color: var(--app-text-muted);
    background: var(--app-panel);
    box-shadow: none;
    cursor: default;
    filter: none;
}

.aivideo-character-submit:disabled {
    color: #fff;
    background: var(--app-text-muted);
    box-shadow: none;
    cursor: default;
    filter: none;
}

.aivideo-character-button-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
}

.aivideo-character-available-assets {
    min-height: 94px;
    gap: 9px;
    grid-template-columns: repeat(6, minmax(72px, 1fr));
}

.aivideo-character-available-tile {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    box-sizing: border-box;
    padding: 0;
    overflow: hidden;
    border: 2px solid var(--app-border-faint);
    border-radius: 13px;
    background: var(--app-panel);
    cursor: pointer;
}

.aivideo-character-available-tile.is-selected {
    border-color: var(--app-primary);
}

.aivideo-character-available-tile:focus-visible {
    outline: 3px solid rgba(26, 86, 255, .2);
    outline-offset: 2px;
}

.aivideo-character-selected-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: var(--app-primary);
    font-size: 11px;
    font-weight: 700;
}

.aivideo-character-loading,
.aivideo-character-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    color: var(--app-text-subtle);
    font-size: 12px;
    line-height: 18px;
}

.aivideo-character-loading,
.aivideo-character-empty-message {
    grid-column: 1 / -1;
}

.aivideo-character-progress {
    justify-content: flex-start;
    box-sizing: border-box;
    padding: 12px;
    border-radius: 12px;
    color: var(--app-primary);
    background: var(--app-selected-panel);
}

.aivideo-character-progress[hidden],
.aivideo-character-error[hidden] {
    display: none;
}

.aivideo-modal-spinner {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    box-sizing: border-box;
    border: 2px solid var(--app-border);
    border-top-color: var(--app-primary);
    border-radius: 50%;
    animation: aivideo-modal-spin .8s linear infinite;
}

.aivideo-character-error {
    color: var(--app-danger);
    font-size: 12px;
    line-height: 18px;
}

.aivideo-character-modal-footer {
    flex: 0 0 auto;
    padding: 18px;
    border-top: 1px solid var(--app-border-faint);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.aivideo-character-submit {
    width: auto;
    min-width: 228px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 12px 18px;
    border: 0;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
    box-shadow: 0 8px 22px rgba(26, 86, 255, .24);
    font: 700 14px/20px var(--app-font-family);
    cursor: pointer;
    transition: filter .15s ease, transform .1s ease, box-shadow .15s ease;
}

.aivideo-character-submit:hover:not(:disabled),
.aivideo-character-submit:focus-visible:not(:disabled) {
    filter: brightness(1.06);
    box-shadow: 0 10px 28px rgba(26, 86, 255, .32);
}

.aivideo-character-submit:active:not(:disabled) {
    transform: scale(.99);
}

@keyframes aivideo-modal-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .aivideo-create-character-modal {
        width: calc(100dvw - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 20px;
    }

    .aivideo-character-modal-header {
        align-items: flex-start;
        padding: 16px;
    }

    .aivideo-character-modal-scroll {
        padding: 0 16px 14px;
    }

    .aivideo-character-modal-footer {
        padding: 14px 16px 16px;
    }

    .aivideo-character-selected-assets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aivideo-character-available-assets {
        grid-template-columns: repeat(4, minmax(58px, 1fr));
    }

    .aivideo-character-modal-subtitle {
        max-width: 300px;
    }

    .aivideo-character-upload-label {
        display: inline;
    }

    .aivideo-character-secondary-button {
        width: auto;
        min-width: 0;
        padding: 8px 12px;
    }

    .aivideo-character-image-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .aivideo-character-modal-footer {
        display: grid;
        grid-template-columns: auto 1fr;
    }

    .aivideo-character-submit {
        width: 100%;
        min-width: 0;
    }
}

@media (max-height: 520px) {
    .aivideo-create-character-modal {
        max-height: calc(100dvh - 12px);
    }

    .aivideo-character-modal-header,
    .aivideo-character-modal-footer {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* Character picker and settings are non-modal DOM portals anchored to Compose controls. */

.aivideo-character-picker-modal {
    width: 100%;
    min-height: min(164px, calc(100dvh - 24px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 18px;
    color: var(--app-text-primary);
    background: var(--app-surface);
    box-shadow: 0 12px 38px rgba(26, 86, 255, .16), 0 3px 12px rgba(12, 16, 51, .08);
}

.aivideo-character-picker-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 10px;
}

.aivideo-character-picker-title,
.aivideo-character-picker-count {
    margin: 0;
}

.aivideo-character-picker-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 21px;
}

.aivideo-character-picker-count {
    margin-top: 1px;
    color: var(--app-text-muted);
    font-size: 11px;
    line-height: 16px;
}

.aivideo-character-picker-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.aivideo-character-refresh,
.aivideo-character-delete {
    box-sizing: border-box;
    padding: 7px 9px;
    border: 0;
    border-radius: 10px;
    color: var(--app-primary);
    background: transparent;
    font: 600 11px/16px var(--app-font-family);
    cursor: pointer;
}

.aivideo-character-refresh:hover:not(:disabled),
.aivideo-character-refresh:focus-visible:not(:disabled),
.aivideo-character-delete:hover:not(:disabled),
.aivideo-character-delete:focus-visible:not(:disabled) {
    background: var(--app-selected-panel);
    outline: none;
}

.aivideo-character-refresh:disabled,
.aivideo-character-delete:disabled {
    color: var(--app-text-muted);
    background: transparent;
    cursor: default;
}

.aivideo-character-picker-content {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 14px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.aivideo-character-picker-state {
    min-height: 88px;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px;
    box-sizing: border-box;
    border-radius: 12px;
    color: var(--app-text-muted);
    background: var(--app-panel);
    text-align: center;
    font-size: 12px;
    line-height: 18px;
}

.aivideo-character-picker-state p { margin: 0; }
.aivideo-character-picker-state.is-error { color: var(--app-danger); }

.aivideo-character-picker-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    box-sizing: border-box;
    border: 1px solid var(--app-border-faint);
    border-radius: 12px;
    background: var(--app-panel);
    transition: border-color .15s ease, background-color .15s ease;
}

.aivideo-character-picker-row.is-selected {
    border-color: var(--app-primary);
    background: var(--app-selected-panel);
}

.aivideo-character-picker-row.is-disabled {
    border-color: var(--app-border-faint);
    color: var(--app-text-muted);
    background: var(--app-panel);
}

.aivideo-character-choice {
    min-width: 0;
    min-height: 56px;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 9px;
    box-sizing: border-box;
    padding: 7px 4px 7px 8px;
    border: 0;
    border-radius: 11px;
    color: inherit;
    background: transparent;
    text-align: left;
    font-family: var(--app-font-family);
    cursor: pointer;
}

.aivideo-character-choice:focus-visible {
    outline: 3px solid rgba(26, 86, 255, .18);
    outline-offset: -2px;
}

.aivideo-character-choice:disabled { cursor: default; }

.aivideo-character-picker-preview {
    position: relative;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: flex;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
    font-size: 15px;
    font-weight: 700;
}

.aivideo-character-picker-preview.is-initial {
    position: static;
}

.aivideo-character-picker-preview-fallback,
.aivideo-character-picker-preview-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.aivideo-character-picker-preview-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
}

.aivideo-character-picker-preview-image {
    display: block;
    object-fit: cover;
}

.aivideo-character-picker-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.aivideo-character-picker-copy strong,
.aivideo-character-picker-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aivideo-character-picker-copy strong {
    color: var(--app-text-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 17px;
}

.aivideo-character-picker-copy small {
    color: var(--app-text-muted);
    font-size: 10px;
    line-height: 14px;
}

.aivideo-character-selected {
    flex: 0 0 auto;
    color: var(--app-primary);
    font-size: 14px;
    font-weight: 800;
}

.aivideo-character-delete { color: var(--app-danger); }

.aivideo-character-picker-footer {
    flex: 0 0 auto;
    padding: 0 14px 14px;
}

.aivideo-character-create {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    box-sizing: border-box;
    padding: 9px 14px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    color: var(--app-primary);
    background: var(--app-selected-panel);
    font: 700 13px/18px var(--app-font-family);
    cursor: pointer;
    transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}

.aivideo-character-create:hover,
.aivideo-character-create:focus-visible {
    border-color: var(--app-primary);
    box-shadow: 0 5px 16px rgba(26, 86, 255, .12);
    outline: none;
}

.aivideo-character-create:active { transform: scale(.99); }

/* Confirmations stay modal; generation settings use the anchored popover host. */
.aivideo-settings-popover,
.aivideo-confirmation-modal {
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid var(--app-border);
    color: var(--app-text-primary);
    background: var(--app-surface);
    box-shadow: var(--app-shadow-dialog);
}

.aivideo-settings-popover {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
}

.aivideo-confirmation-modal {
    width: min(440px, calc(100dvw - 32px));
    max-height: calc(100dvh - 32px);
    border-radius: var(--app-radius-dialog);
}

.aivideo-alert-modal {
    width: fit-content;
    min-width: min(320px, calc(100dvw - 32px));
    max-width: min(500px, calc(100dvw - 32px));
}

.aivideo-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px 14px;
}

.aivideo-settings-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.aivideo-settings-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    color: var(--app-primary);
}

.aivideo-settings-icon svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.aivideo-settings-title,
.aivideo-settings-label {
    margin: 0;
}

.aivideo-settings-slider-header,
.aivideo-settings-slider-limits {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aivideo-settings-slider-value {
    color: var(--app-primary);
    font-size: 13px;
    font-weight: 700;
}

.aivideo-settings-slider {
    width: 100%;
    margin: 2px 0 0;
    accent-color: var(--app-primary);
    cursor: pointer;
}

.aivideo-settings-slider-limits {
    color: var(--app-text-muted);
    font-size: 11px;
    line-height: 16px;
}

.aivideo-settings-title {
    font-size: 18px;
    font-weight: 750;
    line-height: 24px;
}

.aivideo-settings-body {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 20px 18px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c8d4ff transparent;
}

.aivideo-settings-body::-webkit-scrollbar {
    width: 5px;
}

.aivideo-settings-body::-webkit-scrollbar-track {
    background: transparent;
}

.aivideo-settings-body::-webkit-scrollbar-thumb {
    border-radius: 99px;
    background: #c8d4ff;
}

.aivideo-settings-body::-webkit-scrollbar-thumb:hover {
    background: #a0b4ff;
}

.aivideo-settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aivideo-settings-label {
    color: var(--app-text-subtle);
    font-size: 12px;
    font-weight: 650;
    line-height: 18px;
}

.aivideo-settings-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.aivideo-settings-ratios { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.aivideo-settings-option,
.aivideo-settings-audio {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1.5px solid var(--app-border);
    border-radius: 12px;
    color: var(--app-text-subtle);
    background: var(--app-surface);
    font: 600 13px/18px var(--app-font-family);
    cursor: pointer;
}

.aivideo-settings-option.is-selected,
.aivideo-settings-audio.is-selected {
    border-color: var(--app-primary);
    color: var(--app-primary);
    background: var(--app-selected-panel);
}

.aivideo-settings-option:hover,
.aivideo-settings-option:focus-visible,
.aivideo-settings-audio:hover,
.aivideo-settings-audio:focus-visible {
    border-color: var(--app-primary);
    outline: none;
}

.aivideo-settings-audio:disabled {
    opacity: .5;
    cursor: not-allowed;
    border-color: var(--app-border);
}

.aivideo-ratio-icon {
    display: block;
    box-sizing: border-box;
    border: 1.5px solid currentColor;
    border-radius: 2px;
}

.aivideo-ratio-icon.ratio-landscape { width: 16px; height: 10px; }
.aivideo-ratio-icon.ratio-square { width: 12px; height: 12px; }
.aivideo-ratio-icon.ratio-portrait { width: 9px; height: 15px; }

.aivideo-settings-audio {
    width: 100%;
    justify-content: flex-start;
}

.aivideo-settings-check {
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: 1.5px solid var(--app-border);
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
}

.aivideo-settings-audio.is-selected .aivideo-settings-check {
    border-color: var(--app-primary);
    background: var(--app-primary);
}

.aivideo-settings-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--app-border-faint);
}

.aivideo-button {
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 17px;
    border: 0;
    border-radius: 14px;
    font: 700 13px/18px var(--app-font-family);
    cursor: pointer;
}

.aivideo-button-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
    box-shadow: 0 7px 20px rgba(26, 86, 255, .23);
}

.aivideo-button-secondary {
    color: var(--app-text-subtle);
    background: var(--app-panel);
    border: 1px solid var(--app-border);
}

.aivideo-button:hover,
.aivideo-button:focus-visible { filter: brightness(1.05); outline: none; }
.aivideo-button:active { transform: scale(.99); }
.aivideo-button-primary.is-destructive { background: var(--app-danger); box-shadow: 0 7px 20px rgba(244, 63, 94, .2); }

.aivideo-settings-footer .aivideo-button { width: 100%; }

.aivideo-confirmation-modal {
    padding: 22px;
}

.aivideo-confirmation-title,
.aivideo-confirmation-message {
    margin: 0;
}

.aivideo-confirmation-title {
    font-size: 19px;
    font-weight: 750;
    line-height: 25px;
}

.aivideo-confirmation-message {
    margin-top: 8px;
    color: var(--app-text-subtle);
    font-size: 13px;
    line-height: 20px;
}

.aivideo-confirmation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

.aivideo-alert-modal .aivideo-confirmation-actions.is-single-action {
    justify-content: center;
}

.aivideo-alert-progress {
    margin: 20px auto 2px;
}

.aivideo-confirmation-actions[hidden],
.aivideo-alert-progress[hidden] {
    display: none;
}

@media (max-width: 480px) {
    .aivideo-confirmation-modal {
        width: calc(100dvw - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 20px;
    }

    .aivideo-confirmation-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
