/* LUXE THEME - Marketing AI Generator (Light Default) */
:root {
    /* Light Mode (Default) */
    --mag-bg-main: #FFFFFF;
    --mag-bg-card: #F5F5F7;
    /* Apple-like light gray */
    --mag-text-main: #1D1D1F;
    --mag-text-muted: #86868B;
    --mag-accent: #0071E3;
    /* Apple Blue */
    --mag-accent-hover: #0077ED;
    --mag-border: #D2D2D7;
    --mag-border-focus: #0071E3;
    --mag-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --mag-font: 'SF Pro Text', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mag-radius: 18px;
    --mag-btn-text: #FFFFFF;

    /* Gallery Settings */
    --mag-gallery-col-min: 180px;
}

/* Dark Mode Override */
.mag-dark-mode {
    --mag-bg-main: #121212;
    --mag-bg-card: #1E1E1E;
    --mag-text-main: #F5F5F7;
    --mag-text-muted: #A1A1A6;
    --mag-accent: #D4AF37;
    /* Gold for Dark Mode */
    --mag-accent-hover: #F2C94C;
    --mag-border: #424245;
    --mag-border-focus: #D4AF37;
    --mag-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --mag-btn-text: #000000;
}

.mag-nano-wrapper {
    max-width: 1100px;
    margin: 40px auto;
    padding: 40px;
    border-radius: 24px;
    background: var(--mag-bg-main);
    color: var(--mag-text-main);
    box-shadow: var(--mag-shadow);
    font-family: var(--mag-font);
    border: 1px solid var(--mag-border);
    transition: background 0.3s, color 0.3s;
    position: relative;
}

/* Header & Toggle */
.mag-nano-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--mag-border);
}

.mag-nano-header-left {
    display: flex;
    flex-direction: column;
}

.mag-nano-header-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--mag-text-main);
    letter-spacing: -0.01em;
}

.mag-nano-header-title small {
    font-size: 0.9rem;
    color: var(--mag-text-muted);
    font-weight: 400;
    margin-top: 4px;
}

.mag-nano-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mag-theme-toggle {
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    border-radius: 100px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--mag-text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.mag-theme-toggle:hover {
    background: var(--mag-border);
}

/* Layout Grid */
.mag-nano-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    /* Form | Result (Larger) */
    gap: 40px;
}

@media (max-width: 900px) {
    .mag-nano-grid {
        grid-template-columns: 1fr;
        display: flex;
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }
}

/* Form Elements */
.mag-nano-card {
    background: transparent;
}

.mag-nano-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mag-text-muted);
    margin-bottom: 8px;
    display: block;
    font-weight: 600;
}

.mag-nano-textarea {
    width: 100%;
    min-height: 120px;
    border-radius: 12px;
    border: 1px solid var(--mag-border);
    background: var(--mag-bg-card);
    color: var(--mag-text-main);
    padding: 16px;
    font-size: 1rem;
    resize: vertical;
    transition: all 0.2s;
    font-family: var(--mag-font);
}

/* Prompt Section Title & Spacing */
.mag-nano-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--mag-text-main);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
}

.mag-nano-prompt-container {
    margin-top: 30px;
    /* Added spacing as requested */
    border-top: 1px solid transparent;
    /* Separator if needed, keeping clean for now */
}

