/**
 * MotionFy Create Page Styles
 * 
 * Brand Tokens:
 *   --brand-ink: #0B1220 (buttons, primary text)
 *   --brand-accent: #3B82F6 (tiny accents only)
 *   --surface: #FFFFFF
 *   --border-soft: #E6EBF2
 * 
 * Design Constraints:
 *   - No gradients, no decorative shadows
 *   - Subtle fade transitions only (180-250ms)
 *   - Touch targets >= 44px
 *   - Body font >= 16px
 */

/* ============================================================
   CSS Custom Properties (Brand Tokens)
   ============================================================ */
:root {
    --brand-ink: #0B1220;
    --brand-accent: #3B82F6;
    --surface: #FFFFFF;
    --border-soft: #E6EBF2;
    --text-primary: #0B1220;
    --text-secondary: #5A6578;
    --text-muted: #8B95A5;
    --bg-subtle: #F8F9FB;
    --bg-hover: #F1F3F7;
    --success: #10B981;
    --error: #EF4444;
    
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --transition-fast: 180ms ease;
    --transition-normal: 220ms ease;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ============================================================
   Base Styles
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

.mf-body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   Header
   ============================================================ */
.mf-header {
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px; /* Narrower header */
}

.mf-header__inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px 0 0; /* Remove top/bottom/left padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

/* Left side: Logo + Navigation Links */
.mf-header__left {
    display: flex;
    align-items: center;
    gap: 0;
}

.mf-header__logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
}

.mf-header__logo-img {
    height: 80px; /* Logo larger than header, allowed to overflow */
    width: auto;
    object-fit: cover;
    object-position: left center;
    transform: scale(1.35);
}

.mf-header__nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 24px; /* Space between logo and nav links */
}

/* Right side: Auth Buttons / Avatar */
.mf-header__right {
    display: flex;
    align-items: center;
}

.mf-header__link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 0;
    transition: color var(--transition-fast);
}

.mf-header__link:hover {
    color: var(--text-primary);
}

.mf-header__link--active {
    color: var(--text-primary);
    font-weight: 500;
}

/* Dark mode nav links - lighter and better contrast */
html.theme-dark .mf-header__link,
body.theme-dark .mf-header__link {
    color: #b5b5b5;
}

html.theme-dark .mf-header__link:hover,
body.theme-dark .mf-header__link:hover {
    color: #e0e0e0;
}

html.theme-dark .mf-header__link--active,
body.theme-dark .mf-header__link--active {
    color: #f2f2f2;
    font-weight: 600;
}

.mf-header__link--desktop {
    display: none;
}

.mf-header__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 16px;
    background: var(--brand-ink);
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.mf-header__cta:hover {
    background: #1a2636;
}

/* ============================================================
   Main Layout
   ============================================================ */
.mf-main {
    min-height: calc(100vh - 64px);
}

.mf-create {
    display: flex;
    flex-direction: column;
    max-width: 1440px;
    margin: 0 auto;
}

/* ============================================================
   Controls Column (Left)
   ============================================================ */
.mf-controls {
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    /* Mobile: Center vertically, but don't force full screen */
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 50vh; /* Reduced from full viewport to allow preview to be seen */
    padding: 20px 0;
}

.mf-controls__inner {
    padding: 40px 20px;
    width: 100%;
}

/* Disabled state during generation */
.mf-controls--disabled {
    pointer-events: none;
    opacity: 0.6;
}

.mf-controls--disabled .mf-step__generate {
    /* Keep generate button visible but it's already disabled */
    pointer-events: auto;
    opacity: 1;
}

/* ============================================================
   Step Panels
   ============================================================ */
.mf-step {
    display: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.mf-step--active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.mf-step--fading-out {
    opacity: 0;
    transform: translateY(-6px);
}

.mf-step__header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.mf-step__indicator {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mf-step__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.mf-step__optional {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 400;
}

.mf-step__content {
    margin-bottom: 24px;
}

.mf-step__actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

/* ============================================================
   Buttons
   ============================================================ */
.mf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.mf-btn--primary {
    background: var(--brand-ink);
    color: white;
}

.mf-btn--primary:hover:not(:disabled) {
    background: #1a2636;
}

.mf-btn--primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mf-btn--secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-soft);
}

