/* Generator Page Styles */

/* ==============================================
   GENERATOR PAGE — SAFE MODERN POLISH
   Visual-only refinements. No layout movement.
   ============================================== */

/* Tattoo Generator - Rebuilt Layout */
.tg-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
    margin-top: 64px;
    overflow: hidden;
    position: relative;
    background: var(--bg-gradient);
}

@media (max-width: 768px) {
    .tg-layout {
        height: calc(100vh - 64px);
        margin-top: 64px;
    }
}

/* Page specific overrides */

/* Generator desktop header token overrides (consumed by desktop-glass-unify.css). */
.generator-page {
    /* Single header layer on generator (see desktop-glass-unify.css) */
    --generator-header-bg: transparent;
    --generator-header-border: var(--header-glass-border);
    --generator-header-backdrop: none;
}

.generator-page .btn {
    padding: 8px 16px;
    font-size: 0.8rem;
}

.stencil-top-reset-btn {
    height: 32px;
    padding: 0 12px;
    margin-right: 10px;
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1;
}

.stencil-top-reset-btn:hover {
    border-color: var(--glass-border-strong);
    background: rgba(255, 255, 255, 0.1);
}

/* Preview Feed / Stack */
/* Main Content Layout */
.tg-view-wrapper {
    display: flex;
    flex: 1;
    height: 100%;
    overflow: hidden;
    position: relative;
    gap: var(--space-4);
    padding: var(--space-4);
    /* STYLE / UI NOTES: Visible gap between images */
    gap: 16px;
}

@media (max-width: 1023px) {
    .tg-view-wrapper {
        flex-direction: column;
        padding: 8px;
        gap: 16px;
        /* STYLE / UI NOTES: Visible gap */
    }
}

/* Active Preview Area */
.tg-main-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    min-height: 400px;
}

.tg-active-image-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

#tg-main-preview {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.6s ease;
}

/* History Sidebar */
.tg-history-sidebar {
    width: 200px;
    background: rgba(2, 6, 23, 0.4);
    backdrop-filter: blur(10px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: var(--transition-base);
}

@media (max-width: 1023px) {
    .tg-history-sidebar {
        width: 100%;
        height: 120px;
        border-left: none;
        border-top: 1px solid var(--glass-border);
    }
}

.history-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--glass-border);
    text-align: center;
}

.history-header h3 {
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin: 0;
}

.tg-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    scrollbar-width: none;
}

.tg-history-list::-webkit-scrollbar {
    display: none;
}

@media (max-width: 1023px) {
    .tg-history-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
}

.tg-history-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: var(--transition-base);
    flex-shrink: 0;
}

@media (max-width: 1023px) {
    .tg-history-item {
        width: 80px;
        height: 80px;
    }
}

.tg-history-item:hover {
    border-color: var(--neon-green);
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-green-glow);
}

.tg-history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Slide-Up Animation Effects */
.slide-up-exit {
    animation: slideUpExit 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideUpExit {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-100px) scale(0.8);
        opacity: 0;
    }
}