.mag-nano-textarea:focus {
    outline: none;
    border-color: var(--mag-border-focus);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* Style Tags (Chips) */
.mag-nano-style-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.mag-nano-tag {
    font-size: 0.8rem;
    padding: 8px 14px;
    border-radius: 100px;
    border: 1px solid var(--mag-border);
    background: var(--mag-bg-main);
    color: var(--mag-text-main);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.mag-nano-tag:hover {
    background: var(--mag-bg-card);
    border-color: var(--mag-text-muted);
}

.mag-nano-tag.mag-nano-tag-active {
    background: var(--mag-accent);
    color: #fff;
    border-color: var(--mag-accent);
}

.mag-dark-mode .mag-nano-tag.mag-nano-tag-active {
    color: #000;
}

/* --- NEW MODE NAVIGATOR --- */
.mag-mode-nav {
    display: flex;
    background: var(--mag-bg-card);
    border-radius: 16px;
    padding: 6px;
    margin-bottom: 30px;
    gap: 8px;
    border: 1px solid var(--mag-border);
}

.mag-mode-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px;
    border-radius: 12px;
    color: var(--mag-text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mag-mode-tab:hover {
    color: var(--mag-text-main);
    background: rgba(0, 0, 0, 0.03);
}

.mag-mode-tab.active {
    background: var(--mag-bg-main);
    color: var(--mag-text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mag-dark-mode .mag-mode-tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

.mag-dark-mode .mag-mode-tab.active {
    background: #2C2C2E;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}


/* --- MODE CONTENT TRANSITIONS --- */
.mag-mode-content {
    display: none;
    animation: magSlideUp 0.4s ease-out;
}

.mag-mode-content.active {
    display: block;
}

@keyframes magSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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


/* --- SPECIALIZED UPLOADS --- */
.mag-upload-area {
    background: var(--mag-bg-card);
    border: 1px dashed var(--mag-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: center;
    transition: border-color 0.2s;
}

.mag-upload-area:hover {
    border-color: var(--mag-accent);
}

.mag-upload-label {
    display: block;
    margin-bottom: 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mag-text-muted);
}

.mag-upload-item.main-product {
    width: 100%;
    margin: 0 auto;
    height: auto;
}

.mag-upload-item.main-product .mag-upload-btn {
    width: 100%;
    /* Full width in container */
    height: auto;
    aspect-ratio: 16/9;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mag-upload-item.main-product.small .mag-upload-btn {
    aspect-ratio: auto;
    padding: 20px;
}

.mag-upload-btn .mag-upload-icon {
    font-size: 2rem;
    margin-bottom: 4px;
}

.mag-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.mag-upload-item.small {
    width: 100%;
    height: 80px;
}

/* --- TEMPLATE CAROUSEL --- */
#mag-template-carousel-wrapper {
    margin-bottom: 24px;
}

.mag-carousel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mag-carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.mag-carousel::-webkit-scrollbar {
    height: 6px;
}

.mag-carousel::-webkit-scrollbar-thumb {
    background: var(--mag-border);
    border-radius: 3px;
}

.mag-tpl-item {
    flex: 0 0 140px;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.mag-tpl-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.mag-tpl-item:hover {
    transform: translateY(-4px);
}

.mag-tpl-item.selected {
    border-color: var(--mag-accent);
    box-shadow: 0 4px 15px rgba(0, 113, 227, 0.3);
}

.mag-tpl-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.75rem;
    text-align: center;
    backdrop-filter: blur(4px);
}

/* --- TEXT INPUT GROUPS --- */
.mag-input-group {
    margin-bottom: 20px;
}

.mag-input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--mag-text-muted);
}

.mag-text-input,
.mag-text-field {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--mag-border);
    background: var(--mag-bg-card);
    color: var(--mag-text-main);
    font-size: 0.95rem;
    transition: border 0.2s;
    margin-bottom: 8px;
}

.mag-text-input:focus,
.mag-text-field:focus {
    outline: none;
    border-color: var(--mag-accent);
}

.mag-toggle-group {
    display: flex;
    gap: 16px;
}

.mag-toggle-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--mag-text-main);
}

/* Pro Switch */
.mag-pro-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
}

.mag-pro-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--mag-text-muted);
    letter-spacing: 0.05em;
}

.mag-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.mag-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mag-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--mag-border);
    transition: .4s;
    border-radius: 34px;
}

.mag-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.mag-slider {
    background-color: var(--mag-accent);
}

input:checked+.mag-slider:before {
    transform: translateX(20px);
}

/* Rounded Upload Icons */
.mag-upload-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    /* More spacing */
    margin-bottom: 10px;
}

.mag-upload-item {
    width: 50px;
    /* Slightly smaller as requested "petit minimaliste" */
    height: 50px;
    position: relative;
    /* Ensure containment */
}

/* CRITICAL FIX: Hide the default file input text/button completely */
.mag-upload-input,
.mag-hidden-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    z-index: 10;
    /* Above label to capture click if needed, or preferably pointer-events:none if label handles it */
    cursor: pointer;
    /* Hide standard chrome */
    font-size: 0;
}

/* Ensure label acts as the visible button */
.mag-upload-btn {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px dashed var(--mag-border);
    /* Thinner border for minimalist */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--mag-bg-card);
    transition: all 0.2s;
    position: relative;
    z-index: 5;
}

.mag-upload-btn:hover {
    border-color: var(--mag-accent);
    transform: scale(1.05);
}

