/* Chat UI Styles (Welcome, Messages, and Input) */

/* ── Workflow Studio: choice chips ──────────────────────────────────────── */
.wf-choice-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.wf-choice-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1.5px solid var(--color-border-light);
    border-radius: 24px;
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.wf-choice-chip:hover {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.wf-choice-chip:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ── Workflow Studio: title / thumb-text option lists ───────────────────── */
.wf-title-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.wf-title-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border-light);
    border-radius: 10px;
    background: var(--color-surface);
}

.wf-title-option-text {
    flex: 1;
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text-primary);
}

.wf-title-lock-btn,
.wf-thumb-text-lock-btn,
.wf-hook-lock-btn,
.wf-structure-lock-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1.5px solid var(--color-primary);
    border-radius: 20px;
    background: transparent;
    color: var(--color-primary);
    font-size: var(--font-size-xs, 12px);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.wf-title-lock-btn:hover,
.wf-thumb-text-lock-btn:hover,
.wf-hook-lock-btn:hover,
.wf-structure-lock-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

/* ── Hook options ─────────────────────────────────────────────────────────── */
.wf-hook-kind-label {
    display: block;
    font-size: var(--font-size-xs, 11px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.wf-hook-text {
    display: block;
    line-height: 1.6;
}

/* ── Structure proposal ───────────────────────────────────────────────────── */
.wf-structure-proposal {
    margin-top: 12px;
}

.wf-structure-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wf-structure-section {
    padding: 10px 14px;
    border: 1.5px solid var(--color-border-light);
    border-radius: 10px;
    background: var(--color-surface);
}

.wf-structure-title {
    display: block;
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    margin-bottom: 3px;
}

.wf-structure-purpose {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.wf-structure-notes {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-style: italic;
    margin: 8px 0 12px;
}

.wf-structure-controls {
    flex-wrap: wrap;
}

.wf-success-lottie {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 4px 2px;
}

.wf-success-lottie__anim {
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    display: block;
}

.wf-success-lottie__label {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1.35;
}

@media (max-width: 520px) {
    .wf-success-lottie {
        gap: 10px;
        min-height: 52px;
    }

    .wf-success-lottie__anim {
        flex-basis: 48px;
        width: 48px;
        height: 48px;
    }
}

/* ── Final project view ───────────────────────────────────────────────────── */
.wf-final-project {
    margin-top: 16px;
    overflow: hidden;
    background: var(--color-surface);
}

.wf-final-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--color-bg-secondary);
}

.wf-final-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wf-final-script {
    padding: 20px;
}

.wf-final-script-title {
    font-size: var(--font-size-lg, 18px);
    font-weight: 700;
    color: var(--color-text-primary);
    margin: 0 0 16px;
    line-height: 1.4;
}

.wf-final-section {
    margin-bottom: 20px;
}

.wf-final-section-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.wf-final-section-content {
    font-size: var(--font-size-base);
    line-height: 1.7;
    color: var(--color-text-primary);
    white-space: pre-wrap;
}

/* ── Workflow Studio: loop regenerate controls ──────────────────────────── */
.wf-loop-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.wf-loop-hint-input {
    flex: 1;
    padding: 7px 12px;
    border: 1.5px solid var(--color-border-light);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
}

.wf-loop-hint-input::placeholder {
    color: var(--color-text-secondary);
}

.wf-loop-regen-btn,
.wf-thumb-text-regen-btn,
.wf-hook-regen-btn,
.wf-structure-regen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--color-border-light);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.wf-loop-regen-btn:hover,
.wf-thumb-text-regen-btn:hover,
.wf-hook-regen-btn:hover,
.wf-structure-regen-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Welcome / Initial Selection */
.chat-initial-selection {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: var(--space-8);
    gap: var(--space-6);
}

.chat-initial-selection.active {
    display: flex;
}

.chat-welcome {
    text-align: center;
    margin-bottom: var(--space-8);
}

.chat-welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
}

.chat-welcome-icon svg {
    width: 32px;
    height: 32px;
    stroke-width: 1.5;
}

.chat-welcome h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0 0 var(--space-2) 0;
}

.chat-welcome p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.5;
}

.chat-start-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: 100%;
    max-width: 600px;
}

.test-loader-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    background: transparent;
    border: 1px dashed var(--color-border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.test-loader-btn:hover {
    color: var(--color-text-primary);
    border-color: var(--color-text-secondary);
    background: var(--color-bg-hover);
}

.test-loader-btn svg {
    width: 14px;
    height: 14px;
}

.chat-start-option {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.chat-start-option:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-light);
}