.slide-up-enter {
    animation: slideUpEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideUpEnter {
    0% {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* History Stack & Active Frame */
/* History Stack List Container */
.tg-stack-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 32px !important;
    /* Increased gap for visibility */
    padding: var(--space-4) !important;
    align-items: center !important;
    width: 100% !important;
}

.tg-stack-item,
.tg-active-frame {
    width: 100%;
    height: auto;
    min-height: 420px;
    margin-bottom: 24px;
    /* Safety gap */
    background: transparent;
    border: none;
    backdrop-filter: none;
    border-radius: var(--radius-lg);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
    flex-shrink: 0;
    transition: var(--transition-base);
    padding: 0;
}

@media (min-width: 1024px) {
    .tg-stack-item {
        max-width: 560px;
        height: 85vh;
        max-height: 800px;
        margin: 0 auto 32px auto !important;
        position: relative;
    }
}

.tg-stack-item:hover {
    border-color: var(--glass-border-strong);
    transform: translateY(-4px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);
}

.tg-stack-item:hover .image-header-row {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mobile Image Sizing (<1024px) */
.tg-stack-item img,
.tg-preview {
    width: 100%;
    height: auto;
    object-fit: contain;
    padding: 0;
}

@media (max-width: 1023px) {
    .tg-stack-item img {
        max-height: 60vh;
        max-width: 90%;
        margin: 0 auto;
    }
}

/* New Universal Stacking Styles */
.tg-stack-img-wrap {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

@media (min-width: 1024px) {
    .tg-stack-img-wrap {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.tg-stack-img-wrap img {
    width: 100%;
    display: block;
}

/* New Download Header Row */
.image-header-row {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    padding: 4px 0 12px;
    z-index: 20;
    transition: var(--transition-base);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@media (min-width: 1025px) {
    .image-header-row {
        position: absolute;
        top: -18px;
        right: 10px;
        width: auto;
        padding: 0;
        opacity: 1 !important;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        z-index: 100;
    }

    .tg-image-actions {
        top: -42px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .tg-stack-item img {
        max-height: 100%;
        max-width: 100%;
        object-fit: contain;
    }
}

.tg-stack-download {
    background: rgba(16, 185, 129, 0.8) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tg-stack-download:hover {
    background: var(--neon-green) !important;
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--accent-green-glow);
}

.tg-stack-download svg {
    stroke: white !important;
    width: 18px;
    height: 18px;
}

/* Image Actions (Download / Edit / Delete) */
.tg-image-actions {
    position: absolute;
    top: -42px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    gap: 8px;
    /* Space between buttons */
    z-index: 20;
}

.tg-stack-btn {
    background: rgba(0, 0, 0, 0.5);
    /* Slightly darker for better visibility */
    border: 1px solid var(--glass-border-strong);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: var(--transition-base);
    text-decoration: none;
    /* For download/edit links */
}

.tg-stack-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

/* Button variants */
.tg-stack-btn.download:hover {
    background: var(--neon-green);
    color: #020617;
    border-color: var(--neon-green);
}

.tg-stack-btn.edit:hover {
    background: var(--neon-green);
    color: #020617;
    border-color: var(--neon-green);
}

.tg-stack-btn.remix:hover {
    background: var(--neon-green);
    color: #020617;
    border-color: var(--neon-green);
}

.tg-stack-btn.delete:hover {
    background: #ef4444;
    /* Red for Delete */
    color: white;
    border-color: #ef4444;
}

/* iPad/tablet only: completely lock viewport. Only image history scrolls. */
@media (min-width: 768px) and (max-width: 1024px) {
    html,
    body.generator-page {
        height: 100%;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        touch-action: none !important;
    }

    body.generator-page {
        position: fixed;
        inset: 0;
        width: 100%;
    }

    body.generator-page .tg-layout {
        height: calc(100svh - 64px);
        min-height: calc(100svh - 64px);
        overflow: hidden !important;
    }

    body.generator-page .tg-sidebar {
        height: 100% !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
    }

    body.generator-page .tg-stack-container {
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
    }

    body.generator-page .tg-history-list {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain !important;
        touch-action: pan-y;
    }
}

/* iPad landscape (coarse pointer) can be wider than 1024px; keep same app-like lock. */
@media (orientation: landscape) and (pointer: coarse) and (min-width: 901px) and (max-width: 1366px) {
    html,
    body.generator-page {
        height: 100%;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        touch-action: none !important;
    }

    body.generator-page {
        position: fixed;
        inset: 0;
        width: 100%;
    }

    body.generator-page .tg-layout {
        height: calc(100svh - 64px);
        min-height: calc(100svh - 64px);
        overflow: hidden !important;
    }

    body.generator-page .tg-sidebar {
        height: 100% !important;
        overflow-y: auto !important;
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
    }

    body.generator-page .tg-stack-container,
    body.generator-page .tg-history-list {
        overscroll-behavior: contain !important;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y !important;
    }
}

/* Mobile adjustments if needed */
@media (max-width: 768px) {
    .tg-image-actions {
        top: -34px;
        right: 12px;
        left: auto;
        transform: none;
        gap: 6px;
    }

    .tg-stack-btn {
        width: 36px;
        height: 36px;
    }

    .tg-stack-btn svg {
        width: 18px;
        height: 18px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .tg-image-actions {
        top: -46px;
    }
}

/* Loading State */
.tg-generating-loader {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    color: var(--neon-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulse 1.5s infinite;
    text-shadow: 0 0 20px var(--accent-green-glow);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-top-color: var(--neon-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.tg-preview.slide-up {
    animation: slideUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Empty State */
.tg-empty-state {
    text-align: center;
    color: var(--text-dim);
    margin: auto;
    transform: translateY(-5vh);
    /* Nudge up slightly from center */
    font-size: 1.2rem;
    max-width: 400px;
    background: var(--glass-bg);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(var(--glass-blur));
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), var(--glass-inner-glow);
}

/* Error Message */
.tg-error-msg {
    text-align: center;
    color: #ff4444;
    font-size: 1.1rem;
    max-width: 300px;
    background: rgba(2, 6, 23, 0.8);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 68, 68, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 15;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.tg-error-msg p {
    margin: 0;
    line-height: 1.6;
    font-weight: 500;
}

/* Fixed Composer (Base/Mobile) */
.tg-composer {
    position: fixed;
    bottom: var(--space-4);
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 95%;
    max-width: 900px;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-strong);
    border-radius: var(--radius-lg);
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), var(--glass-inner-glow);
    transform: translateY(calc(-1 * var(--kb-offset, 0px)));
    transition: transform 0.2s ease-out;
}

/* Fix: Elevate composer above header when expanded to help prioritize hit area */
.tg-composer.tg-composer--expanded {
    z-index: 2500;
}

.tg-composer-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tg-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 4px;
}

.neg-icon-n {
    font-family: 'Unbounded', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1;
}

.tg-prompt-wrapper {
    flex: 1;
}

.tg-icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
}

.tg-icon-btn:hover,
.tg-icon-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--neon-green);
    border-color: var(--neon-green);
    box-shadow: 0 0 15px var(--accent-green-glow);
}

.tg-params-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 4px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look */
}

.tg-params-row::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar for Chrome/Safari */
}

.tg-param-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 4px 10px;
    flex-shrink: 0;
    /* Prevent items from shrinking */
}

.tg-param-group label {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-weight: 800;
}

.tg-param-group input,
.tg-mini-select {
    background: transparent;
    border: none;
    color: var(--neon-green);
    font-family: 'Unbounded', sans-serif;
    font-size: 16px;
    /* CRITICAL: Must be 16px to prevent iOS zoom/floating keyboard */
    font-weight: 700;
    outline: none;
    text-align: center;
    padding: 2px;
}

.tg-mini-select {
    text-align: left;
    max-width: 110px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    appearance: none;
    background: rgba(255, 255, 255, 0.03) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 6px center;
    border: 1px solid var(--glass-border);
    color: var(--neon-green);
    border-radius: 12px;
    padding: 2px 20px 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
}

.tg-mini-select option {
    background: var(--deep-black);
    color: var(--neon-green);
}

.res-group input {
    width: 48px;
    color: var(--neon-green);
}

.x-sep {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.tg-param-group input[id*="strength"],
.tg-param-group input[id*="steps"] {
    width: 32px;
    color: var(--neon-green);
}

/* Negative Popup (Bubble) */
.tg-neg-popup {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 10px;
    width: 280px;
    background: rgba(2, 6, 23, 0.98);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border-strong);
    border-radius: var(--radius-md);
    padding: 15px;
    display: none;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    z-index: 1001;
    transform-origin: bottom left;
    animation: bubblePopup 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bubblePopup {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.neg-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.neg-popup-header span {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
}

#tg-neg-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.tg-neg-popup textarea {
    width: 100%;
    min-height: 80px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--neon-green);
    padding: 10px;
    font-family: inherit;
    font-size: 16px;
    /* CRITICAL: Must be 16px to prevent iOS zoom/floating keyboard */
    resize: none;
    outline: none;
}

.tg-neg-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--glass-border-strong);
}

/* Controls Row */
.tg-controls-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 20px;
}

.tg-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
}