.mag-upload-btn.file-selected {
    border-style: solid;
    border-color: var(--mag-accent);
    background: var(--mag-accent);
    color: #fff;
}

.mag-upload-icon-small {
    font-size: 1.2rem;
    /* proportional to 50px */
}

.mag-upload-status {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #4cd964;
    border-radius: 50%;
    border: 2px solid var(--mag-bg-main);
    display: none;
    z-index: 15;
}

.mag-upload-btn.file-selected .mag-upload-status {
    display: block;
}

.mag-upload-btn.file-selected .mag-upload-icon-small {
    filter: brightness(200%);
}

/* Hover to Remove logic */
.mag-upload-btn.file-selected:hover::after {
    content: "×";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    backdrop-filter: blur(2px);
}

.mag-upload-btn-add {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px dashed var(--mag-border);
    background: transparent;
    color: var(--mag-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

/* Inputs & Selects */
.mag-nano-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 20px;
}

.mag-nano-select,
.mag-nano-file {
    flex: 1;
    min-width: 180px;
}

.mag-nano-select select,
.mag-nano-file input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--mag-border);
    background: var(--mag-bg-card);
    color: var(--mag-text-main);
    font-size: 0.9rem;
}

/* Main Button */
.mag-nano-btn {
    width: 100%;
    margin-top: 30px;
    padding: 16px;
    border-radius: 14px;
    border: none;
    background: var(--mag-accent);
    color: var(--mag-btn-text);
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mag-nano-btn:hover:not(:disabled) {
    background: var(--mag-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.mag-nano-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Preview Area */
.mag-nano-preview-card {
    display: flex;
    flex-direction: column;
}

.mag-nano-preview {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    object-fit: contain;
    /* Ensures functionality */
}

/* Ensure wrapper doesn't Clip too aggressively */
.mag-nano-preview-wrapper {
    flex: 1;
    border-radius: var(--mag-radius);
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    min-height: 700px;
    /* Taller default */
    padding: 10px;
    /* Breathing room */
}

.mag-nano-preview-visible {
    display: block;
    animation: magFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes magFadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Gallery & Toolbar */
.mag-nano-gallery {
    margin-top: 60px;
    border-top: 1px solid var(--mag-border);
    padding-top: 40px;
}

.mag-gallery-title {
    font-family: 'Playfair Display', serif;
    /* Belle police classy si dispo, sinon fallback */
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--mag-text-main);
    margin: 0;
    text-align: left;
    background: linear-gradient(45deg, var(--mag-text-main), var(--mag-text-muted));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mag-gallery-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 20px;
}

.mag-gallery-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mag-filter-btn {
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    color: var(--mag-text-muted);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.mag-filter-btn:hover,
.mag-filter-btn.active {
    background: var(--mag-text-main);
    color: var(--mag-bg-main);
    border-color: var(--mag-text-main);
}

.mag-gallery-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mag-gallery-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 4px;
    background: var(--mag-border);
    border-radius: 2px;
    outline: none;
    pointer-events: auto;
    /* Fix interactivity */
    cursor: pointer;
}

.mag-gallery-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--mag-text-main);
    cursor: pointer;
    transition: transform 0.1s;
}

.mag-gallery-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.mag-nano-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--mag-gallery-col-min), 1fr));
    gap: 16px;
    transition: grid-template-columns 0.2s ease;
}

.mag-nano-gallery-item {
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
}

.mag-nano-gallery-item:hover {
    transform: scale(1.03);
}

.mag-nano-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Multi-select Checkbox */
.mag-gallery-checkbox-wrapper {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 4px;
    padding: 3px;
    backdrop-filter: blur(10px);
}

.mag-dark-mode .mag-gallery-checkbox-wrapper {
    background: rgba(0, 0, 0, 0.7);
}

.mag-gallery-item-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--mag-accent);
}

/* Hidden gallery items */
.mag-gallery-hidden {
    display: none;
}


/* Detailed View Overlay (Social) */
.mag-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.mag-lightbox.active {
    display: flex;
}

.mag-lightbox-content {
    background: transparent;
    /* No card background */
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    box-shadow: none;
    position: relative;
    pointer-events: none;
    /* Let clicks pass through for close except on buttons */
}