.chat-start-option .option-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
}

.chat-start-option .option-icon svg {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}

.chat-start-option:hover .option-icon {
    color: var(--color-text-primary);
}

.chat-start-option .option-content {
    flex: 1;
    min-width: 0;
}

.chat-start-option h4 {
    margin: 0 0 4px 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.4;
}

.chat-start-option p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.chat-start-option .option-arrow {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--color-text-secondary);
    transition: all 0.2s ease;
}

.chat-start-option .option-arrow svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.chat-start-option:hover .option-arrow {
    color: var(--color-text-primary);
    transform: translateX(2px);
}

/* Chat Messages */
.chat-interface {
    display: none;
    flex-direction: column;
    height: 100%;
}

.chat-interface.active {
    display: flex;
}

/* Quick, smooth entrance when a script is selected */
.chat-messages.script-appearing {
    animation: scriptAppear 0.26s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes scriptAppear {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    /* Allow horizontal scroll for refinement bar on split screen / narrow viewports */
    padding: var(--space-6) var(--space-4);
    scroll-behavior: smooth;
}

.chat-messages-inner {
    max-width: var(--sw-chat-max-width);
    margin: 0 auto;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-interface.refining .chat-messages-inner,
.chat-messages:has(.sources-active) .chat-messages-inner {
    max-width: 1400px;
    /* Expand the whole track so the shift doesn't hit the left edge */
}

.chat-message {
    margin-bottom: var(--space-6);
    max-width: var(--sw-chat-max-width);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.chat-message-user {
    display: flex;
    justify-content: flex-end;
}

.chat-message-ai {
    display: flex;
    justify-content: flex-start;
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expand AI message width when sources or refinement sidebars are active */
.chat-message-ai.sources-active,
.chat-interface.refining .chat-message-ai {
    max-width: 1400px;
    width: 100%;
}

/* Shift the block slightly to stay balanced without hitting the left edge */
.chat-message-ai.sources-active {
    transform: translateX(-100px);
    /* Default shift for large screens */
}

.chat-interface.refining .chat-message-ai.sources-active {
    transform: translateX(-200px);
}

@media (max-width: 1366px) {
    .chat-message-ai.sources-active {
        transform: translateX(-50px);
        /* Reduced shift for laptops */
    }

    .chat-interface.refining .chat-message-ai.sources-active {
        transform: translateX(-100px);
    }
}

@media (max-width: 1100px) {

    .chat-message-ai.sources-active,
    .chat-interface.refining .chat-message-ai.sources-active {
        transform: translateX(0);
        /* Center without shifting on small desktops */
    }
}

.message-bubble {
    max-width: 80%;
    padding: var(--space-4) var(--space-5);
    position: relative;
}

.chat-message-user .message-bubble {
    position: relative;
    max-width: 90%;
    padding: 0.75rem 1rem;
    background: var(--sw-message-user-bg);
    color: var(--sw-message-user-text);
    border: 1px solid var(--sw-message-user-border);
    border-radius: 1.5rem !important;
    border-bottom-right-radius: 0.625rem !important;
}

[data-theme='dark'] .chat-message-user .message-bubble {
    background: #1a1a1a;
    color: #fff;
    border-color: #2a2a2a;
}

.chat-message-ai .message-bubble {
    background: var(--sw-message-ai-bg);
    color: var(--color-text-primary);
    border-bottom-left-radius: 4px;
}

.message-content {
    font-size: var(--font-size-base);
    line-height: 1.6;
    word-wrap: break-word;
}

/* Guided workflow step indicator — icon + title at top of AI messages */
.workflow-step-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    user-select: none;
}

.workflow-step-badge__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--wf-step-icon-bg);
    color: var(--wf-step-icon-color);
    border: none;
}

.workflow-step-badge__icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.workflow-step-badge__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.workflow-step-badge__title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--color-text-primary);
}

.workflow-step-badge__progress {
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: var(--color-text-secondary);
    opacity: 0.88;
}

/* Lordicon step badge — larger animated tile per workflow step */
.workflow-step-badge--lordicon {
    gap: 14px;
    margin-bottom: 14px;
}

.workflow-step-badge--lordicon .workflow-step-badge__icon--lordicon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    border: none;
    background: var(--wf-step-icon-bg);
    flex-shrink: 0;
}