.tg-strength-num {
    width: 75px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    text-align: center;
    font-size: 0.9rem;
    font-family: 'Unbounded', sans-serif;
    outline: none;
}

.tg-strength-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    outline: none;
}

.tg-strength-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--neon-green);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 15px var(--accent-green-glow);
    transition: var(--transition-fast);
}

.tg-strength-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent-purple);
}

/* Desktop parity: Generator brush slider should match Sketch desktop slider */
@media (min-width: 1025px) {
    .tg-body .tg-strength-slider {
        -webkit-appearance: none;
        appearance: none;
        height: 14px;
        border-radius: 999px;
        background:
            linear-gradient(180deg, rgba(34, 197, 94, 0.16) 0%, rgba(2, 6, 23, 0.06) 100%),
            linear-gradient(90deg, rgba(16, 185, 129, 0.9) 0%, rgba(16, 185, 129, 0.78) 52%, rgba(13, 45, 38, 0.72) 100%);
        border: 1px solid rgba(16, 185, 129, 0.36);
        box-shadow:
            inset 0 1px 1px rgba(34, 197, 94, 0.2),
            inset 0 -1px 2px rgba(2, 6, 23, 0.58),
            0 4px 12px rgba(2, 6, 23, 0.34);
    }

    .tg-body .tg-strength-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        border: 1px solid rgba(15, 23, 42, 0.9);
        background:
            radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 0.98) 45%, rgba(226, 232, 240, 0.95) 75%, rgba(203, 213, 225, 0.92) 100%);
        box-shadow:
            0 4px 10px rgba(2, 6, 23, 0.35),
            0 0 0 1px rgba(15, 23, 42, 0.45),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset -3px -4px 6px rgba(148, 163, 184, 0.35);
        cursor: pointer;
    }

    .tg-body .tg-strength-slider::-moz-range-track {
        height: 14px;
        border-radius: 999px;
        border: 1px solid rgba(16, 185, 129, 0.36);
        background:
            linear-gradient(180deg, rgba(34, 197, 94, 0.16) 0%, rgba(2, 6, 23, 0.06) 100%),
            linear-gradient(90deg, rgba(16, 185, 129, 0.9) 0%, rgba(16, 185, 129, 0.78) 52%, rgba(13, 45, 38, 0.72) 100%);
        box-shadow:
            inset 0 1px 1px rgba(34, 197, 94, 0.2),
            inset 0 -1px 2px rgba(2, 6, 23, 0.58),
            0 4px 12px rgba(2, 6, 23, 0.34);
    }

    .tg-body .tg-strength-slider::-moz-range-thumb {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        border: 1px solid rgba(15, 23, 42, 0.9);
        background:
            radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 0.98) 45%, rgba(226, 232, 240, 0.95) 75%, rgba(203, 213, 225, 0.92) 100%);
        box-shadow:
            0 4px 10px rgba(2, 6, 23, 0.35),
            0 0 0 1px rgba(15, 23, 42, 0.45),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset -3px -4px 6px rgba(148, 163, 184, 0.35);
        cursor: pointer;
    }
}

