/* public/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg-dark: #050505;
    --bg-card: rgba(20, 20, 20, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --accent: #a855f7;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --font-main: 'Inter', sans-serif;
    --font-display: 'Plus Jakarta Sans', sans-serif;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg-dark);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    background-color: var(--bg-dark);
    background-image: none;
    /* Remove arrow if possible or keep it */
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Ultra-Only Elements Visibility */
.settings-icon.ultra-only {
    display: none !important;
    /* Hidden by default */
}

.settings-icon-container.ultra-active .settings-icon.ultra-only {
    display: flex !important;
    /* Show in Ultra mode */
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.3);
}

.field-grid label.full-width {
    grid-column: 1 / -1;
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

/* --- Navigation --- */
#top-menu-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    background: rgba(5, 5, 5, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 2000;
    transition: all 0.3s ease;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

#top-menu-bar>* {
    pointer-events: auto;
    /* Re-enable clicks for children */
}

.menu-group-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 2001;
}

.brand a {
    pointer-events: auto;
    display: block;
    position: relative;
    z-index: 2002;
    cursor: pointer;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

/* --- Credits & Profile --- */
#credits-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 12px;
}

.buy-credits-btn {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.buy-credits-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

#credit-display {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

#profile-button {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s var(--ease-out);
}

#profile-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

#profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: #111;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    min-width: 180px;
    display: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    animation: slideDown 0.2s var(--ease-out);
}

#profile-dropdown.show {
    display: block;
}

#profile-dropdown a {
    display: block;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.2s;
}

#profile-dropdown a:hover {
    background: var(--bg-glass);
    color: #fff;
}

/* --- Hero Section --- */
.generator-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    width: 100%;
    z-index: 10;
    animation: fadeUp 0.8s var(--ease-out);
    transition: all 0.5s var(--ease-out);
}

.hero-text {
    transition: all 0.5s var(--ease-out);
    max-height: 300px;
    opacity: 1;
    overflow: hidden;
}

body.has-results .hero-text {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

body.has-results .generator-hero {
    justify-content: flex-end;
    padding-bottom: 40px;
}

body.has-results .input-interface {
    padding: 14px;
    gap: 12px;
    transform: translateY(0);
}

body.has-results .prompt-input {
    min-height: 60px;
    font-size: 1rem;
}

.hero-title {
    font-size: 4rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    background: linear-gradient(180deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.04em;
    padding-bottom: 0.1em;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
    font-weight: 400;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* --- Input Interface --- */
.input-interface {
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(22px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
    width: 100%;
    width: 100%;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s var(--ease-out);
    position: relative;
    z-index: 100;
}

.input-interface.minimized {
    transform: translate(-50%, 120%) !important;
    opacity: 0;
    pointer-events: none;
}

.input-interface:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 30px 100px rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
}

html.has-results .input-interface:focus-within,
body.has-results .input-interface:focus-within {
    transform: translate(-50%, -2px);
}

.prompt-container {
    width: 100%;
}

.prompt-input {
    min-height: 60px;
    resize: none;
    font-size: 1.25rem;
    line-height: 1.5;
    border-radius: 0;
    background: transparent;
    width: 100%;
    border: none;
    color: #fff;
    padding: 0 8px;
    font-family: var(--font-main);
}

.prompt-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.prompt-input:focus {
    outline: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    padding-bottom: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-controls-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ultra-toggle-wrapper {
    display: flex;
    align-items: center;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    height: 24px;
}

.ultra-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
    user-select: none;
}

.ultra-label:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ultra-text {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    transition: color 0.3s ease;
}

.ultra-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

#ultra-mode-toggle:checked+.ultra-label {
    border-color: rgba(139, 92, 246, 0.5);
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

#ultra-mode-toggle:checked+.ultra-label .ultra-text {
    color: #fff;
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
}

#ultra-mode-toggle:checked+.ultra-label .ultra-badge {
    background: linear-gradient(135deg, #8b5cf6, #d946ef);
    color: #fff;
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.4);
}

.settings-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
}