/* Left: Image */
/* Full Screen Media */
.mag-lightbox-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    /* Take full space */
    top: 0;
    left: 0;
    pointer-events: auto;
    /* Enable interaction like zoom if needed */
}

.mag-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease-out;
    /* Smooth zoom */
}

/* Controls Overlay */
.mag-lightbox-controls-top {
    position: absolute;
    top: 30px;
    left: 30px;
    display: flex;
    gap: 15px;
    z-index: 999999;
    pointer-events: auto;
}

.mag-lightbox-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 100px;
    cursor: pointer;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.mag-lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mag-lightbox-info {
    display: none !important;
    /* Hide info panel */
}

.mag-lightbox-back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-3px);
}

/* Right: Social & Info */
.mag-lightbox-info {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--mag-border);
    background: var(--mag-bg-main);
    color: var(--mag-text-main);
    overflow-y: auto;
}

.mag-info-header {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--mag-border);
}

.mag-info-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 10px;
    color: var(--mag-text-main);
}

.mag-info-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--mag-text-muted);
}

.mag-info-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Reactions */
.mag-reactions {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.mag-reaction-btn {
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--mag-text-main);
}

.mag-reaction-btn:hover {
    background: var(--mag-border);
    transform: translateY(-2px);
}

.mag-reaction-btn.active {
    background: rgba(0, 113, 227, 0.1);
    border-color: var(--mag-accent);
    color: var(--mag-accent);
}

/* Comments */
.mag-comments-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mag-comments-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mag-text-muted);
}

.mag-comments-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 10px;
}

.mag-comment {
    margin-bottom: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.mag-comment strong {
    color: var(--mag-text-main);
    margin-right: 6px;
}

.mag-comment span {
    color: var(--mag-text-muted);
}

.mag-comment-form {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.mag-comment-input {
    flex: 1;
    padding: 12px;
    border-radius: 100px;
    border: 1px solid var(--mag-border);
    background: var(--mag-bg-card);
    color: var(--mag-text-main);
    font-size: 0.9rem;
}

.mag-comment-input:focus {
    outline: none;
    border-color: var(--mag-accent);
}

.mag-comment-submit {
    background: var(--mag-accent);
    color: #fff;
    border: none;
    border-radius: 100px;
    padding: 0 20px;
    font-weight: 600;
    cursor: pointer;
}

/* Lightbox Nav */
.mag-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.mag-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 100;
}

.mag-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mag-lightbox-prev {
    left: 40px;
}

.mag-lightbox-next {
    right: 40px;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .mag-lightbox-content {
        flex-direction: column;
        height: 90vh;
    }

    .mag-lightbox-media {
        flex: 1;
        max-height: 50%;
    }

    .mag-lightbox-info {
        flex: 1;
        padding: 20px;
    }

    .mag-lightbox-prev {
        left: 10px;
    }

    .mag-lightbox-next {
        right: 10px;
    }
}

/* Gallery Overlay Stats */
.mag-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    display: flex;
    gap: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.mag-nano-gallery-item:hover .mag-gallery-overlay {
    opacity: 1;
}

.mag-stat {
    color: #fff;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mag-stat i {
    font-size: 14px;
}

/* Back to Studio Button */
.mag-back-to-studio {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--mag-accent);
    color: #fff;
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    border: none;
    z-index: 999;
    display: none;
    /* Shown via JS on scroll */
    transition: transform 0.2s;
}

.mag-back-to-studio:hover {
    transform: translateY(-2px);
}

/* Utilities */
.mag-hidden {
    display: none !important;
}

.mag-nano-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}