/* Mobile/Tablet: Hide Desktop Sidebar */
@media (max-width: 1023px) {
    .tg-sidebar {
        display: none !important;
    }
}

/* Sidebar Specific Styles (Shared for visibility but hidden by default) */
.sidebar-section {
    margin-bottom: var(--space-2);
}

.sidebar-section label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: var(--space-2);
}

.tg-sidebar-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--neon-green);
    padding: var(--space-3);
    font-family: inherit;
    font-size: 16px;
    /* CRITICAL: Must be 16px to prevent iOS zoom/floating keyboard */
    resize: vertical;
    min-height: 140px;
    outline: none;
    transition: var(--transition-base);
}

.tg-sidebar-textarea:focus {
    border-color: var(--neon-green);
    background: rgba(255, 255, 255, 0.08);
}

.tg-collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: var(--space-3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: var(--transition-base);
}

.tg-collapsible-header:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.tg-collapsible-content {
    padding-top: var(--space-3);
}

.tg-sidebar-dropdown {
    width: 100%;
    appearance: none;
    background: rgba(255, 255, 255, 0.03) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 12px center;
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 6px 32px 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition-base);
}

.tg-sidebar-dropdown:hover,
.tg-sidebar-dropdown:focus {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--neon-green);
    box-shadow: 0 0 15px var(--accent-green-glow);
}

.tg-sidebar-dropdown option {
    background: var(--deep-black);
    color: white;
    padding: 10px;
}

.tg-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.tg-resolution-row {
    display: flex;
    gap: 0;
}

.res-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0 var(--space-2);
    transition: var(--transition-base);
}

.res-input-wrap:focus-within {
    border-color: var(--neon-green);
    background: rgba(255, 255, 255, 0.08);
}

.tg-prompt-textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--neon-green);
    padding: 10px 4px;
    resize: none;
    height: 44px;
    /* Fixed initial height */
    max-height: 200px;
    font-family: inherit;
    font-size: 16px;
    /* CRITICAL: Must be 16px to prevent iOS zoom/floating keyboard */
    outline: none;
    line-height: 1.4;
    transition: height 0.2s ease-in-out;
    overflow-y: hidden;
}

.res-divider {
    color: var(--text-dim);
    font-size: 1rem;
    padding: 0 var(--space-2);
    font-weight: 300;
}

.tg-sidebar-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
}

.tg-sidebar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--neon-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-green-glow);
}

.tg-sidebar-generate-btn {
    width: 100%;
    background: var(--neon-green);
    color: #020617;
    border: none;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: var(--transition-base);
    box-shadow: 0 0 20px var(--accent-green-glow);
}

.tg-sidebar-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 35px var(--accent-green-glow);
}

.tg-generate-btn#tg-generate-btn {
    background: var(--neon-green) !important;
    color: var(--deep-black) !important;
    box-shadow: 0 0 20px var(--accent-green-glow), 0 0 40px rgba(16, 185, 129, 0.2);
    border: 1px solid var(--neon-green);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 10;
    overflow: hidden;
    /* Hide text content on phone portrait - icon only */
    font-size: 0;
    line-height: 0;
}

.tg-generate-btn#tg-generate-btn:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.8), 0 0 60px rgba(34, 197, 94, 0.4);
}

.tg-generate-btn#tg-generate-btn svg {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    stroke: #020617;
    /* Ensure icon is dark */
    position: relative;
    z-index: 1;
    /* SVG stays above any text background */
}

.mobile-only {
    display: none;
}

@media (max-width: 1023px) {
    .mobile-only {
        display: flex;
    }
}

.desktop-only {
    display: flex;
}

@media (max-width: 1023px) {
    .desktop-only {
        display: none;
    }
}

