* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    /* Base font size - adjust this value to change all font sizes */
    font-size: 14px;
    line-height: 150%;
}

body {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    font-weight: 400;
    color: #fff;
    background-color: #4A4852;
    padding: 0px;
    overflow: hidden; /* Prevent page-level scrolling; panels manage their own scroll */
}

/* Loading overlay: full-viewport video intro */
body.loading {
    overflow: hidden;
}
/* Loading spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading card styles */
.loading-card {
    position: relative;
    background-color: #23242A;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(94, 33, 255, 0.2);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.loading-card .panel-label {
    position: absolute;
    left: -22px;
    top: 24px;
    width: 23px;
    height: auto;
    background: #23242A;
    border-radius: 9px 0 0 9px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    padding: 25px 0px;
}

.loading-card .panel-label span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    color: #7A5BFF;
    font-weight: 200;
    letter-spacing: 1px;
    font-size: 12px;
}

/* Hide legacy panel labels inside redesigned Preferences card */
#controls .panel-label { display: none !important; }

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

.loading-message {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0.9;
    animation: softPulse 1.2s ease-in-out infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(94, 33, 255, 0.2);
    border-top: 3px solid #5E21FF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Loading card fade-in animation */
.loading-card.fade-in {
    opacity: 0;
    animation: fadeInQuick 220ms ease both;
}

/* Generated content fade-in animation */
.generated-content.fade-in {
    opacity: 0;
    animation: fadeInQuick 260ms ease both;
}
#loading-overlay {
    position: fixed;
    z-index: 999999; /* above everything */
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 1s ease;
}

#loading-overlay.is-fading {
    opacity: 0;
    pointer-events: none;
}

#loading-overlay video#loading-video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* cover the container */
    object-position: center center;
    display: block;
}

/* Typography Basic styles */

button, textarea, input, option, select {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
    font-weight: 400;
}
.primary-btn {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}
.tabs, .tab {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}
.carousel-action-btn {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}
a, a:visited {
    color: #fff;
}

.container {
    width: auto;
    float: left;
}

#logo {
    width: 124px;
    margin: 2.5rem 0 0 1.8rem;
}

/* Telegram-style chat bubble notification (matches auth bubble style/speed) */
#app-notification {
    position: relative;
    display: inline-block;
    margin-left: 16px;
    margin-top: 8px;
    padding: 12px 18px;
    background: rgba(12, 13, 20, 0.96);
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.5;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 8px rgba(35, 36, 42, 0.5), 0 1px 3px rgba(0, 0, 0, 0.6);
    max-width: 350px;
    white-space: normal;
    opacity: 0;
    transform: translateY(10px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease-out;
    backdrop-filter: blur(18px);
    z-index: 1000;
}

/* Show state with smooth animation (matches .auth-bubble.visible) */
#app-notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Hide state (matches .auth-bubble.fade-out) */
#app-notification.hide {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

/* Soft pulse animation for notification text during generation */
@keyframes softPulse {
    0% { 
        opacity: 1; 
        transform: translateX(0) scale(1);
    }
    50% { 
        opacity: 0.7; 
        transform: translateX(0) scale(0.98);
    }
    100% { 
        opacity: 1; 
        transform: translateX(0) scale(1);
    }
}

#app-notification.pulsing {
    animation: softPulse 1.5s ease-in-out infinite;
}

/* Typing indicator animation */
@keyframes typingDots {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

#app-notification.typing::after {
    content: '...';
    animation: typingDots 1.4s infinite;
    margin-left: 2px;
}

/* Disabled state visual for generate buttons during processing */
.carousel-action-btn:disabled,
.carousel-action-btn[disabled],
.primary-btn:disabled,
.primary-btn.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Disabled state visual for textareas during generation */
textarea:disabled,
textarea[disabled] {
    opacity: 0.5;
    background-color: rgba(255, 255, 255, 0.02);
    cursor: not-allowed;
}

/* Quick, elegant fade-in utilities */
@keyframes fadeInUpQuick {
    0% { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInQuick {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Animation keyframes for page load and section changes */
@keyframes fadeInSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0px);
    }
}

@keyframes fadeInSlideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0px);
    }
}

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

.fade-in-up {
    opacity: 0;
    animation: fadeInUpQuick 260ms ease both;
}

.fade-in {
    opacity: 0;
    animation: fadeInQuick 220ms ease both;
}

/* Apply subtle image fade-in separate from container */
.result-item img.will-fade-in {
    opacity: 0;
    transition: opacity 600ms ease-out;
}
.result-item img.will-fade-in.is-visible {
    opacity: 1;
}

/* Hide legacy floating notifications UI if present */
#notifications-container { display: none !important; }
.upload-success-notification,
.upload-info-notification,
.upload-error-notification { display: none !important; }
.moodboard-image-counter { /* keep visible as requested, but avoid bottom-right popup look */
    position: static !important;
}




/* Column layout */

/* Main UI container wrapper for all fixed UI elements */
#main-wrap {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1; /* Above canvas background (z-index: 0) */
    container-type: size; /* Enable container query units (cqw/cqh) */
}

/* Restore pointer events for all child elements */
#main-wrap > * {
    pointer-events: auto;
}

#head {
    position: fixed;
    top: 0;
    left: 0;
    height: 86px;
}

#canvas {
    width: auto;
    max-width: 90vw;
    border-radius: 4px;
    margin: 50px auto;
    display: inline-block;
    background-color: transparent;
    box-shadow: none;
    cursor: move; /* Indicate the canvas is draggable */
}

#side-right {
    display: none;
    width: 0;
}

/* Left-stack tabs: horizontal tab row above prompt (replaces former #nav in #side-left) */
#left-stack-tabs {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    width: 100%;
    flex-shrink: 0;
    margin-bottom: 3px;
}

#left-stack-tabs .tab-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: transparent;
    border: none;
    color: #757482;
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.2s ease, color 0.2s ease;
}

#left-stack-tabs .tab-btn:hover {
    color: white;
    cursor: pointer;
}

#left-stack-tabs .tab-btn.tab.active {
    color: #fff;
}

#left-stack-tabs .tab-btn img {
    margin: 0;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

#left-stack-tabs .tab-btn#magic-board-tab img {
    width: 22px;
    margin-left: -1px;
}

#left-stack-tabs .tab-btn span {
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 1;
    max-width: none;
    margin-left: 0;
    padding: 0;
    transform: none;
}

#left-stack-tabs .tab-btn#magic-board-tab span {
    padding-top: 2px;
}

#left-stack-tabs.first-load {
    animation: fadeInSlideRight 0.6s ease-out forwards;
}

/* No placeholder needed in #canvas */
#canvas-placeholder { display: none !important; }

/* Position #controls to align with left-stack and have a 20px margin from the left */
/* Reusable UI container */
.uibox {
    background-color: #000000;
    padding: 0.875rem; /* 14px / 16px = 0.875rem */
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

#controls {
    margin-top: 0;
    margin-left: 20px; /* 20px gap from left-stack */
}

/* Style #controls to look like a panel card with left label */
#controls.uibox {
    width: 700px;
    background-color: #23242A;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    position: relative;
}

/* Remove panel-label styling for #controls */

/* Table-like alignment inside controls */
#controls.uibox .row { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; margin-bottom: 10px; }
#controls.uibox .row label { color: #ddd; font-weight: 500; }
#controls.uibox .row input,
#controls.uibox .row select,
#controls.uibox .row textarea { width: 100%; }

.tab-btn img {
    width: 18px;
    height: auto;
    margin: 2px;
}
.tab-btn#video-generation-tab img {
    width: 18px;
    height: auto;
}
.tab-btn span {
    display: block;
}

/* Bottom-right controls */
#bottom-right-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 30000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

#bottom-right-controls .tab-btn {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-start;
    color: #fff;
    text-decoration: none;
    transition: all 0.2s ease;
    gap: 0px;
}

#bottom-right-controls .tab-btn:hover {
    cursor: pointer;
}

#bottom-right-controls .tab-btn img {
    width: 20px;
    height: 20px;
    margin-bottom: 0;
    flex-shrink: 0;
    transition: all 0.3s ease;
    transform-origin: right center;
}

#bottom-right-controls .tab-btn:hover img {
    transform: scale(1.2);
}

#bottom-right-controls .tab-btn span {
    font-size: 10px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    margin-right: 5px;
}

#bottom-right-controls .tab-btn:hover span {
    opacity: 1;
    transform: translateY(0);
}

#app-version {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 30000;
    font-size: 10px;
    color: #666;
    font-weight: 400;
}

/* User menu container */
#user-menu-container {
    position: absolute;
    top: 14px;
    right: 20px;
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 0px;
}

/* Gallery view toggle in user menu (icon + label, 28px gap to next element) */
#user-menu-container #gallery-view-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin-right: 28px;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px 0;
}

#user-menu-container #gallery-view-toggle img {
    width: 20px;
    height: 20px;
}

#user-menu-container #gallery-view-toggle span {
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
}

#user-icon-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

#user-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#user-icon-btn img {
    width: 20px;
    height: 20px;
}

/* Credits display in header */
#user-credits-display {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    color: #ffffff;
    margin-top: 2px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    background-color: rgba(49, 48, 61, 1);
    padding: 4px 13px 3px 11px;
}

#user-credits-display.credits-ready {
    opacity: 1;
    transform: translateY(0);
}

#user-credits-display .credits-icon {
    width: 15px;
    height: 15px;
    margin-top: -3px;
}

#user-credits-display .credits-amount {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}

/* User popup card */
#user-popup-card {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 340px;
    background: #1E1E25;
    border-radius: 12px;
    padding: 16px;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
    visibility: hidden;
}

#user-popup-card:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

#user-popup-card > * {
    margin-bottom: 12px;
}

#user-popup-card > *:last-child {
    margin-bottom: 0;
}

#user-email-display {
    font-size: 0.9rem;
    color: #fff;
    font-weight: 500;
    padding: 11px 0 11px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#user-credits-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #d7d7e6;
    padding: 6px 3px 9px 10px;
}

#user-credits-amount {
    font-weight: 600;
    color: #FF9E9E;
    padding-right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#user-credits-amount .credits-icon {
    width: 13px;
    height: 13px;
}
#user-credits-label { color: #5E5E86 }
#user-credits-container {
    background: #292934;
    border-radius: 16px;
    padding: 12px;
    width: 106%;
    margin-left: -3%;

    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
    text-transform: uppercase;
}

/* Fade-in class for user data */
.user-data-loaded {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.user-data-loaded #user-email-display,
.user-data-loaded #user-credits-amount {
    opacity: 1 !important;
}
#user-popup-card button {
    border: none;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border-radius: 6px;
    color: #d7d7e6;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
    text-transform: uppercase;
}
#user-popup-card button#buy-credits-btn {
    border: none;
    width: 104%;
    padding: 14px 12px;
    margin: 0 0 -2% -2%;
    background-color: transparent;
    border-radius: 11px;
    color: #d7d7e6;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
    text-transform: uppercase;
    opacity: 1;
    background: #131319;
}
#user-popup-card button#buy-credits-btn img { opacity: 0.5 }
#user-popup-card button#buy-credits-btn:hover img { opacity: 1 }
#user-popup-card button:hover { cursor: pointer; }
#user-popup-card button#logout-btn-new,
#user-popup-card button#change-password-btn { opacity: 0.5; margin-bottom: 0 }
#user-popup-card button#logout-btn-new:hover { color: #ff4757; opacity: 1; }
#user-popup-card button#change-password-btn:hover { opacity: 1; }

#user-popup-card button img {
    width: 16px;
    height: 16px;
}

/* Close button for user popup */
#user-popup-card button.user-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: url('/img/icon-close-button.png') center center no-repeat;
    background-size: 16px 16px;
    border: none;
    color: transparent;
    font-size: 0;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 1;
}

.user-popup-close:hover {
    background: rgba(0,0,0,0.8) url('/img/icon-close-button.png') center center no-repeat;
    background-size: 16px 16px;
}

/* Hover interaction for desktop */
@media (hover: hover) {
    #user-menu-container:hover #user-popup-card {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        visibility: visible;
    }
    
    /* Keep popup visible when hovering over it */
    #user-popup-card:hover {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        visibility: visible;
    }
}

#logout-btn-new:hover {
    border-color: #ff4757;
    color: #ff4757;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    html {
        font-size: 14px; /* Slightly smaller base font size on mobile */
    }
    
    .container {
        flex-direction: column;
    }
    
    #canvas, #side-right {
        width: 100%;
        margin-bottom: 1.25rem; /* 20px / 16px = 1.25rem */
    }
    
    #controls {
        width: 100%;
    }
    
    /* Adjust bottom-right controls for mobile */
    #bottom-right-controls {
        bottom: 10px;
        right: 10px;
        gap: 8px;
    }
    
    /* Adjust app version for mobile */
    #app-version {
        bottom: 10px;
        left: 10px;
    }
    
    #user-menu-container {
        top: 10px;
        right: 10px;
    }
    
    #user-popup-card {
        right: -20px;
        min-width: 260px;
    }
}

h1, h2 {
    margin-bottom: 1.25rem; /* 20px / 16px = 1.25rem */
    color: #fff;
}

h1 {
    font-size: 2rem; /* 32px / 16px = 2rem */
}

h2 {
    font-size: 1.5rem; /* 24px / 16px = 1.5rem */
}

h3 {
    font-size: 1.25rem; /* 20px / 16px = 1.25rem */
}

/* Settings Panel */

.settings-container {
    margin-top: 1.875rem; /* 30px */
    padding: 0.9375rem; /* 15px */
    background-color: #f5f5f5;
    border-radius: 0.5rem; /* 8px */
    max-width: 64rem; /* 1024px */
    margin-left: auto;
    margin-right: auto;
}

