/* =================================================================
   CUSTOM FAQ STYLES - MODERN AESTHETIC
   ================================================================= */

/* --- Main Section & Card Styling --- */
.faq-section .card {
    border: none;
    border-bottom: 1px solid #e9ecef;
    border-radius: 0;
    margin-bottom: 10px;
}

.faq-section .card:last-child {
    border-bottom: none;
}

/* --- Card Header (The clickable area) --- */
.faq-section .card-header {
    background-color: #fff;
    border-bottom: none;
    padding: 1rem 1.25rem;
}

/* --- FAQ Question Button Styling --- */
.faq-section .card-header .btn-link {
    color: #212529;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    width: 100%;
    text-align: left;
    padding-left: 15px;
    display: block;
}

.faq-section .card-header .btn-link:hover {
    color: #0056b3;
}

/* --- Modern Chevron Icon (+) / (-) --- */
.faq-section .card-header .btn-link {
    position: relative;
    padding-right: 30px;
}

.faq-section .card-header .btn-link::after {
    content: '›';
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%) rotate(90deg);
    font-size: 1.8rem;
    font-weight: 300;
    color: #adb5bd;
    transition: transform 0.3s ease-in-out;
}

.faq-section .card-header .btn-link:not(.collapsed)::after {
    transform: translateY(-50%) rotate(-90deg);
}

/* --- Card Body (The answer) --- */
.faq-section .card-body {
    padding: 0 1.25rem 1.5rem 1.25rem;
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
}

.faq-section .card-body a {
    font-weight: 600;
    color: #007bff;
}

/* --- Remove focus outline for a cleaner look --- */
.faq-section .card-header .btn-link:focus {
    box-shadow: none;
    text-decoration: none;
}

/* ===================================================================
   LOADING OVERLAY
   =================================================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-progress {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ===================================================================
   PROFESSIONAL GRADIENT GENERATOR CSS - MOBILE-FIRST DESIGN
   =================================================================== */

:root { 
    --body-background: #fff !important;
    --primary: #6366f1; 
    --primary-hover: #4f46e5; 
    --primary-light: #f0f9ff;
    --bg-primary: #ffffff; 
    --bg-secondary: #f8fafc; 
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0; 
    --border-focus: #c7d2fe;
    --text-primary: #1e293b; 
    --text-secondary: #64748b; 
    --text-muted: #94a3b8;
    --danger: #ef4444; 
    --success: #22c55e; 
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); 
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
    --radius: 12px; 
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --touch-target: 48px;
    --mobile-padding: 16px;
    --mobile-gap: 12px;
}

* { 
    box-sizing: border-box; 
    -webkit-overflow-scrolling: touch;
}