/* PC/Desktop Layout (Width >= 1024px) - High-End Unified UI */
@media (min-width: 1024px) {
    .tg-layout {
        display: flex;
        flex-direction: row;
        height: 100vh;
        margin-top: 0;
        padding-top: 64px;
        padding-bottom: 0;
        background: var(--deep-black);
        overflow: hidden;
    }

    .tg-container {
        display: grid;
        grid-template-columns: 320px 1fr;
        gap: var(--space-4);
        height: calc(100vh - 64px);
        overflow: visible;
        padding-bottom: var(--space-4);
    }

    .tg-main-content {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    .tg-stack-container {
        flex: 1;
        overflow-y: auto;
        padding: var(--space-4);
        /* scroll-behavior: smooth; DISABLED to prevent visible jumps */
        /* scroll-behavior: smooth; */
        scrollbar-width: thin;
        scrollbar-color: var(--glass-border) transparent;
    }

    /* Animation kept for items */
    .tg-stack-item {
        position: relative;
        /* animation: stackSlideIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; DISABLED */
    }

    @keyframes stackSlideIn {
        from {
            opacity: 0;
            transform: translateY(50px) scale(0.95);
        }

        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }


    .tg-sidebar {
        display: block;
        width: 300px;
        height: 100%;
        background: rgba(2, 6, 23, 0.98);
        border-right: none;
        /* Removed Divider */
        padding: var(--space-4);
        padding-top: var(--space-2);
        overflow-y: visible;
        /* For bubble overlay */
        flex-shrink: 0;
        z-index: 100;
    }

    .tg-main-content {
        flex: 1;
        height: 100%;
        overflow-y: auto;
        background: var(--bg-gradient);
    }

    .tg-composer {
        display: none !important;
    }
}

.tg-preview-area {
    padding: var(--space-4);
    width: 100%;
    max-width: 1100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.tg-active-frame {
    width: 100%;
    height: 85vh;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.8);
    border-radius: 24px;
    backdrop-filter: blur(20px);
    margin-top: -40px;
    /* Moves image slightly up as requested */
}

/* Sidebar Refinements */
.sidebar-section {
    margin-bottom: var(--space-2);
}

.tg-sidebar-textarea {
    min-height: 140px;
    /* Taller */
    padding: var(--space-2);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}

.neg-textarea {
    min-height: 24px;
    /* Very small */
    font-size: 0.75rem;
    opacity: 0.8;
    color: var(--neon-green);
}

.tg-sidebar-textarea:focus {
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.08);
    opacity: 1;
}

/* Resolution Boxes (Integrated) */
.tg-res-row {
    display: flex;
    gap: var(--space-2);
}

.res-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition-base);
}

.res-box:focus-within {
    border-color: var(--accent-purple);
    background: rgba(255, 255, 255, 0.08);
}

.res-tag {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-dim);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.res-box input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--neon-green);
    padding: 8px 10px;
    font-size: 0.85rem;
    font-family: 'Unbounded', sans-serif;
    outline: none;
    text-align: center;
}

.tg-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dual-row {
    gap: 12px;
}

.label-input-group {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.label-input-group label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    white-space: nowrap;
}

/* Strength Controls */
.strength-input-wrap {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 2px 6px;
}

.strength-input-wrap input {
    width: 45px;
    background: transparent;
    border: none;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--accent-green-glow);
    font-family: 'Unbounded', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-align: center;
    outline: none;
}

/* Slider Knob (Thumb) */
.tg-sidebar-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
    margin-top: 10px;
}

.tg-sidebar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--neon-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-green-glow);
    transition: transform 0.2s ease;
}

.tg-sidebar-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: var(--space-2);
}

.tg-sidebar-generate-btn {
    padding: 12px;
    font-size: 0.85rem;
}

.tg-sidebar button,
.tg-sidebar .btn,
.tg-sidebar-generate-btn,
.tg-generate-btn {
    align-items: center;
    justify-content: center;
}

.tg-sidebar-textarea,
.tg-sidebar-dropdown,
.tg-num-input,
.tg-select-trigger,
.tg-mini-select-trigger {
    color: var(--text-white);
    border-color: var(--glass-border-strong);
}

#v2-image-box {
    border: 1px solid var(--glass-border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

@media (min-width: 901px) {
    .tg-layout {
        display: flex;
        flex-direction: row;
        height: calc(100vh - 64px);
        margin-top: 64px;
        padding-top: 0;
        overflow: visible;
    }

    .tg-sidebar {
        display: flex;
        flex-direction: column;
        width: 300px;
        height: calc(100vh - 64px);
        padding: 16px;
        overflow: visible;
        flex-shrink: 0;
        box-sizing: border-box;
    }

    .tg-main-content {
        flex: 1;
        height: calc(100vh - 64px);
        overflow: hidden;
    }

    .tg-stack-container {
        height: 100%;
        overflow-y: auto;
    }

    .tg-sidebar .sidebar-section {
        flex: 1 1 auto;
        margin-bottom: 10px;
        min-height: 0;
    }

    .tg-sidebar .sidebar-section:first-child {
        padding-top: 20px;
    }

    .tg-sidebar .sidebar-section label {
        margin-bottom: 8px;
    }

    .tg-sidebar #tg-prompt-side {
        flex: 0 0 120px;
        min-height: 120px;
        height: 120px;
        resize: none;
    }

    .tg-sidebar #tg-negative-prompt {
        min-height: 48px;
    }

    .tg-sidebar .tg-custom-select,
    .tg-sidebar .tg-res-row,
    .tg-sidebar .dual-row {
        flex: 0 0 auto;
        gap: 10px;
    }

    .tg-sidebar .tg-label-row {
        margin-bottom: 6px;
    }

    .tg-sidebar .tg-sidebar-slider {
        margin-top: 6px;
    }

    .tg-sidebar .sidebar-footer {
        flex: 0 0 auto;
        margin-top: auto;
        padding-top: 0;
    }

    .tg-sidebar #tg-credit-display-desktop {
        margin-bottom: 6px !important;
    }
}