.settings-container h3 {
    margin-top: 0;
    margin-bottom: 0.9375rem; /* 15px */
    color: #333;
}


.settings-group label { display: grid; grid-template-columns: 90px 1fr; align-items: center; font-weight: 500; cursor: pointer; gap: 8px; }

.settings-group input[type="checkbox"] { margin-right: 0.625rem; /* 10px */ transform: scale(1.2); width: 18px; height: 18px; }

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    cursor: pointer;
}

.toggle-switch .toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 26px;
    transition: background 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-checkbox:checked + .toggle-slider {
    background: #4CAF50;
}

.toggle-checkbox:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-switch:hover .toggle-slider {
    background: rgba(255, 255, 255, 0.25);
}

.toggle-checkbox:checked + .toggle-slider:hover {
    background: #45a049;
}

.setting-description { margin-top: 6px; margin-left: 1.5625rem; /* 25px */ font-size: 0.85rem; color: #9C9C9C; line-height: 1.4; }

.settings-status { padding: 0.625rem; /* 10px */ background-color: rgba(255,255,255,0.02); border: 1px dashed rgba(255,255,255,0.08); border-radius: 10px; margin-top: 16px; }

#status-text {
    font-weight: bold;
    color: #dc3545; /* red for error */
}

#status-text.success {
    color: #28a745; /* green for success */
}

/* Canvas Position Reset Button */
.reset-btn {
    transition: all 0.3s ease;
    font-weight: 500;
    border: 2px solid transparent;
}

.reset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

.reset-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.2);
}
.tabs {
    background-color: rgba(30, 30, 37, 0.46);
    border-radius: 2px 24px 24px 24px;
    padding: 18px;
}

#bottom-right-controls .tab-btn {
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.75rem; /* 16px / 16px = 1rem */
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    display: block;
    text-align: center;
    margin: 0;
    line-height: 130%;
    text-transform: uppercase;
    font-weight: 200;
}

#bottom-right-controls .tab-btn.active {
    opacity: 1;
    /* background-color: #23242A; */
    border-radius: 4px;
    line-height: 130%;
}

span.grey {
    color: #9C9C9C
}

/* Tab content container with flex layout */
.tab-content {
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* Magic Board split layout removed in favor of floating panels */

/* Panel Card base */
.panel-card {
    position: relative;
    /* box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.03); */

}
.panel-card.magic-board-surface {
    padding: 0px 0px 14px 0px;
}
#left-stack:has(#t2i-prompt-floating:not(.hidden)) .magic-board-surface,
#left-stack:has(#video-prompt-floating:not(.hidden)) .magic-board-surface {
    display: none !important;
}
.panel-card .panel-body {
    /* border: 1px solid rgba(255,255,255,0.08); */
    border-radius: 12px;

}

/* Vertical left label strip */
/* Protruding side label */
/* removed panel-label styles per redesign */

/* Prompt specific */
.prompt-surface .prompt-body .textarea-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.prompt-surface .prompt-body textarea {
    background: rgb(40, 41, 51);
    border-radius: 5px;
    min-height: 64px;
    height: auto;
    resize: none;
    padding: 0.4rem 0.7rem;
    line-height: 150%;
    font-size: 1rem;
    overflow-y: auto;
    padding: 10px 14px;
}

/* SuperPrompt row: below textarea, left-aligned */
.prompt-surface .prompt-body .enhance-prompt-row {
    margin-top: 0.25rem;
    flex-shrink: 0;
    text-align: left;

    position: absolute;
    bottom: 0;
    width: 100%;

    border-radius: 0 0px 5px 5px;
    width: 100%;
    text-align: center;
    background: linear-gradient(to top, rgba(32, 32, 41, 0.86), rgba(33, 33, 41, 0.78) 42.86%, rgba(32, 32, 43, 0.39) 53.78%, rgba(33, 33, 42, 0));
}

.prompt-surface .panel-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 0;
    margin-top: 5px;
}

/* Superprompt / Enhance Prompt link inside textarea */
.prompt-surface .textarea-wrapper .enhance-prompt-icon {
    width: 10px;
    height: 10px;
    margin-right: 0.35rem;
    vertical-align: middle;
}
.prompt-surface .textarea-wrapper .enhance-prompt-link {
    position: static;
    align-self: flex-start;
    margin-top: 0.25rem;
    color: #6a6a71;
    text-decoration: none;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    pointer-events: auto;
    white-space: nowrap;
    transition: all 0.1s ease;
    border-radius: 5px;
    font-weight: 400;
    background: linear-gradient(to top, rgba(32, 32, 40, 1), rgba(32, 32, 40, 1) 36.97%, rgba(30, 30, 37, 0.59));
    border-radius: 5px 5px 0px 0px;
    padding: 5px 9px;
}

.prompt-surface .textarea-wrapper .enhance-prompt-link:hover {
    color: #fff;
    background-color: rgba(30, 30, 30, 1);
}

.tab-top-content {
    flex: 1 0 auto;
}

.tab-bottom-content {
    margin-top: auto;
}

.hidden {
    display: none;
}

.form-group {
    margin-bottom: 0.9375rem; /* 15px / 16px = 0.9375rem */
}

label {
    display: block;
    margin-bottom: 0.3125rem; /* 5px / 16px = 0.3125rem */
}

.form-group > label {
    text-transform: uppercase;
    letter-spacing: 0px;
    font-size: 0.7rem;
    color: #ff9d9e;
    font-weight: 600;   
}

input[type="number"],
input[type="text"],
select,
textarea {
    padding: 0.625rem; /* 10px / 16px = 0.625rem */
    border: none;
    border-radius: 0.25rem; /* 4px / 16px = 0.25rem */
    font-size: 1rem; /* 16px / 16px = 1rem */
    background-color: #34353E;
    color: #fff;
}

input[type="range"] {
    width: 100%;
    max-width: 18.75rem; /* 300px / 16px = 18.75rem */
    margin-right: 0.625rem; /* 10px / 16px = 0.625rem */
}

.full-width {
    width: 100%;
}

button {
    padding: 0.5rem 0.9375rem; /* 8px 15px / 16px = 0.5rem 0.9375rem */
    background-color: transparent;
    border-radius: 0.25rem; /* 4px / 16px = 0.25rem */
    cursor: pointer;
    font-size: 0.875rem; /* 14px / 16px = 0.875rem */
    color: #fff;
}
.results-container {
    width: auto;
    display: inline-block;
}

/* Results floating panel should not constrain the image size */
.results-surface.panel-card {
    width: auto;
    max-width: none;
    padding: 0 !important; /* Remove padding so image can fill entire card */
    /* Background will be controlled by state - placeholder/loading vs image */
}

/* Placeholder and loading states - explicit background to avoid inheritance issues in carousel */
#main-box.is-placeholder,
#main-box.is-loading,
.results-surface.panel-card:has(.placeholder-message),
.results-surface.panel-card:has(.loading-content),
.results-surface.panel-card.loading-card {
    background: rgba(13, 11, 19, 0.26) !important;
}

/* Image state - transparent background */
.results-surface.panel-card:has(> img),
.results-surface.panel-card:has(> video) {
    background: transparent !important; /* Transparent when showing image */
}

/* Ensure results panels show a label like prompt cards */
/* Results label uses the same style; no overrides needed */

/* Ensure results panels auto-size and are placed in normal flow */
.canvas-content .floating-panel.results-surface,
.canvas-content .results-surface {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: block;
    z-index: 3;
}

/* Unified Feed / Gallery carousel should fill the canvas, not be centered like floating cards */
.canvas-content #results-carousel-container {
    position: absolute;
    left: 0;
    top: 0;
    transform: none;
    z-index: 2; /* Below floating panels like prompts, above background */
}

/* Provide baseline z-index for any results-surface (explicit per request) */
.results-surface { z-index: 1; }

/* Always center loading card while generating */
.canvas-content .floating-panel.loading-card {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
}

/* Center loading content vertically within its container */
.loading-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
}

.results-surface .panel-body { /* ensure no extra constraints if present */
    width: auto;
    padding: 0 !important; /* Remove padding so image can fill entire card */
    margin: 0 !important;
    border: none !important;
    /* Background will be controlled by parent state */
}

/* Placeholder and loading states - ensure inner body also has the same background 
#main-box.is-placeholder .panel-body,
#main-box.is-loading .panel-body,
.results-surface.panel-card:has(.placeholder-message) .panel-body,
.results-surface.panel-card:has(.loading-content) .panel-body,
.results-surface.panel-card.loading-card .panel-body {
    background: rgba(13, 11, 19, 0.26) !important;
}
*/
/* Image state - transparent panel-body */
.results-surface.panel-card:has(> img) .panel-body,
.results-surface.panel-card:has(> video) .panel-body {
    background: transparent !important;
}

/* Direct image/video styling in results surface - fill container exactly */
.results-surface > img,
.results-surface > video {
    object-fit: cover !important; /* Fill container while maintaining aspect ratio */
    border-radius: 12px !important; /* Match container radius */
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
}
.results-surface > img:hover,
.results-surface > video:hover {
    cursor: zoom-in;
}
/* All images/videos should fill their container exactly */
.results-surface > img,
.results-surface > video {
    width: 100% !important;
    height: 100% !important;
}

.results-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem; /* 20px / 16px = 1.25rem */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* When we want images sized by viewport, stack them (no grid constraints) */
.results-grid.viewport-sized {
    display: block;
}

/* When there's only one image */
.results-grid:has(.result-item:only-child) { display: block; }

.results-grid:has(.result-item:only-child) .result-item {
    width: 100%;
    max-width: 100%;
}

/* When there are multiple images */
.results-grid:not(:has(.result-item:only-child)) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.result-item {
    position: relative;
    border-radius: 0.25rem; /* 4px / 16px = 0.25rem */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-item img {
    width: 100%;
    max-width: 40vw;
    height: auto;
    display: block;
    object-fit: contain;
    cursor: pointer;
}

/* Aspect-based sizing to avoid flicker using known resolution */
.result-item img.landscape {
    width: 70vw;
    height: auto;
    max-width: 70vw;
    max-height: 80vh;
}

.result-item img.portrait {
    width: auto;
    height: 75vh;
    max-height: 75vh;
}

.result-item img.square {
    width: auto;
    height: 70vh;
    max-height: 70vh;
}

/* Video-specific styles */
.result-item.video-result {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-item video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 0.25rem;
}

.video-info {
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.875rem;
    position: absolute;
    top: 0;
    right: 0;
    border-radius: 0 0 0 0.25rem;
    opacity: 0.8;
}

.video-info p {
    margin: 0.25rem 0;
}
#canvas button {
    background-color: rgba(0, 0, 0, 0.3);
    border: none;
    position: absolute;
    bottom: 20px;
    right: 20px;
    padding: 10px 60px;
}
img#video-preview {
    width: 100%;
    border-radius: 2px;
}
/* Media queries for responsive adjustments */
@media (max-width: 1200px) {
    .results-grid:not(:has(.result-item:only-child)) {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .results-grid:not(:has(.result-item:only-child)) {
        grid-template-columns: 1fr;
    }
    
    .results-container {
        padding: 0 0.5rem;
    }
}

.result-info {
    padding: 0.625rem; /* 10px / 16px = 0.625rem */
    background-color: #f9f9f9;
}

.spinner {
    margin: 0.625rem 0; /* 10px / 16px = 0.625rem */
    color: #666;
}

#image-preview-container {
    margin-top: 0.9375rem; /* 15px */
    max-width: 100%;
}

#image-preview {
    max-width: 100%;
    height: auto;
    border-radius: 0.25rem; /* 4px */
    display: block;
}

/* Upscale preview should fit container like other sections */
#upscale-preview-container {
    margin-top: 0.9375rem; /* 15px */
    max-width: 100%;
}

#upscale-preview {
    width: 100%;
    height: auto;
    border-radius: 0.25rem; /* 4px */
    display: block;
}

/* Image upload container styles */
.image-upload-container {
    position: relative;
    border: 2px dashed #ccc;
    border-radius: 0.5rem; /* 8px */
    padding: 1.5rem; /* 24px */
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.05);
    border-color: #5E21FF;
    width: 100%;
    padding: 10px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.image-upload-container:hover {
    border-color: #7a4bfb;
    background-color: rgba(94, 33, 255, 0.05);
}

.image-upload-container input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-progress-container {
    margin-top: 0.5rem; /* 8px */
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background-color: #5E21FF;
    border-radius: 2px;
    transition: width 0.3s ease;
}
/* Modal styles */
.modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 1.875rem; /* 30px / 16px = 1.875rem */
    border-radius: 0.5rem; /* 8px / 16px = 0.5rem */
    width: 100%;
    max-width: 31.25rem; /* 500px / 16px = 31.25rem */
    box-shadow: 0 0.25rem 0.9375rem rgba(0, 0, 0, 0.2); /* 4px 15px / 16px = 0.25rem 0.9375rem */
}

.modal-content h2 {
    margin-bottom: 0.9375rem; /* 15px / 16px = 0.9375rem */
}

.modal-content input {
    width: 100%;
    margin: 0.9375rem 0; /* 15px / 16px = 0.9375rem */
    padding: 0.625rem; /* 10px / 16px = 0.625rem */
    border: 1px solid #ddd;
    border-radius: 0.25rem; /* 4px / 16px = 0.25rem */
    font-size: 1rem; /* 16px / 16px = 1rem */
}

/* Make sure ranges and their values are on the same line */
.form-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.form-group label {
    width: 100%;
}

.form-group input[type="range"] {
    flex: 1;
    margin-right: 0.625rem; /* 10px / 16px = 0.625rem */
}