body.fullscreen-active { 
    overflow: hidden; 
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ===================================================================
   MOBILE-FIRST LAYOUT
   =================================================================== */

.gradient-app { 
    width: 100%;
    margin: 0;
    background: var(--bg-primary); 
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header { 
    padding: var(--mobile-padding); 
    border-bottom: 1px solid var(--border); 
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    /*position: sticky;*/
    top: 0;
    backdrop-filter: blur(10px);
}

.app-header h1 { 
    margin: 0; 
    font-size: 20px; 
    font-weight: 800; 
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    line-height: 1.2;
}

.app-main { 
    display: flex;
    flex-direction: column;
    gap: var(--mobile-gap);
    padding: var(--mobile-padding);
    flex: 1;
}

/* ===================================================================
   PREVIEW SECTION
   =================================================================== */

.preview-section { 
    display: flex; 
    flex-direction: column; 
    gap: var(--mobile-gap);
    order: 1;
}

.gradient-bar-section { 
    background: white; 
    padding: 24px; 
    border-radius: var(--radius-lg); 
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.gradient-bar-title { 
    margin: 0 0 16px 0; 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.gradient-bar-wrapper { 
    position: relative; 
    height: 60px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); 
    border-radius: var(--radius); 
    border: 2px solid var(--border); 
    cursor: pointer;
    margin-bottom: 20px;
    touch-action: manipulation;
    user-select: none;
}

.gradient-bar { 
    width: 100%; 
    height: 100%; 
    border-radius: calc(var(--radius) - 2px); 
}

.color-stops { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    pointer-events: none; 
}

.color-stop { 
    position: absolute; 
    top: 50%; 
    width: 32px;
    height: 32px;
    border: 3px solid white; 
    border-radius: 50%; 
    transform: translate(-50%, -50%); 
    cursor: pointer;
    pointer-events: all; 
    transition: var(--transition); 
    touch-action: manipulation;
    z-index: 5;
}

.color-stop::before {
    content: '';
    position: absolute;
    top: -8px;
    left: -8px;
    right: -8px;
    bottom: -8px;
    border-radius: 50%;
}

.color-stop:hover, 
.color-stop:active,
.color-stop.active { 
    transform: translate(-50%, -50%) scale(1.25); 
    z-index: 10;
}

.color-stop.active { 
    border-color: var(--primary); 
}

.preview-area { 
    position: relative; 
    height: 250px;
    border-radius: var(--radius-lg); 
    border: 1px solid rgba(0, 0, 0, 0.06); 
    overflow: hidden; 
    background: var(--bg-secondary);
    touch-action: manipulation;
}

.gradient-preview { 
    width: 100%; 
    height: 100%; 
}

.preview-action-btn { 
    position: absolute; 
    top: var(--mobile-gap); 
    background: rgba(255, 255, 255, 0.95); 
    border: 1px solid rgba(0, 0, 0, 0.08); 
    border-radius: 10px; 
    padding: 12px; 
    cursor: pointer; 
    transition: var(--transition); 
    width: var(--touch-target); 
    height: var(--touch-target); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    backdrop-filter: blur(10px);
    touch-action: manipulation;
}

.preview-action-btn:hover,
.preview-action-btn:active { 
    background: white; 
    transform: translateY(-2px);
}

.preview-action-btn svg { 
    width: 20px; 
    height: 20px; 
    stroke: var(--text-secondary); 
    stroke-width: 2; 
    fill: none; 
    stroke-linecap: round; 
    stroke-linejoin: round; 
}

.fullscreen-btn { 
    right: var(--mobile-gap); 
}

/* ===================================================================
   PROFESSIONAL CONTROLS CONTAINER
   =================================================================== */

.controls-container { 
    display: flex;
    flex-direction: column;
    gap: 16px;
    order: 2;
}

.controls-grid-section { 
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px; 
    background: white;
    border-radius: var(--radius-lg); 
    border: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    transition: var(--transition);
}

.form-group { 
    display: flex; 
    flex-direction: column; 
    gap: 10px;
}

.form-label { 
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px; 
    font-weight: 600; 
    margin-bottom: 0;
    color: var(--text-primary);
    letter-spacing: 0.2px;
    text-transform: uppercase;
    opacity: 0.8;
}

.form-input { 
    width: 100%; 
    padding: 14px 16px;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    font-size: 15px;
    min-height: var(--touch-target);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-secondary);
    font-weight: 500;
    touch-action: manipulation;
    outline: none;
}

.form-input:hover {
    border-color: rgba(0, 0, 0, 0.2);
    background: white;
}

.form-input:focus { 
    border-color: var(--primary);
    background: white;
    transform: translateY(-1px);
}

.color-input-field {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
    cursor: pointer;
    border: 2px solid rgba(0, 0, 0, 0.1);
    font-size: 16px;
    padding: 16px;
    transition: all 0.3s ease;
}

.color-input-field:hover {
    transform: scale(1.02);
}

.editor-section {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
}

.editor-section .form-group {
    flex: 1;
}

.delete-btn-wrapper {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
}

.settings-section {
    gap: 20px;
}

/* ===================================================================
   PROFESSIONAL BUTTON STYLING (ENHANCED)
   =================================================================== */

.btn { 
    padding: 14px 16px; /* Optimized padding */
    border: none;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 14px; /* Slightly smaller font */
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-primary); /* Use primary text color */
    border: 1px solid var(--border); /* Subtle border for definition */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-height: var(--touch-target);
    touch-action: manipulation;
    user-select: none;
    letter-spacing: 0.3px;
    transition: all 0.15s ease-out; /* Faster transition */
}

.btn:hover { 
    transform: translateY(-2px);
    border-color: var(--border-focus);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    color: var(--text-secondary);
    transition: color 0.15s ease-out;
    pointer-events: none; /* <-- ADD THIS LINE */
}

.btn:hover svg {
    color: var(--primary);
}

.btn-primary { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border: none; /* Primary button doesn't need a border */
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25), 0 2px 4px rgba(99, 102, 241, 0.15);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35), 0 3px 8px rgba(99, 102, 241, 0.2);
}