.workflow-step-badge__lordicon-mount {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    pointer-events: none;
}

.workflow-step-badge__lordicon-mount svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 46px;
    max-height: 46px;
}

.workflow-step-badge--lordicon .workflow-step-badge__title {
    font-size: 14px;
}

/* Step bubble: subtle affordance that hover animates the step icon */
.chat-message-ai.wf-has-step-lordicon .message-bubble {
    cursor: default;
}


.message-content p {
    margin: 0 0 var(--space-2) 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-timestamp {
    font-size: 11px;
    opacity: 0.7;
    margin-top: var(--space-2);
}

/* Loading Message */
.chat-message-loading {
    display: flex;
    justify-content: flex-start;
}

.chat-message-loading .message-bubble {
    background: var(--sw-message-ai-bg);
    padding: var(--space-4);
}

.chat-message-loading .loading-bubble {
    padding: var(--space-5) var(--space-5);
    max-width: 420px;
}

.loading-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.loading-status {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Step text: smooth fade when changing */
.loading-step-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    transition: opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1), transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-step-text.loading-step-fade-out {
    opacity: 0;
    transform: translateY(-3px);
}

/* Inline source icons: only on research/sources step. Stacked circles, appear one-by-one like search results. */
.loading-source-icons {
    display: none;
    align-items: center;
    margin-left: var(--space-3);
}

.loading-status.loading-step--web .loading-source-icons {
    display: flex;
}

.loading-source-icons-row {
    display: flex;
    align-items: center;
}

.loading-source-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-left: -10px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-bg-secondary);
    box-shadow: 0 0 0 1.5px var(--color-border-light);
    opacity: 0;
    transform: scale(0.82);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-source-icon-wrap:first-child {
    margin-left: 0;
}

.loading-source-icon-wrap.visible {
    opacity: 1;
    transform: scale(1);
}

.loading-source-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--color-text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input-container {
    padding: var(--space-6) var(--space-4);
    max-width: var(--sw-chat-max-width);
    margin: 0 auto;
    width: 100%;
}

.sw-chat-input-box {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-light);
    border-radius: 32px;
    padding: var(--space-4) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
}

.sw-chat-input-box:focus-within {
    border-color: var(--color-gray-700);
    box-shadow: var(--shadow-xl);
}

.chat-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
    font-family: inherit;
    line-height: var(--line-height-relaxed);
    max-height: 200px;
    padding: 0;
}

.chat-input::placeholder {
    color: var(--color-text-tertiary);
}

.sw-chat-input-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
}

.chat-input-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.chat-option-pill {
    padding: var(--space-2) var(--space-4);
    border-radius: 12px;
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chat-option-pill:hover:not(.active) {
    background: var(--color-bg-hover);
    border-color: var(--color-border-medium);
    color: var(--color-text-primary);
}

.chat-option-pill.active {
    background: var(--color-primary-light);
    color: var(--color-primary-600);
    border-color: var(--color-primary);
}

:root[data-theme='dark'] .chat-option-pill.active {
    color: var(--color-primary-400);
    border-color: var(--color-primary-600);
}

.sw-chat-input-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-send-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-translucent, rgba(59, 130, 246, 0.35));
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-border-dark);
}

.chat-send-btn i {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

/* Voice Input Button */
.chat-voice-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-tertiary);
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.chat-voice-btn i,
.chat-voice-btn svg {
    width: 14px;
    height: 14px;
}

.chat-voice-btn i {
    stroke-width: 2;
}

.chat-voice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-voice-icon--audio {
    display: none;
}

.chat-voice-btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--color-border-medium);
    color: var(--color-text-primary);
}

.chat-voice-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-translucent, rgba(59, 130, 246, 0.35));
    border-color: var(--color-primary);
}