.form-group span {
    width: 1.875rem; /* 30px / 16px = 1.875rem */
    text-align: right;
}

/* Separator styles */
.sep {
    position: relative;
}

.sep.top {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.25rem; /* 20px / 16px = 1.25rem */
    margin-top: 1.25rem; /* 20px / 16px = 1.25rem */
}

.sep.bottom {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1.25rem; /* 20px / 16px = 1.25rem */
    margin-bottom: 1.25rem; /* 20px / 16px = 1.25rem */
}

/* Result image styling */
.result-image-container {
    position: relative;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    width: 100%;
    /* aspect-ratio: 1 / 1; */  /* Force a square container */
}

.result-image {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
    display: block;
    border-radius: 0.5rem;
}

/* Save Image Button Styling */
.save-image-btn {
    position: absolute;
    bottom: 0.625rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.28);
    color: white;
    border: 1px solid rgba(255, 255, 255, 1);
    border-radius: 0.25rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
    z-index: 5;
    opacity: 0.9;
    padding-left: 5rem;
    padding-right: 5rem;
    font-weight: 600;
}

.save-image-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
    opacity: 1;
}

.result-image-container:hover .save-image-btn {
    opacity: 1;
}

.info-toggle {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s, opacity 0.2s;
    opacity: 0.7;
}

.info-toggle:hover {
    background-color: rgba(0, 0, 0, 0.8);
    opacity: 1;
}

.info-toggle span {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
}

.image-metadata {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 0.5rem;
    padding: 1rem;
    color: white;
    overflow-y: auto;
    z-index: 5;
}

.image-metadata h4 {
    margin-bottom: 0.75rem;
    text-align: left;
}

.metadata-content {
    font-size: 0.85rem;
}

.metadata-content p {
    margin-bottom: 0.5rem;
    word-wrap: break-word;
    line-height: 1.4;
}

.metadata-content strong {
    color: #3498db;
    margin-right: 0.3rem;
}

/* Make the scrollbar more visible in the metadata */
.image-metadata::-webkit-scrollbar {
    width: 0.5rem;
}

.image-metadata::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.image-metadata::-webkit-scrollbar-thumb {
    background: rgba(52, 152, 219, 0.5);
    border-radius: 0.25rem;
}

.image-metadata::-webkit-scrollbar-thumb:hover {
    background: rgba(52, 152, 219, 0.8);
}

/* Resolution options styling */
.resolution-options {
    display: none; /* Hide the old radio buttons */
}

/* Bottom settings bar removed */

/* Ensure connection overlays never block clicks */
#connections-container,
#connections-container *,
#fallback-connections,
#fallback-connections * {
    pointer-events: none !important;
}

/* Settings group styles for tab-specific settings */
.settings-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Define hover media query for non-touch devices */
:root {
    --hover-media: 'hover';
}

/* Bottom settings bar removed */

/* Setting popup styles */
.setting-popup {
    position: absolute;
    bottom: 48px; /* Position directly above the bottom bar */
    left: 50%;
    transform: translateX(-50%);
    background-color: #000000;
    border: 1px solid #5E21FF;
    border-radius: 8px;
    padding: 20px;
    width: 280px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

/* On devices that support hover, also show popup on hover */
@media (hover: hover) {
    .setting-item:hover .setting-popup {
        display: flex;
    }
    
    .setting-popup:hover {
        display: flex;
    }
}

/* Support for click-based popup activation */
.setting-popup.active {
    display: flex;
}

/* Bottom settings bar removed */

/* Bottom settings bar removed */

/* Create an invisible connection between the item and popup */
.setting-item::after {
    content: '';
    position: absolute;
    width: 100px; /* Even wider connection area */
    height: 20px; /* Shorter connection distance */
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: transparent;
    pointer-events: auto;
    z-index: 1000;
}

.setting-popup::before {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    right: 0;
    height: 15px;
    background-color: transparent;
    z-index: 1001;
}

.setting-popup::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #5E21FF;
}

.setting-popup h4 {
    color: white;
    font-size: 1rem;
    margin: 0 0 8px 0;
    text-align: center;
}

.setting-popup .popup-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: auto;
}

/* Make popup items easier to tap/click */
.setting-popup input[type="range"] {
    width: 100%;
    margin: 0;
    height: 24px;
}

.setting-popup select {
    width: 100%;
    background-color: #23242A;
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 1rem;
    height: 40px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' 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");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
    padding-right: 2rem;
}

.setting-popup .value-display {
    color: white;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 4px;
}