.mf-btn--secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mf-btn--secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   Ad Type Cards (Step 1)
   ============================================================ */
.mf-ad-types {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mf-ad-type {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft); /* Default 1px */
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-ad-type:hover {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-ad-type[aria-checked="true"] {
    border-color: var(--brand-accent);
    background: #EFF6FF; /* Stronger tint */
    border-width: 2px; /* Thicker border */
    padding: 15px; /* Adjust for border width to keep size same-ish */
}

.mf-ad-type__indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    border: 2px solid var(--border-soft);
    border-radius: 50%;
    flex-shrink: 0;
    transition: border-color var(--transition-fast);
}

.mf-ad-type[aria-checked="true"] .mf-ad-type__indicator {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
}

.mf-ad-type[aria-checked="true"] .mf-ad-type__indicator::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.mf-ad-type__content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mf-ad-type__name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-ad-type__desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ============================================================
   Upload (Step 2)
   ============================================================ */
.mf-upload {
    margin-bottom: 20px;
}

.mf-upload__dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 24px;
    border: 2px dashed var(--border-soft);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-upload__dropzone:hover,
.mf-upload__dropzone--dragover {
    border-color: var(--brand-accent);
    background: var(--bg-subtle);
}

/* Compact state when images are already selected (recreate mode) */
.mf-upload__dropzone--compact {
    min-height: auto;
    padding: 12px;
}

.mf-upload__dropzone--compact .mf-upload__dropzone-content {
    display: none;
}

.mf-upload__icon {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.mf-upload__text {
    margin: 0;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 500;
}

.mf-upload__hint {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.mf-upload__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.mf-upload__previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.mf-upload__previews:empty {
    display: none;
}

.mf-upload__preview {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-subtle);
}

.mf-upload__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mf-upload__preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mf-upload__guidance {
    margin: 16px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Toggle */
.mf-toggle {
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

/* Dark mode toggle border */
html.theme-dark .mf-toggle,
body.theme-dark .mf-toggle {
    border-color: #3a3a3a;
}

.mf-toggle__label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.mf-toggle__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.mf-toggle__switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-soft);
    border-radius: 12px;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.mf-toggle__switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.mf-toggle__input:checked + .mf-toggle__switch {
    background: var(--brand-accent);
}

.mf-toggle__input:checked + .mf-toggle__switch::after {
    transform: translateX(20px);
}

.mf-toggle__text {
    font-size: 14px;
    color: var(--text-primary);
}

/* ============================================================
   Tags (Step 3)
   ============================================================ */
.mf-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.mf-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 22px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mf-tag:hover {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-tag[aria-pressed="true"] {
    border-color: var(--brand-accent);
    background: #EFF6FF;
    color: var(--brand-accent);
}

.mf-tag:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mf-tags__hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* Mini Input */
.mf-mini-input {
    margin-top: 20px;
}

.mf-mini-input__label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-mini-input__field {
    width: 100%;
    max-width: 280px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.mf-mini-input__field:focus {
    outline: none;
    border-color: var(--brand-accent);
}

.mf-mini-input__field::placeholder {
    color: var(--text-muted);
}

.mf-mini-input__counter {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.mf-mini-input__helper {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    font-style: italic;
}

/* ============================================================
   Camera Motion Buttons (Step 4) - Compact, text-left, icon-right
   ============================================================ */
.mf-camera-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.mf-camera-btn {
    display: block;
    cursor: pointer;
}

.mf-camera-btn__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.mf-camera-btn__box {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-camera-btn:hover .mf-camera-btn__box {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-camera-btn__input:checked + .mf-camera-btn__box {
    border-color: var(--brand-accent);
    background: #EFF6FF;
    border-width: 2px;
    padding: 11px 13px;
}

.mf-camera-btn__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.mf-camera-btn__name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-camera-btn__desc {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mf-camera-btn__icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.mf-camera-btn__input:checked + .mf-camera-btn__box .mf-camera-btn__icon {
    color: var(--brand-accent);
}

/* Focus state */
.mf-camera-btn:focus-within .mf-camera-btn__box {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

/* Dark mode support for camera buttons */
html.theme-dark .mf-camera-btn__box,
body.theme-dark .mf-camera-btn__box {
    background: #1a1a1a;
    border-color: #3a3a3a;
}

html.theme-dark .mf-camera-btn:hover .mf-camera-btn__box,
body.theme-dark .mf-camera-btn:hover .mf-camera-btn__box {
    border-color: #505050;
    background: #252525;
}

html.theme-dark .mf-camera-btn__input:checked + .mf-camera-btn__box,
body.theme-dark .mf-camera-btn__input:checked + .mf-camera-btn__box {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--brand-accent);
}

html.theme-dark .mf-camera-btn__name,
body.theme-dark .mf-camera-btn__name {
    color: #f2f2f2;
}

html.theme-dark .mf-camera-btn__desc,
body.theme-dark .mf-camera-btn__desc {
    color: #a0a0a0;
}

html.theme-dark .mf-camera-btn__icon,
body.theme-dark .mf-camera-btn__icon {
    color: #707070;
}

html.theme-dark .mf-camera-btn__input:checked + .mf-camera-btn__box .mf-camera-btn__icon,
body.theme-dark .mf-camera-btn__input:checked + .mf-camera-btn__box .mf-camera-btn__icon {
    color: var(--brand-accent);
}

/* ============================================================
   Radio Options (Step 4)
   ============================================================ */
.mf-radios {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.mf-radio {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-radio:hover {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-radio:has(.mf-radio__input:checked) {
    border-color: var(--brand-accent);
    background: #F8FAFF;
}

.mf-radio__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.mf-radio__indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid var(--border-soft);
    border-radius: 50%;
    flex-shrink: 0;
    transition: border-color var(--transition-fast);
}

.mf-radio:has(.mf-radio__input:checked) .mf-radio__indicator {
    border-color: var(--brand-accent);
    background: var(--brand-accent);
}

.mf-radio:has(.mf-radio__input:checked) .mf-radio__indicator::after {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.mf-radio__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mf-radio__name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-radio__desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Duration */
.mf-duration {
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
}

.mf-duration__label {
    display: block;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-duration__options {
    display: flex;
    gap: 10px;
}

.mf-duration__option {
    cursor: pointer;
}

.mf-duration__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.mf-duration__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 44px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.mf-duration__option:hover .mf-duration__btn {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

/* Dark mode duration button hover fix */
html.theme-dark .mf-duration__option:hover .mf-duration__btn,
body.theme-dark .mf-duration__option:hover .mf-duration__btn {
    border-color: #505050;
    background: #2a2a2a;
    color: #f2f2f2;
}

.mf-duration__input:checked + .mf-duration__btn {
    border-color: var(--brand-accent);
    background: #EFF6FF;
    color: var(--brand-accent);
}

/* Credit Cost Display */
.mf-credit-cost {
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    text-align: center;
}

.mf-credit-cost__text {
    font-size: 14px;
    color: var(--text-secondary);
}

.mf-credit-cost__text strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Dark mode credit cost */
html.theme-dark .mf-credit-cost,
body.theme-dark .mf-credit-cost {
    background: rgba(255, 255, 255, 0.05);
}

/* ============================================================
   Aspect Ratio Selection (Step 2)
   ============================================================ */
.mf-aspect-ratio {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
}

/* Dark mode aspect ratio border */
html.theme-dark .mf-aspect-ratio,
body.theme-dark .mf-aspect-ratio {
    border-color: #3a3a3a;
}

.mf-aspect-ratio__label {
    display: block;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

html.theme-dark .mf-aspect-ratio__label,
body.theme-dark .mf-aspect-ratio__label {
    color: #d4d6df;
}

.mf-aspect-ratio__options {
    display: flex;
    gap: 10px;
}

.mf-aspect-ratio__option {
    cursor: pointer;
    flex: 1;
}

.mf-aspect-ratio__input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.mf-aspect-ratio__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-aspect-ratio__value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.mf-aspect-ratio__name {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

html.theme-dark .mf-aspect-ratio__name,
body.theme-dark .mf-aspect-ratio__name {
    color: #94a3b8;
}

.mf-aspect-ratio__option:hover .mf-aspect-ratio__btn {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn {
    border-color: var(--brand-accent);
    background: #EFF6FF;
}

.mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn .mf-aspect-ratio__value {
    color: var(--brand-accent);
}

/* Locked state for Change Motion mode */
.mf-aspect-ratio--locked .mf-aspect-ratio__option {
    cursor: not-allowed;
    pointer-events: none;
}

.mf-aspect-ratio--locked .mf-aspect-ratio__btn {
    opacity: 0.6;
}

.mf-aspect-ratio--locked .mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn {
    opacity: 1;
}

.mf-aspect-ratio__locked-hint {
    display: none;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.mf-aspect-ratio--locked .mf-aspect-ratio__locked-hint {
    display: block;
}

/* Dark mode aspect ratio */
html.theme-dark .mf-aspect-ratio__btn,
body.theme-dark .mf-aspect-ratio__btn {
    background: #1a1a1a;
    border-color: #3a3a3a;
    color: #f8fafc;
}

html.theme-dark .mf-aspect-ratio__option:hover .mf-aspect-ratio__btn,
body.theme-dark .mf-aspect-ratio__option:hover .mf-aspect-ratio__btn {
    border-color: #505050;
    background: #252525;
}

html.theme-dark .mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn,
body.theme-dark .mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--brand-accent);
}

html.theme-dark .mf-aspect-ratio__value,
body.theme-dark .mf-aspect-ratio__value {
    color: #f2f2f2;
}

html.theme-dark .mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn .mf-aspect-ratio__value,
body.theme-dark .mf-aspect-ratio__input:checked + .mf-aspect-ratio__btn .mf-aspect-ratio__value {
    color: var(--brand-accent);
}

/* ============================================================
   Result State
   ============================================================ */
.mf-result {
    display: none;
    opacity: 0;
    transition: opacity 300ms ease;
    text-align: center;
    padding: 40px 0;
}

.mf-create--result .mf-controls__inner {
    /* Reset padding to allow result to sit at top */
    padding-top: 40px;
    padding-bottom: 40px;
}

.mf-create--result .mf-step {
    /* Ensure all steps are completely removed from layout */
    display: none !important;
    visibility: hidden;
    height: 0;
    margin: 0;
    padding: 0;
}

.mf-create--result .mf-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align to top */
    opacity: 1;
    margin-top: 0; /* No top margin */
    padding-top: 0; /* No extra padding */
}

.mf-result__title {
    font-size: 28px; /* Slightly larger for impact */
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.mf-result__desc {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 40px; /* More space before buttons */
    max-width: 400px;
    line-height: 1.5;
}

.mf-result__actions {
    display: flex;
    flex-direction: column;
    gap: 16px; /* More breathing room */
    width: 100%;
    max-width: 320px;
}

/* Remove mobile reordering to keep Message/Actions on top */
@media (max-width: 767px) {
    .mf-create--result .mf-controls {
        min-height: auto;
        /* Ensure spacing below actions before preview starts */
        padding-bottom: 40px;
        /* Remove centering that pushes content down */
        justify-content: flex-start;
    }
    
    .mf-create--result .mf-controls__inner {
        padding-top: 24px; /* Less padding on mobile */
    }
}

/* ============================================================
   Post-Generation: What do you want to do next?
   ============================================================ */
.mf-result__next {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
    width: 100%;
    max-width: 400px;
}

.mf-result__next-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.mf-result__next-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mf-result__next-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.mf-result__next-action:hover {
    border-color: #CBD5E1;
    background: var(--bg-subtle);
}

.mf-result__next-icon {
    width: 22px;
    height: 22px;
    color: var(--brand-accent);
    flex-shrink: 0;
}

.mf-result__next-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.mf-result__next-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.mf-result__next-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.mf-result__next-cost {
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-accent);
    white-space: nowrap;
}

/* Dark mode */
html.theme-dark .mf-result__next-action,
body.theme-dark .mf-result__next-action {
    background: #1a1a1a;
    border-color: #3a3a3a;
}

html.theme-dark .mf-result__next-action:hover,
body.theme-dark .mf-result__next-action:hover {
    background: #252525;
    border-color: #505050;
}

html.theme-dark .mf-result__next-name,
body.theme-dark .mf-result__next-name {
    color: #f2f2f2;
}

/* Dark mode border for "What do you want to do next?" section */
html.theme-dark .mf-result__next,
body.theme-dark .mf-result__next {
    border-color: #3a3a3a;
}

html.theme-dark .mf-result__next-title,
body.theme-dark .mf-result__next-title {
    color: #8a8a8a;
}

html.theme-dark .mf-result__next-desc,
body.theme-dark .mf-result__next-desc {
    color: #8a8a8a;
}

/* ============================================================
   Preview Column (Right)
   ============================================================ */
.mf-preview {
    background: var(--bg-subtle);
    min-height: 400px;
}

.mf-preview__inner {
    padding: 24px 20px;
}

/* Canvas Wrapper - controls the aspect ratio behavior */
.mf-canvas-wrapper {
    /* Mobile: fixed width, variable height */
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Canvas */
.mf-canvas {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    /* Mobile: full width, height from aspect ratio */
    width: 100%;
    /* Smooth transition only for output changes */
    transition: none;
}

/* When output is present, allow aspect ratio transition */
.mf-canvas--has-output {
    transition: aspect-ratio 200ms ease;
}

/* Aspect ratio variants - ONLY apply when output is present */
.mf-canvas--has-output[data-output-ratio="16:9"] {
    aspect-ratio: 16 / 9;
}

.mf-canvas--has-output[data-output-ratio="9:16"] {
    aspect-ratio: 9 / 16;
}

.mf-canvas--has-output[data-output-ratio="1:1"] {
    aspect-ratio: 1 / 1;
}

/* Dark mode canvas background */
html.theme-dark .mf-canvas,
body.theme-dark .mf-canvas {
    background: #0a0a0a;
    border-color: #2a2a2a;
}

/* Preview Image (States A-D) */
.mf-canvas__preview {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 175ms ease;
}

.mf-canvas__preview[hidden] {
    display: none;
}

.mf-canvas__preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 175ms ease;
}

/* Preview during generation (State D) */
.mf-canvas__preview--generating {
    opacity: 0.85;
}

.mf-canvas__preview--generating .mf-canvas__preview-img {
    filter: blur(1px);
}

/* Helper text below preview */
.mf-canvas__helper {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    min-height: 20px;
}

.mf-canvas__hero {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease;
}

.mf-canvas__hero:not([hidden]) {
    opacity: 1;
}

/* When hero image is shown, completely hide preview */
.mf-canvas:has(.mf-canvas__hero:not([hidden])) .mf-canvas__preview {
    display: none;
}

.mf-canvas__hero-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: #05060c;
}

.mf-canvas__video {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease;
}

.mf-canvas__video:not([hidden]) {
    opacity: 1;
}

.mf-canvas__video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.mf-canvas__video-img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.mf-canvas__video-label {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: var(--success);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mf-canvas__video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    border-radius: var(--radius-md);
}

/* ============================================================
   Preview Aspect Ratio Letterboxing/Pillarboxing
   Container stays 16:9, content is letterboxed with neutral bg
   ============================================================ */
.mf-canvas--letterbox {
    background: #e8eaed; /* Light neutral gray */
}

html.theme-dark .mf-canvas--letterbox,
body.theme-dark .mf-canvas--letterbox {
    background: #1a1a1a; /* Dark neutral gray */
}

/* Adjust object-fit for different aspect ratios */
.mf-canvas--letterbox .mf-canvas__preview-img,
.mf-canvas--letterbox .mf-canvas__hero-img,
.mf-canvas--letterbox .mf-canvas__video-player {
    object-fit: contain;
}

/* Preview aspect ratio indicators */
.mf-canvas[data-aspect-ratio="16:9"] .mf-canvas__preview-img,
.mf-canvas[data-aspect-ratio="16:9"] .mf-canvas__hero-img {
    object-fit: cover;
}

.mf-canvas[data-aspect-ratio="9:16"] .mf-canvas__preview-img,
.mf-canvas[data-aspect-ratio="9:16"] .mf-canvas__hero-img,
.mf-canvas[data-aspect-ratio="1:1"] .mf-canvas__preview-img,
.mf-canvas[data-aspect-ratio="1:1"] .mf-canvas__hero-img {
    object-fit: contain;
}

/* Status */
.mf-status {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin-top: 16px;
}

.mf-status__text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.mf-status__text:empty::before {
    content: 'Ready to generate';
    color: var(--text-muted);
}

.mf-status--active .mf-status__text {
    color: var(--brand-accent);
}

/* Metadata */
.mf-metadata {
    margin-top: 24px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    opacity: 0.5;
    transition: opacity 300ms ease;
}

.mf-metadata--active {
    opacity: 1;
}

.mf-metadata__title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.mf-metadata__list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 0;
}

.mf-metadata__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mf-metadata__label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mf-metadata__value {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================================
   Footer
   ============================================================ */
.mf-footer {
    border-top: 1px solid var(--border-soft);
    background: var(--surface);
}

.mf-footer__inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.mf-footer__copy {
    font-size: 13px;
    color: var(--text-muted);
}

.mf-footer__links {
    display: flex;
    gap: 20px;
}

.mf-footer__link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 0;
    transition: color var(--transition-fast);
}

.mf-footer__link:hover {
    color: var(--text-primary);
}

/* ============================================================
   Desktop Layout (min-width: 768px)
   ============================================================ */
@media (min-width: 768px) {
    .mf-header {
        height: 80px; /* Narrower header on desktop */
    }
    
    .mf-header__inner {
        padding: 0 32px 0 0; /* Remove top/bottom/left padding */
    }
    
    .mf-header__logo {
        height: 100%;
        margin-left: 16px; /* Move logo inward on desktop */
    }
    
    .mf-header__logo-img {
        height: 112px; /* Logo larger than header, allowed to overflow */
        transform: scale(1.35);
    }
    
    .mf-header__left {
        gap: 0;
    }
    
    .mf-header__nav {
        gap: 24px;
        margin-left: 32px; /* More space on desktop */
    }
    
    .mf-header__link--desktop {
        display: block;
    }
    
    .mf-header__cta {
        padding: 10px 20px;
        font-size: 15px;
    }
    
    .mf-create {
        flex-direction: row;
        min-height: calc(100vh - 80px - 57px);
    }
    
    .mf-controls {
        width: 40%;
        max-width: 480px;
        border-bottom: none;
        border-right: 1px solid var(--border-soft);
        overflow-y: auto;
        /* Reset mobile centering */
        min-height: auto;
        justify-content: flex-start;
        display: block;
    }
    
    .mf-controls__inner {
        padding: 32px;
    }
    
    .mf-step__title {
        font-size: 20px;
    }
    
    .mf-preview {
        flex: 1;
        min-height: auto;
    }
    
    .mf-preview__inner {
        padding: 32px;
        position: sticky;
        top: 80px;
    }
    
    /* Desktop: Canvas wrapper with fixed height, variable width */
    .mf-canvas-wrapper {
        /* Fixed height container for desktop */
        height: 360px;
        width: auto;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .mf-canvas {
        /* Desktop: height fills wrapper, width from aspect ratio */
        width: auto;
        height: 100%;
        aspect-ratio: 16 / 9;
    }
    
    /* Output aspect ratios on desktop - height stays fixed, width adjusts */
    .mf-canvas--has-output[data-output-ratio="16:9"] {
        aspect-ratio: 16 / 9;
    }
    
    .mf-canvas--has-output[data-output-ratio="9:16"] {
        aspect-ratio: 9 / 16;
    }
    
    .mf-canvas--has-output[data-output-ratio="1:1"] {
        aspect-ratio: 1 / 1;
    }
    
    .mf-metadata__list {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .mf-footer__inner {
        flex-direction: row;
        justify-content: space-between;
        padding: 20px 32px;
    }
    
    .mf-complete-actions {
        flex-direction: row;
    }
}

/* ============================================================
   Large Desktop (min-width: 1024px)
   ============================================================ */
@media (min-width: 1024px) {
    .mf-controls {
        max-width: 520px;
    }
    
    .mf-controls__inner {
        padding: 40px;
    }
    
    .mf-preview__inner {
        padding: 40px;
    }
    
    /* Larger canvas wrapper on large desktops */
    .mf-canvas-wrapper {
        height: 420px;
    }
}

/* ============================================================
   Utility: Focus Visible
   ============================================================ */
.mf-btn:focus-visible,
.mf-ad-type:focus-visible,
.mf-tag:focus-visible,
.mf-upload__dropzone:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

/* ============================================================
   Utility: Fade Transition Class
   ============================================================ */
.mf-fade-in {
    animation: mfFadeIn 200ms ease forwards;
}

.mf-fade-out {
    animation: mfFadeOut 180ms ease forwards;
}

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

@keyframes mfFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}