.chat-voice-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-voice-btn.is-listening {
    background: var(--color-error, #ef4444);
    border-color: transparent;
    color: var(--color-white);
}

.chat-voice-btn.is-listening .chat-voice-icon--mic {
    display: none;
}

.chat-voice-btn.is-listening .chat-voice-icon--audio {
    display: flex;
}

@media (prefers-reduced-motion: reduce) {
    .chat-voice-btn.is-listening {
        box-shadow: 0 0 0 2px var(--color-error, #ef4444);
    }

    /* Prefer a static icon when the user requests reduced motion */
    .chat-voice-btn.is-listening .chat-voice-icon--mic {
        display: flex;
    }

    .chat-voice-btn.is-listening .chat-voice-icon--audio {
        display: none;
    }
}

/* Time Selector Dropdown */
.time-selector-wrapper {
    position: relative;
}

.time-option #time-display {
    display: inline-block;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.time-dropdown {
    position: absolute;
    bottom: calc(100% + var(--space-2));
    left: 0;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-medium);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transform-origin: bottom left;
    transition: opacity 160ms ease, transform 190ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 160ms;
    z-index: var(--z-popover);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-2) 0 var(--space-1);
    will-change: opacity, transform;
}

.time-selector-wrapper.active .time-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 160ms ease, transform 190ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s;
}

.time-selector-wrapper.open-down .time-dropdown {
    bottom: auto;
    top: calc(100% + var(--space-2));
    transform-origin: top left;
    transform: translateY(-6px);
}

.time-selector-wrapper.open-down.active .time-dropdown {
    transform: translateY(0);
}

.time-option-item {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: block;
}

.time-option-custom {
    position: relative;
    font-weight: var(--font-weight-medium);
}

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

.time-option-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary-700);
    font-weight: var(--font-weight-semibold);
}

.time-custom-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    will-change: opacity;
    transition: opacity 90ms ease, border-color 90ms ease;
    border-top: 1px solid transparent;
    padding: 0 var(--space-4) 0;
    margin-top: 0;
}

.time-custom-panel.uses-gsap {
    transition: none;
}

.time-custom-panel.is-open {
    max-height: 132px;
    opacity: 1;
    border-top-color: var(--color-border-light);
    padding: var(--space-3) var(--space-4) var(--space-2);
    margin-top: var(--space-1);
}

.time-custom-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.time-custom-value-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.time-custom-value {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    font-weight: var(--font-weight-semibold);
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.time-custom-slider {
    width: 100%;
    cursor: pointer;
    margin: 0;
    min-width: 0;
}

.time-custom-slider:focus-visible {
    outline: none;
}

.time-custom-slider:active::-webkit-slider-thumb {
    transform: scale(1.08);
}

.time-custom-slider:active::-moz-range-thumb {
    transform: scale(1.08);
}

.time-custom-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--color-primary-light), var(--color-border-medium));
}

.time-custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: var(--color-surface-elevated);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
    margin-top: -6px;
}

.time-custom-slider::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--color-primary-light), var(--color-border-medium));
}

.time-custom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--color-primary);
    background: var(--color-surface-elevated);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
}

/* ------------------------------------------------------------------ */
/* Attach selector                                                      */
/* ------------------------------------------------------------------ */

.attach-selector-wrapper {
    position: relative;
}

/* pill state when files are staged */
.attach-option.has-attachments {
    background: var(--color-primary-light);
    color: var(--color-primary-600);
    border-color: var(--color-primary);
}

:root[data-theme='dark'] .attach-option.has-attachments {
    color: var(--color-primary-400);
    border-color: var(--color-primary-600);
}

.attach-dropdown {
    position: absolute;
    bottom: calc(100% + var(--space-2));
    left: 0;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-medium);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-base);
    z-index: var(--z-popover);
    overflow: hidden;
    padding: var(--space-1) 0;
}

.attach-selector-wrapper.active .attach-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.attach-option-item {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.attach-option-item i {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

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

.attach-option-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.attach-option-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    font-weight: var(--font-weight-normal);
}

/* Attachment chips strip */
.sw-attachment-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) 0;
}

#sw-attachment-chips[hidden] {
    display: none !important;
    padding: 0 !important;
}

.sw-attachment-chip {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-light);
    border-radius: 8px;
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    max-width: 200px;
}

.sw-attachment-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sw-attachment-chip-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.sw-attachment-chip-preview {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg-tertiary);
}

.sw-attachment-chip-remove {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-text-tertiary);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition-fast);
    line-height: 1;
}

.sw-attachment-chip-remove:hover {
    color: var(--color-text-primary);
}

.sw-attachment-chip-remove i,
.sw-attachment-chip-remove svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Rules selector (custom instructions) popover                        */
/* ------------------------------------------------------------------ */

.rules-selector-wrapper {
    position: relative;
}

.rules-popover {
    position: absolute;
    bottom: calc(100% + var(--space-2));
    right: 0;
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-medium);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 360px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-base);
    z-index: var(--z-popover);
    overflow: hidden;
    padding: var(--space-3);
}