.setting-popup input[type="number"] {
    padding: 8px;
    width: 100%;
    font-size: 1rem;
    background-color: #23242A;
    color: white;
    border: none;
    border-radius: 4px;
    height: 40px;
}
#settings-styles-popup {
    width: 800px;
}
#settings-styles-popup {
    max-width: 90vw;
    overflow: hidden;
}
#settings-styles-popup .popup-controls {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
#settings-styles-popup .style-btn {
    width: 100%;
    min-width: 0; /* allow grid items to shrink within column */
}
#settings-styles-popup .style-btn img {
    width: 100%;
    max-width: 100%;
    height: 100px;
    display: block;
}
#settings-styles-popup .style-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Support unique ids for inline Styles popup per tab */
[id^="settings-styles-popup"] .popup-controls {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    display: block !important; /* inner wrapper will be the grid */
}
[id^="settings-styles-popup"] .popup-controls > div { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: 8px; }
[id^="settings-styles-popup"] .popup-controls > * { grid-column: auto / span 1 !important; }
[id^="settings-styles-popup"] .popup-controls > :nth-child(odd) { grid-column: 1 !important; }
[id^="settings-styles-popup"] .popup-controls > :nth-child(even) { grid-column: 2 !important; }
[id^="settings-styles-popup"] .style-btn { width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: center; grid-column: auto / span 1 !important; }
[id^="settings-styles-popup"] .style-btn img { width: 100%; max-width: 100%; height: 120px; object-fit: cover; border-radius: 6px; display: block; }
[id^="settings-styles-popup"] .style-btn span { display: block; font-size: 12px; color: #d7d7e6; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[id^="settings-styles-popup"] .style-btn.active { outline: 2px solid #5E21FF; }

/* Ensure overlay cloned controls in inline dropdown also use 2-column grid and are full width */
.inline-settings .inline-dropdown-panel .popup-controls {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    display: block !important; /* inner wrapper will be the grid */
}
.inline-settings .inline-dropdown-panel .popup-controls > div { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: 8px; }

/* Override generic inline flex rule for Styles popup specifically */
.inline-settings .setting-popup[id^="settings-styles-popup"] .popup-controls {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.inline-settings .inline-dropdown-panel .popup-controls > * { grid-column: auto / span 1 !important; }
.inline-settings .inline-dropdown-panel .popup-controls > :nth-child(odd) { grid-column: 1 !important; }
.inline-settings .inline-dropdown-panel .popup-controls > :nth-child(even) { grid-column: 2 !important; }
.inline-settings .inline-dropdown-panel .style-btn { width: 100%; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: center; grid-column: auto / span 1 !important; }
.inline-settings .inline-dropdown-panel .style-btn img { width: 100%; max-width: 100%; height: 120px; object-fit: cover; border-radius: 6px; display: block; }
.inline-settings .inline-dropdown-panel .style-btn span { display: block; font-size: 12px; color: #d7d7e6; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-settings .inline-dropdown-panel .style-btn.active { background-color: #5E21FF; }
/* Improve the control items for better tappability */
.control-item {
    padding: 12px;
    background-color: #111113;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    font-weight: 500;
    font-size: 1rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-item:hover {
    background-color: #23242A;
}
.control-item.style-btn {
    border: none;
}
.style-btn img {
    width: auto; height: 100px; object-fit: cover; border-radius: 6px;
}
/* Buttons */
.settings-popup-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.settings-popup-buttons button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
}

.settings-popup-buttons .cancel-btn {
    background-color: #23242A;
    color: white;
}

.settings-popup-buttons .ok-btn {
    background-color: #5E21FF;
    color: white;
}

/* Reset other unnecessary styles */
/* Bottom settings bar removed */

/* No longer need expanded view */
/* Bottom settings bar removed */

/* For the specific tabs - no longer needed */
#text-to-image-content .advanced,
#image-upscale-content .advanced,
#background-removal-content .advanced {
    display: none; /* Redundant - using hidden-advanced class now */
}

/* Advanced sections styling */
.advanced {
    margin-top: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #42434E;
    border-radius: 0.5rem;
    overflow: hidden;
    font-size: 0.9rem;
}

.advanced-header {
    cursor: pointer;
    padding: 0.825rem;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
    transition: background-color 0.2s;
    position: relative;
    z-index: 2;
    user-select: none;
}

.advanced-header:hover {
    background-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.advanced-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    flex-grow: 1;
}

.advanced-toggle {
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.advanced-toggle:before {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #ffffff;
}

.advanced-toggle.open:before {
    transform: rotate(180deg);
}

.advanced.expanded .advanced-toggle {
    transform: rotate(180deg);
}

.advanced-content {
    display: none;
    padding: 1rem;
}

.advanced.expanded .advanced-content {
    display: block;
    background-color: rgba(94, 33, 255, 0.05);
    border-top: 1px solid rgba(94, 33, 255, 0.3);
}

/* Hidden advanced sections for settings bar to access */
.hidden-advanced {
    position: absolute;
    left: -9999px;
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Give the generate buttons more prominence since we have more space */
.primary-btn {
    margin: 0;
    padding: 0.75rem;
    color: #FF9E9E;
    border: none;
    border-radius: 0.25rem; /* 4px / 16px = 0.25rem */
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}
.prompt-body .primary-btn {
    padding: 0.3rem 0;
}

/* The dropdown toggle for advanced settings */
/* Bottom settings bar removed */

/* Bottom settings bar removed */

/* For expanded view, ensure the settings group expands properly */
.settings-expanded .settings-group {
    flex-wrap: wrap;
    width: 100%;
}

/* Bottom settings bar removed */

/* Resolution dropdown styling */
.resolution-select {
    background-color: #23242A;
    color: #fff;
    border: none;
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    border-radius: 3px;
    height: 24px;
}

.resolution-select option {
    background-color: #23242A;
    color: #fff;
    font-size: 0.75rem;
    padding: 0.3rem;
}

/* Expandable Advanced Settings */
.advanced-header,
.advanced-toggle,
.advanced-content {
    display: none; /* Hide completely */
}

/* Advanced settings position */
.tab-content .advanced {
    margin-top: auto;
    margin-bottom: 1rem;
}

/* Put prompt and regular settings at the top */
.tab-content .form-group:not(.advanced) {
    margin-bottom: 0.75rem;
} 


/* nodes connections UI */
.connections-container {
    pointer-events: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1 !important;
    overflow: visible !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Smaller screens adjustment */
/* Bottom settings bar removed */

/* Bottom settings bar removed */

/* Bottom settings bar removed */

/* Bottom settings bar removed */

/* Allow JS to control visibility of the settings bar (no forced overrides) */
/* (Removed forced visibility overrides to enable JS control) */

/* Connections container and SVG styling */
#connections-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; /* lower than cards (5-10), higher than background (0) */
    overflow: visible;
}

#connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

/* Canvas placeholder messages */
#canvas-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Allow clicks to pass through */
}

.placeholder-message {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    text-align: center;
    max-width: 80%;
    pointer-events: none; /* Allow clicks to pass through */
    user-select: none; /* Prevent text selection */
}

/* Center placeholder within results card */
.results-surface { position: relative; }
.results-surface .placeholder-message {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

/* Hide placeholder when results are present */
.results-container:not(:empty) ~ #canvas-placeholder {
    display: none;
}

/* Error message styling */
.error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin: 20px;
    text-align: center;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.error::before {
    content: "❌ ";
    font-size: 1.2em;
    margin-right: 8px;
}

/* No results message styling */
.no-results {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    padding: 40px 20px;
    font-style: italic;
}

/* Magic Board styles */
.magic-board-surface.panel-card,#mb-floating.panel-card{width:20vw}
#mb-floating.panel-card:not(.hidden){height:30vh;min-height:240px;max-height:30vh;display:flex;flex-direction:column}
.magic-board-surface.panel-card{max-height:85vh}
#mb-floating .panel-body{width:100%;flex:1;min-height:0;overflow-y:auto;overflow-x:hidden}
.magic-board-surface .panel-body{max-height:calc(85vh - 36px);overflow-y:auto;overflow-x:hidden}
#magic-board-box,#magic-board-gallery{width:100%;max-width:100%;box-sizing:border-box}
#magic-board-box{
    position:relative;
    background-image: radial-gradient(#2B2B36 1px, transparent 1px);
    background-size: 16px 16px;
    background-color: #1E1E25;

}

/* Tap-to-upload: hidden file input (visually hidden, focusable for a11y) */
.magic-board-file-input-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.magic-board-tap-upload-btn {
    display: none; /* shown only on mobile */
    width: 100%;
    margin-top: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(94, 33, 255, 0.25);
    border: 1px solid rgba(94, 33, 255, 0.5);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.magic-board-tap-upload-btn:hover {
    background: rgba(94, 33, 255, 0.4);
    border-color: rgba(94, 33, 255, 0.7);
}

/* Firefox-specific scrolling fixes for magic board gallery */
@-moz-document url-prefix() {
    #magic-board-gallery {
        height: calc(85vh - 120px) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        scrollbar-width: thin;
        scrollbar-color: rgba(94, 33, 255, 0.5) transparent;
        padding-right: 8px !important;
    }
    
    #mb-floating .panel-body,
    .magic-board-surface .panel-body {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        scrollbar-width: thin;
        scrollbar-color: rgba(94, 33, 255, 0.5) transparent;
    }
}
.magic-board-label { display: none; }
.magic-board-instructions {

    border-radius: 4px;
    padding: 12px;
    /* Fill full height when gallery is empty */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hide when gallery has images */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.magic-board-instructions p {
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    text-align: center;
}

/* Hide instructions when gallery has images - handled by JavaScript */
.magic-board-instructions.hidden {
    opacity: 0;
    visibility: hidden;
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* (Removed old global drag-and-drop overlay styles) */

/* Magic Board image styles */
.magic-board-image {
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: move;
}

.magic-board-image:hover {
    transform: scale(1.02);
}

.magic-board-image:active {
    cursor: grabbing;
}

/* Smooth transitions for dragging */
.magic-board-image.dragging {
    transition: none; /* Disable transitions while dragging for smooth movement */
    z-index: 1001;
}

/* Smooth visibility transitions */
.magic-board-image.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.magic-board-image.visible {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.3s ease;
}

.magic-board-image img {
    pointer-events: none;
}

.magic-board-image-close {
    font-family: Arial, sans-serif;
    line-height: 1;
    transition: all 0.2s ease;
}

.magic-board-image-close:hover {
    background-color: #ff2222 !important;
    transform: scale(1.1);
}

/* Upload loading and animation styles */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.8); }
}

@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translateX(100%); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

@keyframes slideOut {
    from { 
        opacity: 1; 
        transform: translateX(0); 
    }
    to { 
        opacity: 0; 
        transform: translateX(100%); 
    }
}

/* Loading placeholder styles */
.magic-board-loading-placeholder {
    backdrop-filter: blur(2px);
    box-shadow: 0 4px 12px rgba(94, 33, 255, 0.2);
}

/* Vision Board gallery */
.vision-board-surface, #vision-board-box {
    /* Vision Board container styling */
    border-radius: 14px; /* larger, softer radius like mock */
    /*box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); */
}

/* (Removed old magic-board drop-active box styling) */

.magic-board-gallery {
    display: grid;
    gap: 0; /* Remove gap to eliminate spacing between images */
    overflow-x: hidden;
    padding-right: 0; /* Remove extra right padding */
    /* When empty, overlay the entire container */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;

}
.magic-board-gallery .close-button {
    width: 16px;
    height: 16px;
    margin-right: 6px;

    margin-top: 6px;
}
/* When gallery has content, position it normally below instructions */
.magic-board-gallery.has-content {
    position: static;
}

/* Single image: fill 100% width, auto height to fit image aspect ratio */
.magic-board-gallery.is-single {
    grid-template-columns: 1fr;
    height: auto; /* Auto height to fit content */
    overflow: visible; /* No scrolling needed for single image */
}

.magic-board-gallery.is-single .mb-thumb:nth-child(n+2) {
    /* Safety: if duplicate DOM nodes exist in single-image mode, hide extras */
    display: none !important;
}

.magic-board-gallery.is-single .mb-thumb {
    width: 100%;
    height: auto; /* Auto height to fit image's natural aspect ratio */
    max-height: none; /* Remove max-height constraint */
    overflow: hidden;
    border-radius: 10px;
    position: relative;
}

.magic-board-gallery.is-single .mb-thumb img {
    width: 100%;
    height: auto; /* Auto height to maintain aspect ratio */
    object-fit: contain; /* Use contain instead of cover to avoid gaps */
    border-radius: 10px;
    position: relative; /* Change from absolute to relative positioning */
    top: auto;
    left: auto;
    display: block;
    cursor: zoom-in;
}

/* Multi images: 3-per-row grid (same visual language as Gallery View) */
.magic-board-gallery.is-multi {
    position: relative;
    width: 100%;
    height: auto;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.magic-board-gallery .mb-thumb {
    position: relative;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
}

.magic-board-gallery .mb-thumb-inner {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
}

.magic-board-gallery .mb-thumb.newly-added {
    opacity: 0;
    transform: translateY(8px);
    transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.magic-board-gallery .mb-thumb.newly-added.loaded {
    opacity: 1;
    transform: translateY(0);
}

.magic-board-gallery .mb-thumb.removing {
    opacity: 0;
    transform: scale(0.8);
    transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.magic-board-gallery .mb-thumb.repositioning {
    transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Multi: grid cell – aspect-ratio cell, image centered and ratio preserved */
.magic-board-gallery.is-multi .mb-thumb {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.magic-board-gallery.is-multi .mb-thumb img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 3px;
}

/* Connector points for vector lines (anchors) */
/* removed connector points */
/* removed connector styles per redesign */

#mb-connector { right: -6px; top: 24px; }
#prompt-connector { right: -6px; top: 24px; }

@media (max-width: 1024px) {
    #magic-board-content .magic-board-layout { grid-template-columns: 1fr; }
}

/* Base thumb img (single uses full width; multi overrides with centered contain) */
.magic-board-gallery .mb-thumb img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    object-position: center;
    cursor: zoom-in;
}

/* Reuse shared .image-preview-close button, but ensure placement inside thumbs */
.magic-board-gallery .mb-thumb-inner .image-preview-close {
    position: absolute;
    top: 0;
    right: 0;
}

/* Numbered labels on Magic Board images (draggable into prompt) */
.magic-board-gallery .magic-board-image-number {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    pointer-events: auto;
}
.magic-board-gallery .magic-board-image-number:active {
    cursor: grabbing;
}
.magic-board-gallery .magic-board-image-number.dragging {
    opacity: 0.4;
    transform: translateX(-50%) scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Visual cue when dragging image label over Magic Board prompt */
#magic-board-prompt.magic-board-prompt-drop-active {
    outline: 2px solid rgba(94, 33, 255, 0.6);
    outline-offset: 2px;
}

/* Base styles for shared close button when used outside preview containers */
.image-preview-close {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 5;
}

.upload-spinner {
    animation: spin 1s linear infinite;
}

.upload-success-notification {
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}

/* Consistent close button styles */
.close-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: url('/img/icon-close-button.png') center center no-repeat;
    background-size: 20px 20px;
    color: transparent;
    font-size: 0;
    cursor: pointer;
    line-height: 100%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.close-button:hover {
    background: url('/img/icon-close-button.png') center center no-repeat;
    background-size: 20px 20px;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 200ms ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.lightbox-overlay.open { opacity: 1; }

.lightbox-media-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 92vw;
    max-height: 90vh;
}

.lightbox-img,
.lightbox-video {
    max-width: 92vw;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transform: scale(0.98);
    transition: transform 220ms ease;
}

.lightbox-overlay.open .lightbox-img,
.lightbox-overlay.open .lightbox-video { transform: scale(1); }

.lightbox-boundary-msg {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 8px 16px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.9rem;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease;
    z-index: 10001;
}

.lightbox-boundary-msg.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.lightbox-close {
    position: fixed;
    top: 26px;
    right: 26px;
}

/* Enhanced drop zone feedback */
.canvas-container.moodboard-drop-active {
    border: 3px dashed #5E21FF !important;
    background-color: rgba(94, 33, 255, 0.1) !important;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.canvas-container.moodboard-drop-active::after {
    content: '📁 Drop images here to add them to your vision board';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #5E21FF;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    pointer-events: none;
    z-index: 1000;
    animation: pulse 2s infinite;
}

/* Fixed-size generated/loading card: inner content must fit container exactly */
.results-surface.fixed-size, .loading-card.fixed-size { box-sizing: border-box; /* width/height are set inline by JS */ }
.results-surface.fixed-size .panel-body,
.loading-card.fixed-size .panel-body {
    padding: 0; /* avoid shrinking inner image due to panel padding */
    width: 100%;
    height: 100%;
}
.results-surface.fixed-size .results-grid,
.results-surface.fixed-size .result-item {
    width: 100%;
    height: 100%;
}
.results-surface.fixed-size .result-item img,
.results-surface.fixed-size .result-item video {
    border-radius: 4px;
    object-fit: contain;
}
/* Keep download button inside card without pushing layout */
.results-surface.fixed-size .download-btn {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

/* Right-side actions aligned to the result panel */
.result-actions {
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translate(16px, -50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 6;
}
.result-actions .action-btn {
    background: rgba(0,0,0,0.5);
    border: 0;
    color: #fff;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.result-actions .action-btn:hover { background: rgba(0,0,0,0.7); }

/* Mobile: dock actions under the result */
@media (max-width: 768px) {
    .result-actions {
        position: static;
        transform: none;
        flex-direction: row;
        justify-content: center;
        margin-top: 10px;
    }
    /* Left stack above the centered result */
    .left-stack {
        left: 50% !important;
        top: 10vh !important;
        transform: translateX(-50%) !important;
        width: 90vw;
    }
    .canvas-content .floating-panel.prompt-surface,
    .canvas-content .floating-panel.vision-board-surface {
        width: 100% !important;
        max-width: none !important;
    }
}

/* For tablet and smaller laptop screens - ensure left-stack stays in viewport */
@media (min-width: 769px) and (max-width: 1200px) {
    .left-stack {
        left: max(10px, var(--left-stack-x)) !important;
        max-width: min(var(--left-stack-max-width), calc(100vw - max(10px, var(--left-stack-x)) - 20px)) !important;
    }
}

/* Inline settings within prompt card */
.inline-settings {
    margin-top: 6px;
    transition: opacity 180ms ease, transform 180ms ease;
}
.inline-settings .settings-group {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px 6px !important; /* row x column gap */
    width: 100% !important;
    overflow: visible !important; /* no horizontal scroll */
    padding: 0 !important;
}
.inline-settings .setting-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    min-height: 50px;
    width: 100% !important;
    padding: 4px 10px;
    border-radius: 4px;
    background: #1e1e25;
}
.inline-settings .setting-item:hover {
    cursor: pointer;
    background: #151519;
}
/* Label above value, subtle accent like mock */
.inline-settings .setting-item label {
    order: -1;
    margin: 0 0 6px 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #5E5E86;
    text-transform: none;
    letter-spacing: 0.2px;
    text-align: left;
}
.inline-settings .setting-item .current-value {
    font-size: 0.85rem;
    color: #9C9C9C;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
}
/* Compact variant: title and value on one line */
.inline-settings .setting-item.compact { flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; min-height: 32px; }
.inline-settings .setting-item.compact label { order: 0; margin: 0; font-size: 0.85rem; color: #5E5E86; }
.inline-settings .setting-item.compact .current-value { order: 1;     font-size: 0.85rem; }

/* Grid spans by setting type for 2-column layout */
.inline-settings .settings-group .setting-item[data-setting="resolution"] { grid-column: span 2; }
.inline-settings .settings-group .setting-item[data-setting="seed"] { grid-column: span 2; }
.inline-settings .settings-group .setting-item[data-setting="numResults"] { grid-column: span 2; }
.inline-settings .settings-group .setting-item[data-setting="scheduler"] { grid-column: span 2; }

/* Keep Model and Styles as single-column, stacked title/value */
.inline-settings .settings-group .setting-item[data-setting="model"] { grid-column: span 1; }
.inline-settings .settings-group .setting-item[data-setting="styles"] { grid-column: span 2; }

/* Hide popups in inline mode; we'll style/open them later per dropdown */
.inline-settings .setting-popup { display: none !important; }
/* Disable invisible hover connector in inline mode to prevent overlap */
.inline-settings .setting-item::after { content: none !important; pointer-events: none !important; width: 0; height: 0; }
/* Responsive spacing for small screens */
@media (max-width: 900px) {
    .inline-settings .settings-group { grid-template-columns: 1fr; }
}
.inline-settings .setting-popup .popup-controls { display: flex !important; gap: 6px; }
.inline-settings .setting-item label { margin-bottom: 4px; }
/* Keep Styles as a popup */
.inline-settings #settings-styles-popup {
    position: absolute;
    display: none;
}
.inline-settings.hidden { opacity: 0; transform: translateY(-4px); }
.inline-settings:not(.hidden) { opacity: 1; transform: translateY(0); }

/* Ensure the inline settings toggle button remains clickable above inline content */
.prompt-body .inline-settings-toggle {
    position: relative;
    z-index: 2002;
    cursor: pointer;
    margin-left: 0;
    margin-right: auto;
    text-align: left;
    color: #606278;
    min-width: 120px;
    font-size: 1rem;
}
.prompt-body .inline-settings-container.inline-settings {
    position: relative;
    z-index: 1;
    padding-bottom: 6px;
}
/* Extra safety: disable pointer events on hidden popups so they can't intercept clicks */
.inline-settings .setting-popup,
.inline-settings .setting-popup::before,
.inline-settings .setting-popup::after {
    pointer-events: none !important;
}

/* Inline dropdown overlay (covers whole inline-settings area) */
.inline-settings .inline-dropdown-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: stretch;
    justify-content: center;
    background-color: rgba(41, 41, 52, 0.95);
    z-index: 2001; /* below the toggle button, above content */
    border-radius: 14px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    left: -6px;
    top: -6px;
}
.inline-settings .inline-dropdown-overlay.active { display: flex; }
.inline-settings .inline-dropdown-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: 6px;
    width: 100%;
}
.inline-settings .inline-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border-radius: 8px;
    margin-bottom: 6px;
    padding: 4px 10px;
}
.inline-settings .inline-dropdown-title {
    font-size: 0.9rem;
    color: #8b8bb0;
    letter-spacing: 0.6px;
    font-weight: bold
}
/* .inline-settings .inline-dropdown-close uses .close-button base styles */
.inline-settings .inline-dropdown-list {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: auto;
}
.inline-settings .inline-dropdown-option {
    text-align: left;
    padding: 10px;
    color: #9C9C9C;
    border-radius: 8px;
    cursor: pointer;
    border: none;
}
.inline-settings .inline-dropdown-list input[type="range"],
.inline-settings .inline-dropdown-list input[type="number"] {
    background: #1f1f2a;
    color: #d7d7e6;
    border: 1px solid #2e2e3a;
}
.inline-settings .inline-dropdown-option:hover {
    color: #fff;
    background-color: rgba(19, 19, 25, 0.3);
}
.inline-settings .inline-dropdown-option.selected {
    color: #FF9E9E;
    background-color: rgba(19, 19, 25, 1);
}

/* Credit Display Styles */
.credit-display {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(19, 19, 25, 0.8);
    border-radius: 8px;
    border: 1px solid #2e2e3a;
    position: static;
    width: 100%;
    box-sizing: border-box;
}

.credit-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.credit-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #d7d7e6;
    font-size: 0.9rem;
    font-weight: 600;
}

.credit-icon {
    font-size: 1rem;
}

.credit-amount {
    color: #5E21FF;
    font-weight: bold;
}

.credit-low {
    color: #ff6b6b !important;
    animation: credit-warning 1s ease-in-out infinite alternate;
}

@keyframes credit-warning {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Gallery Carousel / Results container - fills viewport width, scrolls vertically */
#results-carousel-container {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    overflow: hidden;
}

/* When in carousel mode, inner scroll container handles scrolling */
#results-carousel-container.carousel-view .carousel-scroll-container {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* When in gallery (tiled) mode, the container itself scrolls */
#results-carousel-container.tiled-view {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.gallery-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: transparent;
}

.carousel-scroll-container {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.carousel-items-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    /* Height will be calculated: itemCount * 100vh */
}

.carousel-item {
    width: 100%;
    height: 80vh !important; /* Increased height to reduce overlap while maintaining partial visibility */
    min-height: 400px; /* Minimum height constraint for very small screens */
    max-height: 90vh; /* Maximum height constraint for very large screens */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-direction: column; /* Ensure vertical stacking */
}

/* Carousel item deletion animation */
.carousel-item.is-deleting {
    animation: fadeOutScale 300ms ease-out forwards;
    pointer-events: none;
}

@keyframes fadeOutScale {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Carousel items stack vertically; focus/visibility handled by JS */

/* Critical: never transform the placeholder item; transforms create a new containing block and can break centering */
/* Placeholder slot uses 80vh so #main-box (centered in slot) appears in the middle of the viewport with no gap below */
.carousel-item[data-generation-id="placeholder"] {
    transform: none !important;
    display: flex; /* keep carousel's flex centering for placeholder too */
    align-items: center;
    justify-content: center;
    position: relative;
    height: 80vh !important;
    min-height: 80vh;
}

/* Fade-in animation for carousel items */
.carousel-item {
    opacity: 0;
    animation: fadeInQuick 220ms ease both;
}

.carousel-item.is-visible {
    opacity: 1;
}

.carousel-item img, .carousel-item video {
    border-radius: 16px;
    /* margin-top: -10vh */
    transition: opacity 200ms ease-in-out, filter 200ms ease-in-out; /* Base transition for smooth focus changes */
}
/* Empty ruleset removed */

/* Ensure media inside carousel fade in smoothly once loaded */
.carousel-image-container img.will-fade-in,
.carousel-image-container video.will-fade-in,
img.will-fade-in,
video.will-fade-in {
    opacity: 0;
    transition: opacity 600ms ease-out;
}
.carousel-image-container img.will-fade-in.is-visible,
.carousel-image-container video.will-fade-in.is-visible,
img.will-fade-in.is-visible,
video.will-fade-in.is-visible {
    opacity: 1;
}

/* Ensure nested .results-surface doesn't conflict */
.carousel-item .results-surface:not(#main-box) {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
}

/* #main-box should scroll with the carousel like other elements */

/* Carousel focus states - higher specificity to override will-fade-in */
.carousel-item.in-focus .carousel-image-container img,
.carousel-item.in-focus .carousel-image-container video {
    opacity: 1 !important;
    transition: opacity 200ms ease-in-out, filter 200ms ease-in-out; /* Consistent timing with base transition */
}

.carousel-item.out-of-focus .carousel-image-container img,
.carousel-item.out-of-focus .carousel-image-container video {
    opacity: 0.2 !important;
    transition: all 600ms ease-in-out;

  filter: grayscale(1);
}

.carousel-item.next-focus .carousel-image-container img,
.carousel-item.next-focus .carousel-image-container video {
    opacity: 0.2 !important; /* Slightly more visible than out-of-focus */
    transition: opacity 200ms ease-in-out, filter 200ms ease-in-out; /* Consistent timing with base transition */

    filter: grayscale(1);
}

/* Handle #main-box content (placeholder messages, loading spinners) */
.carousel-item.in-focus #main-box {
    opacity: 1 !important;
    transition: opacity 200ms ease-in-out; /* Consistent timing */
}

.carousel-item.out-of-focus #main-box {
    opacity: 0.1 !important;
    transition: opacity 600ms ease-in-out;
}

.carousel-item.next-focus #main-box {
    opacity: 0.3 !important;
    transition: opacity 200ms ease-in-out; /* Consistent timing */
}