.hidden-toggle {
    display: none;
}

.mode-chip-group {
    display: inline-flex;
    gap: 8px;
}

.mode-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-chip:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.mode-chip.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.mode-chip svg {
    opacity: 0.7;
}

.mode-chip.active svg {
    opacity: 1;
}

.settings-icon-container {
    display: flex;
    align-items: center;
}

.settings-icon-row {
    display: flex;
    gap: 8px;
    display: none;
}

.settings-icon-row.active {
    display: flex;
}

.settings-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.settings-icon.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.settings-icon.boosted {
    color: #fbbf24;
}

.input-controls-right {
    display: flex;
    align-items: center;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.field-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.field-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.field-grid label select,
.field-grid label input[type="text"],
.field-grid label input[type="number"],
.field-grid label input[type="range"] {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 6px 0;
    font-family: inherit;
}

select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    padding: 8px 12px;
    font-family: inherit;
}

.field-grid label input[type="number"]::-webkit-inner-spin-button {
    opacity: 0.4;
}

.slider-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-field strong {
    font-size: 0.95rem;
    color: #fff;
}

.slider-field.disabled {
    opacity: 0.5;
}

.slider-field.disabled strong {
    color: #777;
}

input[type="range"] {
    accent-color: #a855f7;
    width: 100%;
}

.upload-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.upload-tile {
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 16px 20px;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #ddd;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-tile .icon {
    font-size: 1.4rem;
}

.upload-tile:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(99, 102, 241, 0.08);
}