.rules-selector-wrapper.active .rules-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@keyframes rules-popover-shake {
    0%, 100% { transform: translateY(0) translateX(0); }
    15% { transform: translateY(0) translateX(-6px); }
    30% { transform: translateY(0) translateX(6px); }
    45% { transform: translateY(0) translateX(-4px); }
    60% { transform: translateY(0) translateX(4px); }
    75% { transform: translateY(0) translateX(-2px); }
}

.rules-popover.rules-popover-shake {
    animation: rules-popover-shake 0.4s ease-in-out;
}

.rules-popover-header {
    margin-bottom: var(--space-2);
}

.rules-popover-title {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
}

.rules-textarea {
    width: 100%;
    height: 88px;
    min-height: 88px;
    max-height: 88px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border-medium);
    border-radius: 8px;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
    resize: none;
    transition: border-color var(--transition-fast);
    box-sizing: border-box;
}

.rules-textarea::placeholder {
    color: var(--color-text-tertiary);
}

.rules-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.rules-popover-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border-light);
}

.rules-toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    user-select: none;
}

.rules-use-toggle {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.rules-toggle-text {
    line-height: 1.3;
}

.rules-save-btn {
    padding: var(--space-1) var(--space-3);
    border-radius: 8px;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: var(--color-white);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.rules-save-btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.rules-save-btn.saved {
    background: var(--color-success);
    border-color: var(--color-success);
}

.rules-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--color-border-dark);
    border-color: var(--color-border-medium);
}

/* Unsaved changes bar */
.rules-unsaved-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding: var(--space-2) 0 0;
    border-top: 1px solid var(--color-border-light);
}

.rules-unsaved-bar[hidden] {
    display: none;
}

.rules-unsaved-text {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.rules-unsaved-actions {
    display: flex;
    gap: var(--space-2);
}

.rules-discard-btn {
    padding: var(--space-1) var(--space-3);
    border-radius: 8px;
    border: 1px solid var(--color-border-medium);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.rules-save-bar-btn {
    padding: var(--space-1) var(--space-3);
}

/* Pill: active when rules are on and have content */
.rules-option.rules-on {
    background: var(--color-primary-light);
    color: var(--color-primary-600);
    border-color: var(--color-primary);
}

:root[data-theme='dark'] .rules-option.rules-on {
    color: var(--color-primary-400);
    border-color: var(--color-primary-600);
}

/* Responsive ChatUI */
@media (max-width: 768px) {
    .rules-popover {
        min-width: 240px;
        max-width: calc(100vw - var(--space-6));
    }

    .chat-messages {
        padding: var(--space-4) var(--space-3);
    }

    .message-bubble {
        max-width: 90%;
    }

    .chat-start-options {
        padding: 0 var(--space-2);
        gap: var(--space-3);
    }

    .chat-welcome {
        padding: 0 var(--space-2);
        margin-bottom: var(--space-6);
    }

    .chat-initial-selection {
        padding: var(--space-4);
    }
}

.chat-input-container.refining .sw-chat-input-box {
    display: none;
}

/* Script Writer Usage Indicator – wrapper so hover area includes tooltip for clickable Upgrade */
.sw-usage-wrapper {
    position: relative;
    display: inline-flex;
    padding-top: 100px;
    margin-top: -100px;
}

.sw-usage-wrapper:hover .sw-usage-tooltip {
    opacity: 1;
    visibility: visible;
}

.sw-usage-indicator {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-secondary);
    transition: all var(--transition-base);
    flex-shrink: 0;
    cursor: pointer;
    line-height: 1;
    /* Default percentage */
    --usage-percent: 100%;
}

/* The Ring (Background) */
.sw-usage-indicator::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(var(--color-text-secondary) var(--usage-percent),
            var(--color-border-medium) 0);
    transition: background 0.3s ease;
    z-index: 1;
}

/* The Center Cutout (creates the ring effect) */
.sw-usage-indicator::after {
    content: '';
    position: absolute;
    inset: 2px;
    /* Thickness of the border */
    border-radius: 50%;
    background: var(--color-surface-elevated);
    z-index: 2;
}

.sw-usage-indicator:hover {
    color: var(--color-text-primary);
}

.sw-usage-indicator:hover::before {
    background: conic-gradient(var(--color-text-primary) var(--usage-percent),
            var(--color-border-dark) 0);
}