/* First item styling - oldest generation */
.carousel-item.first-item {
    /* Reserved for future styling of the oldest generation */
    position: relative;
    margin-top: 10vh;
}
/* Removed margin-bottom - now handled by JavaScript updateContainerHeight() */
/* Smooth orientation-based resizing for #main-box with enhanced animation */
#main-box {
    /* Dynamic aspect ratio from JS via CSS custom property */
    aspect-ratio: var(--aspect-ratio, 1.78); /* 16:9 default */
    
    transition: 
        aspect-ratio 300ms cubic-bezier(0.4, 0, 0.2, 1),
        width 300ms cubic-bezier(0.4, 0, 0.2, 1), 
        height 300ms cubic-bezier(0.4, 0, 0.2, 1),
        transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
        opacity 200ms ease;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Orientation-based max constraints with viewport limits */
#main-box.landscape {
    width: min(70vw, calc(80vh * var(--aspect-ratio, 1.78)));
    height: auto;
}

#main-box.portrait {
    height: min(80vh, calc(70vw / var(--aspect-ratio, 0.56)));
    width: auto;
}

#main-box.square {
    width: min(70vh, 70vw);
    height: auto;
}

/* Placeholder content container */
#main-box .placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
}
/* Force #main-box to be centered in the viewport within the placeholder carousel item */
/* Always show placeholder message at full opacity (even when slot has out-of-focus from scroll) */
.carousel-item[data-generation-id="placeholder"] #main-box {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    opacity: 1 !important;
    max-height: 77%;
}

.carousel-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Ensure placeholder rendered inside results surface is centered */
.results-surface .panel-body {
    display: flex;
    align-items: center;
    justify-content: center;
}

.carousel-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

/* Mirror #main-box sizing for media inside carousel via orientation classes */
.carousel-image-container img.landscape,
.carousel-image-container video.landscape {
    max-width: 70vw;
    height: auto;
    max-height: 70vh;
    /*test
    max-height: 90%;
    max-width: 100%;*/
}
.carousel-image-container img.portrait,
.carousel-image-container video.portrait {
    max-height: 80vh;
    width: auto;

    /*test*/
    max-height: 90%;
    max-width: 100%;
}
.carousel-image-container img.square,
.carousel-image-container video.square {
    max-height: 70vh;
    width: auto;
}

/* Container-based sizing (overrides vw/vh when supported) */
@supports (width: 1cqw) {
    /* Main box default and orientation sizes driven by container */
    #main-box {
        aspect-ratio: var(--aspect-ratio, 1.78);
        transition: 
            aspect-ratio 300ms cubic-bezier(0.4, 0, 0.2, 1),
            width 300ms cubic-bezier(0.4, 0, 0.2, 1),
            height 300ms cubic-bezier(0.4, 0, 0.2, 1),
            transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
            opacity 200ms ease;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: -5cqh;
    }
    #main-box.landscape {
        width: min(70cqw, calc(80cqh * var(--aspect-ratio, 1.78)));
        height: auto;
    }
    #main-box.portrait {
        height: min(80cqh, calc(70cqw / var(--aspect-ratio, 0.56)));
        width: auto;
    }
    #main-box.square {
        width: min(70cqh, 70cqw);
        height: auto;
    }

    /* Mirror #main-box sizing for media inside carousel via orientation classes */
    .carousel-image-container img.landscape,
    .carousel-image-container video.landscape {
        max-width: 70cqw;
        height: auto;
        max-height: 70cqh;
    }
    .carousel-image-container img.portrait,
    .carousel-image-container video.portrait {
        max-height: 80cqh;
        width: auto;
        max-height: 90%;
        max-width: 100%;
    }
    .carousel-image-container img.square,
    .carousel-image-container video.square {
        max-height: 70cqh;
        width: auto;
    }
}

.carousel-image:hover {
    transform: scale(1.02);
}

/* Jump to generate button */
#jump-to-generate {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    font-family: inherit;
    
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
}

#jump-to-generate.visible {
    opacity: 1;
    pointer-events: auto;
}

#jump-to-generate:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    border-radius: 12px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none; /* do not block scroll */
}

/* Ensure the entire placeholder item doesn't intercept scroll/clicks */
.carousel-item[data-generation-id="placeholder"],
.carousel-item[data-generation-id="placeholder"] * {
    pointer-events: none;
}

.carousel-loading-placeholder .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(94, 33, 255, 0.2);
    border-top: 3px solid #5E21FF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.carousel-loading-placeholder .loading-text {
    color: #ffffff;
    font-size: 0.9rem;
    opacity: 0.8;
}

.carousel-loading-placeholder .error-text {
    color: #ff6b6b;
    font-size: 0.9rem;
    text-align: center;
}

/* ─── Gradient loading placeholder (generation in progress) ─── */
/* Wrapper so gradient fills #main-box when shown */
#main-box .placeholder-content .loading-content.gradient-placeholder-wrap {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    position: relative;
}
#main-box .placeholder-content .loading-content.gradient-placeholder-wrap .crt-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    padding: clamp(4px, 1.5vmin, 18px);
    background: #1a1814;
    box-shadow:
      inset 0 2px 6px rgba(255,255,255,0.05),
      0 0 60px rgba(0,0,0,0.6);
  }
#main-box .placeholder-content .crt-wrap .crt-screen {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: clamp(2px, 0.5vmin, 6px);
    box-shadow:
      inset 0 0 clamp(20px, 8vmin, 60px) rgba(0,0,0,0.5),
      inset 0 0 0 1px rgba(255,255,255,0.04),
      0 0 clamp(15px, 5vmin, 40px) rgba(80,40,180,0.2);
  }
#main-box .placeholder-content .crt-wrap .crt-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #080710;
    z-index: 0;
  }
#main-box .placeholder-content .orb-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    animation: global-hue 48s linear infinite;
  }
@keyframes global-hue {
    0%   { filter: hue-rotate(0deg)   saturate(1.0) brightness(1.0); }
    20%  { filter: hue-rotate(70deg)  saturate(1.2) brightness(1.05); }
    40%  { filter: hue-rotate(150deg) saturate(0.9) brightness(0.95); }
    60%  { filter: hue-rotate(220deg) saturate(1.3) brightness(1.08); }
    80%  { filter: hue-rotate(300deg) saturate(1.0) brightness(1.0); }
    100% { filter: hue-rotate(360deg) saturate(1.0) brightness(1.0); }
  }
#main-box .placeholder-content .orb {
    position: absolute;
    border-radius: 50%;
    mix-blend-mode: screen;
    will-change: transform, opacity;
  }
#main-box .placeholder-content .orb-1 {
    width: 85vmin;  height: 85vmin;
    top: -20vmin;  left: -18vmin;
    filter: blur(12vmin);
    opacity: 0.58;
    animation:
      drift-1 17s ease-in-out infinite alternate,
      color-1 22s ease-in-out infinite alternate,
      size-1  11s ease-in-out infinite alternate;
  }
#main-box .placeholder-content .orb-2 {
    width: 72vmin;  height: 72vmin;
    bottom: -18vmin; right: -14vmin;
    filter: blur(11vmin);
    opacity: 0.5;
    animation:
      drift-2 21s ease-in-out infinite alternate,
      color-2 18s ease-in-out infinite alternate,
      size-2  14s ease-in-out infinite alternate;
  }
#main-box .placeholder-content .orb-3 {
    width: 58vmin;  height: 58vmin;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    filter: blur(10vmin);
    opacity: 0.42;
    animation:
      drift-3 13s ease-in-out infinite alternate,
      color-3 27s ease-in-out infinite alternate,
      size-3   9s ease-in-out infinite alternate;
  }
#main-box .placeholder-content .orb-4 {
    width: 48vmin;  height: 48vmin;
    bottom: 5%;  left: -8vmin;
    filter: blur(9vmin);
    opacity: 0.38;
    animation:
      drift-4 19s ease-in-out infinite alternate,
      color-4 15s ease-in-out infinite alternate,
      size-4  12s ease-in-out infinite alternate;
  }
#main-box .placeholder-content .orb-5 {
    width: 42vmin;  height: 42vmin;
    top: -5vmin; right: -8vmin;
    filter: blur(8vmin);
    opacity: 0.36;
    animation:
      drift-5 15s ease-in-out infinite alternate,
      color-5 20s ease-in-out infinite alternate,
      size-5  16s ease-in-out infinite alternate;
  }