#v2-download {
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border-strong);
    color: var(--text-white);
}

#v2-error {
    color: var(--accent-purple);
}

/* STABILITY GUARDRAIL: Desktop Generator strength slider must match Sketch desktop slider. */
@media (min-width: 1025px) {
    .tg-sidebar #tg-strength-side.tg-sidebar-slider {
        -webkit-appearance: none !important;
        appearance: none !important;
        height: 14px !important;
        border-radius: 999px !important;
        background:
            linear-gradient(180deg, rgba(34, 197, 94, 0.16) 0%, rgba(2, 6, 23, 0.06) 100%),
            linear-gradient(90deg, rgba(16, 185, 129, 0.9) 0%, rgba(16, 185, 129, 0.78) 52%, rgba(13, 45, 38, 0.72) 100%) !important;
        border: 1px solid rgba(16, 185, 129, 0.36) !important;
        box-shadow:
            inset 0 1px 1px rgba(34, 197, 94, 0.2),
            inset 0 -1px 2px rgba(2, 6, 23, 0.58),
            0 4px 12px rgba(2, 6, 23, 0.34) !important;
    }

    .tg-sidebar #tg-strength-side.tg-sidebar-slider::-webkit-slider-thumb {
        -webkit-appearance: none !important;
        appearance: none !important;
        width: 12px !important;
        height: 12px !important;
        border-radius: 50% !important;
        border: 1px solid rgba(15, 23, 42, 0.9) !important;
        background:
            radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 0.98) 45%, rgba(226, 232, 240, 0.95) 75%, rgba(203, 213, 225, 0.92) 100%) !important;
        box-shadow:
            0 4px 10px rgba(2, 6, 23, 0.35),
            0 0 0 1px rgba(15, 23, 42, 0.45),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset -3px -4px 6px rgba(148, 163, 184, 0.35) !important;
        cursor: pointer !important;
    }

    .tg-sidebar #tg-strength-side.tg-sidebar-slider::-moz-range-track {
        height: 14px !important;
        border-radius: 999px !important;
        border: 1px solid rgba(16, 185, 129, 0.36) !important;
        background:
            linear-gradient(180deg, rgba(34, 197, 94, 0.16) 0%, rgba(2, 6, 23, 0.06) 100%),
            linear-gradient(90deg, rgba(16, 185, 129, 0.9) 0%, rgba(16, 185, 129, 0.78) 52%, rgba(13, 45, 38, 0.72) 100%) !important;
        box-shadow:
            inset 0 1px 1px rgba(34, 197, 94, 0.2),
            inset 0 -1px 2px rgba(2, 6, 23, 0.58),
            0 4px 12px rgba(2, 6, 23, 0.34) !important;
    }

    .tg-sidebar #tg-strength-side.tg-sidebar-slider::-moz-range-thumb {
        width: 12px !important;
        height: 12px !important;
        border-radius: 50% !important;
        border: 1px solid rgba(15, 23, 42, 0.9) !important;
        background:
            radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 1) 0%, rgba(248, 250, 252, 0.98) 45%, rgba(226, 232, 240, 0.95) 75%, rgba(203, 213, 225, 0.92) 100%) !important;
        box-shadow:
            0 4px 10px rgba(2, 6, 23, 0.35),
            0 0 0 1px rgba(15, 23, 42, 0.45),
            inset 0 1px 0 rgba(255, 255, 255, 1),
            inset -3px -4px 6px rgba(148, 163, 184, 0.35) !important;
        cursor: pointer !important;
    }
}


@media (max-width: 1024px) {
    .tg-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .mobile-only {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    .tg-main-content {
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Mobile/tablet stack layout */
    .tg-stack-container {
        height: 100%;
        overflow-y: auto;
        padding-bottom: 250px;
        /* More space to scroll past prompt box */
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* Scroll from top */
        align-items: center;
    }

    /* Gap handled by global .tg-stack-list */
    .tg-stack-list {
        padding: 16px;
    }

    .tg-generating-loader {
        padding-bottom: 80px;
        /* Force loader safely above composer without hiding image */
    }

    .tg-composer {
        box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.02);
    }

    .tg-prompt-wrapper {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.10);
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.06),
            0 8px 24px rgba(0, 0, 0, 0.16);
    }

    .tg-prompt-wrapper:focus-within {
        border-color: var(--neon-green);
        background: rgba(255, 255, 255, 0.08);
    }

    .tg-prompt-textarea {
        color: var(--text-white);
    }

    .tg-prompt-textarea::placeholder {
        color: #94a3b8;
    }
}