.sw-usage-indicator.unlimited {
    color: var(--color-text-tertiary);
}

.sw-usage-indicator.unlimited::before {
    background: none;
    border: 1px solid var(--color-border-medium);
}

.sw-usage-indicator.unlimited::after {
    display: none;
}

.sw-usage-indicator.low {
    color: var(--color-text-primary);
}

.sw-usage-indicator.low::before {
    background: conic-gradient(var(--color-primary) var(--usage-percent),
            var(--color-border-medium) 0);
}

.sw-usage-indicator.depleted {
    opacity: 0.6;
}

.sw-usage-indicator.depleted::before {
    background: var(--color-border-medium);
}

.sw-usage-indicator span {
    position: relative;
    z-index: 3;
    /* Above the cutout */
}

.sw-usage-indicator i {
    width: 12px;
    height: 12px;
    stroke-width: 2.5;
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Custom Tooltip */
.sw-usage-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border-medium);
    border-radius: var(--border-radius-base);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
    z-index: var(--z-tooltip);
    pointer-events: none;
    min-width: 180px;
}

.sw-usage-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-surface-elevated);
}

.sw-usage-indicator:hover .sw-usage-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Allow hovering and clicking the tooltip (e.g. Upgrade button) without it disappearing */
.sw-usage-tooltip {
    pointer-events: auto;
}

.sw-usage-tooltip-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    margin-bottom: var(--space-1);
    font-weight: var(--font-weight-medium);
    width: 100%;
}

.sw-usage-tooltip-subtext {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-3);
    font-weight: var(--font-weight-normal);
    width: 100%;
}

.sw-usage-tooltip-upgrade {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    background: var(--gradient-primary);
    color: var(--color-white);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    transition: all var(--transition-base);
    margin-top: var(--space-1);
}

.sw-usage-tooltip-upgrade:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

@keyframes pulse-warning {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(245, 158, 11, 0);
    }
}

@keyframes pulse-error {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
    }
}

/* Profile Modal Styles */
.profile-modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    /* Ensure the modal itself doesn't scroll */
}

.profile-modal-content .modal-header {
    padding: var(--space-5) var(--space-6);
    display: flex;
    align-items: center;
}

.profile-modal-content .modal-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-2xl);
    margin: 0;
    line-height: 1;
    /* Force tight alignment */
}

.profile-modal-content .modal-header h2 span {
    display: flex;
    align-items: center;
    transform: translateY(1px);
    /* micro-adjustment for optical centering */
}

.profile-modal-content .modal-header h2 i,
.profile-modal-content .modal-header h2 svg {
    width: 28px;
    height: 28px;
    color: var(--color-text-primary);
    stroke-width: 2.5px;
    display: block;
    flex-shrink: 0;
}

.profile-modal-content .modal-close-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    border-radius: 50%;
}

.profile-modal-content .modal-close-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text-primary);
    transform: rotate(90deg);
}

.profile-modal-content .modal-body {
    overflow: hidden;
    flex: 1;
    min-height: 0;
    padding-right: var(--space-2);
    display: flex;
    flex-direction: column;
}

.profile-modal-content .form-group {
    margin-bottom: var(--space-4);
    flex-shrink: 0;
}

.profile-modal-content .form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--color-text-primary);
}

.profile-modal-content .form-group input[type="text"] {
    width: 100%;
    color: var(--color-text-primary);
    transition: all var(--transition-base);
}

.profile-modal-content .form-group input[type="text"]:hover {
    border-color: var(--color-border-medium);
}

.profile-modal-content .form-group input[type="text"]:focus {
    outline: none;
    background: var(--color-bg-secondary);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.profile-modal-content .input-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-1);
}

.profile-modal-content .char-count {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.profile-modal-content .video-selection-section {
    margin-top: var(--space-6);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.profile-modal-content .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
    flex-shrink: 0;
}

.profile-modal-content .section-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

.profile-modal-content .selection-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    padding: var(--space-1) var(--space-2);
    background: var(--color-bg-secondary);
    border-radius: 4px;
}

.profile-modal-content .selection-count.complete {
    background: var(--color-success-bg);
    color: var(--color-success);
    font-weight: 500;
}

.profile-modal-content .section-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
    flex-shrink: 0;
}

.profile-modal-content .video-selection-section .outlier-search-bar {
    flex-shrink: 0;
}