.mag-nano-action-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--mag-border);
    background: transparent;
    color: var(--mag-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mag-nano-action-btn:hover {
    border-color: var(--mag-accent-gold);
    color: var(--mag-accent-gold);
}

/* Credit Badge Pulse Animation */
@keyframes magPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* ===================================
   PRICING SECTION  
   =================================== */

.mag-pricing-section {
    margin-top: 80px;
    padding: 60px 40px;
    background: var(--mag-bg-card);
    border-radius: 24px;
    border: 1px solid var(--mag-border);
}

.mag-pricing-header {
    text-align: center;
    margin-bottom: 40px;
}

.mag-pricing-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(45deg, var(--mag-text-main), var(--mag-accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mag-pricing-header p {
    font-size: 1.1rem;
    color: var(--mag-text-muted);
}

.mag-lightbox-formats-wrapper {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.mag-lightbox-formats {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

.mag-fmt-tab {
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.mag-fmt-tab:hover,
.mag-fmt-tab.active {
    background: var(--mag-accent);
    border-color: var(--mag-accent);
    transform: translateY(-2px);
}

/* Lightbox Image Container */
.mag-lightbox-img {
    max-width: 100%;
}

/* Period Toggle */
.mag-pricing-toggle {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 50px;
}

.mag-period-btn {
    padding: 12px 32px;
    border-radius: 100px;
    border: 1px solid var(--mag-border);
    background: transparent;
    color: var(--mag-text-muted);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.mag-period-btn.active {
    background: var(--mag-accent);
    color: var(--mag-btn-text);
    border-color: var(--mag-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.mag-dark-mode .mag-period-btn.active {
    color: #000;
}

/* Pricing Grid */
.mag-pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Pricing Cards */
.mag-pricing-card {
    background: var(--mag-bg-main);
    border: 2px solid var(--mag-border);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.mag-pricing-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.mag-pricing-card:hover::before {
    left: 100%;
}

.mag-pricing-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Tier specific styling */
.mag-tier-silver {
    border-color: #C0C0C0;
}

.mag-tier-gold {
    border-color: #FFD700;
}

.mag-tier-premium {
    border-color: #8A62FF;
    background: linear-gradient(135deg, rgba(138, 98, 255, 0.05), transparent);
}

.mag-tier-premium:hover {
    border-color: #8A62FF;
    box-shadow: 0 20px 50px rgba(138, 98, 255, 0.3);
}

/* Pricing Badge */
.mag-pricing-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 100px;
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.mag-badge-annual {
    position: relative;
}

.mag-annual-tag {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #4cd964;
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Pricing Price */
.mag-pricing-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--mag-text-main);
    margin-bottom: 16px;
}

/* Pricing Credits */
.mag-pricing-credits {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--mag-accent);
    margin-bottom: 20px;
}

/* Pricing Description */
.mag-pricing-desc {
    color: var(--mag-text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 30px;
    min-height: 60px;
}

/* Pricing CTA */
.mag-pricing-cta {
    display: inline-block;
    padding: 16px 40px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    transition: all 0.3s;
    border: 2px solid;
}

.mag-pricing-cta.mag-tier-silver {
    background: #C0C0C0;
    border-color: #C0C0C0;
    color: #1D1D1F;
}

.mag-pricing-cta.mag-tier-gold {
    background: #FFD700;
    border-color: #FFD700;
    color: #1D1D1F;
}

.mag-pricing-cta.mag-tier-premium {
    background: #8A62FF;
    border-color: #8A62FF;
    color: #FFF;
}

.mag-pricing-cta:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .mag-pricing-grid {
        grid-template-columns: 1fr;
    }

    .mag-pricing-header h2 {
        font-size: 2rem;
    }
}

/* ===================================
   MOBILE RESPONSIVE STYLES  
   =================================== */

@media (max-width: 768px) {

    /* Header Responsive */
    .mag-nano-header {
        flex-direction: column;
        gap: 16px;
    }

    .mag-nano-header-row-1 {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .mag-nano-header-row-2 {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
        width: 100%;
    }

    .mag-nano-header-title span {
        font-size: 1.3rem;
    }

    .mag-nano-header-title small {
        font-size: 0.75rem;
    }

    #mag-credits-badge,
    .mag-plan-badge {
        font-size: 0.8rem !important;
        padding: 6px 12px !important;
    }

    .mag-theme-toggle {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* Grid Layout - Stack vertically */
    .mag-nano-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Hide preview on mobile initially */
    .mag-nano-preview-wrapper {
        display: none;
        min-height: 400px;
    }

    .mag-nano-preview-wrapper.mag-mobile-show {
        display: flex;
    }

    /* Form adjustments */
    .mag-nano-wrapper {
        padding: 20px;
        margin: 20px auto;
    }

    .mag-nano-textarea {
        font-size: 16px;
        /* Prevent zoom on iOS */
        min-height: 100px;
    }

    /* Buttons */
    .mag-nano-btn {
        padding: 14px;
        font-size: 1rem;
        min-height: 48px;
        /* Touch friendly */
    }

    /* Upload grid */
    .mag-upload-grid {
        gap: 12px;
    }

    .mag-upload-item {
        width: 60px;
        height: 60px;
    }

    /* Pricing Section */
    .mag-pricing-section {
        padding: 40px 20px;
        margin-top: 60px;
    }

    .mag-pricing-header h2 {
        font-size: 1.8rem;
    }

    .mag-pricing-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Gallery */
    .mag-nano-gallery {
        margin-top: 40px;
        padding-top: 30px;
    }

    .mag-gallery-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .mag-nano-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    /* Bulk actions toolbar mobile */
    #mag-bulk-actions-toolbar>div {
        flex-direction: column;
        align-items: stretch !important;
        gap: 8px !important;
    }

    #mag-bulk-actions-toolbar button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .mag-nano-wrapper {
        padding: 15px;
    }

    .mag-nano-header-title span {
        font-size: 1.1rem;
    }

    #mag-credits-badge span:last-child,
    .mag-plan-badge span {
        font-size: 0.7rem !important;
    }

    .mag-pricing-header h2 {
        font-size: 1.5rem;
    }

    .mag-nano-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* --- FIXES & OVERRIDES --- */

/* Fix Lightbox Button Interactivity */
.mag-lightbox-controls-top {
    z-index: 9999999 !important;
    pointer-events: auto !important;
}

.mag-lightbox-btn {
    pointer-events: auto;
    cursor: pointer;
}

/* Mobile: Hide Preview Placeholder until result */
@media (max-width: 900px) {

    /* DEFAULT: Placeholder shown, Image area small */
    .mag-nano-preview-wrapper:not(.mag-has-image) #mag-nano-preview-placeholder {
        display: flex !important;
    }

    .mag-nano-preview-wrapper:not(.mag-has-image) {
        min-height: 100px;
    }

    /* HAS IMAGE: Placeholder hidden, Image area expanded */
    .mag-nano-preview-wrapper.mag-has-image #mag-nano-preview-placeholder {
        display: none !important;
    }

    .mag-nano-preview-wrapper.mag-has-image {
        min-height: 400px;
        /* or auto? fixed height implies containment */
    }
}

/* --- LOADER --- */
.mag-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: var(--mag-radius);
}

.mag-dark-mode .mag-loader-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.mag-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--mag-border);
    border-top: 4px solid var(--mag-accent);
    border-radius: 50%;
    animation: magSpin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes magSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#mag-loader-text {
    font-weight: 600;
    color: var(--mag-text-main);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Global Niche Select */
#mag_global_niche {
    width: 100%;
    padding: 12px;
    font-weight: 600;
    font-size: 1rem;
    border-color: var(--mag-accent);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* 
===================================
   TEMPLATE CAROUSEL & ITEMS
   (Fixes PC layout expansion & Adds Navigation)
===================================
*/

/* Wrapper adds relative context for absolute arrows */
.mag-carousel-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 20px;
    padding: 0 30px;
    /* Space for arrows */
}

/* Constrain Grid Column Width */
.mag-carousel {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 10px 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    /* Ensure it doesn't expand grid */
    width: 100%;
    max-width: 100%;

    /* Hide scrollbar visually but keep scroll */
    scrollbar-width: none;
    /* Firefox */
}

.mag-carousel::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* Navigation Arrows */
.mag-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: var(--mag-bg-card);
    border: 1px solid var(--mag-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    color: var(--mag-text-main);
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.mag-carousel-nav:hover {
    background: var(--mag-accent);
    color: #fff;
    border-color: var(--mag-accent);
}

.mag-carousel-nav.prev {
    left: -5px;
}

.mag-carousel-nav.next {
    right: -5px;
}

/* Template Items */
.mag-tpl-item {
    /* Show exactly 3 items: (100% - 2 gaps of 15px) / 3 */
    flex: 0 0 calc((100% - 30px) / 3);
    height: 140px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    background: var(--mag-bg-input);
}

.mag-tpl-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.mag-tpl-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.mag-tpl-item:hover img {
    transform: scale(1.05);
    /* Zoom effect */
}

.mag-tpl-item.selected {
    border-color: var(--mag-accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.2);
}

.mag-tpl-item.selected::after {
    content: "✅";
    position: absolute;
    top: 5px;
    right: 5px;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mag-tpl-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 6px 4px;
    font-size: 0.75rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.mag-tpl-placeholder {
    width: 100%;
    text-align: center;
    padding: 30px;
    color: var(--mag-text-muted);
    font-style: italic;
}