.btn-primary svg {
    color: white; /* Ensure icon is white on primary button */
}

/* ===================================================================
   RADIO GROUP
   =================================================================== */

.radio-group { 
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 6px;
    border: 1.5px solid rgba(0, 0, 0, 0.06);
}

.radio-option { 
    flex: 1;
    position: relative;
}

.radio-input { 
    position: absolute;
    opacity: 0;
}

.radio-label { 
    display: block;
    padding: 12px 20px;
    text-align: center;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    color: var(--text-secondary);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    font-size: 14px;
    letter-spacing: 0.3px;
}

.radio-label:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

.radio-input:checked + .radio-label { 
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3), 0 1px 3px rgba(99, 102, 241, 0.2);
    transform: translateY(-1px);
}

/* ===================================================================
   ACTIONS SECTION
   =================================================================== */

.actions-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Make the Download button span both columns */
#downloadBtn {
    grid-column: 1 / -1; /* This makes it full-width */
    margin-top: 8px; /* Add a little space above */
}

/* ===================================================================
   RANGE SLIDER
   =================================================================== */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    height: 44px;
    width: 100%;
    touch-action: manipulation;
    padding: 0 !important;
}

input[type="range"]::-webkit-slider-track {
    background: linear-gradient(to right, var(--bg-tertiary) 0%, var(--bg-tertiary) 100%);
    height: 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    background: white;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3), 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: -8px;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    border-width: 4px;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5), 0 1px 3px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-track {
    background: linear-gradient(to right, var(--bg-tertiary) 0%, var(--bg-tertiary) 100%);
    height: 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-moz-range-thumb {
    background: white;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3), 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4), 0 2px 6px rgba(0, 0, 0, 0.15);
    border-width: 4px;
}

/* ===================================================================
   UNIFIED DOWNLOAD MODAL
   =================================================================== */

.unified-download-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.unified-download-modal.visible {
    opacity: 1;
}

.download-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.download-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 800px; /* Increased max-width for more columns */
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.download-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.download-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.download-options-container {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
    /* Use a responsive grid for main content */
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 640px) {
    .download-options-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .download-options-container {
        grid-template-columns: repeat(3, 1fr);
    }
}


.download-section {
    margin-bottom: 0; /* Remove margin-bottom from section as grid handles spacing */
    background: var(--bg-primary);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.download-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--bg-tertiary);
    padding-bottom: 8px;
}

/* Make custom size section span across columns */
.download-section:last-child {
    grid-column: 1 / -1;
    margin-bottom: 0;
    background: var(--bg-tertiary);
}

.download-option-btn {
    /* Made buttons more compact */
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
    text-align: left;
}

.download-option-btn:hover:not(.disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15);
}

.download-option-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.download-option-btn.downloading {
    background: var(--primary-light);
    border-color: var(--primary);
}

.download-option-btn.success {
    background: #f0fdf4;
    border-color: #22c55e;
}

.download-option-btn.error {
    background: #fef2f2;
    border-color: #ef4444;
}

.option-icon {
    font-size: 18px; /* Smaller icon */
    flex-shrink: 0;
}

.option-info {
    flex: 1;
    display: flex;
    flex-direction: row; /* Changed to row for compact view */
    align-items: center;
    justify-content: space-between;
}

.option-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.option-size {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
    margin-left: 10px;
}

.download-status {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

.success-icon {
    color: #22c55e;
    font-size: 18px;
    font-weight: 700;
}

.error-icon {
    color: #ef4444;
    font-size: 18px;
    font-weight: 700;
}

.custom-size-inputs {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.custom-size-inputs .custom-input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    background: white;
}

.custom-size-inputs .custom-input:focus {
    border-color: var(--primary);
    outline: none;
}

.custom-size-inputs .custom-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.custom-size-inputs .size-separator {
    color: var(--text-muted);
    font-weight: 700;
    display: flex;
    align-items: center;
}

.custom-size-inputs .custom-generate-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 10px 16px;
}

