/* --- GLOBAL & FONTS --- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700;800;900&family=Cormorant+Garamond:wght@300;400;500;600;700&family=DM+Sans:wght@400;500;700&family=Dancing+Script:wght@400;500;600;700&family=Great+Vibes&family=Inter:wght@100;200;300;400;500;600;700;800;900&family=Josefin+Sans:wght@100;200;300;400;500;600;700&family=Lato:wght@100;300;400;700;900&family=Lora:wght@400;500;600;700&family=Merriweather:wght@300;400;700;900&family=Montserrat:wght@100;200;300;400;500;600;700;800;900&family=Nunito:wght@200;300;400;500;600;700;800;900&family=Open+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@100;200;300;400;500;600;700;800;900&family=Playfair+Display:wght@400;500;600;700;800;900&family=Poppins:wght@100;200;300;400;500;600;700;800;900&family=Quicksand:wght@300;400;500;600;700&family=Raleway:wght@100;200;300;400;500;600;700;800;900&family=Roboto:wght@100;300;400;500;700;900&family=Source+Sans+Pro:wght@200;300;400;600;700;900&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

:root {
    --gold: #D4AF37;
    --dark-bg: #121212;
    --light-bg: #1E1E1E;
    --border-color: rgba(212, 175, 55, 0.2);
    --text-primary: #FFFFFF;
    --text-secondary: #AAAAAA;
    --glow-color: rgba(212, 175, 55, 0.4);

    /* Social Icon specific variables */
    --social-icon-size: 48px;
    --social-icon-border-color-rest: #CBA35A;
    --social-icon-background-tint: rgba(255, 255, 255, 0.1); /* 10% white tint */
    --social-icon-blur: blur(12px); /* 10-14px blur */
    --social-icon-shadow-rest: 
        0 4px 10px rgba(0,0,0,0.3), /* Outer soft shadow */
        inset 0 0 8px rgba(255,255,255,0.05); /* Inner subtle highlight */

    /* Profile Photo specific variables */
    --profile-photo-size: 140px;
    --profile-photo-border-radius: 50%;
    --profile-photo-filter: none;
    --profile-photo-glow-color: transparent;
    --profile-photo-glow-spread: 0px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(180deg, var(--dark-bg) 0%, #000 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* --- APP LAYOUT --- */
.app-container {
    display: grid;
    grid-template-columns: 600px 1fr; /* Desktop default: Builder on left, Preview on right */
    grid-template-areas: "builder preview"; /* Define areas for desktop */
    height: 100vh;
    /* Adjusted padding-bottom to account for the desktop global footer */
    padding-bottom: 3.5rem; /* Approx height of the desktop global footer (1rem padding top/bottom + text line-height) */
}

/* --- BUILDER PANEL (LEFT) --- */
.builder-panel {
    grid-area: builder; /* Assign to builder area */
    background-color: #000;
    padding: 2.5rem 2rem; /* Increased padding top/bottom for more breathing room */
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.builder-header {
    margin-bottom: 2rem;
    text-align: center;
}
.builder-header h1 { color: var(--gold); font-family: 'Playfair Display', serif; }
.builder-header p { color: var(--text-secondary); font-size: 0.9rem; }

/* Logo placed above the header title, responsive and consistent spacing */
.builder-logo {
    display: block;
    margin: 0 auto 0.8rem;
    max-width: 220px;
    width: clamp(140px, 30%, 220px);
    height: auto;
}

.undo-redo-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.control-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background-color: var(--light-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px; /* Ensure minimum tap target size */
}

.control-btn:hover:not(:disabled) {
    background-color: #2a2a2a;
    box-shadow: 0 0 8px var(--glow-color);
    border-color: var(--gold);
}

.control-btn:active:not(:disabled) { /* Added active state */
    transform: scale(0.95);
    background-color: #3b3b3b;
    box-shadow: 0 0 5px var(--glow-color);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- TABS --- */
.builder-tabs {
    display: flex;
    justify-content: space-between; /* Distribute tabs evenly */
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tab-link {
    flex-grow: 1;
    flex-basis: 0; /* Allow flex-grow to take over */
    min-width: 48px; /* Minimum tap target size */
    padding: 0.75rem 0.5rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    min-height: 44px; /* Ensure minimum tap target size */
}
.tab-link span { /* Hide tab labels by default to save horizontal space */
    display: none; 
}
.tab-link:hover {
    background-color: #2a2a2a;
    box-shadow: 0 0 10px var(--glow-color);
}
.tab-link:active { /* Added active state */
    transform: scale(0.95);
    background-color: var(--gold); /* Keep active color consistent */
    color: #000;
}
.tab-link.active {
    background-color: var(--gold);
    color: #000;
    font-weight: 600;
    box-shadow: 0 0 15px var(--glow-color);
}
.tab-pane {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}
.tab-pane.active {
    display: block;
}

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

.builder-content {
    flex-grow: 1;
}

.builder-sections { flex-grow: 1; }

.builder-section {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.builder-section summary {
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 1rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--gold);
    transition: letter-spacing 0.3s ease;
}
.builder-section summary:hover { letter-spacing: 1px; }
.builder-section summary::-webkit-details-marker { display: none; }
.builder-section summary::after {
    content: '\f078';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.3s ease;
}
.builder-section[open] > summary::after { transform: rotate(180deg); }

.section-content { padding-bottom: 1.5rem; }

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}
.form-group label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    min-height: 44px; /* Ensure minimum tap target size */
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    box-shadow: 0 0 10px var(--glow-color);
    border-color: var(--gold);
}
.form-group input[type="color"] {
    width: 100%; 
    height: 44px; /* Slightly increased height for better tap area */
    border: 1px solid var(--border-color); 
    border-radius: 8px;
    cursor: pointer;
}
.form-group input[type="file"] {
    font-size: 0.9rem;
}
.form-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--light-bg);
    border-radius: 5px;
    outline: none;
    transition: background 0.2s;
    border: 1px solid var(--border-color);
    min-height: 44px; /* Make the entire track a better tap target */
    padding: 0 0.75rem; /* Add horizontal padding for better aesthetics and interaction */
    background-clip: padding-box; /* Ensure background matches padding for track */
}

.form-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    transition: background 0.15s ease-in-out;
}

.form-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    transition: background 0.15s ease-in-out;
    border: none;
}

.form-group input[type="range"]:hover::-webkit-slider-thumb,
.form-group input[type="range"]:focus::-webkit-slider-thumb {
    background: #F0D78C;
}

.form-group input[type="range"]:hover::-moz-range-thumb,
.form-group input[type="range"]:focus::-moz-range-thumb {
    background: #F0D78C;
}