@media (max-width: 768px) {
    .tg-composer {
        border-radius: 28px;
        width: 96%;
        bottom: 0;
    }
}

/* Tablet portrait prompt width */
@media (orientation: portrait) and (min-width: 600px) and (max-width: 1024px) {
    .tg-prompt-textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Tablet (601–1024): use same prompt/composer colors as phone — inherit
   @media (max-width: 1024px) rules above; avoid !important overrides that
   removed the green focus ring and tweaked borders vs narrow phones. */

/* Storage Notice Modal Specifics */
#tg-storage-notice .tg-modal {
    border-color: var(--neon-green);
    box-shadow: 0 0 50px rgba(16, 185, 129, 0.2);
}

#tg-storage-notice h2 {
    background: linear-gradient(to right, #fff, var(--neon-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.2rem;
}

#tg-storage-notice p {
    font-size: 0.95rem;
    color: #e2e8f0;
}

/* Tutorial Modal Specifics */
.tg-tutorial-content {
    width: 92vw;
    max-width: 720px;
    padding: 20px;
    border-color: var(--neon-green);
    box-shadow: 0 0 60px rgba(16, 185, 129, 0.15);
}

.tg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.tg-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: white;
}

.tg-close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.tg-close-btn:hover {
    color: white;
}

.tg-video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: #000;
    border: 1px solid var(--glass-border);
}

.tg-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.slide-out {
    animation: slideOutModal 0.5s forwards;
}

@keyframes slideOutModal {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

.tg-watch-tutorial-btn {
    display: none !important;
}

.tg-watch-tutorial-btn:hover {
    background: var(--neon-green);
    color: #020617;
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-green-glow);
}

.tg-watch-tutorial-btn svg {
    stroke: currentColor;
}

@media (max-width: 768px) {
    .tg-watch-tutorial-btn {
        display: none !important;
    }
}

.tg-watch-tutorial-btn {
    display: none !important;
}

.tg-watch-tutorial-btn:hover {
    background: var(--neon-green);
    color: #020617;
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-green-glow);
}

.tg-watch-tutorial-btn svg {
    stroke: currentColor;
}

@media (max-width: 768px) {
    .tg-watch-tutorial-btn {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .tg-param-group input {
        font-size: 14px;
    }

    #tg-mic-btn {
        display: none;
    }
}

/* Widescreen only: Swap order of Generate Button and Credits */
@media (min-width: 1024px) {
    .sidebar-footer {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    #tg-generate-btn-side {
        order: 1;
    }

    #tg-credit-display-desktop {
        order: 2;
    }
}

/* Custom Searchable Dropdown */
.tg-custom-select {
    position: relative;
    width: 100%;
}

.tg-select-trigger {
    background: rgba(255, 255, 255, 0.03);
    /* Match param group bg */
    border: 1px solid var(--glass-border);
    padding: 10px 12px;
    border-radius: 12px;
    /* Match other inputs */
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.8rem;
    transition: var(--transition-base);
}

.tg-select-trigger:hover {
    border-color: var(--neon-green);
    background: rgba(255, 255, 255, 0.05);
}

.tg-select-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: #0a0a0a;
    border: 1px solid var(--glass-border-strong);
    border-radius: 12px;
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    max-height: 80vh;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tg-select-menu.open {
    display: flex;
}

.tg-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0; /* Keep search sticky */
}