/* Mobile specific styling for modal position */
@media (max-width: 799px) {
    .download-modal-content {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        align-self: flex-end;
        max-height: 85vh;
        width: 100%;
    }
    
    .download-modal-header {
        padding: 16px 20px;
    }
    
    .download-options-container {
        padding: 16px 20px;
        grid-template-columns: 1fr; /* Force single column on small screens */
    }
    
    .download-section:last-child {
        /* Ensure custom section stays full width on mobile */
        grid-column: 1 / 1;
    }
}
.unified-download-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.unified-download-modal.visible {
    opacity: 1;
}

.download-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.download-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 900px; /* Wider for more columns */
    width: 100%;
    max-height: 90vh;
    overflow: hidden; /* Hide scrollbar by default */
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.download-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px; /* Reduced padding */
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.download-modal-header h3 {
    margin: 0;
    font-size: 18px; /* Smaller header text */
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}

.download-options-container {
    padding: 16px 24px;
    overflow-y: auto; /* Fallback for very small screens */
    flex: 1;
    display: grid;
    /* Responsive grid for options */
    grid-template-columns: repeat(2, 1fr);
    gap: 8px; /* Tighter gap */
    align-content: start; /* Align items to the top */
}

/* More columns on wider screens */
@media (min-width: 768px) {
    .download-options-container {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1024px) {
    .download-options-container {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* CRITICAL CHANGE: Remove the visual 'card' from the section wrapper */
.download-section {
    /* display: contents makes the wrapper disappear, promoting its children to the parent grid */
    display: contents;
}

/* Style the category headers to span the grid and act as separators */
.download-section h4 {
    grid-column: 1 / -1; /* Span all columns */
    margin: 12px 0 4px 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
.download-section:first-of-type h4 {
    margin-top: 0;
}

/* Style the custom size section separately at the bottom */
.download-section.custom-size-section {
    display: block; /* Override 'contents' to make it a grid item again */
    grid-column: 1 / -1;
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

/* Smaller, more efficient buttons */
.download-option-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0; /* Grid gap handles spacing */
    transition: all 0.2s ease;
    text-align: left;
}

.download-option-btn:hover:not(.disabled) {
    background: white;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.download-option-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.download-option-btn.downloading { background: var(--primary-light); border-color: var(--primary); }
.download-option-btn.success { background: #f0fdf4; border-color: #22c55e; }
.download-option-btn.error { background: #fef2f2; border-color: #ef4444; }

.option-icon { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }
.option-info { flex: 1; display: flex; align-items: baseline; justify-content: space-between; overflow: hidden; gap: 8px; }
.option-name { font-weight: 500; font-size: 13px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.option-size { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.download-status { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--bg-tertiary); border-top-color: var(--primary); }
.success-icon, .error-icon { font-size: 16px; font-weight: 700; }
.success-icon { color: #22c55e; }
.error-icon { color: #ef4444; }

.custom-size-inputs { display: flex; align-items: center; gap: 8px; }
.custom-size-inputs .custom-input { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 6px; text-align: center; font-weight: 500; font-size: 13px; background: white; }
.custom-size-inputs .custom-input:focus { border-color: var(--primary); outline: none; }
.custom-size-inputs .size-separator { color: var(--text-muted); font-weight: 600; }
.custom-size-inputs .custom-generate-btn { flex-shrink: 0; white-space: nowrap; padding: 8px 14px; font-size: 13px; }

/* Mobile specific styling for modal position */
@media (max-width: 639px) {
    .download-modal-content { max-width: 100%; border-radius: 16px 16px 0 0; align-self: flex-end; max-height: 85vh; width: 100%; }
    .download-options-container { padding: 16px 20px; grid-template-columns: 1fr; }
}

/* ===================================================================
   PRESETS SECTION
   =================================================================== */

.presets-section { 
    padding: var(--mobile-padding); 
    background: var(--bg-primary); 
    border-top: 1px solid var(--border); 
    order: 3;
}

.presets-header { 
    margin: 0 0 var(--mobile-padding) 0; 
    font-size: 20px; 
    font-weight: 700; 
    color: var(--text-primary);
    text-align: center;
}

.preset-category { 
    margin-bottom: 24px; 
}

.preset-category-title { 
    margin: 0 0 16px 0; 
    font-size: 14px; 
    font-weight: 700; 
    color: var(--text-secondary); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
}

.presets-grid { 
    display: grid;
}

.preset-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.preset-item:focus,
.preset-item:focus-visible {
    outline: none !important;
}

/* ===================================================================
   RESPONSIVE BREAKPOINTS
   =================================================================== */

@media (min-width: 768px) {
    :root {
        --mobile-padding: 20px;
        --mobile-gap: 16px;
    }
    
    .gradient-app {
        margin: 10px;
        border-radius: var(--radius);
        min-height: auto;
    }
    
    .app-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        padding: 20px;
    }
    
    .preview-section {
        order: 1;
    }
    
    .controls-container {
        order: 2;
    }
    
    .presets-section {
        order: 3;
        grid-column: 1 / -1;
    }
    
    .preview-area {
        height: 350px;
    }
    
    .gradient-bar-wrapper {
        height: 48px;
    }
    
    .color-stop {
        width: 28px;
        height: 28px;
    }
    
    .editor-section {
        display: grid;
        grid-template-columns: 1fr 1fr auto;
        gap: 16px;
        align-items: end;
    }
    
    .settings-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
        align-items: start;
    }
    
    .actions-section {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .gradient-app {
        max-width: 1400px;
        margin: 20px auto;
        border-radius: var(--radius-lg);
    }
    
    .app-header {
        padding: 32px 32px 24px 32px;
    }
    
    .app-header h1 {
        font-size: 32px;
    }
    
    .app-main {
        padding: 24px;
        gap: 24px;
    }
    
    .preview-area {
        height: 400px;
    }
    
    .color-stop {
        width: 24px;
        height: 24px;
    }
    
    .color-stop:hover {
        transform: translate(-50%, -50%) scale(1.25);
    }
    
    .presets-section {
        padding: 32px;
    }
    
    .presets-header {
        font-size: 24px;
        margin-bottom: 24px;
    }
}

@media (max-width: 480px) {
    .download-modal-content {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        align-self: flex-end;
        max-height: 85vh;
    }
    
    .download-modal-header {
        padding: 16px 20px;
    }
    
    .download-options-container {
        padding: 16px 20px;
    }
}

/* ===================================================================
   FULLSCREEN & UTILITY STYLES
   =================================================================== */

.fullscreen-overlay { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100vh;
    z-index: 9999; 
    cursor: zoom-out; 
    opacity: 0; 
    transition: opacity 0.3s ease-in-out; 
    touch-action: manipulation;
}

.fullscreen-overlay.visible { 
    opacity: 1; 
}

.toast-message {
    position: fixed !important;
    top: 20px !important;
    left: 16px !important;
    right: 16px !important;
    max-width: none !important;
    border-radius: var(--radius-sm) !important;
    font-size: 14px !important;
    text-align: center !important;
    z-index: 10001 !important;
}

.hidden { 
    display: none !important; 
}

button:focus-visible,
input:focus-visible,
.radio-label:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
    border-radius: 10px;
}

.color-stop,
.preset-item,
.btn,
.radio-label {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

@supports (padding: max(0px)) {
    .app-header {
        padding-left: max(var(--mobile-padding), env(safe-area-inset-left));
        padding-right: max(var(--mobile-padding), env(safe-area-inset-right));
        padding-top: max(var(--mobile-padding), env(safe-area-inset-top));
    }
    
    .app-main {
        padding-left: max(var(--mobile-padding), env(safe-area-inset-left));
        padding-right: max(var(--mobile-padding), env(safe-area-inset-right));
    }
    
    .presets-section {
        padding-left: max(var(--mobile-padding), env(safe-area-inset-left));
        padding-right: max(var(--mobile-padding), env(safe-area-inset-right));
        padding-bottom: max(var(--mobile-padding), env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-secondary: #000000;
    }
}