hr { border: none; border-top: 1px solid var(--border-color); margin: 1.5rem 0; }

.theme-selector, .layout-selector, .size-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
}
.theme-option, .layout-option, .size-option {
    padding: 0.75rem;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 44px; /* Ensure minimum tap target size */
}
.theme-option:hover, .layout-option:hover, .size-option:hover { 
    background-color: #2a2a2a; 
    box-shadow: 0 0 10px var(--glow-color);
}
.theme-option:active, .layout-option:active, .size-option:active { /* Added active state */
    transform: scale(0.95);
    opacity: 0.8;
}
.theme-option.active, .layout-option.active, .size-option.active {
    background-color: var(--gold);
    color: #000;
    font-weight: 600;
    box-shadow: 0 0 10px var(--glow-color);
}

/* Custom Dropdown for Social Link Type */
.social-type-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem; /* Increased gap for better spacing */
    width: 100%;
    z-index: 1; 
}

.dropdown-selected-value {
    flex-grow: 1;
    padding: 0.75rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    transition: all 0.3s ease;
    min-height: 44px; /* Ensure minimum tap target size */
}

.dropdown-selected-value:hover,
.dropdown-selected-value.active {
    outline: none;
    box-shadow: 0 0 10px var(--glow-color);
    border-color: var(--gold);
    background-color: #2a2a2a;
}

.dropdown-selected-value:active { /* Added active state */
    transform: scale(0.98);
    opacity: 0.9;
    background-color: #3b3b3b;
}

.dropdown-selected-value i,
.dropdown-selected-value svg { /* Added svg selector */
    font-size: 1.2rem;
    width: 20px;
    height: 20px; /* Ensure SVG has a defined height */
    text-align: center;
    color: var(--gold); /* This will apply to fill:currentColor for SVGs */
    flex-shrink: 0;
}

/* NEW: Style for custom images inside the dropdown button */
.dropdown-selected-value img {
    width: 20px; /* Fixed width for consistency with FA icons */
    height: 20px; /* Fixed height for consistency with FA icons */
    object-fit: contain; /* Ensure image fits without distortion */
    flex-shrink: 0; /* Prevent image from shrinking */
}

/* Style for the custom link name input within the dropdown button */
.social-type-dropdown .dropdown-selected-value .custom-link-name-input {
    flex-grow: 1; /* Take remaining space */
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit; /* Inherit font from parent button */
    font-size: 1rem;
    padding: 0;
    margin-left: 0.5rem; /* Space between icon and input */
    outline: none; /* No outline on focus */
}

/* Ensure the dropdown button properly holds its content */
.social-type-dropdown .dropdown-selected-value {
    display: flex; /* Make it a flex container */
    align-items: center;
    gap: 0.5rem; /* Default gap for icon and text/input */
    width: auto; /* Allow content to dictate width if flex-grow is not enough */
    flex-grow: 1;
}

/* Ensure the label text in the dropdown button doesn't shrink unnecessarily */
.social-type-dropdown .dropdown-selected-value .dropdown-label-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* Removed ::after pseudo-element to hide the chevron */
.dropdown-selected-value::after {
    content: none; 
}

/* The selected-value.active::after rule is now also obsolete */
.dropdown-selected-value.active::after {
    content: none;
}

/* Global dropdown options list */
.dropdown-options-list {
    position: fixed;
    z-index: 1000;
    /* top, left, min-width set by JS */
    max-height: 200px; 
    overflow-y: auto;
    background-color: #000; 
    border: 1px solid var(--gold);
    border-radius: 8px;
    list-style: none;
    padding: 0.5rem 0;
    margin-top: 5px; /* Small gap between selected and options */
    box-shadow: 0 5px 20px rgba(0,0,0,0.5), 0 0 15px var(--glow-color); 
    display: none; /* Hidden by default */
    backdrop-filter: blur(5px); 
    background-color: rgba(30, 30, 30, 0.8); 
    animation: dropdownOpen 0.2s ease-out; /* Smooth opening */
}

.dropdown-options-list.show {
    display: block;
}

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

.dropdown-options-list li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-options-list li:hover {
    background-color: var(--gold);
    color: #000;
}
.dropdown-options-list li:active { /* Added active state */
    opacity: 0.8;
    background-color: var(--gold);
    color: #000;
}

.dropdown-options-list li i,
.dropdown-options-list li svg { /* Added svg selector */
    font-size: 1.3rem;
    width: 25px;
    height: 25px; /* Ensure SVG has a defined height */
    text-align: center;
}

/* Style for the new upload button */
.upload-custom-icon-btn {
    padding: 0.75rem 0.5rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--gold);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px; /* Slightly increased width for better tap area */
    height: 44px; /* Slightly increased height for better tap area */
}

.upload-custom-icon-btn:hover {
    box-shadow: 0 0 10px var(--glow-color);
    border-color: var(--gold);
    background-color: #2a2a2a;
}
.upload-custom-icon-btn:active { /* Added active state */
    transform: scale(0.95);
    opacity: 0.8;
}