.upload-list {
    flex: 1;
    min-height: 52px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(255, 255, 255, 0.01);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.upload-list .badge {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 0.8rem;
    color: #ddd;
}

.muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.muted.tiny {
    font-size: 0.75rem;
    margin-top: 4px;
}

.toggle-wrapper.small span {
    font-size: 0.85rem;
}

/* Removed old settings-icon styles as they are replaced above */

.panel-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Bottom Controls --- */
.bottom-controls {
    position: fixed;
    bottom: 24px;
    z-index: 1000;
    display: none;
    /* Hidden by default */
    gap: 12px;
}

body.has-results .bottom-controls {
    display: flex;
    /* Show when results exist */
}

.bottom-controls.left {
    left: 24px;
}

.bottom-controls.right {
    right: 24px;
}

.glass-btn {
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.glass-btn svg {
    opacity: 0.8;
}

.glass-btn:hover svg {
    opacity: 1;
}

.settings-panel {
    display: none;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 18px;
    animation: fadeInPanel 0.2s ease;
}

.settings-panel.active {
    display: block;
}

@keyframes fadeInPanel {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

.generation-preview {
    margin-top: 0;
    border: none;
    border-radius: 20px;
    padding: 0;
    background: rgba(5, 5, 5, 0.65);
    backdrop-filter: blur(10px);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

body.has-results .generation-preview {
    margin-top: 0;
    padding: 0;
    border: none;
    max-height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    /* Behind input interface */
    opacity: 1;
    pointer-events: all;
    background: transparent;
    /* No background */
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
    min-height: 32px;
}

/* Results Mode (triggered by JS) */
html.has-results,
body.has-results {
    overflow: hidden;
    /* Prevent page scroll, let grid handle it */
    height: 100%;
    margin: 0;
    padding: 0;
}

html.has-results .input-interface,
body.has-results .input-interface {
    min-height: auto;
    height: auto;
    padding: 20px 0;
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: none;
    width: 90%;
    max-width: 800px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 24px;
    top: auto;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1000;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 
   REMOVED: The rule hiding .generator-hero was causing the entire UI (preview + input) 
   to disappear because they are children of .generator-hero.
   The .hero-text is already hidden by a separate rule above.
*/

html.has-results .preview-container,
body.has-results .preview-container {
    display: block;
    opacity: 1;
    pointer-events: all;
}

.view-toggle-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
}

.view-toggle-btn.visible {
    opacity: 1;
    pointer-events: all;
}

.view-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 200;
    opacity: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.generation-preview:hover .nav-arrow {
    opacity: 0.6;
}

.nav-arrow:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.left {
    left: 20px;
}

.nav-arrow.right {
    right: 20px;
}

.view-toggle-btn.visible {
    opacity: 1;
    pointer-events: all;
}

.view-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* --- Carousel & Grid Views --- */
/* --- Carousel & Grid Views --- */
.preview-grid {
    position: relative;
    width: 100%;
    height: 100vh;
    /* Full screen */
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 20px;
    padding: 80px 7.5vw 20px;
    /* (100 - 85) / 2 */
    margin-bottom: 0;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.3s ease;
}

.preview-grid.ready {
    opacity: 1;
}

.preview-grid::-webkit-scrollbar {
    display: none;
}

/* Grid View Mode (Justified) */
.preview-grid.grid-view {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    height: auto;
    min-height: 80vh;
    padding: 100px 20px 120px;
    /* More bottom padding for input bar */
    overflow-x: hidden;
    overflow-y: visible;
    scroll-snap-type: none;
    gap: 0;
    /* Handled by JS margin */
}

.preview-grid.grid-view .preview-card {
    position: relative;
    /* Width/Height set by JS */
    opacity: 1;
    transform: none;
    pointer-events: all;
    z-index: 1;
    cursor: pointer;
    flex: none;
    margin: 0;
    scroll-snap-align: none;
    border-radius: 8px;
    overflow: hidden;
}

/* Carousel Mode (Default) */
.preview-card {
    flex: 0 0 auto;
    position: relative;
    height: 100%;
    /* Maximize height */
    width: auto;
    aspect-ratio: auto;
    max-width: 85vw;
    /* Very wide */
    border-radius: 0;
    /* Remove rounding for full feel, or keep minimal */
    border: none;
    background: transparent;
    overflow: hidden;
    scroll-snap-align: center;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: pointer;
    box-shadow: none;
    /* Remove shadow to avoid "frame" look */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    /* Faded neighbors */
    transform: scale(0.95);
    /* Subtle scale down */
    filter: blur(0px);
    /* No blur, just fade */
}

/* Active State (Center) */
.preview-card.active {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
    z-index: 10;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
    /* Deep shadow only for active */
}

.preview-card img,
.preview-card video {
    width: auto;
    height: 100%;
    max-height: calc(100vh - 140px);
    /* Keep within screen minus header/padding */
    max-width: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    border-radius: 12px;
    /* Subtle radius */
}

.preview-card img,
.preview-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the calculated box */
    display: block;
    pointer-events: none;
    border-radius: 0;
    /* Let card handle radius */
}

.preview-card.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
    animation: shimmer 1.2s ease infinite;
}

/* Skeleton visibility in carousel */
.preview-card.skeleton {
    width: 60vh;
    /* Fixed width for skeleton */
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
}

.preview-grid.grid-view .preview-card.skeleton {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

@keyframes shimmer {
    from {
        transform: translateX(-100%);
    }

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

.input-interface.generating {
    transform: translateY(6px);
    opacity: 0.95;
}

.select-wrapper {
    position: relative;
    flex: 0 0 180px;
}

.custom-select {
    width: 100%;
    appearance: none;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 16px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-select:hover {
    background: rgba(255, 255, 255, 0.06);
}

.custom-select option {
    background: #111;
    color: #fff;
}

.generate-btn {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #333;
    box-shadow: none;
}

.btn-cost-badge {
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    user-select: none;
}

/* Custom Toggle Switch */
.toggle-wrapper input {
    appearance: none;
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    position: relative;
    transition: background 0.2s;
    cursor: pointer;
    margin: 0;
}

.toggle-wrapper input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.toggle-wrapper input:checked {
    background: var(--primary);
}

.toggle-wrapper input:checked::after {
    transform: translateX(16px);
}

/* --- Loading Overlay --- */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: #050505;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

#loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader-visual {
    width: 200px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 24px;
    position: relative;
}

.loader-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 20px var(--primary);
    transition: width 0.3s ease;
}

.loader-text {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 8px;
    font-weight: 500;
}

.loader-subtext {
    font-family: 'Courier New', monospace;
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0.7;
}

/* --- Animations --- */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

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

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

/* --- My Websites Page Styles --- */
.container {
    max-width: 1000px;
    margin: 100px auto 40px;
    padding: 0 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
}

.websites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.site-card {
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: all 0.3s var(--ease-out);
    position: relative;
    overflow: hidden;
}

.site-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.site-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.site-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.site-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #fff;
    color: #000;
}

.btn-primary:hover {
    background: #e0e0e0;
}

.btn-outline {
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: #fff;
    color: #fff;
}

.delete-site-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: #555;
    cursor: pointer;
    transition: color 0.2s;
}

.delete-site-btn:hover {
    color: #ef4444;
}

/* --- Status Popup (Toast) --- */
#status-popup {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20, 20, 20, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: 50px;
    color: #fff;
    font-size: 0.9rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease-out);
    z-index: 10000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#status-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@keyframes popup {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

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