.tg-style-search {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    padding: 8px 12px;
    border-radius: 8px;
    color: white;
    outline: none;
    font-size: 0.8rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.tg-style-search:focus {
    border-color: var(--neon-green);
}

.tg-style-options {
    flex: 1;
    overflow-y: auto;
    max-height: 400px;
    padding-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.tg-style-options::-webkit-scrollbar {
    width: 4px;
}

.tg-style-options::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.tg-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tg-option:hover,
.tg-option.selected {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.tg-option.selected::after {
    content: '✓';
    color: var(--neon-green);
    font-weight: bold;
}

/* Generator + Sketch style dropdown visibility polish (visual-only) */
:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-select-menu {
    background: linear-gradient(180deg, rgba(7, 18, 16, 0.95) 0%, rgba(2, 6, 23, 0.94) 100%);
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow:
        0 16px 44px rgba(2, 6, 23, 0.78),
        0 0 24px rgba(16, 185, 129, 0.12);
}

:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-search-wrap {
    background: rgba(8, 24, 21, 0.78);
    border-bottom-color: rgba(16, 185, 129, 0.22);
}

:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-style-search {
    background: rgba(2, 6, 23, 0.66);
    border-color: rgba(16, 185, 129, 0.28);
    color: #e2e8f0;
}

:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-style-search::placeholder {
    color: rgba(203, 213, 225, 0.88);
}

:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-option {
    color: rgba(226, 232, 240, 0.92);
}

:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-option:hover,
:is(#tg-style-container-side, #tg-style-container-mobile, #qe-style-container-desktop, #qe-style-container-mobile) .tg-option.selected {
    background: rgba(16, 185, 129, 0.18);
    color: #f8fafc;
}

/* Mobile specific overrides */
.tg-mini-select-container {
    position: relative;
    max-width: 140px;
    /* Limit width in mobile bar */
}

.tg-mini-select-trigger {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 2px 20px 2px 8px;
    /* Room for arrow */
    border-radius: 12px;
    color: white;
    font-family: 'Unbounded', sans-serif;
    font-size: 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.tg-mini-select-trigger::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid white;
    opacity: 0.7;
}

/* On mobile, the dropdown should perhaps pop up or be absolute positioned carefully */
.tg-composer .tg-select-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    /* Override any restricted width */
    margin: 0;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 2005;
    /* Above composer */
    animation: slideUpMenu 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUpMenu {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.tg-custom-select .tg-select-menu .tg-search-wrap {
    background: transparent;
    /* Cleaner on bottom sheet */
    padding: 16px;
}

.tg-custom-select .tg-select-menu .tg-style-options {
    max-height: 50vh;
}

/* ==============================================
   GENERATOR PAGE — SAFE MODERN POLISH OVERRIDES
   CSS-only, visual polish only, no layout changes
   ============================================== */

.tg-layout {
    background: var(--bg-gradient);
}

.tg-sidebar,
.tg-composer,
.tg-neg-popup,
.tg-empty-state,
.tg-select-menu {
    background: rgba(7, 18, 16, 0.76);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.32),
        0 0 36px rgba(34, 197, 94, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.10),
        inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.tg-sidebar {
    background: rgba(5, 13, 24, 0.86);
    border-right-color: rgba(255, 255, 255, 0.06);
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.34),
        0 0 28px rgba(34, 197, 94, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.tg-sidebar-textarea,
.tg-prompt-wrapper,
.tg-select-trigger,
.tg-mini-select-trigger,
.res-box,
.strength-input-wrap,
.tg-style-search,
.tg-neg-popup textarea {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.10);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 8px 24px rgba(0, 0, 0, 0.16);
}

.sidebar-section label,
.tg-param-group label,
.history-header h3 {
    letter-spacing: 0.04em;
    color: #cbd5e1;
}

.tg-sidebar-textarea,
.tg-prompt-textarea,
.tg-style-search,
.tg-num-input,
.tg-neg-popup textarea {
    color: var(--text-white);
}

.tg-sidebar-textarea::placeholder,
.tg-prompt-textarea::placeholder,
.tg-style-search::placeholder,
.tg-neg-popup textarea::placeholder {
    color: #94a3b8;
}

.tg-sidebar-generate-btn,
#tg-generate-btn,
.tg-icon-btn,
.tg-stack-btn,
.tg-stack-download {
    transition:
        transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        background 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        border-color 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
        color 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tg-sidebar-generate-btn,
#tg-generate-btn {
    box-shadow:
        0 10px 28px rgba(34, 197, 94, 0.18),
        0 0 26px rgba(34, 197, 94, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.20);
}

.tg-sidebar-generate-btn:hover,
#tg-generate-btn:hover {
    box-shadow:
        0 14px 34px rgba(34, 197, 94, 0.22),
        0 0 34px rgba(34, 197, 94, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.tg-icon-btn,
.tg-stack-btn,
.tg-stack-download {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tg-icon-btn:hover,
.tg-stack-btn:hover,
.tg-stack-download:hover {
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.24),
        0 0 20px rgba(34, 197, 94, 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tg-stack-item,
.tg-active-frame {
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.24));
}

.tg-stack-img-wrap {
    border-radius: calc(var(--radius-md) + 2px);
}

.tg-stack-item img,
.tg-preview,
#tg-main-preview {
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.42),
        0 0 24px rgba(34, 197, 94, 0.04);
}

.tg-empty-state {
    border-color: rgba(255, 255, 255, 0.10);
}

.tg-generating-loader {
    text-shadow:
        0 0 16px rgba(34, 197, 94, 0.28),
        0 0 32px rgba(34, 197, 94, 0.12);
}

.tg-select-trigger:hover,
.tg-mini-select-trigger:hover,
.tg-style-search:focus,
.tg-sidebar-textarea:focus,
.tg-neg-popup textarea:focus,
.tg-num-input:focus {
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow:
        0 0 0 1px rgba(34, 197, 94, 0.22),
        0 10px 24px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tg-option {
    transition:
        background 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
        color 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tg-option:hover,
.tg-option.selected {
    background: rgba(255, 255, 255, 0.08);
}