/* New Social Link Group Grid Layout */
.social-link-group {
    display: grid;
    grid-template-columns: auto 1fr auto; /* Drag, Main Content Area, Remove */
    /* Use auto rows with implicit rows so controls wrap naturally instead of being forced into fixed row indexes */
    grid-auto-rows: auto;
    gap: 0.75rem 1rem; /* Row gap, Column gap */
    align-items: center;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px dashed rgba(212, 175, 55, 0.1);
    cursor: grab;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.social-link-group:hover {
    background-color: rgba(212, 175, 55, 0.05);
}

.social-link-group.dragging {
    opacity: 0.5;
    cursor: grabbing;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.social-link-group .drag-handle {
    grid-column: 1;
    grid-row: 1 / span 4; /* Spans all four content rows vertically */
    align-self: start; /* Align to the top of the grid area */
    margin-top: 0.5rem; /* Add some space from the top of the group */
    display: flex; /* Centering for the icon */
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: grab;
    transition: color 0.2s;
}

.social-link-group .drag-handle:hover {
    color: var(--gold);
}

.social-link-group .social-type-dropdown {
    grid-column: 2;
    grid-row: 1;
    display: flex; /* Make it a flex container for dropdown and upload button */
    align-items: center;
    gap: 0.5rem; /* Space between dropdown button and upload button */
}

/* NEW: Custom name input for custom links */
.social-link-group .social-custom-name {
    grid-column: 2 / -1; /* Span across main content and remove button columns */
    grid-row: 2;
    width: 100%; /* Ensure it takes full width of its grid area */
    min-height: 44px; /* Ensure minimum tap target size */
}

.social-link-group .social-url {
    grid-column: 2 / -1; /* Span across the main content and remove button columns */
    grid-row: 3; /* Shifted down one row */
    width: 100%; /* Ensure it takes full width of its grid area */
    min-height: 44px; /* Ensure minimum tap target size */
}

/* Place both color inputs side-by-side within the main content area so they never fall off the right edge.
   On narrow screens they will wrap naturally beneath other inputs. */
.social-link-group .social-custom-color,
.social-link-group .social-outline-glow-color {
    /* Put both color inputs into the main content column so they align and stay reachable */
    grid-column: 2 / 3;
    width: 100%;
    height: 44px; /* Consistent height with upload button */
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

/* When there is room, display them side-by-side using an inner grid (applied in builder markup). 
   The builder HTML already wraps these into a 2-column container; this CSS ensures each color field behaves. */

.social-link-group .remove-social-btn {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    margin-top: 0.5rem;
    background: none; border: none; color: var(--gold); cursor: pointer;
    transition: color 0.3s ease;
    font-size: 1.2rem; padding: 0.5rem;
    min-width: 44px; /* Ensure minimum tap target size */
    min-height: 44px; /* Ensure minimum tap target size */
    display: flex; /* For centering the icon */
    align-items: center;
    justify-content: center;
}
.social-link-group .remove-social-btn:hover { color: #ff4d4d; }
.social-link-group .remove-social-btn:active { /* Added active state */
    transform: scale(0.9);
    opacity: 0.7;
}

.social-link-group:last-child {
    border-bottom: none;
}

/* Responsive: ensure social link group stacks on very narrow screens to avoid overflow */
@media (max-width: 520px) {
    .social-link-group {
        grid-template-columns: auto 1fr; /* collapse remove button into flow */
        grid-auto-rows: auto;
    }
    /* Make the remove button flow below content for easier tapping */
    .social-link-group .remove-social-btn {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }
    /* Ensure the two color inputs appear side-by-side inside their inner container or wrap */
    .social-link-group > div[style*="grid-template-columns:1fr 60px"] {
        grid-template-columns: 1fr 1fr;
    }
}

/* Specific styles for color inputs within the social link group */
.social-link-group .social-custom-color,
.social-link-group .social-outline-glow-color {
    height: 44px; /* Consistent height with upload button */
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

/* Ensure color pickers used for social title / label match button sizes and spacing */
.social-link-group .social-title-color,
.social-link-group .social-custom-color,
.social-link-group .social-outline-glow-color,
.social-link-group .upload-custom-icon-btn {
    width: 44px; /* Match square size */
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    background-clip: padding-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Make sure color swatch inside inputs displays cleanly on WebKit */
.social-link-group .social-title-color::-webkit-color-swatch,
.social-link-group .social-custom-color::-webkit-color-swatch,
.social-link-group .social-outline-glow-color::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
    padding: 0;
}

.text-btn {
    margin-top: 0.5rem;
    font-size: 1rem;
    padding: 0.75rem 1.25rem; /* Increased padding */
    background-color: var(--light-bg); /* Darker background */
    border: 1px solid var(--gold); /* Gold border */
    border-radius: 8px; /* Rounded corners */
    color: var(--text-primary); /* White text */
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex; /* Align icon and text */
    align-items: center;
    justify-content: center;
    gap: 0.5rem; /* Space between icon and text */
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3); /* Subtle shadow */
    min-height: 44px; /* Ensure minimum tap target size */
}

.text-btn:hover {
    background-color: var(--gold); /* Gold background on hover */
    color: var(--dark-bg); /* Dark text on hover */
    box-shadow: 0 0 15px var(--glow-color); /* Gold glow */
    transform: translateY(-2px); /* Slight lift */
}
.text-btn:active { /* Added active state */
    transform: translateY(0) scale(0.98); /* Less pronounced scale, no lift */
    background-color: var(--gold);
    color: var(--dark-bg);
}

.text-btn i {
    color: inherit; /* Icon color inherits from button text */
    transition: color 0.3s ease;
}

.text-btn:hover i {
    color: var(--dark-bg); /* Dark icon on hover */
}

/* Typography Section Enhancements */
.typography-element-settings details {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--light-bg);
}

.typography-element-settings summary {
    color: var(--text-primary);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.typography-element-settings summary i {
    color: var(--gold);
}

.typography-element-settings summary::after {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    content: '\f078';
    margin-left: auto;
    transition: transform 0.2s;
}

.typography-element-settings details[open] summary::after {
    transform: rotate(180deg);
}

.typography-element-settings .element-controls {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

/* New style for grouping font size and weight */
.font-size-weight-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem; /* Space between font size and weight */
}
.font-size-weight-group .form-group {
    margin-bottom: 0; /* Remove bottom margin if grouped */
}

.text-element-order-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

.text-element-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: grab;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.text-element-item:hover {
    background-color: rgba(212, 175, 55, 0.05);
}

.text-element-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}
.text-element-item:active { /* Added active state for draggable items */
    transform: scale(0.98);
    background-color: rgba(212, 175, 55, 0.1);
}

.text-element-item .drag-handle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* --- FOOTER & BUTTONS --- */
.builder-footer {
    padding-top: 1rem;
    display: flex; /* Changed from grid to flex */
    flex-direction: column; /* Stack items vertically */
    align-items: center; /* Center horizontally */
    gap: 1rem; /* Space between text and button */
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* Desktop footer controls layout */
.footer-controls-desktop {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.footer-controls-desktop .undo-redo-controls {
    display: flex;
    gap: 0.5rem;
}
.footer-controls-desktop .action-buttons-desktop {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Ensure desktop footer controls are hidden on small screens (mobile uses mobile-action-bar) */
@media (max-width: 768px) {
    .footer-controls-desktop { display: none; }
}

.builder-footer .footer-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    width: 100%;
}
.builder-footer .footer-info a {
    color: var(--gold);
    text-decoration: none;
    transition: color 0.3s ease;
}
.builder-footer .footer-info a:hover {
    color: #F0D78C;
    text-decoration: underline;
}

/* Add a small wrapper style to align the builder-only footer nicely */
.builder-footer .builder-footer-info {
    width: 100%;
    margin-top: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.gold-btn {
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, #F0D78C, var(--gold));
    color: #000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}
.gold-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--glow-color);
}
.gold-btn:active { /* Added active state */
    transform: translateY(0) scale(0.98);
    opacity: 0.9;
}
.gold-btn.clear {
    background: var(--light-bg);
    color: var(--gold);
    border: 1px solid var(--gold);
}
.gold-btn.clear:hover {
    background: var(--gold);
    color: var(--dark-bg);
}
.gold-btn.clear:active { /* Added active state */
    transform: translateY(0) scale(0.98);
    opacity: 0.9;
}

/* --- PREVIEW PANEL (RIGHT) --- */
.preview-panel {
    grid-area: preview; /* Assign to preview area */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow: auto;
    min-height: 100vh;
}

.ecard {
    width: 450px;
    height: auto;
    min-height: auto;
    max-height: none;
    border-radius: 24px;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 15px var(--glow-color), 0 10px 50px rgba(0,0,0,0.7);
    transition: all 0.5s ease, transform 0.4s ease;
    flex-shrink: 0;
    text-align: initial; /* Ensure no inherited text-align from parent that might interfere */
}

.ecard.card-refresh {
    animation: refresh-anim 0.5s ease-in-out;
}
@keyframes refresh-anim {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.98); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.card-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    height: auto;
    overflow-y: visible;
    padding-bottom: 1rem;
    flex-grow: 1;
}

.preview-photo {
    width: var(--profile-photo-size);
    height: var(--profile-photo-size);
    border-radius: var(--profile-photo-border-radius);
    object-fit: cover;
    border: 4px solid rgba(255, 255, 255, 0.5);
    margin: 0 auto 1.5rem; /* Explicitly center the photo */
    box-shadow: 0 5px 20px rgba(0,0,0,0.3), 0 0 var(--profile-photo-glow-spread) var(--profile-photo-glow-color); /* Added glow */
    filter: var(--profile-photo-filter); /* Added filter */
    transition: all 0.3s ease; /* Ensure transitions apply to new properties */
    flex-shrink: 0;
}
.preview-name { 
    font-size: 2.2rem; 
    margin-bottom: 0.25rem; 
    flex-shrink: 0; 
    width: 100%; /* Ensure the element takes full width so text-align applies correctly */
}
.preview-title { 
    font-size: 1rem; 
    color: var(--text-secondary); 
    margin-bottom: 2rem; 
    flex-shrink: 0; 
    width: 100%; /* Ensure the element takes full width so text-align applies correctly */
}

.preview-company {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    width: 100%; /* Ensure the element takes full width so text-align applies correctly */
}

.preview-quote {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-style: italic;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
    width: 100%; /* Ensure the element takes full width so text-align applies correctly */
}

#preview-links-container {
    width: 100%;
    max-height: none;
    overflow-y: visible;
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
    flex-grow: 1;
    align-items: flex-start;
    min-height: 0;
}
.social-link {
    display: flex; align-items: center; text-decoration: none; color: inherit; transition: all 0.3s ease;
    --icon-color: #ffffff; /* Default icon color, can be overridden by inline style */
    --outline-glow-color: var(--brand-color); /* Default to brand color for glow */
}
.social-link:hover { transform: scale(1.05); } /* Original hover for full-label */
.social-link i,
.social-link svg,
.social-link img { 
    font-size: 1.5rem; width: 30px; text-align: center;
    color: var(--icon-color); /* This ensures custom color is applied, for SVG it's fill:currentColor */
    width: auto; /* Allow Font Awesome icons to size themselves */
    height: auto;
    max-width: 24px; /* Max size for font awesome icons to not be too big */
    max-height: 24px; /* Max size for font awesome icons to not be too big */
    object-fit: contain; /* Maintain aspect ratio without cropping */
    display: flex; /* For perfect centering */
    justify-content: center;
    align-items: center;
}

/* Social Brand Colors as CSS Variables */
.social-instagram { --brand-color: #E4405F; }
.social-youtube { --brand-color: #FF0000; }
.social-x { --brand-color: #000000; } /* Brand color is black, but for glow we will use white */
.social-facebook { --brand-color: #1877F2; }
.social-linkedin { --brand-color: #0A66C2; }
.social-tiktok { --brand-color: #FF0050; } /* Primary brand color, for glow we'll use a mix */
.social-snapchat { --brand-color: #FFFC00; }
.social-whatsapp { --brand-color: #25D366; }
.social-telegram { --brand-color: #24A1DE; }
.social-pinterest { --brand-color: #E60023; }
.social-email { --brand-color: #EA4335; }
.social-phone { --brand-color: #00b894; }

/* Add default glow for custom social links in preview (if not explicitly overridden) */
.social-link.social-custom {
    --brand-color: #7A8C98; /* Default grey/neutral for custom link */
}
.links-icon-only .social-custom:hover,
.links-icon-only .social-custom:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 20px 5px var(--brand-color), inset 0 0 8px rgba(255,255,255,0.05);
}
.links-full-label .social-custom:hover, .links-full-label .social-custom:focus {
    border-color: var(--brand-color); box-shadow: 0 0 15px var(--brand-color), inset 0 0 5px rgba(255,255,255,0.05);
}

/* Social Layouts - Icon-Only Mode (Liquid Glass Look) */
.links-icon-only {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px; /* 12-16px desktop gap */
    max-height: none;
    overflow-y: visible;
}
@media (max-width: 768px) { /* Adjust for mobile */
    .links-icon-only {
        gap: 12px; /* 8-12px mobile gap */
    }
}

.links-icon-only .social-link {
    width: var(--social-icon-size);
    height: var(--social-icon-size);
    min-width: var(--social-icon-size);
    min-height: var(--social-icon-size);
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: var(--social-icon-background-tint); 
    backdrop-filter: var(--social-icon-blur); 
    border: 2px solid var(--social-icon-border-color-rest); /* Gold border at rest */
    box-shadow: var(--social-icon-shadow-rest); /* Soft inner highlight + outer soft shadow */
    transition: all 0.18s ease-out; /* 180ms ease-out scale + ring glow */
    position: relative;
    outline: none; /* Remove default browser outline for focus */
}
.links-icon-only .social-link:hover,
.links-icon-only .social-link:focus { /* Hover & Keyboard Focus */
    transform: scale(1.02);
    /* Brand-specific glows are defined below */
}
.links-icon-only .social-link:active { /* Active/Pressed state */
    transform: scale(0.98);
    /* Reduced glow, fallback to gold if no brand glow is set */
    box-shadow: 0 0 10px 2px var(--outline-glow-color, var(--social-icon-border-color-rest)), 
                inset 0 0 4px rgba(255,255,255,0.03);
}
.links-icon-only .social-link span { display: none; } /* Hide label in icon-only mode */
.links-icon-only .social-link i,
.links-icon-only .social-link svg { /* Target both i and svg for consistent icon styling */
    font-size: 24px; /* Icon glyph size for 48px button */
    color: var(--icon-color); /* Use CSS variable for icon color, applies to SVG fill:currentColor */
    width: auto; /* Allow Font Awesome icons to size themselves */
    height: auto;
    max-width: 24px; /* Max size for font awesome icons to not be too big */
    max-height: 24px; /* Max size for font awesome icons to not be too big */
    display: flex; /* For perfect centering of Font Awesome icons and SVGs */
    justify-content: center;
    align-items: center;
}
.links-icon-only .social-link img {
    width: 24px; /* Explicitly set size for img in icon-only */
    height: 24px;
    object-fit: contain;
}

/* Brand-specific Glows for Icon-Only Mode */
.links-icon-only .social-instagram:hover,
.links-icon-only .social-instagram:focus {
    border-color: #833ab4; /* Dominant color for border */
    box-shadow: 0 0 20px 5px #fd1d1d, /* Red/Pink */
                0 0 30px 8px #833ab4, /* Purple */
                0 0 40px 10px #fcb045, /* Orange */
                inset 0 0 8px rgba(255,255,255,0.05); /* Keep inner highlight */
}
.links-icon-only .social-facebook:hover,
.links-icon-only .social-facebook:focus {
    border-color: #1877F2;
    box-shadow: 0 0 20px 5px #1877F2, inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-x:hover,
.links-icon-only .social-x:focus {
    border-color: #FFFFFF; /* White ring on dark background */
    box-shadow: 0 0 20px 5px rgba(255, 255, 255, 0.7), inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-tiktok:hover,
.links-icon-only .social-tiktok:focus {
    border-color: #00F2EA; /* Cyan for border */
    box-shadow: 0 0 20px 5px #FF0050, /* Pink neon */
                0 0 30px 8px #00F2EA, /* Cyan neon */
                inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-linkedin:hover,
.links-icon-only .social-linkedin:focus {
    border-color: #0A66C2;
    box-shadow: 0 0 20px 5px #0A66C2, inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-youtube:hover,
.links-icon-only .social-youtube:focus {
    border-color: #FF0000;
    box-shadow: 0 0 20px 5px #FF0000, inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-whatsapp:hover,
.links-icon-only .social-whatsapp:focus {
    border-color: #25D366;
    box-shadow: 0 0 20px 5px #25D366, inset 0 0 8px rgba(255,255,255,0.05);
}
.links-icon-only .social-email:hover, 
.links-icon-only .social-email:focus {
    border-color: #EA4335;
    box-shadow: 0 0 20px 5px #EA4335, inset 0 0 8px rgba(255,255,255,0.05);
}

/* Social Layouts - Full Label */
.links-full-label {
    flex-direction: column;
    max-width: fit-content;
    margin-left: auto;
    margin-right: auto;
    overflow-y: visible;
    gap: 8px; /* 8-10px gap */
}

#preview-links-container[style*="align-items: flex-start"] {
    align-items: flex-start !important;
    margin-left: 0;
    margin-right: auto;
}

#preview-links-container[style*="align-items: flex-end"] {
    align-items: flex-end !important;
    margin-left: auto;
    margin-right: 0;
}

.links-full-label .social-link {
    gap: 10px; /* 8-10px gap between icon and label */
    padding: 0.75rem 1.25rem;
    background: rgba(0, 0, 0, 0.2); /* Slightly darker background than liquid glass */
    backdrop-filter: blur(8px); /* Slightly less blur */
    border: 2px solid var(--social-icon-border-color-rest); /* Gold border for full label too */
    border-radius: 50px;
    min-width: 200px;
    justify-content: flex-start;
    transition: all 0.18s ease-out; /* 180ms ease-out */
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 0 5px rgba(255,255,255,0.03); /* Subtle shadow for full label */
    outline: none; /* Remove default browser outline for focus */
}

.links-full-label .social-link:hover,
.links-full-label .social-link:focus {
    transform: scale(1.01); /* Slightly less scale than icon-only */
    box-shadow: 0 0 15px var(--outline-glow-color), inset 0 0 5px rgba(255,255,255,0.05);
    border-color: var(--outline-glow-color);
}
.links-full-label .social-link:active {
    transform: scale(0.99);
    box-shadow: 0 0 8px 1px var(--outline-glow-color);
}

/* Icon styling in full-label mode */
.links-full-label .social-link i,
.links-full-label .social-link svg { /* Added svg selector */
    font-size: 24px; /* Icon size in full-label mode */
    width: auto;
    height: auto;
    text-align: center;
    color: var(--icon-color); /* Applies to SVG fill:currentColor */
    flex-shrink: 0;
    /* Removed text-stroke/fill as it interfered with crispness, relying on FA's SVG */
    max-width: 24px;
    max-height: 24px;
    display: flex; /* For perfect centering of Font Awesome icons and SVGs */
    justify-content: center;
    align-items: center;
}
.links-full-label .social-link img {
    width: 24px; /* Explicitly set size for img in full-label */
    height: 24px;
    object-fit: contain;
}

/* Instagram gradient hover (Full Label) */
.links-full-label .social-instagram:hover,
.links-full-label .social-instagram:focus {
    border-color: #833ab4;
    box-shadow: 0 0 15px rgba(131, 58, 180, 0.5), 0 0 25px rgba(253, 29, 29, 0.3), 0 0 35px rgba(252, 176, 69, 0.2), inset 0 0 5px rgba(255,255,255,0.05);
}

/* Twitter/X specific - white outline glow (Full Label) */
.links-full-label .social-x:hover,
.links-full-label .social-x:focus {
    border-color: #FFFFFF;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.7), inset 0 0 5px rgba(255,255,255,0.05);
}

/* TikTok specific - cyan/pink neon mix (Full Label) */
.links-full-label .social-tiktok:hover,
.links-full-label .social-tiktok:focus {
    border-color: #00F2EA;
    box-shadow: 0 0 15px #FF0050, 0 0 25px #00F2EA, inset 0 0 5px rgba(255,255,255,0.05);
}

/* Apply other brand glows to full-label as well, using their specific brand colors for the glow */
.links-full-label .social-facebook:hover, .links-full-label .social-facebook:focus {
    border-color: #1877F2; box-shadow: 0 0 15px #1877F2, inset 0 0 5px rgba(255,255,255,0.05);
}
.links-full-label .social-linkedin:hover, .links-full-label .social-linkedin:focus {
    border-color: #0A66C2; box-shadow: 0 0 15px #0A66C2, inset 0 0 5px rgba(255,255,255,0.05);
}
.links-full-label .social-youtube:hover, .links-full-label .social-youtube:focus {
    border-color: #FF0000; box-shadow: 0 0 15px #FF0000, inset 0 0 5px rgba(255,255,255,0.05);
}
.links-full-label .social-whatsapp:hover, .links-full-label .social-whatsapp:focus {
    border-color: #25D366; box-shadow: 0 0 15px #25D366, inset 0 0 5px rgba(255,255,255,0.05);
}
.links-full-label .social-email:hover, .links-full-label .social-email:focus {
    border-color: #EA4335; box-shadow: 0 0 15px #EA4335, inset 0 0 5px rgba(255,255,255,0.05);
}

/* Profile Section */
.profile-section {
    flex-shrink: 0;
    text-align: center;
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.8s ease-out;
}

/* Viewfinder Container */
.viewfinder-container {
    position: relative;
    width: 100%;
    max-width: 280px;
    margin: 0 auto 1rem;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.viewfinder-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    filter: saturate(0.8) contrast(1.1);
}

.viewfinder-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(0.5px);
    transition: filter 0.3s ease;
}

.viewfinder-container:hover .viewfinder-image {
    filter: saturate(1) contrast(1.15) blur(0);
}

/* Viewfinder Overlay */
.viewfinder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 10;
    pointer-events: none;
}

/* HUD Elements */
.hud-top {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

.battery-icon i,
.settings-icon i {
    font-size: 0.875rem;
}

/* Focus Points */
.focus-points {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.focus-square {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.focus-square.top-left {
    top: 15px;
    left: 15px;
    border-right: none;
    border-bottom: none;
}

.focus-square.top-right {
    top: 15px;
    right: 15px;
    border-left: none;
    border-bottom: none;
}

.focus-square.bottom-left {
    bottom: 15px;
    left: 15px;
    border-right: none;
    border-top: none;
}

.focus-square.bottom-right {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

/* Center Focus */
.center-focus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.center-crosshair {
    width: 60px;
    height: 60px;
    position: relative;
}

.center-crosshair::before,
.center-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
}

.center-crosshair::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    transform: translateY(-50%);
}

.center-crosshair::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
}

/* REC Indicator */
.rec-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ff3333;
    font-size: 0.75rem;
    font-weight: bold;
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: #ff3333;
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* HUD Bottom */
.hud-bottom {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
}

/* Grid Lines */
.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.grid-vertical,
.grid-horizontal {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
}

.grid-vertical {
    width: 1px;
    height: 100%;
    top: 0;
}

.grid-vertical:nth-child(1) { left: 33.33%; }
.grid-vertical:nth-child(2) { right: 33.33%; }

.grid-horizontal {
    height: 1px;
    width: 100%;
    left: 0;
}

.grid-horizontal:nth-child(3) { top: 33.33%; }
.grid-horizontal:nth-child(4) { bottom: 30%; }

/* Links Section */
.links-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #ffffff;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.contact-btn::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 ease;
}

.contact-btn:hover::before {
    left: 100%;
}

.contact-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.contact-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.contact-btn .x-logo {
    width: 1.125rem;
    height: 1.125rem;
}

/* Brand-specific button colors */
.phone-btn:hover {
    border-color: #00b894;
    box-shadow: 0 8px 25px rgba(0, 184, 148, 0.2);
}

.whatsapp-btn:hover {
    border-color: #25d366;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.2);
}

.email-btn:hover {
    border-color: #ea4335;
    box-shadow: 0 8px 25px rgba(234, 67, 53, 0.2);
}

.instagram-btn:hover {
    border-color: #e4405f;
    box-shadow: 0 8px 25px rgba(228, 64, 95, 0.2);
}

.youtube-btn:hover {
    border-color: #ff0000;
    box-shadow: 0 8px 25px rgba(255, 0, 0, 0.2);
}

.snapchat-btn:hover {
    border-color: #fffc00;
    color: #000000;
    background: rgba(255, 252, 0, 0.1);
}

.twitter-btn:hover {
    border-color: #1da1f2;
    box-shadow: 0 8px 25px rgba(29, 161, 242, 0.2);
}

.portfolio-btn:hover {
    border-color: #6366f1;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.2);
}

/* vCard Section */
.vcard-section {
    flex-shrink: 0;
    text-align: center;
    margin-top: auto;
}

.vcard-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    color: var(--text-primary);
    text-decoration: none;
    margin-top: auto;
    margin: auto; /* Explicitly center the vcard button */
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.vcard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--glow-color);
    background: rgba(212, 175, 55, 0.2);
}
.vcard-btn:active { /* Added active state */
    transform: translateY(0) scale(0.98);
    opacity: 0.9;
}

/* Card Sizes */
.ecard.size-compact {
    width: 400px;
    min-height: auto;
    max-height: none;
}

.ecard.size-compact .links-full-label,
.ecard.size-compact .links-icon-only {
    max-height: none;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes kenBurns {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

@keyframes grain {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-1px, 1px); }
    20% { transform: translate(-2px, 0); }
    30% { transform: translate(1px, -1px); }
    40% { transform: translate(-1px, -2px); }
    50% { transform: translate(2px, 1px); }
    60% { transform: translate(-1px, 1px); }
    70% { transform: translate(1px, 2px); }
    80% { transform: translate(-2px, -1px); }
    90% { transform: translate(1px, -1px); }
    100% { transform: translate(0, 0); }
}

/* --- EMOJI ANIMATION --- */
.floating-emoji-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1; overflow: hidden;
    mask-image: radial-gradient(ellipse at center, black 50%, transparent 100%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 50%, transparent 100%);
}
.emoji-float {
    position: absolute;
    opacity: 0.3;
    animation: floatUp linear infinite;
}
@keyframes floatUp {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10%, 90% { opacity: 0.4; }
    100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
}

/* --- TOGGLE SWITCH --- */
.toggle-group { flex-direction: row; justify-content: space-between; align-items: center;}
.switch{position:relative;display:inline-block;width:60px;height:34px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.4s;transition:.4s}.slider:before{position:absolute;content:"";height:26px;width:26px;left:4px;bottom:4px;background-color:#fff;-webkit-transition:.4s;transition:.4s}input:checked+.slider{background-color:var(--gold)}input:focus+.slider{box-shadow:0 0 1px var(--gold)}input:checked+.slider:before{-webkit-transform:translateX(26px);-ms-transform:translateX(26px);transform:translateX(26px)}.slider.round{border-radius:34px}.slider.round:before{border-radius:50%}

/* --- SAVE FEEDBACK --- */
.save-feedback {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translate(-50%, 200%);
    background: linear-gradient(145deg, #F0D78C, var(--gold));
    color: #000;
    padding: 1rem 2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 8px 25px var(--glow-color);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.save-feedback.show {
    transform: translate(-50%, 0);
}
.save-feedback .checkmark {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
}

/* --- ACCESSIBILITY: REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .social-link {
        transition-duration: 0.09s !important; /* Reduce transition by 50% */
        transform: none !important; /* Disable scaling */
        box-shadow: none !important; /* Disable complex shadows/glows */
    }
    .links-icon-only .social-link:hover,
    .links-icon-only .social-link:focus,
    .links-full-label .social-link:hover,
    .links-full-label .social-link:focus {
        box-shadow: 0 0 10px 2px var(--outline-glow-color, var(--social-icon-border-color-rest)), 
                    inset 0 0 4px rgba(255,255,255,0.03) !important; /* Simplified glow */
    }
}

/* NEW: Mobile Action Bar - Hidden by default */
.mobile-action-bar {
    display: none;
}

/* --- NEW GLOBAL FOOTER FOR DESKTOP --- */
.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 990; /* Below mobile action bar (z-index typically higher, e.g., 1000) */
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
    backdrop-filter: blur(10px); /* Blur effect */
    border-top: 1px solid var(--border-color); /* Subtle top border */
    padding: 1rem 1.5rem; /* Generous padding */
    text-align: center;
    color: var(--text-secondary); /* Text color */
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif; /* Modern, clean font */
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5); /* Subtle shadow */
    border-top-left-radius: 12px; /* Rounded corners for the top edge */
    border-top-right-radius: 12px;
}

.app-footer p {
    margin: 0; /* Remove default paragraph margin */
    line-height: 1.5;
}

.app-footer a {
    color: var(--gold); /* Link color */
    text-decoration: none;
    transition: color 0.3s ease;
}

.app-footer a:hover {
    color: #F0D78C;
    text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    body { overflow: auto; }
    .app-container {
        grid-template-columns: 1fr; /* Stacks vertically */
        grid-template-areas: "builder" "preview"; /* Builder on top, Preview below (HTML order) */
        height: auto;
    }
    .builder-panel { 
        border-right: none; 
        border-bottom: 1px solid var(--border-color); 
        padding: 1.5rem;
    }
    .preview-panel { 
        padding: 4rem 1rem;
        display: flex; /* Make it a flex container to center ecard */
        justify-content: center; /* Center ecard horizontally */
        align-items: center; /* Center ecard vertically */
        min-height: 60vh; /* Ensure some minimum height for visibility */
    }
    .tab-link { flex-basis: 15%; } 

    /* Adjust global dropdown for smaller screens if needed */
    .dropdown-options-list {
        max-width: calc(100% - 20px); /* Ensure it doesn't overflow viewport on small screens */
        left: 10px !important; /* Override JS left and align to left edge */
        right: 10px !important; /* Override JS right and align to right edge */
        width: auto !important; /* Allow width to be determined by left/right */
        min-width: 150px; /* Still maintain minimum readability */
    }

    /* Reset app-container padding-bottom for smaller screens (handled by specific media queries) */
    .app-container {
        padding-bottom: 0;
    }
}

/* NEW: Media query for screens under 768px */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr; /* Single column layout */
        grid-template-rows: auto 1fr; /* Preview takes content height, builder takes remaining */
        grid-template-areas:
            "builder"
            "preview"; /* Builder on top, Preview below */
        height: auto; /* Allow height to adapt to content */
        /* Add padding-bottom to prevent content from being obscured by the fixed action bar */
        padding-bottom: calc(5rem + 1.15rem + env(safe-area-inset-bottom)); /* Estimated action bar height + new footer text + safe area */
    }

    .builder-panel {
        /* Override 1024px settings for smaller screens */
        border-bottom: 1px solid var(--border-color); /* restore bottom border for separation on mobile */
        padding: 1.5rem; /* keep compact padding consistent with tablet */
        /* Ensure content scrolls above the sticky bar */
        padding-bottom: calc(2rem + 5rem + 1.15rem + env(safe-area-inset-bottom));
    }

    .preview-panel {
        /* Override 1024px settings for smaller screens */
        padding: 2rem 1rem; /* Adjust padding for mobile, more top/bottom spacing around the card */
        min-height: 50vh; /* Smaller min-height for mobile screens */
        /* display: flex, justify-content: center, align-items: center inherited from 1024px */
    }
    
    .ecard {
        width: clamp(280px, 90vw, 420px); /* Responsive width with min/max */
        margin: 0 auto; /* Centering the card */
        /* Padding: 1.5rem; is already set in the 768px block */
    }

    /* Spacing between sections for readability within the builder panel */
    .builder-header {
        margin-bottom: 1.5rem;
    }
    .builder-tabs {
        margin-bottom: 1.5rem;
    }
    .section-content {
        padding-bottom: 2rem; /* Increased spacing after each section content */
    }
    .builder-footer {
        /* Hide the original footer entirely on mobile when the sticky bar is active */
        display: none;
    }

    /* Adjust tab link sizing for better tap targets on small screens */
    .tab-link {
        padding: 0.6rem 0.2rem; /* Slightly reduced padding */
        font-size: 0.8rem; /* Slightly larger font than 0.75rem for better readability */
        min-height: 44px; /* Ensure minimum tap target size, overriding previous */
    }
    .tab-link i {
         font-size: 1.1rem; /* Adjust icon size to match new font size */
    }

    /* Stack font size and weight inputs on small screens for Typography tab */
    .font-size-weight-group {
        grid-template-columns: 1fr; /* Stack vertically */
        gap: 0.5rem; /* Reduce gap when stacked */
    }

    /* Hide desktop undo/redo controls */
    .undo-redo-controls {
        display: none;
    }

    /* Mobile Action Bar - visible on mobile */
    .mobile-action-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        display: flex;
        flex-direction: column; /* Stack info and buttons */
        justify-content: center; /* Center content vertically */
        padding: 0.5rem 1rem; /* Adjust padding for mobile */
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); /* Add safe area insets */
        background-color: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.5);
        z-index: 1000;
        gap: 0.5rem; /* Space between info and buttons */
    }

    /* Style info text within the mobile action bar */
    .mobile-action-bar .mobile-footer-info {
        color: var(--text-secondary);
        font-size: 0.75rem; /* Smaller font size for mobile */
        text-align: center;
        width: 100%;
        margin-bottom: 0.25rem; /* Small space before buttons */
    }
    .mobile-action-bar .mobile-footer-info a {
        color: var(--gold);
        text-decoration: none;
    }
    .mobile-action-bar .mobile-footer-info a:hover {
        text-decoration: underline;
    }

    /* Container for buttons in mobile action bar */
    .mobile-action-bar .mobile-action-buttons {
        display: flex;
        justify-content: space-around;
        width: 100%; /* Ensure buttons take full width */
        gap: 0.25rem; /* Gap between buttons */
    }

    /* Style buttons within the mobile action bar */
    .mobile-action-bar .control-btn,
    .mobile-action-bar .gold-btn {
        flex: 1; /* Make buttons take equal space */
        margin: 0; /* Remove horizontal margin as gap handles it */
        padding: 0.8rem 0.75rem; /* Increase padding for tap target */
        font-size: 0.95rem; /* Adjust font size */
        min-height: 48px; /* Fixed height for better tap target */
    }

    /* Make Clear All visually consistent and not too large on mobile */
    #clear-btn-mobile {
        min-width: 0;
        padding: 0.7rem 0.6rem;
    }

    /* Hide desktop footer on mobile */
    .desktop-only-footer {
        display: none;
    }

    /* Show mobile footer text within action bar */
    .mobile-only-footer {
        display: block; 
    }

    /* --- MOBILE-SPECIFIC FIXES REQUESTED --- */

    /* 1) Social media dropdown: ensure it is fixed, centered vertically, scrollable, and readable on mobile */
    .dropdown-options-list {
        position: fixed !important;
        top: 20% !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        background-color: rgba(0,0,0,0.95) !important;
        border-radius: 12px !important;
        padding: 0.5rem !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 15px var(--glow-color) !important;
        -webkit-overflow-scrolling: touch; /* smoother scrolling on iOS */
        width: min(calc(100% - 32px), 360px) !important; /* keep it readable and not full-bleed */
        left: 50% !important;
        transform: translate(-50%, 0) !important;
        z-index: 1200 !important;
    }

    /* Ensure each option remains tappable and not too close to edges on mobile */
    .dropdown-options-list li {
        padding: 0.9rem 1rem;
        font-size: 1.05rem;
        border-radius: 8px;
        margin: 0.25rem;
    }

    /* 2) Clear All button visibility & sizing on mobile (only mobile) */
    #clear-btn {
        display: block !important;
        margin-top: 12px !important;
        max-width: 90% !important;
        width: auto !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box;
    }

}
/* For screens where mobile-action-bar is hidden (desktop/tablet landscape) */
@media (min-width: 769px) {
    .app-footer {
        display: block; /* Show desktop footer */
    }
    /* Ensure builder-panel desktop padding is not affected */
    .builder-panel {
        padding-bottom: 2.5rem; /* Revert to desktop default */
    }
}

/* Further mobile optimizations (if necessary, but the 768px rule should be quite comprehensive) */
@media (max-width: 480px) {
    .container {
        padding: 1.5rem 1rem;
    }
    
    .name {
        font-size: 1.5rem;
    }
    
    .viewfinder-container {
        max-width: 240px;
    }
    
    .hud-top,
    .hud-bottom,
    .rec-indicator {
        font-size: 0.625rem;
    }
    
    .focus-square {
        width: 15px;
        height: 15px;
    }
    
    .focus-square.top-left {
        top: 15px;
        left: 15px;
        border-right: none;
        border-bottom: none;
    }
    
    .focus-square.top-right {
        top: 15px;
        right: 15px;
        border-left: none;
        border-bottom: none;
    }
    
    .focus-square.bottom-left {
        bottom: 15px;
        left: 15px;
        border-right: none;
        border-top: none;
    }
    
    .focus-square.bottom-right {
        bottom: 15px;
        right: 15px;
        border-left: none;
        border-top: none;
    }
}

/* NEW: Custom Emojis Picker Styles */
.emoji-picker-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start; /* Align button and display to the left */
}

.selected-emojis-display {
    width: 100%;
    min-height: 44px; /* Ensure visible even if no emojis */
    padding: 0.5rem;
    background-color: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: text; /* Indicate it's interactive */
    transition: all 0.3s ease;
}

.selected-emojis-display:focus-within {
    box-shadow: 0 0 10px var(--glow-color);
    border-color: var(--gold);
}

.selected-emoji-item {
    display: inline-flex;
    align-items: center;
    background-color: rgba(212, 175, 55, 0.1); /* Subtle background */
    border: 1px solid var(--gold);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    gap: 0.25rem;
    font-size: 1.1rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.selected-emoji-item .remove-emoji-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
    /* Ensure minimum tap target size */
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selected-emoji-item .remove-emoji-btn:hover {
    color: #ff4d4d;
}

.selected-emoji-item .remove-emoji-btn:active { /* Added active state */
    transform: scale(0.9);
    opacity: 0.7;
}

.emoji-picker-popup {
    position: fixed; /* Changed from absolute to fixed for reliable positioning relative to viewport */
    top: 100%; /* Position below the trigger button/display */
    left: 0;
    width: 300px; /* Fixed width for the picker grid */
    max-height: 250px;
    overflow-y: auto;
    background-color: #000;
    border: 1px solid var(--gold);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5), 0 0 15px var(--glow-color);
    padding: 0.75rem;
    display: none; /* Hidden by default */
    grid-template-columns: repeat(6, 1fr); /* 6 columns of emojis */
    gap: 0.5rem;
    z-index: 1001; /* Ensure it's above other elements */
    animation: fadeIn 0.2s ease-out;
}

.emoji-picker-popup.show {
    display: grid;
}

.emoji-picker-popup button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* Ensure minimum tap target size */
    min-width: 44px;
    min-height: 44px;
}

.emoji-picker-popup button:hover {
    background-color: rgba(212, 175, 55, 0.2);
    transform: scale(1.1);
}

.emoji-picker-popup button.selected {
    background-color: var(--gold);
    color: #000;
    border: 1px solid var(--gold);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

.emoji-picker-popup button:active { /* Added active state */
    transform: scale(0.9);
    opacity: 0.8;
}

/* Adjust text-btn for open-emoji-picker-btn specifically to align with other inputs */
#open-emoji-picker-btn {
    margin-top: 0; /* Remove top margin from generic .text-btn */
    width: fit-content; /* Allow width to fit content */
    padding: 0.75rem 1rem; /* Adjust padding for a smaller button */
    /* Ensure minimum tap target size */
    min-height: 44px;
}

/* Ensure the full-label-alignment-group is properly displayed when active */
#full-label-alignment-group {
    display: flex;
    flex-direction: column; /* Override potential row flex from toggle-group if it was moved */
    margin-top: 1rem; /* Space from above element */
}

/* Ensure builder-panel footer info is hidden on desktop so the footer text only appears on mobile */
@media (min-width: 769px) {
    .builder-footer .builder-footer-info {
        display: flex;
        justify-content: center;
        align-items: center;
    }
}

/* Mobile-only footer styling (keeps look consistent with mobile action bar) */
.mobile-footer-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    width: 100%;
}
.mobile-footer-info a {
    color: var(--gold);
    text-decoration: none;
}
.mobile-footer-info a:hover {
    color: #F0D78C;
    text-decoration: underline;
}