@keyframes drift-1 {
    0%   { transform: translate(0,       0)       rotate(0deg); }
    25%  { transform: translate(10vmin,  7vmin)   rotate(8deg); }
    50%  { transform: translate(3vmin,   14vmin)  rotate(-5deg); }
    75%  { transform: translate(14vmin,  3vmin)   rotate(12deg); }
    100% { transform: translate(7vmin,   11vmin)  rotate(-3deg); }
  }
@keyframes drift-2 {
    0%   { transform: translate(0,        0); }
    30%  { transform: translate(-12vmin, -6vmin); }
    60%  { transform: translate(-3vmin,  -14vmin); }
    100% { transform: translate(-9vmin,  -9vmin); }
  }
@keyframes drift-3 {
    0%   { transform: translate(-50%, -50%) scale(1); }
    20%  { transform: translate(calc(-50% + 14vmin), calc(-50% - 8vmin))  scale(1.18); }
    50%  { transform: translate(calc(-50% - 11vmin), calc(-50% + 11vmin)) scale(0.82); }
    80%  { transform: translate(calc(-50% + 6vmin),  calc(-50% + 14vmin)) scale(1.12); }
    100% { transform: translate(calc(-50% - 8vmin),  calc(-50% - 6vmin))  scale(0.9); }
  }
@keyframes drift-4 {
    0%   { transform: translate(0,       0); }
    40%  { transform: translate(18vmin, -11vmin); }
    70%  { transform: translate(11vmin, -21vmin); }
    100% { transform: translate(21vmin, -8vmin); }
  }
@keyframes drift-5 {
    0%   { transform: translate(0,        0); }
    35%  { transform: translate(-11vmin,  14vmin); }
    65%  { transform: translate(-19vmin,  8vmin); }
    100% { transform: translate(-8vmin,   18vmin); }
  }