/* Video List */
.profile-modal-content .video-scroll-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: var(--space-4);
    background: transparent;
    border-radius: var(--border-radius-base);
    border: var(--border-width-thin) solid var(--color-border-light);
}

.profile-modal-content .video-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    border: none;
    min-height: min-content;
}



.profile-modal-content .video-list-loading,
.profile-modal-content .video-list-empty,
.profile-modal-content .video-list-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    gap: var(--space-2);
    color: var(--color-text-secondary);
    grid-column: 1 / -1;
}

.profile-modal-content .video-list-loading i,
.profile-modal-content .video-list-empty i,
.profile-modal-content .video-list-error i {
    font-size: 32px;
}

.profile-modal-content .video-list-error {
    color: var(--color-error);
}

/* Video Card in Modal */
.profile-modal-content .video-card-modal {
    position: relative;
    border: var(--border-width-thin) solid var(--color-border-light);
    border-radius: var(--border-radius-base);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--color-surface-elevated);
}

.profile-modal-content .video-card-modal:hover:not(.disabled) {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.profile-modal-content .video-card-modal.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.profile-modal-content .video-card-modal.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.video-card-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.video-card-checkbox input[type="checkbox"] {
    display: none;
}

.video-card-checkbox label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid white;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    transition: all var(--transition-base);
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    /* Let clicks pass to the card */
}

.video-card-modal:hover .video-card-checkbox label,
.video-card-modal.selected .video-card-checkbox label {
    opacity: 1;
    transform: scale(1);
}

.video-card-checkbox input[type="checkbox"]:checked+label {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.video-card-checkbox label i {
    color: white;
    font-size: 14px;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.video-card-checkbox input[type="checkbox"]:checked+label i {
    opacity: 1;
}

.video-card-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    /* 16:9 aspect ratio */
    overflow: hidden;
}

.video-card-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-card-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: var(--font-size-xs);
    border-radius: 4px;
}

.video-card-info {
    padding: var(--space-3);
}

.video-card-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: var(--space-1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-card-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: flex;
    gap: var(--space-1);
}

/* Load More Button Wrapper */
.profile-modal-content .load-more-btn {
    width: 100%;
    margin: var(--space-6) 0 var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--color-surface-sunken);
    border: var(--border-width-thin) solid var(--color-border-light);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    box-shadow: none;
    flex-shrink: 0;
}

.profile-modal-content .load-more-btn:hover:not(:disabled) {
    background: var(--color-bg-hover);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.profile-modal-content .load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal Buttons */
.script-writer-modal .modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

.script-writer-modal .btn-secondary,
.script-writer-modal .btn-primary {
    padding: var(--space-2) var(--space-6);
    border-radius: 10px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    line-height: 1;
}

.script-writer-modal .btn-secondary span,
.script-writer-modal .btn-primary span {
    display: flex;
    align-items: center;
    transform: translateY(1px);
    /* micro-adjustment for optical vertical centering */
}

.script-writer-modal .btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.script-writer-modal .btn-secondary:hover {
    background: var(--color-border-light);
}

.script-writer-modal .btn-primary {
    background: var(--color-primary);
    color: white;
}

.script-writer-modal .btn-primary i,
.script-writer-modal .btn-primary svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

.script-writer-modal .btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.script-writer-modal .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Prefill overlay (outlier-details remix only in app code) */
.script-writer-prefill-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-primary);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.script-writer-prefill-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Outlier “Remix in Script Writer” shortcut: no fade-in while main area gets layout (avoids a blank flash) */
.script-writer-prefill-overlay.is-visible.script-writer-prefill-overlay--outlier-remix {
    transition: none;
}

.script-writer-prefill-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

.script-writer-prefill-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.script-writer-prefill-dots span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--color-text-secondary);
    opacity: 0.4;
    animation: sw-prefill-dot 1.05s ease-in-out infinite;
}

.script-writer-prefill-dots span:nth-child(1) {
    animation-delay: 0ms;
}

.script-writer-prefill-dots span:nth-child(2) {
    animation-delay: 120ms;
}

.script-writer-prefill-dots span:nth-child(3) {
    animation-delay: 240ms;
}

@keyframes sw-prefill-dot {

    0%,
    70%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    35% {
        transform: translateY(-9px);
        opacity: 1;
    }
}

.script-writer-prefill-label {
    margin: 0;
    max-width: 16rem;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--color-text-secondary);
    text-align: center;
}