/* Dynamic Grid Layouts */
/* Dynamic Grid Layouts - Full Page Fill */
.preview-grid.grid-view {
    height: 100vh;
    /* Force full height */
    padding: 100px 20px 40px;
    /* Account for header */
    align-content: stretch;
    grid-auto-rows: 1fr;
    /* Default rows stretch */
}

/* 2 Items: Split vertically */
.preview-grid.grid-view.grid-2 {
    grid-template-columns: 1fr 1fr;
}

/* 3 Items: 1 Big Left, 2 Stacked Right */
.preview-grid.grid-view.grid-3 {
    grid-template-columns: 1.5fr 1fr;
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "main side1"
        "main side2";
}

.preview-grid.grid-view.grid-3 .preview-card:nth-child(1) {
    grid-area: main;
}

.preview-grid.grid-view.grid-3 .preview-card:nth-child(2) {
    grid-area: side1;
}

.preview-grid.grid-view.grid-3 .preview-card:nth-child(3) {
    grid-area: side2;
}

/* 4 Items: 2x2 Grid */
.preview-grid.grid-view.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* 5 Items: 1 Big Left, 4 Small Right (2x2) */
.preview-grid.grid-view.grid-5 {
    grid-template-columns: 1.5fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    grid-template-areas:
        "main side1 side2"
        "main side3 side4";
}

.preview-grid.grid-view.grid-5 .preview-card:nth-child(1) {
    grid-area: main;
}

.preview-grid.grid-view.grid-5 .preview-card:nth-child(2) {
    grid-area: side1;
}

.preview-grid.grid-view.grid-5 .preview-card:nth-child(3) {
    grid-area: side2;
}

.preview-grid.grid-view.grid-5 .preview-card:nth-child(4) {
    grid-area: side3;
}

.preview-grid.grid-view.grid-5 .preview-card:nth-child(5) {
    grid-area: side4;
}

/* 6 Items: 2 Big, 4 Small or 3x2 */
.preview-grid.grid-view.grid-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* 7 Items: 1 Big, 6 Small */
.preview-grid.grid-view.grid-7 {
    grid-template-columns: 1.5fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    grid-template-areas:
        "main side1 side2"
        "main side3 side4"
        "main side5 side6";
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(1) {
    grid-area: main;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(2) {
    grid-area: side1;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(3) {
    grid-area: side2;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(4) {
    grid-area: side3;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(5) {
    grid-area: side4;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(6) {
    grid-area: side5;
}

.preview-grid.grid-view.grid-7 .preview-card:nth-child(7) {
    grid-area: side6;
}

/* 8 Items: 4x2 */
.preview-grid.grid-view.grid-8 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr 1fr;
}

/* Ensure images cover the area */
.preview-grid.grid-view .preview-card {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.preview-grid.grid-view .preview-card img,
.preview-grid.grid-view .preview-card video {
    height: 100%;
    width: 100%;
    object-fit: cover;
}