@keyframes color-1 {
    0%   { background: radial-gradient(circle, #3a1fcc 0%, transparent 70%); }
    16%  { background: radial-gradient(circle, #8b0057 0%, transparent 70%); }
    33%  { background: radial-gradient(circle, #1a4fcc 0%, transparent 70%); }
    50%  { background: radial-gradient(circle, #6600aa 0%, transparent 70%); }
    66%  { background: radial-gradient(circle, #004f8a 0%, transparent 70%); }
    83%  { background: radial-gradient(circle, #cc1050 0%, transparent 70%); }
    100% { background: radial-gradient(circle, #330099 0%, transparent 70%); }
  }
@keyframes color-2 {
    0%   { background: radial-gradient(circle, #b8247a 0%, transparent 70%); }
    25%  { background: radial-gradient(circle, #d44400 0%, transparent 70%); }
    50%  { background: radial-gradient(circle, #7b1fa2 0%, transparent 70%); }
    75%  { background: radial-gradient(circle, #c62828 0%, transparent 70%); }
    100% { background: radial-gradient(circle, #0077aa 0%, transparent 70%); }
  }
@keyframes color-3 {
    0%   { background: radial-gradient(circle, #00a878 0%, transparent 70%); }
    20%  { background: radial-gradient(circle, #1ab8d8 0%, transparent 70%); }
    40%  { background: radial-gradient(circle, #007888 0%, transparent 70%); }
    60%  { background: radial-gradient(circle, #0055ff 0%, transparent 70%); }
    80%  { background: radial-gradient(circle, #00cc99 0%, transparent 70%); }
    100% { background: radial-gradient(circle, #3366ff 0%, transparent 70%); }
  }
@keyframes color-4 {
    0%   { background: radial-gradient(circle, #c45a10 0%, transparent 70%); }
    33%  { background: radial-gradient(circle, #aa2277 0%, transparent 70%); }
    66%  { background: radial-gradient(circle, #887700 0%, transparent 70%); }
    100% { background: radial-gradient(circle, #cc3300 0%, transparent 70%); }
  }
@keyframes color-5 {
    0%   { background: radial-gradient(circle, #1ab8d8 0%, transparent 70%); }
    25%  { background: radial-gradient(circle, #00cc66 0%, transparent 70%); }
    50%  { background: radial-gradient(circle, #8833ee 0%, transparent 70%); }
    75%  { background: radial-gradient(circle, #ff6600 0%, transparent 70%); }
    100% { background: radial-gradient(circle, #0099ff 0%, transparent 70%); }
  }
@keyframes size-1 {
    0%   { width: 85vmin;  height: 85vmin;  filter: blur(12vmin); }
    50%  { width: 105vmin; height: 100vmin; filter: blur(14vmin); }
    100% { width: 78vmin;  height: 90vmin;  filter: blur(11vmin); }
  }
@keyframes size-2 {
    0%   { width: 72vmin; height: 72vmin; filter: blur(11vmin); }
    50%  { width: 56vmin; height: 64vmin; filter: blur(9vmin); }
    100% { width: 88vmin; height: 80vmin; filter: blur(13vmin); }
  }
@keyframes size-3 {
    0%   { width: 58vmin; height: 58vmin; filter: blur(10vmin); }
    50%  { width: 76vmin; height: 70vmin; filter: blur(12vmin); }
    100% { width: 47vmin; height: 50vmin; filter: blur(8vmin); }
  }
@keyframes size-4 {
    0%   { width: 48vmin; height: 48vmin; filter: blur(9vmin); }
    50%  { width: 62vmin; height: 56vmin; filter: blur(11vmin); }
    100% { width: 37vmin; height: 44vmin; filter: blur(7vmin); }
  }
@keyframes size-5 {
    0%   { width: 42vmin; height: 42vmin; filter: blur(8vmin); }
    50%  { width: 30vmin; height: 33vmin; filter: blur(6vmin); }
    100% { width: 52vmin; height: 48vmin; filter: blur(10vmin); }
  }
#main-box .placeholder-content .crt-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0,0,0,0.18) 2px,
      rgba(0,0,0,0.18) 4px
    );
    z-index: 8;
    pointer-events: none;
  }
#main-box .placeholder-content .crt-scan-sweep {
    position: absolute;
    left: 0; right: 0;
    height: 10%;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      rgba(255,255,255,0.012) 30%,
      rgba(255,255,255,0.028) 50%,
      rgba(255,255,255,0.012) 70%,
      transparent 100%
    );
    animation: scan-sweep 5s linear infinite;
    z-index: 9;
    pointer-events: none;
  }
@keyframes scan-sweep {
    0%   { top: -10%; }
    100% { top: 100%; }
  }
#main-box .placeholder-content .crt-phosphor {
    position: absolute;
    inset: 0;
    background-image:
      repeating-linear-gradient(0deg,   transparent, transparent 3px, rgba(0,0,0,0.06) 3px, rgba(0,0,0,0.06) 4px),
      repeating-linear-gradient(90deg,  transparent, transparent 3px, rgba(0,0,0,0.04) 3px, rgba(0,0,0,0.04) 4px);
    z-index: 7;
    pointer-events: none;
  }
#main-box .placeholder-content .crt-flicker {
    position: absolute;
    inset: 0;
    animation: crt-flicker 0.12s steps(1) infinite;
    z-index: 6;
    pointer-events: none;
  }
@keyframes crt-flicker {
    0%,10%,20%,80%,100% { opacity: 1; }
    5%  { opacity: 0.97; }
    15% { opacity: 0.98; }
    50% { opacity: 0.99; }
    75% { opacity: 0.97; }
    92% { opacity: 0.98; }
  }
#main-box .placeholder-content .crt-glitch {
    position: absolute;
    left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.07);
    top: 30%;
    animation: glitch-move 23s ease-in-out infinite;
    z-index: 11;
    pointer-events: none;
    opacity: 0;
  }
#main-box .placeholder-content .crt-glitch-2 {
    top: 65%;
    animation: glitch-move 31s ease-in-out infinite;
    animation-delay: -14s;
  }
@keyframes glitch-move {
    0%, 88%, 100% { opacity: 0; transform: translateX(0); }
    89%  { opacity: 1;   transform: translateX(-8px); height: 2px; }
    90%  { opacity: 0.8; transform: translateX(12px); height: 4px; }
    91%  { opacity: 1;   transform: translateX(-4px); height: 2px; }
    92%  { opacity: 0; }
  }
#main-box .placeholder-content .crt-grain {
    position: absolute;
    inset: -50%;
    width: 200%; height: 200%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.06;
    animation: crt-grain 0.15s steps(1) infinite;
    z-index: 6;
    pointer-events: none;
  }
@keyframes crt-grain {
    0%,100% { transform: translate(0,   0); }
    10%     { transform: translate(-2%, -3%); }
    20%     { transform: translate(3%,   1%); }
    30%     { transform: translate(-1%,  3%); }
    40%     { transform: translate(2%,  -2%); }
    50%     { transform: translate(-3%,  2%); }
    60%     { transform: translate(1%,  -1%); }
    70%     { transform: translate(-2%,  3%); }
    80%     { transform: translate(3%,  -3%); }
    90%     { transform: translate(-1%,  2%); }
  }
#main-box .placeholder-content .crt-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,0.8) 100%);
    z-index: 10;
    pointer-events: none;
  }
#main-box .placeholder-content .crt-screen-glow {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 clamp(30px, 12vmin, 80px) rgba(40,20,120,0.3);
    z-index: 10;
    pointer-events: none;
    border-radius: clamp(2px, 0.5vmin, 6px);
  }
#main-box .placeholder-content .crt-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    gap: clamp(10px, 3vmin, 18px);
  }
#main-box .placeholder-content .pulse-ring {
    position: relative;
    width: clamp(28px, 8vmin, 48px);
    height: clamp(28px, 8vmin, 48px);
  }
#main-box .placeholder-content .pulse-ring::before,
#main-box .placeholder-content .pulse-ring::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(180,255,210,0.4);
    animation: pulse-out 2.4s ease-out infinite;
  }
#main-box .placeholder-content .pulse-ring::after { animation-delay: 1.2s; }
#main-box .placeholder-content .pulse-dot {
    position: absolute;
    inset: 0;
    margin: auto;
    width: clamp(4px, 1.2vmin, 6px);
    height: clamp(4px, 1.2vmin, 6px);
    border-radius: 50%;
    background: rgba(200,255,220,0.95);
    box-shadow: 0 0 10px rgba(160,255,200,0.8), 0 0 20px rgba(100,200,180,0.4);
  }
@keyframes pulse-out {
    0%   { transform: scale(0.5); opacity: 0.7; }
    100% { transform: scale(2.8); opacity: 0; }
  }
#main-box .placeholder-content .crt-label-text {
    color: rgba(200,255,220,0.5);
    font-size: clamp(8px, 1.8vmin, 11px);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(160,255,200,0.5);
    animation: fade-text 2s ease-in-out infinite alternate;
  }
@keyframes fade-text {
    from { opacity: 0.35; }
    to   { opacity: 0.7; }
  }
#main-box .placeholder-content .power-led {
    position: absolute;
    bottom: clamp(-10px, -1.8vmin, -13px);
    left: 50%;
    transform: translateX(-50%);
    width: clamp(4px, 1vmin, 6px);
    height: clamp(4px, 1vmin, 6px);
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 6px #00ff88, 0 0 12px rgba(0,255,136,0.4);
    animation: led-pulse 2.5s ease-in-out infinite alternate;
  }
@keyframes led-pulse {
    from { opacity: 0.7; box-shadow: 0 0 4px #00ff88; }
    to   { opacity: 1;   box-shadow: 0 0 8px #00ff88, 0 0 16px rgba(0,255,136,0.5); }
  }

.carousel-info-overlay {
    position: absolute;
    background: rgba(8, 8, 11, 0.88);
    color: white;
    padding: 20px;
    border-radius: 18px;
    font-size: 0.85rem;
    z-index: 10;
    width: 260px;
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                visibility 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none; /* Always allow scrolling */
    /* Position will be set via JavaScript relative to action buttons */
    top: 0;
    left: 0;
    right: auto;
}

.carousel-info-overlay.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Enable interactions only for specific elements */
.carousel-info-overlay-close,
.carousel-info-copy-link {
    pointer-events: auto;
}

.carousel-info-overlay .info-content {
    text-align: left;
}

/* Close button for info overlay */
.carousel-info-overlay-close {
    position: absolute;
    top: 16px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: url('/img/icon-close-button.png') center center no-repeat;
    background-size: 16px 16px;
    color: transparent;
    font-size: 0;
    cursor: pointer;
    line-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.carousel-info-overlay-close:hover {
    background: url('/img/icon-close-button.png') center center no-repeat;
    background-size: 16px 16px;
}

/* Info overlay content elements */
.carousel-info-prompt {
    font-size: 0.7rem;
    margin-bottom: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    max-height: 220px;
    overflow: auto;
    text-overflow: ellipsis;
}

.carousel-info-copy-link {
    font-size: 0.8rem;
    text-decoration: none;
    margin-bottom: 12px;
    display: inline-block;
    cursor: pointer;
    transition: color 0.2s ease;
    text-transform: uppercase;
    font-family: 'Borna', -apple-system, 'Helvetica Neue', sans-serif;
}

.carousel-info-copy-link:hover {
    color: #9A7BFF;
    text-decoration: underline;
}

.carousel-info-model {
    font-size: 0.8rem;
}

.carousel-info-style {
    font-weight: 500;
    font-size: 0.8rem;
    color: #FF9E9E;
}

.carousel-info-seed {
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.carousel-info-created {
    color: #eee;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 10px;
}

.carousel-info-deletion {
    color: #eee;
    font-size: 0.75rem;
    opacity: 0.8;
}

.carousel-item-info {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.carousel-item:hover .carousel-item-info {
    opacity: 1;
}

/* Carousel action buttons – same look and animation as #nav .tabs: icons only by default, labels + expand on hover */
/* Position set via JS (positionActionButtons): 13px from top, 10px from right edge of image */
.carousel-action-buttons {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    align-items: flex-start;
    overflow: hidden;
    background-color: rgba(30, 30, 37, 0.5);
    border-radius: 2px 24px 24px 24px;
    padding: 18px;
    width: 58px;
    transition: opacity 0.3s cubic-bezier(0.33, 1, 0.68, 1), width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: 0.08s, 0s;
}

.carousel-action-buttons:hover {
    width: 196px;
}

/* Hidden until .ready (avoids wrong position on first hover after load) */
.carousel-item.in-focus .carousel-action-buttons {
    opacity: 0;
    pointer-events: none;
    transition-delay: 0.08s, 0s;
}
.carousel-item.in-focus .carousel-action-buttons.ready {
    opacity: 1;
    pointer-events: auto;
}

/* Compact buttons – icon + label, same structure as #nav .tab-btn */
.carousel-action-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    color: #757482;
    text-decoration: none;
    gap: 0;
    padding: 0;
    cursor: pointer;
    z-index: 100;
    opacity: 1;
    line-height: 150%;
}

.carousel-action-btn img {
    margin-bottom: 0;
    flex-shrink: 0;
    align-self: flex-start;
    width: 16px;
    height: 16px;
    transform-origin: left center;
    transition: transform 0.3s ease;
    border-radius: 0;
}

.carousel-action-btn:hover img {
    /* No hover filter/scale for icons */
}

/* Labels hidden by default, reveal on container hover (like #nav .tabs) */
.carousel-action-btn span {
    font-size: 12px;
    font-weight: 400;
    opacity: 0;
    transform: translateY(3px);
    text-align: left;
    white-space: nowrap;
    max-width: 0;
    overflow: hidden;
    margin-left: 0;
    transition: opacity 0.4s cubic-bezier(0.33, 1, 0.68, 1), transform 0.4s cubic-bezier(0.33, 1, 0.68, 1);
    transition-delay: 0.12s, 0.12s;
    color: inherit;
}

/* Stagger: first child is .visual-anchor.pill, buttons are nth-child(2)…(6) */
.carousel-action-btn:nth-child(2) span { transition-delay: 0.12s, 0.12s; }
.carousel-action-btn:nth-child(3) span { transition-delay: 0.09s, 0.09s; }
.carousel-action-btn:nth-child(4) span { transition-delay: 0.06s, 0.06s; }
.carousel-action-btn:nth-child(5) span { transition-delay: 0.03s, 0.03s; }
.carousel-action-btn:nth-child(6) span { transition-delay: 0.03s, 0.03s; }

.carousel-action-buttons:hover .carousel-action-btn span {
    opacity: 1;
    transform: translateY(0);
    max-width: 140px;
    margin-left: 6px;
    color: #ffffff;
    transition-delay: 0s, 0s;
}

/* When hovering the pill area, make all action labels/icons white */
.carousel-action-buttons:hover .carousel-action-btn {
    color: #ffffff;
}

.carousel-action-buttons:hover .carousel-action-btn:nth-child(2) span { transition-delay: 0s, 0s; }
.carousel-action-buttons:hover .carousel-action-btn:nth-child(3) span { transition-delay: 0.05s, 0.05s; }
.carousel-action-buttons:hover .carousel-action-btn:nth-child(4) span { transition-delay: 0.1s, 0.1s; }
.carousel-action-buttons:hover .carousel-action-btn:nth-child(5) span { transition-delay: 0.15s, 0.15s; }
.carousel-action-buttons:hover .carousel-action-btn:nth-child(6) span { transition-delay: 0.15s, 0.15s; }

.carousel-action-btn:hover {
    color: #ffffff;
}
.carousel-action-btn:hover span {
    color: inherit;
}

.carousel-action-buttons .visual-anchor.pill {
    display: none;
    opacity: 0;
    transform: translateX(-4px) scale(0.95);
    transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.carousel-action-buttons .visual-anchor.pill.animate-in {
    display: none;
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* Visual hint for previous images */
/* Items maintain full height - no negative margins */

/* Single view styles (fallback) */
.single-view {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.single-view .result-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    cursor: zoom-in;
}

/* Tiled (gallery grid) view styles */
.tiled-view {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 24px 12vw;
}

.tiled-view .placeholder-message,
.tiled-view .gallery-grid-placeholder {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    margin-top: 50px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}

.gallery-grid-item {
    aspect-ratio: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-grid-item-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-grid-item img,
.gallery-grid-item video,
.gallery-grid-media {
    max-width: 92%;
    max-height: 92%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0px 0px 10px 1px rgb(0 0 0 / 0.2);
}

.gallery-grid-item img {
    cursor: pointer;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .carousel-item {
        height: 75vh;
        height: 75dvh; /* Dynamic viewport height for mobile - reduced overlap */
        min-height: 300px; /* Minimum height constraint for mobile */
        max-height: 85vh; /* Maximum height constraint for mobile */
    }
    
    .carousel-image {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .carousel-info-overlay {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        font-size: 0.8rem;
        padding: 10px 16px;
    }
    
    .carousel-item-info {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        text-align: center;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tiled-view {
        padding: 16px 20px;
    }
}

/* Scrollbar styling for carousel */
.carousel-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.carousel-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.carousel-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(94, 33, 255, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(94, 33, 255, 0.3);
}

.carousel-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(94, 33, 255, 0.8);
}

/* Firefox scrollbar */
.carousel-scroll-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(94, 33, 255, 0.6) rgba(255, 255, 255, 0.1);
}

/* Sidebar */
:root { --sidebar-width: min(25vw, 300px); }
#app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--sidebar-width);
    max-width: 300px;
    background: #1E1E25;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateX(100%);
    transition: transform 300ms ease;
    z-index: 40000;
    display: flex;
    flex-direction: column;
}
body.sidebar-open #app-sidebar { transform: translateX(0); }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 12px; }
.sidebar-title { font-size: 1rem; margin: 0; }
.sidebar-content { overflow: auto; padding: 12px; }

/* Settings sidebar (Clear Memory, Wizard, Canvas) */
.settings-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.settings-sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.settings-sidebar-heading {
    font-size: 0.95rem;
    font-weight: 600;
    color: #e0e0e0;
    margin: 0 0 4px 0;
}
.settings-sidebar-description {
    font-size: 0.85rem;
    color: #999;
    margin: 0;
    line-height: 1.4;
}
.settings-sidebar-section .settings-sidebar-description {
    margin-top: 2px;
}
.settings-sidebar-btn {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: #2A2A35;
    color: #e0e0e0;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
}
.settings-sidebar-btn:hover {
    background: #353545;
    border-color: rgba(255, 255, 255, 0.25);
}
.settings-sidebar-btn-danger {
    background: #c0392b;
    border-color: #a93226;
    color: #fff;
}
.settings-sidebar-btn-danger:hover {
    background: #a93226;
    border-color: #922b21;
}
.settings-sidebar-btn-success {
    background: #27ae60 !important;
    border-color: #219a52 !important;
}
.settings-sidebar-storage {
    font-size: 0.85rem;
    color: #999;
}
.settings-sidebar-storage .storage-value.warning { color: #f0ad4e; }
.settings-sidebar-storage .storage-value.critical { color: #e74c3c; }
.settings-sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-sidebar-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #ddd;
    cursor: pointer;
}
.settings-sidebar-label input[type="checkbox"] {
    margin: 0;
}

/* Hide legacy #controls panel (settings moved to sidebar) */
#controls {
    display: none !important;
}

/* Transaction History Styles */
.transaction-history-container {
    padding: 0;
}

.transaction-history-loading {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
}

.transaction-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #aaa;
}

.transaction-history-empty-hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
}

.transaction-history-error {
    text-align: center;
    padding: 40px 20px;
    color: #f87171;
}

.transaction-history-error-detail {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 8px;
}

.transaction-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transaction-item {
    background: #2A2A35;
    border-radius: 8px;
    padding: 12px;
}

.transaction-item.transaction-credit {
    border-left-color: #4ade80;
}

.transaction-item.transaction-debit {
    border-left-color: #f87171;
}

.transaction-item.transaction-refund {
    border-left-color: #60a5fa;
}

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

.transaction-type {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transaction-date {
    font-size: 0.8rem;
    color: #888;
}

.transaction-description {
    font-size: 0.9rem;
    color: #ddd;
    margin-bottom: 12px;
    line-height: 1.4;
}

.transaction-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #333;
}

.transaction-balance {
    display: flex;
    gap: 6px;
    align-items: center;
}

.transaction-balance-label {
    font-size: 0.8rem;
    color: #888;
}

.transaction-balance-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.transaction-amount-positive {
    font-size: 1rem;
    font-weight: 700;
    color: #4ade80;
}

.transaction-amount-negative {
    font-size: 1rem;
    font-weight: 700;
    color: #f87171;
}

/* Desktop push layout - canvas-background width is handled in canvas-background.css */
@media (min-width: 769px){
    body.sidebar-open #main-wrap {
        padding-right: var(--sidebar-width);
        transition: padding-right 300ms ease;
    }
}

/* Mobile: full-screen overlay */
@media (max-width: 768px){
    #app-sidebar { width: 100vw; max-width: none; }
}

/* Storage Info Styles */
.storage-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(19, 19, 25, 0.8);
    border-radius: 6px;
    border: 1px solid #2e2e3a;
    margin: 8px 0;
}

.storage-label {
    color: #9C9C9C;
    font-size: 0.85rem;
    font-weight: 500;
}

.storage-value {
    color: #5E21FF;
    font-size: 0.85rem;
    font-weight: 600;
}

.storage-value.warning {
    color: #ff9d9e;
}

.storage-value.critical {
    color: #ff6b6b;
    animation: credit-warning 1s ease-in-out infinite alternate;
}

/* Auth: resend verification styles */
.resend-verification { margin-top: 20px; }
.resend-verification .resend-card {
    text-align: center;
    margin-top: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.resend-verification .resend-text {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
}
.resend-verification .resend-btn {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}
.resend-verification .resend-btn:hover { }
.resend-verification .resend-hint { color: #999; margin-top: 10px; font-size: 12px; }
/* Editable coordinates for left stack positioning */
:root {
    --left-stack-x: 10vw;
    --left-stack-y: 18vh;
    --left-stack-gap: 16px;
    --left-stack-width: 10vw;
    --left-stack-max-width: 340px;
    --left-stack-min-width: 280px;
}

/* =============================================
   MOBILE RESPONSIVE STYLES (Phone Portrait)
   Target: max-width 480px
   ============================================= */

@media (max-width: 480px) {

    /* -----------------------------------------
       CSS Variables for Mobile
       ----------------------------------------- */
    :root {
        --mobile-margin: 16px;
        --mobile-nav-height: 64px;
        --mobile-left-stack-bottom: 80px;
    }

    /* -----------------------------------------
       Logo - Top Center
       ----------------------------------------- */
    #head {
        position: fixed;
        top: 16px;
        left: 0;
        right: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        z-index: 100;
        pointer-events: none;
        transform: none;
    }

    #logo {
        width: 100px;
        margin: 0;
        pointer-events: auto;
    }

    /* Notifications below logo, centered, full-width */
    #app-notification {
        display: block;
        width: 100%;
        margin: 8px 0 0 0;
        text-align: center;
        pointer-events: auto;
    }

    /* Top pill behind logo */
    #head::before {
        content: '';
        position: fixed;
        top: 0;
        left: 16px;
        right: 16px;
        height: 18px;
        background: rgba(30, 30, 37, 0.5);
        border-radius: 0 0 18px 18px;
        z-index: -1;
        pointer-events: none;
    }

    /* -----------------------------------------
       Hide Desktop-Only Elements
       ----------------------------------------- */
    #app-version {
        display: none;
    }

    #user-credits-display {
        display: none;
    }

    #wizard-help-btn {
        display: none;
    }

    .visual-anchor.pill {
        display: none !important;
    }

    /* -----------------------------------------
       Mobile: hide left-stack tabs (bottom nav shows the 3 section tabs via clones)
       ----------------------------------------- */
    #left-stack-tabs {
        display: none !important;
    }

    /* -----------------------------------------
       Settings Icon - 4th position in 5-icon row
       ----------------------------------------- */
    #bottom-right-controls {
        position: fixed !important;
        bottom: 6px !important;
        left: calc(50% + 26px) !important; /* Position 4: -130px + 156px = +26px */
        right: auto !important;
        transform: none !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 0 !important;
        z-index: 30001 !important;
        opacity: 1 !important;
    }

    #bottom-right-controls .tab-btn {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 52px;
        padding: 8px;
        opacity: 1 !important;
    }

    #bottom-right-controls .tab-btn img,
    #bottom-right-controls .tab-btn svg {
        width: 22px !important;
        height: 22px !important;
    }

    #bottom-right-controls .tab-btn span {
        display: none !important;
    }

    #bottom-right-controls .tab-btn:hover span {
        display: none !important;
    }

    /* User icon - 5th position in 5-icon row */
    #user-menu-container {
        position: fixed !important;
        bottom: 6px !important;
        left: calc(50% + 78px) !important; /* Position 5: -130px + 208px = +78px */
        right: auto !important;
        top: auto !important;
        transform: none !important;
        z-index: 30002 !important;
        display: flex !important;
        align-items: center !important;
        gap: 0 !important;
        opacity: 1 !important;
    }

    #user-icon-btn {
        width: 52px;
        height: 52px;
        opacity: 1 !important;
    }

    #user-icon-btn img {
        width: 22px;
        height: 22px;
    }

    /* -----------------------------------------
       Unified Mobile Bottom Nav (5 icons in one row)
       ----------------------------------------- */
    #mobile-bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: var(--mobile-nav-height);
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 0 !important;
        z-index: 30000;
        background: transparent;
    }

    /* Bottom pill under icons */
    #mobile-bottom-nav::before {
        content: '';
        position: fixed;
        bottom: 0;
        left: 16px;
        right: 16px;
        height: 18px;
        background: rgba(30, 30, 37, 0.5);
        border-radius: 18px 18px 0 0;
        z-index: -1;
        pointer-events: none;
    }

    #mobile-bottom-nav .mobile-nav-icon {
        width: 52px;
        height: 52px;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px;
        margin: 0 0 -10px 0;
        background: none;
        border: none;
        cursor: pointer;
        color: #fff;
        opacity: 0.85;
    }

    #mobile-bottom-nav .mobile-nav-icon img,
    #mobile-bottom-nav .mobile-nav-icon svg {
        width: 24px !important;
        height: 24px !important;
        margin: 0;
    }

    #mobile-bottom-nav .mobile-nav-icon span {
        display: none !important;
    }

    body.mobile-nav-unified #bottom-right-controls {
        display: none !important;
    }

    body.mobile-nav-unified #user-menu-container > #user-icon-btn {
        display: none !important;
    }

    /* -----------------------------------------
       Left Stack - Above Bottom Nav, Full Width
       ----------------------------------------- */
    #left-stack {
        position: fixed !important;
        left: var(--mobile-margin) !important;
        right: var(--mobile-margin) !important;
        bottom: var(--mobile-left-stack-bottom) !important;
        top: auto !important;
        width: calc(100% - 32px) !important;
        max-width: none !important;
        min-width: auto !important;
        max-height: calc(100vh - var(--mobile-nav-height) - 70px) !important;
        overflow-y: auto !important;
        transform: none !important;
        z-index: 20000;
        pointer-events: auto !important; /* Ensure clickable on mobile */
    }

    /* All floating panels full width and clickable */
    #left-stack .floating-panel,
    #left-stack .panel-card {
        width: 100% !important;
        max-width: none !important;
        min-width: auto !important;
        max-height: 50vh !important;
        overflow-y: auto !important;
        pointer-events: auto !important;
    }

    /* Prompt panels */
    #t2i-prompt-floating,
    #video-prompt-floating,
    #magic-prompt-floating {
        width: 100% !important;
    }

    .prompt-surface .prompt-body textarea {
        font-size: 17px; /* Prevent iOS zoom on focus */
        max-height: 30vh;
    }

    /* Reference/upload panels */
    #video-ref-floating,
    #upscale-ref-floating,
    #bg-ref-floating {
        width: 100% !important;
    }

    /* -----------------------------------------
       Magic Board Panel - Compact with 130px gallery
       ----------------------------------------- */
    #mb-floating.panel-card {
        width: 100% !important;
        height: 150px !important;
        max-height: none !important;
        min-height: auto !important;
        display: flex;
        flex-direction: column;
    }

    #mb-floating .panel-body {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .magic-board-surface.panel-card {
        max-height: none;
    }

    .magic-board-gallery {
        height: 100% !important;
    }

    .magic-board-gallery.is-multi {
        height: 100% !important;
    }

    .magic-board-instructions {
        padding: 8px;
    }

    .magic-board-instructions p {
        font-size: 0.8rem;
    }

    .magic-board-tap-upload-btn {
        display: block;
        margin-bottom: 10px;
    }

    /* -----------------------------------------
       Canvas/Results Area
       ----------------------------------------- */
    #canvas-background {
        position: fixed;
        top: 0;
        bottom: calc(var(--mobile-left-stack-bottom) + 180px);
        left: 0;
        right: 0;
    }

    .canvas-content {
        height: 100%;
    }

    /* Canvas controls hidden on mobile */
    .canvas-controls {
        display: none;
    }

    /* Gallery Carousel adjustments */
    #results-carousel-container {
        height: 100%;
    }

    .carousel-item {
        height: 50vh !important;
        min-height: 180px !important;
        max-height: 55vh !important;
    }

    .carousel-image-container img,
    .carousel-image-container video {
        max-width: calc(100vw - 32px) !important;
        max-height: 45vh !important;
    }

    .carousel-image-container img.landscape,
    .carousel-image-container video.landscape {
        max-width: calc(100vw - 32px);
        max-height: 40vh;
    }

    .carousel-image-container img.portrait,
    .carousel-image-container video.portrait {
        max-height: 45vh;
        max-width: calc(100vw - 32px);
    }

    .carousel-image-container img.square,
    .carousel-image-container video.square {
        max-height: 40vh;
        max-width: calc(100vw - 32px);
    }

    #main-box {
        margin-top: 0;
    }

    #main-box.landscape {
        width: calc(100vw - 32px) !important;
        height: auto !important;
        max-height: 40vh;
    }

    #main-box.portrait {
        height: 45vh !important;
        width: auto !important;
        max-width: calc(100vw - 32px);
    }

    #main-box.square {
        width: min(40vh, calc(100vw - 32px)) !important;
        height: auto !important;
    }

    /* Action buttons position */
    .carousel-action-buttons {
        right: 4px;
        gap: 2px;
    }

    .carousel-action-btn {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    /* Info overlay on mobile */
    .carousel-info-overlay {
        width: calc(100vw - 64px);
        max-width: 280px;
        font-size: 0.8rem;
        padding: 14px;
    }

    /* Jump to generate button */
    #jump-to-generate {
        bottom: calc(var(--mobile-left-stack-bottom) + 190px);
    }

    /* -----------------------------------------
       Lightbox backdrop (user popup + controls) - matches inline-settings-backdrop
       ----------------------------------------- */
    .lightbox-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 49999;
        transition: background 0.3s ease;
    }
    .lightbox-backdrop.active {
        background: rgba(0, 0, 0, 0.5);
    }

    /* Shared handle bar for all mobile sheets (same as inline-settings-handle) */
    .mobile-sheet-handle {
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }

    /* Shared close button positioning for mobile sheets */
    .mobile-sheet-close {
        position: absolute !important;
        top: 12px !important;
        right: 16px !important;
        width: 40px !important;
        height: 40px !important;
        z-index: 50001 !important;
        border-radius: 50%;
        background: url('/img/icon-close-button.png') center center no-repeat !important;
        background-size: 20px 20px !important;
        color: transparent;
        font-size: 0;
        border: none;
        cursor: pointer;
    }

    /* -----------------------------------------
       User Popup Card - Mobile Bottom Sheet (lightbox style)
       ----------------------------------------- */
    #user-popup-card {
        position: fixed;
        top: auto;
        bottom: var(--mobile-nav-height);
        left: var(--mobile-margin);
        right: var(--mobile-margin);
        width: calc(100% - 32px);
        min-width: auto;
        max-width: none;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 35000;
    }

    #user-popup-card:not(.hidden) {
        transform: translateY(0);
    }

    /* User popup - lightbox sheet (moved to body on open); matches inline-settings */
    #user-popup-card.mobile-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 85vh !important;
        height: auto !important;
        background: #1E1E25 !important;
        z-index: 50000 !important;
        padding: 16px !important;
        padding-top: 60px !important;
        padding-bottom: 24px !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        transform: translateY(100%) !important;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }
    #user-popup-card.mobile-sheet.open {
        transform: translateY(0) !important;
    }

    /* -----------------------------------------
       Settings Panel (Controls) - Mobile Bottom Sheet (lightbox style)
       ----------------------------------------- */
    #controls.uibox {
        position: fixed !important;
        top: auto !important;
        bottom: var(--mobile-nav-height) !important;
        left: var(--mobile-margin) !important;
        right: var(--mobile-margin) !important;
        width: calc(100% - 32px) !important;
        max-width: none !important;
        max-height: 60vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        margin: 0 !important;
        z-index: 25000;
    }

    /* Controls - lightbox sheet (moved to body on open); matches inline-settings */
    #controls.uibox.mobile-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 85vh !important;
        height: auto !important;
        background: #1E1E25 !important;
        z-index: 50000 !important;
        padding: 16px !important;
        padding-top: 60px !important;
        padding-bottom: 24px !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        transform: translateY(100%) !important;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }
    #controls.uibox.mobile-sheet.open {
        transform: translateY(0) !important;
    }

    .settings-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .settings-col.left,
    .settings-col.right {
        width: 100%;
    }

    .settings-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .settings-group label {
        grid-template-columns: 1fr;
    }

    /* -----------------------------------------
       Inline Settings - Mobile Bottom Sheet (iOS-style)
       ----------------------------------------- */
    /* Backdrop overlay - fade in */
    .inline-settings-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0);
        z-index: 49999;
        transition: background 0.3s ease;
    }
    .inline-settings-backdrop.active {
        background: rgba(0, 0, 0, 0.5);
    }

    /* Bottom sheet - slide up from bottom */
    .inline-settings-container.inline-settings.mobile-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 85vh !important;
        height: auto !important;
        background: #1E1E25 !important;
        z-index: 50000 !important;
        padding: 16px !important;
        padding-top: 60px !important;
        padding-bottom: 24px !important;
        margin: 0 !important;
        overflow-y: auto !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    }
    .inline-settings-container.inline-settings.mobile-sheet.open {
        transform: translateY(0);
    }

    /* Handle bar (iOS-style) */
    .inline-settings-handle {
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }

    /* Same look as desktop .close-button (icon, circle) - only position differs on sheet */
    .inline-settings-close-mobile {
        position: fixed !important;
        top: 16px !important;
        right: 16px !important;
        width: 40px !important;
        height: 40px !important;
        z-index: 50001 !important;
        border-radius: 50%;
        background: url('/img/icon-close-button.png') center center no-repeat !important;
        background-size: 20px 20px !important;
        color: transparent;
        font-size: 0;
    }
    .mobile-sheet .inline-settings-close-mobile {
        position: absolute !important;
        top: 12px !important;
        right: 16px !important;
    }

    .inline-settings .settings-group {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: none !important;
        gap: 10px !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .inline-settings .setting-item {
        width: 100% !important;
        padding: 14px 16px !important;
        min-height: 60px !important;
        border-radius: 8px;
    }

    .inline-settings .setting-item label {
        font-size: 0.85rem;
    }

    .inline-settings .setting-item .current-value {
        font-size: 0.9rem;
        display: block !important;
        visibility: visible !important;
    }

    /* Full-width items in mobile overlay */
    .inline-settings .settings-group .setting-item[data-setting] {
        grid-column: span 1 !important;
    }

    /* Inline dropdown overlay - full screen when inside sheet */
    .inline-settings.mobile-sheet .inline-dropdown-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        border-radius: 0 !important;
        padding: 16px !important;
    }

    .inline-settings .inline-dropdown-panel {
        padding: 16px;
        height: 100%;
    }

    .inline-settings .inline-dropdown-header {
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    .inline-settings .inline-dropdown-title {
        font-size: 1rem;
    }

    .inline-settings .inline-dropdown-list {
        flex: 1;
        overflow-y: auto;
    }

    .inline-settings .inline-dropdown-option {
        padding: 16px;
        font-size: 1rem;
        border-radius: 10px;
    }

    /* Toggle button positioning */
    .prompt-body .inline-settings-toggle {
        font-size: 11px;
        min-width: 100px;
    }

    /* -----------------------------------------
       Lightbox - Mobile Adjustments
       ----------------------------------------- */
    .lightbox-img,
    .lightbox-video {
        max-width: calc(100vw - 32px);
        max-height: 80vh;
    }

    .lightbox-close {
        top: 16px;
        right: 16px;
    }

    /* -----------------------------------------
       Result Actions - Adjusted for Mobile
       ----------------------------------------- */
    .result-actions {
        position: static;
        transform: none;
        flex-direction: row;
        justify-content: center;
        margin-top: 12px;
        gap: 8px;
    }

    /* -----------------------------------------
       Sidebar - Already Full Screen via existing 768px rule
       ----------------------------------------- */

    /* -----------------------------------------
       Panel Bodies - Compact Spacing
       ----------------------------------------- */
    .panel-card {
        padding: 10px;
    }

    .panel-card .panel-body {
        padding: 0;
    }

    .prompt-body .panel-actions {
        padding: 8px 0 0 0;
    }

    /* -----------------------------------------
       Loading Overlay - Mobile Adjustments
       ----------------------------------------- */
    .loading-card {
        padding: 12px;
        min-width: 200px;
    }

    .loading-content {
        min-height: 150px;
    }

    /* -----------------------------------------
       Typography Adjustments
       ----------------------------------------- */
    html {
        font-size: 14px;
    }
}

/* =============================================
   LANDSCAPE ON SMALL SCREENS
   Same mobile layout for landscape orientation
   ============================================= */
@media (max-height: 500px) and (orientation: landscape) {
    /* Inherit mobile styles with height adjustments */
    
    :root {
        --mobile-nav-height: 56px;
        --mobile-left-stack-bottom: 70px;
    }

    #left-stack {
        bottom: var(--mobile-left-stack-bottom) !important;
    }

    #mb-floating.panel-card {
        height: 120px !important;
        display: flex;
        flex-direction: column;
    }

    #mb-floating .panel-body {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .carousel-item {
        height: 65vh !important;
        min-height: 120px !important;
    }

    .carousel-image-container img,
    .carousel-image-container video {
        max-height: 55vh !important;
    }

    #canvas-background {
        top: 0;
        bottom: calc(var(--mobile-left-stack-bottom) + 140px);
    }

    #jump-to-generate {
        bottom: calc(var(--mobile-left-stack-bottom) + 150px);
    }

    /* Inline settings sheet - slightly reduced padding in landscape */
    .inline-settings-container.inline-settings.mobile-sheet {
        padding-top: 50px !important;
    }
}