/* ============================================================
   DIRECTOR — Scene Grid 3-Column Layout
   ============================================================
   Glass morphism on dark base — green-tinted glass borders,
   frosted panels, glowing accents.
   ============================================================ */

/* ==================== Master Layout ==================== */
.director-page {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
    background: var(--bg-base);
    overflow: hidden;
}

/* ==================== GLASS PANEL MIXIN (shared by left/right) ==================== */
.dir-left-panel,
.dir-right-panel {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    background: rgba(8, 10, 14, 0.85);
    backdrop-filter: blur(28px) saturate(1.7);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 0;
    box-shadow:
        inset 0 1px 0 rgba(92, 232, 154, 0.06),
        inset 0 0 40px rgba(92, 232, 154, 0.02),
        0 0 50px rgba(0, 0, 0, 0.5);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, min-width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== LEFT PANEL: Selections ==================== */
.dir-left-panel {
    width: 225px;
    flex-shrink: 0;
    border-right: 1px solid rgba(92, 232, 154, 0.1);
    border-left: none;
    border-top: none;
    border-bottom: none;
}

.dir-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px;
    height: 38px;
    overflow: hidden;
    min-width: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    background: transparent;
}

.dir-panel-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-variant: small-caps;
}

.dir-panel-count {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 1px 7px;
    font-family: var(--font-mono);
}

.dir-selections-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dir-selections-list::-webkit-scrollbar { width: 4px; }
.dir-selections-list::-webkit-scrollbar-track { background: transparent; }
.dir-selections-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 4px; transition: background 0.2s; }
.dir-selections-list::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }
.dir-selections-list { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.06) transparent; }

.dir-selection-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.2);
}

.dir-selection-thumb:hover {
    border-color: rgba(92, 232, 154, 0.3);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 12px rgba(92, 232, 154, 0.08);
    transform: translateY(-1px) scale(1.02);
}

.dir-selection-thumb.selected {
    border-color: rgba(74, 222, 128, 0.5);
    border-left: 3px solid rgba(74, 222, 128, 0.7);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.3),
        0 0 16px rgba(74, 222, 128, 0.1);
}

.dir-selection-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dir-selection-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
    font-family: inherit;
}

.dir-selection-thumb:hover .dir-selection-remove {
    opacity: 1;
}

.dir-selection-remove:hover {
    background: rgba(244, 63, 94, 0.8);
    color: #fff;
}

.dir-selection-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    font-size: 10px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
}

/* --- GENERATE VIDEOS button (glass style) --- */
.dir-generate-videos-btn {
    margin: 10px;
    height: 42px;
    border: 1px solid rgba(92, 232, 154, 0.25);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(92, 232, 154, 0.12), rgba(74, 222, 128, 0.08));
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    flex-shrink: 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 2px 12px rgba(0, 0, 0, 0.25),
        0 0 16px rgba(92, 232, 154, 0.06);
    backdrop-filter: blur(8px);
}

.dir-generate-videos-btn:hover {
    background: linear-gradient(135deg, rgba(92, 232, 154, 0.22), rgba(74, 222, 128, 0.14));
    border-color: rgba(92, 232, 154, 0.4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 6px 24px rgba(0, 0, 0, 0.35),
        0 0 24px rgba(92, 232, 154, 0.1);
    transform: translateY(-1px) scale(1.02);
}

.dir-generate-videos-btn:active {
    transform: scale(0.98);
}

.dir-generate-videos-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dir-selections-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.15);
    font-size: 14px;
    text-align: center;
    padding: 20px;
    line-height: 1.5;
}

/* ==================== CENTER WORKSPACE ==================== */
.dir-center {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: rgba(12, 15, 20, 0.6);
}

/* --- Scene Navigation Bar --- */
.dir-scene-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    background: transparent;
}

.dir-scene-nav-btn {
    width: 34px;
    height: 30px;
    border: 1px solid rgba(92, 232, 154, 0.12);
    border-radius: 9px;
    background: rgba(92, 232, 154, 0.05);
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(92, 232, 154, 0.06);
}

.dir-scene-nav-btn:hover {
    border-color: rgba(92, 232, 154, 0.3);
    background: rgba(92, 232, 154, 0.12);
    color: #fff;
    transform: scale(1.05);
}

.dir-scene-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.dir-scene-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    min-width: 80px;
    text-align: center;
}

/* --- Grid View (default) --- */
.dir-grid-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dir-panels-area {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(var(--dir-panels-cols, 3), 1fr);
    grid-template-rows: repeat(var(--dir-panels-rows, 2), 1fr);
    gap: 3px;
    padding: 3px;
    overflow: hidden;
    min-height: 0;
}

.dir-panels-area::-webkit-scrollbar { width: 4px; }
.dir-panels-area::-webkit-scrollbar-track { background: transparent; }
.dir-panels-area::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 4px; }
.dir-panels-area::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }
.dir-panels-area { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.06) transparent; }

/* --- Individual 3x3 Panel (legacy) --- */
.dir-panel-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    background: rgba(92, 232, 154, 0.04);
    border: 1px solid rgba(92, 232, 154, 0.12);
    border-radius: 14px;
    padding: 4px;
    position: relative;
    box-shadow:
        inset 0 1px 0 rgba(92, 232, 154, 0.08),
        0 4px 20px rgba(0, 0, 0, 0.3);
}

.dir-panel-label {
    position: absolute;
    top: -8px;
    left: 8px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-base);
    padding: 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Grid Cell --- */
.dir-panel-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.1);
    background: rgba(92, 232, 154, 0.04);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.dir-panel-cell:hover {
    border-color: rgba(92, 232, 154, 0.2);
    transform: scale(1.02);
}

.dir-panel-cell.selected {
    border-color: rgba(92, 232, 154, 0.5);
    box-shadow: 0 0 12px rgba(92, 232, 154, 0.15);
}

.dir-panel-cell.selected::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    background: rgba(92, 232, 154, 0.9);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 8px;
}

.dir-panel-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- Shimmer Loading --- */
.dir-panel-cell.loading {
    background: linear-gradient(
        110deg,
        rgba(92, 232, 154, 0.03) 0%,
        rgba(92, 232, 154, 0.1) 40%,
        rgba(92, 232, 154, 0.03) 60%
    );
    background-size: 200% 100%;
    animation: dirShimmer 1.5s ease-in-out infinite;
    cursor: default;
}

.dir-panel-cell.loading:hover {
    transform: none;
    border-color: transparent;
}

@keyframes dirShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Cell expand icon (visible on hover) --- */
.dir-cell-expand {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.dir-panel-cell:hover .dir-cell-expand {
    opacity: 1;
}

/* --- Preview View --- */
.dir-preview-view {
    flex: 1;
    display: none;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    position: relative;
    background: rgba(15, 18, 22, 0.8);
}

.dir-preview-view.active {
    display: flex;
}

.dir-grid-view.hidden {
    display: none;
}

.dir-preview-topbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    width: 100%;
    flex-shrink: 0;
}

.dir-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    border-radius: 10px;
    background: rgba(92, 232, 154, 0.06);
    color: var(--text-tertiary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(92, 232, 154, 0.06);
}

.dir-back-btn:hover {
    border-color: rgba(92, 232, 154, 0.3);
    background: rgba(92, 232, 154, 0.12);
    color: #fff;
    transform: translateX(-2px);
}

.dir-preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 12px;
    position: relative;
}

.dir-preview-media {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4), 0 8px 40px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    background: rgba(0, 0, 0, 0.3);
    max-width: 100%;
    max-height: 100%;
}

.dir-preview-media img {
    display: block;
    max-width: calc(100vw - 620px);
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: 8px;
}

.dir-preview-media video {
    display: block;
    max-width: calc(100vw - 620px);
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: 8px;
}

.dir-preview-info {
    padding: 4px 0 0;
    font-size: 14px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    text-align: center;
    flex-shrink: 0;
}

.dir-preview-prompt {
    padding: 0 16px 4px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-muted);
    text-align: center;
    max-height: 36px;
    overflow-y: auto;
    flex-shrink: 0;
    user-select: text;
}

.dir-preview-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    flex-shrink: 0;
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 12, 8, 0.7);
    backdrop-filter: blur(16px) saturate(1.4);
    border-radius: 24px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dir-preview-view:hover .dir-preview-actions {
    opacity: 1;
}

.dir-preview-action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(92, 232, 154, 0.06);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    font-family: inherit;
    box-shadow: inset 0 1px 0 rgba(92, 232, 154, 0.06);
}

.dir-preview-action-btn:hover {
    border-color: rgba(92, 232, 154, 0.3);
    background: rgba(92, 232, 154, 0.14);
    color: #fff;
    transform: scale(1.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.dir-preview-action-btn.active {
    border-color: rgba(92, 232, 154, 0.5);
    background: rgba(92, 232, 154, 0.15);
    color: #fff;
}

.dir-preview-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- Fullscreen button overlay on videos --- */
.dir-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.2);
    background: rgba(6, 12, 8, 0.7);
    backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    z-index: 5;
}

.dir-fullscreen-btn:hover {
    border-color: rgba(92, 232, 154, 0.4);
    background: rgba(6, 12, 8, 0.9);
    color: #fff;
}

/* ==================== BOTTOM BAR ==================== */
.dir-bottom-bar {
    flex: 0 0 auto;
    border-top: 1px solid rgba(92, 232, 154, 0.12);
    background: rgba(6, 12, 8, 0.55);
    backdrop-filter: blur(24px) saturate(1.4);
    padding: 6px 12px 6px;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dir-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dir-prompt-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.dir-prompt-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.dir-voice-script-row {
    padding: 0;
}

.dir-voice-script-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.dir-prompt-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    flex-shrink: 0;
}

.dir-ref-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    flex-shrink: 0;
}

.dir-ref-btn:hover {
    background: rgba(92, 232, 154, 0.14);
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(92, 232, 154, 0.28);
    transform: scale(1.08);
}

.dir-voice-mic-icon {
    position: absolute;
    left: 8px;
    pointer-events: none;
    flex-shrink: 0;
}

.dir-voice-script-input {
    width: 100%;
    background: rgba(6, 12, 8, 0.5);
    border: 1px solid rgba(92, 232, 154, 0.15);
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 8px 10px 8px 28px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.dir-voice-script-input:focus {
    border-color: rgba(92, 232, 154, 0.4);
}

.dir-voice-script-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* --- Ref Thumbnails Row (above prompt) --- */
.dir-ref-thumbnails {
    display: flex;
    gap: 6px;
    padding: 4px 0;
    align-items: center;
    flex-wrap: wrap;
}

.dir-ref-thumb {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(92, 232, 154, 0.2);
    flex-shrink: 0;
}

.dir-ref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dir-ref-thumb-x {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.dir-ref-thumb:hover .dir-ref-thumb-x {
    opacity: 1;
}

.dir-ref-thumb-x:hover {
    background: rgba(244, 63, 94, 0.8);
}

.dir-ref-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 9px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-secondary);
    text-align: center;
    padding: 1px 0;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Bottom inline row for upscale + settings (legacy, now merged into controls-row) */

.dir-prompt-input {
    flex: 1;
    min-height: 72px;
    max-height: 180px;
    resize: vertical;
    overflow-y: auto;
    line-height: 1.5;
    padding: 10px 18px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    border-radius: 14px;
    background: rgba(6, 12, 8, 0.55);
    color: var(--text-secondary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.2);
}

.dir-prompt-input:focus {
    border-color: rgba(92, 232, 154, 0.4);
    background: rgba(6, 12, 8, 0.65);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.15),
        0 0 16px rgba(92, 232, 154, 0.08),
        0 0 0 1px rgba(92, 232, 154, 0.08);
}

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

/* --- GENERATE button — compact, site-green theme --- */
.dir-generate-btn {
    flex: 1;
    min-height: 0;
    align-self: stretch;
    padding: 0 20px;
    border: 1px solid rgba(92, 232, 154, 0.45);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(92, 232, 154, 0.3), rgba(74, 222, 128, 0.18));
    color: rgba(255, 255, 255, 0.95);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.25),
        0 0 20px rgba(92, 232, 154, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dir-generate-btn:hover {
    background: linear-gradient(135deg, rgba(92, 232, 154, 0.45), rgba(74, 222, 128, 0.28));
    border-color: rgba(92, 232, 154, 0.65);
    box-shadow:
        0 0 24px rgba(92, 232, 154, 0.2),
        0 0 48px rgba(74, 222, 128, 0.08),
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-1px) scale(1.03);
}

.dir-generate-btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow:
        0 0 12px rgba(92, 232, 154, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

.dir-generate-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: rgba(92, 232, 154, 0.15);
}

/* --- STOP button --- */
.dir-stop-btn {
    min-height: 30px;
    padding: 0 18px;
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 10px;
    background: rgba(244, 63, 94, 0.12);
    color: #f43f5e;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.4px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow:
        0 0 15px rgba(244, 63, 94, 0.08),
        inset 0 1px 0 rgba(244, 63, 94, 0.1);
}

.dir-stop-btn:hover {
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.5);
    box-shadow: 0 0 24px rgba(244, 63, 94, 0.18);
    transform: translateY(-1px) scale(1.02);
}

.dir-stop-btn:active {
    transform: scale(0.98);
}

/* --- Settings Row --- */
.dir-settings-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    margin-left: auto;
}

.dir-setting-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dir-setting-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: rgba(92, 232, 154, 0.6);
    padding-left: 2px;
}

.dir-chip-select {
    padding: 4px 24px 4px 8px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    border-radius: 9px;
    background: rgba(92, 232, 154, 0.06);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236a8a6e' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 0 rgba(92, 232, 154, 0.05);
}

.dir-chip-select:hover {
    border-color: rgba(92, 232, 154, 0.3);
    background-color: rgba(92, 232, 154, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.dir-chip-select:focus {
    border-color: rgba(92, 232, 154, 0.4);
    box-shadow: 0 0 12px rgba(92, 232, 154, 0.1), 0 0 0 1px rgba(92, 232, 154, 0.06);
}

.dir-setting-group[data-tooltip] {
    position: relative;
}

.dir-setting-group[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.2);
    white-space: normal;
    width: 220px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
}

.dir-setting-group[data-tooltip]:hover::after {
    opacity: 1;
}

/* ==================== RIGHT PANEL: Session Gallery ==================== */
.dir-right-panel {
    width: 295px;
    flex-shrink: 0;
    border-left: 1px solid rgba(92, 232, 154, 0.1);
    border-right: none;
    border-top: none;
    border-bottom: none;
}

.dir-gallery-feed {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: start;
}

.dir-gallery-feed::-webkit-scrollbar { width: 4px; }
.dir-gallery-feed::-webkit-scrollbar-track { background: transparent; }
.dir-gallery-feed::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
.dir-gallery-feed::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }
.dir-gallery-feed { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.08) transparent; }

.dir-gallery-item {
    position: relative;
    contain: layout style;
    flex: 1 1 calc(50% - 4px);
    min-width: 80px;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    background: #1a1a1a;
}

.dir-gallery-item:hover {
    border-color: rgba(92, 232, 154, 0.4);
    transform: scale(1.03);
    z-index: 1;
}

.dir-gallery-item.selected {
    border-color: rgba(74, 222, 128, 0.5);
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.1);
}

.dir-gallery-item.active {
    border: 2px solid rgba(92, 232, 154, 0.7);
    box-shadow: 0 0 8px rgba(92, 232, 154, 0.2);
}

.dir-gallery-item img,
.dir-gallery-item video {
    width: 100%;
    height: auto;
    min-height: 50px;
    display: block;
    border-radius: 6px;
}

.dir-gallery-item-type {
    position: absolute;
    top: 3px;
    left: 3px;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: rgba(6, 12, 8, 0.75);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(92, 232, 154, 0.1);
}

.dir-gallery-item-type.image { color: rgba(92, 232, 154, 0.9); }
.dir-gallery-item-type.video { color: rgba(74, 222, 128, 0.9); }

/* Gallery delete button */
.dir-gallery-del-btn {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.dir-gallery-item:hover .dir-gallery-del-btn {
    opacity: 1;
}

.dir-gallery-del-btn:hover {
    color: #f43f5e;
    background: rgba(0, 0, 0, 0.8);
}

.dir-gallery-dl-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.dir-gallery-item:hover .dir-gallery-dl-btn {
    opacity: 1;
}

.dir-gallery-dl-btn:hover {
    color: #5ce89a;
    background: rgba(0, 0, 0, 0.8);
}

.dir-gallery-gen-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(92, 232, 154, 0.7);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.dir-gallery-item:hover .dir-gallery-gen-btn {
    opacity: 1;
}

.dir-gallery-gen-btn:hover {
    background: rgba(92, 232, 154, 0.95);
}

.dir-gallery-gen-menu {
    background: rgba(18, 18, 18, 0.97);
    border: 1px solid rgba(92, 232, 154, 0.25);
    border-radius: 10px;
    padding: 4px;
    min-width: 180px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.dir-gallery-gen-menu-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 7px;
    text-align: left;
    transition: background 0.12s;
}

.dir-gallery-gen-menu-item:hover {
    background: rgba(92, 232, 154, 0.2);
}

.dir-gallery-gen-menu-item strong {
    font-size: 14px;
    font-weight: 600;
}

.dir-gallery-gen-menu-item span {
    font-size: 12px;
    color: var(--text-muted);
}

.dir-gallery-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dir-gallery-video-overlay svg {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
    opacity: 0.75;
    transition: opacity 0.15s;
}

.dir-gallery-item:hover .dir-gallery-video-overlay svg {
    opacity: 1;
}

.dir-gallery-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.15);
    font-size: 13px;
    text-align: center;
    padding: 20px;
    line-height: 1.5;
}

/* Gallery-specific: reposition fav button to avoid dl button overlap */
.dir-gallery-item .dir-fav-btn {
    bottom: auto;
    right: auto;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
}
.dir-gallery-item .dir-fav-btn.active {
    opacity: 1;
}

/* Hide type badge — play overlay identifies video, saves space */
.dir-gallery-item .dir-gallery-item-type {
    display: none;
}

/* ==================== VIDEO LOADING MOTION GRAPHIC ==================== */
.dir-video-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    z-index: 3;
}

.dir-video-loading-rings {
    position: relative;
    width: 60px;
    height: 60px;
}

.dir-video-loading-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(92, 232, 154, 0.12);
    border-top-color: rgba(92, 232, 154, 0.7);
    border-radius: 50%;
    animation: dirVideoSpin 1s linear infinite;
}

.dir-video-loading-ring-inner {
    position: absolute;
    inset: 8px;
    border: 2px solid rgba(74, 222, 128, 0.1);
    border-top-color: rgba(74, 222, 128, 0.5);
    border-radius: 50%;
    animation: dirVideoSpin 1.5s linear infinite reverse;
}

.dir-video-loading-ring-core {
    position: absolute;
    inset: 16px;
    border: 2px solid rgba(34, 211, 238, 0.08);
    border-top-color: rgba(34, 211, 238, 0.4);
    border-radius: 50%;
    animation: dirVideoSpin 2s linear infinite;
}

@keyframes dirVideoSpin {
    to { transform: rotate(360deg); }
}
@keyframes dir-spin {
    to { transform: rotate(360deg); }
}

/* --- Grid cell video generation overlay --- */
.dir-cell-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 5;
    gap: 4px;
    backdrop-filter: blur(2px);
}
.dir-cell-video-rings {
    position: relative;
    width: 36px;
    height: 36px;
}
.dir-cell-video-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(92, 232, 154, 0.12);
    border-top-color: rgba(92, 232, 154, 0.7);
    border-radius: 50%;
    animation: dirVideoSpin 1s linear infinite;
}
.dir-cell-video-ring-inner {
    position: absolute;
    inset: 6px;
    border: 2px solid rgba(74, 222, 128, 0.1);
    border-top-color: rgba(74, 222, 128, 0.5);
    border-radius: 50%;
    animation: dirVideoSpin 1.5s linear infinite reverse;
}
.dir-cell-video-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dir-cell-video-overlay.dir-cell-video-done {
    background: rgba(0, 0, 0, 0.4);
    animation: dirCellOverlayFade 2s ease-out forwards;
}
.dir-cell-video-overlay.dir-cell-video-error {
    background: rgba(40, 0, 0, 0.5);
    animation: dirCellOverlayFade 3s ease-out forwards;
}
@keyframes dirCellOverlayFade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Big video generation overlay on grid --- */
.dir-videogen-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10;
    border-radius: 4px;
}
.dir-videogen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.dir-videogen-text {
    font-size: 16px;
    color: var(--text-tertiary);
    font-weight: 500;
}
.dir-videogen-progress {
    font-size: 24px;
    font-weight: 700;
    color: rgba(92, 232, 154, 0.9);
    font-family: var(--font-mono);
}

/* Pulse ring animation for generating state */
.dir-pulse-ring {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dir-pulse-ring::before,
.dir-pulse-ring::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(92, 232, 154, 0.3);
    border-radius: 50%;
    animation: dirPulseOut 2s ease-out infinite;
}

.dir-pulse-ring::after {
    animation-delay: 1s;
}

@keyframes dirPulseOut {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* ==================== COMPOSITE PANEL (glass card) ==================== */
.dir-panel-composite {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dir-panel-composite:hover {
    border-color: rgba(92, 232, 154, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.dir-panel-composite.loading {
    background: linear-gradient(
        110deg,
        rgba(92, 232, 154, 0.03) 0%,
        rgba(92, 232, 154, 0.1) 40%,
        rgba(92, 232, 154, 0.03) 60%
    );
    background-size: 200% 100%;
    animation: dirShimmer 1.5s ease-in-out infinite, pulse-border 2s infinite;
    border-color: rgba(92, 232, 154, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
.dir-panel-loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.dir-panel-loading-text {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.dir-composite-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dir-composite-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    z-index: 2;
}

/* Individual images grid: fills the panel completely */
.dir-individual-grid {
    position: absolute;
    inset: 0;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2px;
}

/* Portrait aspect: no special side panel changes — just grid layout via CSS vars */

.dir-composite-cell {
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.dir-composite-cell:hover {
    background: rgba(92, 232, 154, 0.1);
    border-color: rgba(92, 232, 154, 0.3);
}

.dir-composite-cell.selected {
    border-color: rgba(74, 222, 128, 0.5);
    background: rgba(74, 222, 128, 0.08);
}

.dir-composite-cell-check {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    background: rgba(74, 222, 128, 0.9);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 9px;
    z-index: 3;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.dir-composite-cell.processing {
    animation: dirCellPulse 1.2s ease-in-out infinite;
    border-color: rgba(74, 222, 128, 0.3);
}

@keyframes dirCellPulse {
    0%, 100% { background: rgba(92, 232, 154, 0.03); }
    50% { background: rgba(92, 232, 154, 0.12); }
}

.dir-composite-cell.error {
    border-color: rgba(244, 63, 94, 0.5);
    background: rgba(244, 63, 94, 0.1);
}

.dir-composite-cell.upscaled {
    border-color: rgba(74, 222, 128, 0.5);
    background: transparent;
}

.dir-composite-cell-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==================== PANEL EXPAND BUTTON ==================== */
.dir-panel-expand-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    z-index: 5;
    backdrop-filter: blur(4px);
    padding: 0;
}

.dir-panel-composite:hover .dir-panel-expand-btn {
    opacity: 1;
}

.dir-panel-expand-btn:hover {
    background: rgba(6, 12, 8, 0.9);
    border-color: rgba(92, 232, 154, 0.3);
    color: #fff;
    transform: scale(1.05);
}

/* ==================== PANEL DELETE BUTTON ==================== */
.dir-panel-delete-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    z-index: 5;
    padding: 0;
}
.dir-panel-composite:hover .dir-panel-delete-btn {
    opacity: 1;
}
.dir-panel-delete-btn:hover {
    background: rgba(180, 40, 40, 0.8);
    border-color: rgba(244, 63, 94, 0.5);
    color: #fff;
    transform: scale(1.05);
}

/* ==================== EXPANDED PANEL OVERLAY ==================== */
.dir-expand-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.dir-expand-overlay.active {
    opacity: 1;
}

.dir-expand-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(92, 232, 154, 0.2);
    background: rgba(92, 232, 154, 0.08);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    z-index: 10;
}

.dir-expand-close:hover {
    background: rgba(92, 232, 154, 0.15);
    color: #fff;
}

.dir-expand-label {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.dir-expand-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(92, 232, 154, 0.15);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(92, 232, 154, 0.04);
}

.dir-expand-grid {
    position: absolute;
    inset: 0;
    display: grid;
    gap: 2px;
}

.dir-expand-grid .dir-composite-cell {
    overflow: hidden;
    border: none;
    border-radius: 0;
}

.dir-expand-grid .dir-composite-cell-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dir-expand-grid .dir-composite-cell:hover {
    opacity: 0.85;
}

.dir-expand-grid .dir-composite-cell.selected {
    box-shadow: inset 0 0 0 3px rgba(74, 222, 128, 0.7);
    opacity: 1;
}

.dir-expand-grid .dir-composite-cell-check {
    display: block;
}

.dir-expand-grid .dir-fav-btn {
    opacity: 0.7;
    bottom: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
}

.dir-expand-grid .dir-composite-cell:hover .dir-fav-btn {
    opacity: 1;
}

/* ==================== UPSCALE BUTTON (glass style) ==================== */
.dir-upscale-btn {
    height: 30px;
    padding: 0 14px;
    border: 1px solid rgba(92, 232, 154, 0.2);
    border-radius: 9px;
    background: rgba(92, 232, 154, 0.08);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(92, 232, 154, 0.08);
}

.dir-upscale-btn:hover {
    background: rgba(92, 232, 154, 0.16);
    border-color: rgba(92, 232, 154, 0.35);
    box-shadow: 0 0 14px rgba(92, 232, 154, 0.08);
    transform: translateY(-1px) scale(1.02);
}

.dir-upscale-btn:active {
    transform: scale(0.98);
}

.dir-upscale-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==================== SELECTION PENDING STATE ==================== */
.dir-selection-thumb.pending-upscale {
    border-color: rgba(92, 232, 154, 0.2);
    border-style: dashed;
}

.dir-selection-pending {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(92, 232, 154, 0.5);
    font-size: 12px;
    font-weight: 600;
    background: rgba(92, 232, 154, 0.03);
}

/* ==================== LEFT PANEL TABS ==================== */
.dir-left-tabs {
    display: flex;
    gap: 1px;
    overflow: hidden;
    min-width: 0;
    flex: 1;
}

.dir-left-tab {
    padding: 3px 5px;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    display: flex;
    align-items: center;
}

.dir-left-tab:hover {
    color: var(--text-tertiary);
    background: rgba(92, 232, 154, 0.06);
}

.dir-left-tab.active {
    color: var(--text-secondary);
    background: rgba(92, 232, 154, 0.1);
    border-color: rgba(92, 232, 154, 0.12);
}

/* ==================== FAVORITE BUTTONS ==================== */
.dir-fav-btn {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    padding: 0;
    z-index: 2;
}

.dir-gallery-item:hover .dir-fav-btn,
.dir-selection-thumb:hover .dir-fav-btn {
    opacity: 1;
}

.dir-fav-btn:hover {
    background: rgba(6, 12, 8, 0.9);
    color: #f43f5e;
    transform: scale(1.1);
}

.dir-fav-btn.active {
    opacity: 1;
    color: #f43f5e;
    background: rgba(244, 63, 94, 0.15);
}

.dir-fav-btn.active svg {
    fill: currentColor;
}

.dir-fav-btn-sel {
    bottom: auto;
    top: 4px;
    left: 4px;
    right: auto;
    width: 20px;
    height: 20px;
}

/* --- Download button --- */
.dir-dl-btn {
    position: absolute;
    bottom: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    padding: 0;
    z-index: 2;
}
.dir-gallery-item:hover .dir-dl-btn,
.dir-selection-thumb:hover .dir-dl-btn,
.dir-composite-cell:hover .dir-dl-btn {
    opacity: 1;
}
.dir-dl-btn:hover {
    background: rgba(6, 12, 8, 0.9);
    color: rgba(92, 232, 154, 0.9);
    transform: scale(1.1);
}
.dir-expand-grid .dir-dl-btn {
    opacity: 0.7;
    bottom: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
}
.dir-expand-grid .dir-composite-cell:hover .dir-dl-btn {
    opacity: 1;
}
.dir-dl-btn-sel {
    bottom: auto;
    top: 4px;
    right: 4px;
    left: auto;
    width: 20px;
    height: 20px;
}

/* Preview favorite button */
.dir-preview-fav-btn.active {
    color: #f43f5e;
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.25);
}

.dir-preview-fav-btn.active svg {
    fill: currentColor;
}

/* ==================== FAVORITES LIST ==================== */
.dir-favorite-item {
    border-color: rgba(244, 63, 94, 0.2);
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.05);
}

.dir-favorite-item:hover {
    border-color: rgba(244, 63, 94, 0.35);
    box-shadow: 0 0 18px rgba(244, 63, 94, 0.1);
}

.dir-favorite-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dir-fav-type-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(6, 12, 8, 0.7);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(92, 232, 154, 0.08);
}

.dir-fav-type-badge.image { color: rgba(92, 232, 154, 0.9); }
.dir-fav-type-badge.video { color: rgba(74, 222, 128, 0.9); }

.dir-fav-prompt {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-tertiary);
}

/* ==================== STATUS BAR ==================== */
.dir-status-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 14px;
    font-family: var(--font-mono);
    background: rgba(6, 12, 8, 0.55);
    border: 1px solid rgba(92, 232, 154, 0.1);
    border-radius: 10px;
    margin: 6px 0;
    min-height: 28px;
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dir-status-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(92, 232, 154, 0.15);
    border-top-color: rgba(74, 222, 128, 0.85);
    border-radius: 50%;
    animation: dirVideoSpin 0.8s linear infinite;
    flex-shrink: 0;
}

/* ==================== RESPONSIVE ==================== */

/* Large screens: shrink side panels slightly */
@media (max-width: 1400px) {
    .dir-right-panel {
        width: 240px;
    }
    .dir-left-panel {
        width: 200px;
    }
}

/* Medium screens: collapse right panel further */
@media (max-width: 1200px) {
    .dir-right-panel {
        width: 200px;
    }
    .dir-left-panel {
        width: 180px;
    }
}

/* Tablet: hide right panel, shrink left */
@media (max-width: 1024px) {
    .dir-right-panel {
        display: none;
    }
    .dir-left-panel {
        width: 180px;
    }
}

/* Small tablet / large phone: stack vertically */
@media (max-width: 900px) {
    .director-page {
        flex-direction: column;
    }
    .dir-left-panel {
        width: 100%;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid rgba(92, 232, 154, 0.1);
        flex-direction: row;
    }
    .dir-selections-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .dir-selection-thumb {
        width: 120px;
        aspect-ratio: 16/9;
    }
    .dir-right-panel {
        display: flex;
        width: 100%;
        max-height: 180px;
        border-left: none;
        border-top: 1px solid rgba(92, 232, 154, 0.1);
    }
    .dir-gallery-feed {
        columns: unset;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .dir-gallery-item {
        width: 80px;
        flex-shrink: 0;
        display: block;
        break-inside: unset;
        aspect-ratio: 1;
    }
    .dir-gallery-item img,
    .dir-gallery-item video {
        height: 100%;
        object-fit: cover;
    }
    .dir-panels-area {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
    .dir-film-sidebar {
        width: 52px;
    }
    .dir-sidebar-mode-label,
    .dir-stage-label {
        display: none;
    }
}

/* Phone: single column */
@media (max-width: 600px) {
    .dir-panels-area {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .dir-prompt-row, .dir-prompt-main {
        flex-wrap: wrap;
    }
    .dir-prompt-input {
        min-width: 150px;
        order: -1;
        flex-basis: 100%;
    }
    .dir-left-panel {
        max-height: 100px;
    }
    .dir-film-sidebar {
        width: 44px;
    }
    .dir-preview-actions {
        bottom: 8px;
        padding: 6px 12px;
        gap: 6px;
    }
    .dir-preview-action-btn {
        width: 32px;
        height: 32px;
    }
}

/* ==================== CHARACTER REFERENCE PICKER + CHIPS ==================== */
/* --- Shared ref button base --- */
.dir-charref-add-btn,
.dir-imgref-add-btn,
.dir-sceneref-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 22px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(92, 232, 154, 0.06);
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    font-size: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}
.dir-charref-add-btn span,
.dir-imgref-add-btn span,
.dir-sceneref-add-btn span { display: none; }
.dir-charref-add-btn:hover,
.dir-imgref-add-btn:hover,
.dir-sceneref-add-btn:hover {
    background: rgba(92, 232, 154, 0.18);
    border-color: rgba(92, 232, 154, 0.35);
    color: rgba(255, 255, 255, 0.7);
}

/* Image/Scene Reference Chips */
.dir-imgref-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 3px 0 5px 0;
}
.dir-imgref-chip,
.dir-sceneref-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px 2px 2px;
    border-radius: 6px;
    background: rgba(92, 232, 154, 0.1);
    border: 1px solid rgba(92, 232, 154, 0.15);
    font-size: 12px;
    color: var(--text-tertiary);
    max-width: 200px;
    backdrop-filter: blur(8px);
}
.dir-imgref-chip-img,
.dir-sceneref-chip-img {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
}
.dir-imgref-chip-remove,
.dir-sceneref-chip-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    font-size: 14px;
    padding: 0 1px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.dir-imgref-chip-remove:hover,
.dir-sceneref-chip-remove:hover {
    color: rgba(255, 100, 100, 0.8);
}
.dir-sceneref-chip-desc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
    opacity: 0.5;
    font-size: 11px;
}

/* Drag-and-drop highlight on prompt textarea */
.dir-prompt-input.drag-over {
    border-color: rgba(92, 232, 154, 0.5) !important;
    box-shadow: inset 0 0 0 1px rgba(92, 232, 154, 0.15), 0 0 12px rgba(92, 232, 154, 0.08);
}
.dir-charref-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 3px 0 5px 0;
}
.dir-charref-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px 2px 2px;
    border-radius: 6px;
    background: rgba(92, 232, 154, 0.1);
    border: 1px solid rgba(92, 232, 154, 0.15);
    font-size: 12px;
    color: var(--text-tertiary);
    backdrop-filter: blur(8px);
}
.dir-charref-chip-img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
}
.dir-charref-chip-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    font-size: 14px;
    padding: 0 1px;
    line-height: 1;
    transition: color 0.15s;
}
.dir-charref-chip-remove:hover {
    color: rgba(255, 100, 100, 0.8);
}

/* Character Reference Picker Overlay */
.dir-charref-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.dir-charref-modal {
    background: rgba(15, 20, 16, 0.95);
    border: 1px solid rgba(92, 232, 154, 0.2);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.dir-charref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(92, 232, 154, 0.1);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
}
.dir-charref-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
}
.dir-charref-close:hover { color: #fff; }
.dir-charref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
}
.dir-charref-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: 12px;
    border: 1px solid rgba(92, 232, 154, 0.1);
    background: rgba(92, 232, 154, 0.05);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.dir-charref-item:hover { background: rgba(92, 232, 154, 0.15); border-color: rgba(92, 232, 154, 0.3); }
.dir-charref-item.added { opacity: 0.4; cursor: default; }
.dir-charref-thumb {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(92, 232, 154, 0.1);
}
.dir-charref-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.dir-charref-no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.2);
    font-size: 22px;
}
.dir-charref-name {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.dir-charref-added-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 11px;
    background: rgba(92, 232, 154, 0.3);
    padding: 2px 6px;
    border-radius: 8px;
    color: var(--text-tertiary);
}

/* ==================== FILM SIDEBAR ==================== */
.dir-film-sidebar {
    width: 64px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(6, 8, 12, 0.9);
    backdrop-filter: blur(24px) saturate(1.6);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    padding: 6px 0;
    gap: 2px;
    z-index: 10;
}
.dir-sidebar-toggle {
    display: flex;
    justify-content: center;
    padding: 4px 6px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 4px;
}
.dir-sidebar-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
    width: 100%;
}
.dir-sidebar-mode-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
}
.dir-sidebar-mode-btn.film-active {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.25);
    color: rgba(74, 222, 128, 0.9);
}
.dir-sidebar-mode-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.8;
}
.dir-sidebar-stages {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 5px;
}
.dir-stage-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 7px 4px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
    position: relative;
}
.dir-stage-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
}
.dir-stage-btn.active {
    background: rgba(92, 232, 154, 0.1);
    color: rgba(74, 222, 128, 0.9);
    border-color: rgba(92, 232, 154, 0.12);
}
.dir-stage-btn.active::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: rgba(74, 222, 128, 0.8);
    border-radius: 0 3px 3px 0;
}
.dir-stage-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}
.dir-stage-icon {
    font-size: 20px;
    line-height: 1;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dir-stage-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
    opacity: 0.7;
}

/* ==================== FILM STAGE CONTENT (replaces center when not in generate mode) ==================== */
.dir-film-stage-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: rgba(6, 12, 8, 0.3);
}
.dir-film-stage-content h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}
.dir-film-stage-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 16px 0 8px 0;
}

/* Film card grid */
.dir-film-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}
.dir-film-card {
    padding: 18px;
    border-radius: 14px;
    border: 1px solid rgba(92, 232, 154, 0.12);
    background: rgba(6, 12, 8, 0.5);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}
.dir-film-card:hover {
    border-color: rgba(92, 232, 154, 0.3);
    background: rgba(6, 12, 8, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}
.dir-film-card.selected {
    border-color: rgba(45, 183, 48, 0.4);
    background: rgba(45, 183, 48, 0.08);
}
.dir-film-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.dir-film-card-meta {
    font-size: 13px;
    color: var(--text-muted);
}
.dir-film-card-status {
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 8px;
    margin-top: 8px;
    background: rgba(92, 232, 154, 0.15);
    color: var(--text-tertiary);
}

/* New film form */
.dir-film-form {
    padding: 20px;
    border-radius: 14px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(6, 12, 8, 0.5);
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 500px;
}
.dir-film-form label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}
.dir-film-form input,
.dir-film-form textarea,
.dir-film-form select {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(6, 12, 8, 0.6);
    color: var(--text-secondary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
.dir-film-form input:focus,
.dir-film-form textarea:focus,
.dir-film-form select:focus {
    border-color: rgba(92, 232, 154, 0.35);
}
.dir-film-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

/* Shared action buttons for film pipeline */
.dir-film-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid rgba(92, 232, 154, 0.2);
    background: rgba(92, 232, 154, 0.12);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.dir-film-btn:hover {
    background: rgba(92, 232, 154, 0.25);
    color: #fff;
}
.dir-film-btn.primary {
    background: rgba(45, 183, 48, 0.2);
    border-color: rgba(45, 183, 48, 0.3);
    color: #5ce89a;
}
.dir-film-btn.primary:hover {
    background: rgba(45, 183, 48, 0.35);
}
.dir-film-btn.danger {
    color: #f43f5e;
    border-color: rgba(244, 63, 94, 0.2);
}
.dir-film-btn.danger:hover {
    background: rgba(244, 63, 94, 0.15);
}
.dir-film-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Scene selector strip (shown in generate mode when film is selected) */
.dir-scene-selector-strip {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid rgba(92, 232, 154, 0.08);
    flex-shrink: 0;
}
.dir-scene-selector-chip {
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid rgba(92, 232, 154, 0.12);
    background: rgba(6, 12, 8, 0.4);
    color: var(--text-tertiary);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.dir-scene-selector-chip:hover {
    background: rgba(92, 232, 154, 0.15);
    color: var(--text-secondary);
}
.dir-scene-selector-chip.active {
    background: rgba(45, 183, 48, 0.15);
    border-color: rgba(45, 183, 48, 0.3);
    color: #5ce89a;
}

/* Story stage */
.dir-story-prose {
    padding: 16px;
    border-radius: 12px;
    background: rgba(6, 12, 8, 0.4);
    border: 1px solid rgba(92, 232, 154, 0.08);
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    margin-bottom: 16px;
}
.dir-story-scene-card {
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(92, 232, 154, 0.1);
    background: rgba(6, 12, 8, 0.4);
    margin-bottom: 10px;
}
.dir-story-scene-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.dir-story-scene-card-desc {
    font-size: 14px;
    color: var(--text-tertiary);
    line-height: 1.5;
}
.dir-story-scene-card textarea {
    width: 100%;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.12);
    background: rgba(6, 12, 8, 0.5);
    color: var(--text-secondary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    outline: none;
}
.dir-story-scene-card textarea:focus {
    border-color: rgba(92, 232, 154, 0.3);
}

/* Characters stage grid */
.dir-char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.dir-char-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(92, 232, 154, 0.1);
    background: rgba(6, 12, 8, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}
.dir-char-card:hover {
    border-color: rgba(92, 232, 154, 0.25);
}
.dir-char-card.in-film {
    border-color: rgba(45, 183, 48, 0.3);
    background: rgba(45, 183, 48, 0.05);
}
.dir-char-thumb {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(92, 232, 154, 0.1);
}
.dir-char-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.dir-char-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}
.dir-char-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* Scenes stage cards */
.dir-scenes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}
.dir-scene-card {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 2px solid transparent;
    background: rgba(6, 12, 8, 0.4);
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    cursor: pointer;
}
.dir-scene-card:hover {
    border-color: rgba(92, 232, 154, 0.2);
    background: rgba(6, 12, 8, 0.55);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.dir-scene-card.selected {
    border-color: rgba(74, 222, 128, 0.3);
    border-left: 3px solid rgba(74, 222, 128, 0.7);
    background: rgba(74, 222, 128, 0.04);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2), 0 0 16px rgba(74, 222, 128, 0.06);
}

.dir-scene-card-num {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.25);
    min-width: 20px;
    padding-top: 3px;
    font-family: var(--font-mono);
}
.dir-scene-card-body {
    flex: 1;
    min-width: 0;
}
.dir-scene-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 5px;
    letter-spacing: 0.2px;
}
.dir-scene-card-prompt {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.dir-scene-card-meta {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Timeline editor */
.dir-timeline-container {
    margin-top: 16px;
    border-radius: 12px;
    border: 1px solid rgba(92, 232, 154, 0.1);
    background: rgba(6, 12, 8, 0.4);
    overflow: hidden;
}
.dir-timeline-toolbar {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(92, 232, 154, 0.08);
    align-items: center;
}
.dir-timeline-track {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(92, 232, 154, 0.06);
    min-height: 48px;
    position: relative;
}
.dir-timeline-track-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.dir-timeline-track-clips {
    position: relative;
    height: 36px;
    background: rgba(92, 232, 154, 0.04);
    border-radius: 6px;
    overflow: hidden;
}
.dir-timeline-clip {
    position: absolute;
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.dir-timeline-clip.video {
    background: rgba(59, 130, 246, 0.25);
    border: 1px solid rgba(59, 130, 246, 0.35);
}
.dir-timeline-clip.voiceover {
    background: rgba(168, 85, 247, 0.25);
    border: 1px solid rgba(168, 85, 247, 0.35);
}
.dir-timeline-clip.music {
    background: rgba(245, 158, 11, 0.25);
    border: 1px solid rgba(245, 158, 11, 0.35);
}
.dir-timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #f43f5e;
    z-index: 5;
    pointer-events: none;
}

/* Export stage */
.dir-export-panel {
    max-width: 500px;
}
.dir-export-info {
    padding: 14px;
    border-radius: 12px;
    background: rgba(6, 12, 8, 0.4);
    border: 1px solid rgba(92, 232, 154, 0.1);
    margin-bottom: 16px;
}
.dir-export-info p {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 4px 0;
}
.dir-export-progress {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(92, 232, 154, 0.1);
    overflow: hidden;
    margin-top: 12px;
}
.dir-export-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #5ce89a, #4ade80);
    border-radius: 3px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 8px rgba(45, 183, 48, 0.3);
}

/* Generate mode elements */
.dir-generate-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ==================== MODE SELECTOR ==================== */
.dir-mode-selector {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 10px;
    background: rgba(92, 232, 154, 0.06);
    border: 1px solid rgba(92, 232, 154, 0.1);
    flex-shrink: 0;
}

.dir-mode-btn {
    padding: 5px 16px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.dir-mode-btn:hover {
    color: var(--text-tertiary);
    background: rgba(92, 232, 154, 0.08);
}

.dir-mode-btn.active {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.08);
}

/* ==================== SINGLE/VIDEO VIEW ==================== */
.dir-single-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    gap: 16px;
}

.dir-single-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.dir-single-media {
    max-width: 100%;
    object-fit: contain;
    border-radius: 14px;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.04);
}

.dir-single-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    padding: 8px 0;
}

.dir-single-empty {
    color: rgba(255, 255, 255, 0.15);
    font-size: 16px;
    text-align: center;
}

.dir-single-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dir-loader-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(92, 232, 154, 0.1);
    border-top-color: rgba(92, 232, 154, 0.5);
    animation: dir-spin 1.2s linear infinite;
}

@keyframes dir-spin {
    to { transform: rotate(360deg); }
}

.dir-loader-bar {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(92, 232, 154, 0.4), transparent);
    border-radius: 1px;
    animation: dir-shimmer 1.8s ease-in-out infinite;
}

@keyframes dir-shimmer {
    0% { transform: translateX(-120px); }
    100% { transform: translateX(120px); }
}

/* ==================== REGENERATE ALL BUTTON ==================== */
.dir-regen-all-btn {
    min-height: 28px;
    width: auto;
    border: 1px solid rgba(92, 232, 154, 0.25);
    border-radius: 10px;
    background: rgba(92, 232, 154, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 17px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
}
.dir-regen-all-btn:hover {
    background: rgba(92, 232, 154, 0.25);
    border-color: rgba(92, 232, 154, 0.5);
    color: #fff;
    transform: translateY(-1px) scale(1.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.dir-regen-all-btn:active {
    transform: scale(0.95);
}

/* ==================== QUICK VIDEO BUTTON ON CELLS ==================== */
.dir-cell-video-btn {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    padding: 0;
    z-index: 3;
}
.dir-composite-cell:hover .dir-cell-video-btn {
    opacity: 1;
}
.dir-cell-video-btn:hover {
    background: rgba(59, 130, 246, 0.8);
    color: #fff;
    transform: scale(1.15);
}

/* Expand overlay — larger video button */
.dir-cell-video-btn-expand {
    width: 28px;
    height: 28px;
    top: 8px;
    left: 8px;
    opacity: 0.7;
}
.dir-expand-grid .dir-composite-cell:hover .dir-cell-video-btn-expand {
    opacity: 1;
}

/* ==================== IMPORT BUTTON ON CELLS ==================== */
.dir-cell-import-btn {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(6, 12, 8, 0.7);
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    padding: 0;
    z-index: 3;
}
.dir-composite-cell:hover .dir-cell-import-btn {
    opacity: 1;
}
.dir-cell-import-btn:hover {
    background: rgba(92, 232, 154, 0.8);
    color: #fff;
    transform: scale(1.15);
}

/* ==================== EMPTY CELL IMPORT PLACEHOLDER ==================== */
.dir-cell-empty-import {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    height: 100%;
}
.dir-cell-empty-import:hover {
    color: rgba(92, 232, 154, 0.5);
    background: rgba(92, 232, 154, 0.05);
}

/* ==================== DRAG-OVER HIGHLIGHT ==================== */
.dir-composite-cell.drag-over,
.dir-panel-composite.drag-over {
    box-shadow: inset 0 0 0 2px rgba(74, 222, 128, 0.6) !important;
    background: rgba(74, 222, 128, 0.08) !important;
}

/* ==================== SCENE CARDS (Left Panel Scenes Tab) ==================== */
.dir-scene-card {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: rgba(92, 232, 154, 0.03);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(92, 232, 154, 0.06);
}
.dir-scene-card:hover {
    border-color: rgba(92, 232, 154, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(92, 232, 154, 0.08);
    transform: scale(1.02);
}
.dir-scene-card.active {
    border-color: rgba(74, 222, 128, 0.5);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3);
}
.dir-scene-card.active::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
    z-index: 3;
}

/* Mosaic preview grid */
.dir-scene-mosaic {
    position: absolute;
    inset: 0;
    display: grid;
    gap: 1px;
}
.dir-scene-mosaic.dir-scene-mosaic-1 { grid-template-columns: 1fr; }
.dir-scene-mosaic.dir-scene-mosaic-2 { grid-template-columns: 1fr 1fr; }
.dir-scene-mosaic.dir-scene-mosaic-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.dir-scene-mosaic.dir-scene-mosaic-3 > :first-child { grid-row: 1 / 3; }
.dir-scene-mosaic.dir-scene-mosaic-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.dir-scene-mosaic-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Info overlay */
.dir-scene-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 8px 5px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    z-index: 2;
    pointer-events: none;
}
.dir-scene-card-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.dir-scene-card-prompt {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* New Scene button */
.dir-new-scene-btn {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 10px;
    border: 2px dashed rgba(92, 232, 154, 0.2);
    background: transparent;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.dir-new-scene-btn:hover {
    border-color: rgba(74, 222, 128, 0.4);
    color: rgba(74, 222, 128, 0.7);
    background: rgba(74, 222, 128, 0.04);
}

/* Drop zone at bottom of scenes list */
.dir-scene-drop-zone {
    width: 100%;
    min-height: 50px;
    border-radius: 10px;
    border: 2px dashed rgba(92, 232, 154, 0.12);
    background: transparent;
    color: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-top: 4px;
}
.dir-scene-drop-zone.drag-over {
    border-color: rgba(74, 222, 128, 0.5);
    background: rgba(74, 222, 128, 0.06);
    color: rgba(74, 222, 128, 0.7);
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.1);
}

/* ==================== GENERATE MORE + NEW SCENE NAV BUTTONS ==================== */
#dirGenerateMore {
    background: rgba(45, 183, 48, 0.15);
    border-color: rgba(45, 183, 48, 0.3);
    color: rgba(74, 222, 128, 0.9);
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
}
#dirGenerateMore:hover {
    background: rgba(45, 183, 48, 0.25);
    border-color: rgba(74, 222, 128, 0.5);
    color: #4ade80;
}
#dirNewSceneNav {
    font-size: 13px;
}

/* ==================== EXPANDED GRID (scrollable) ==================== */
.dir-panels-area.dir-panels-expanded {
    grid-template-rows: none;
    grid-auto-rows: minmax(200px, auto);
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
}
/* Portrait aspect in expanded mode */
.dir-panels-area.dir-panels-expanded.dir-portrait-expanded {
    grid-auto-rows: minmax(280px, auto);
}
.dir-panels-area.dir-panels-expanded::-webkit-scrollbar { width: 4px; }
.dir-panels-area.dir-panels-expanded::-webkit-scrollbar-track { background: transparent; }
.dir-panels-area.dir-panels-expanded::-webkit-scrollbar-thumb { background: rgba(92, 232, 154, 0.2); border-radius: 4px; }

/* ==================== RESPONSIVE: Scene cards ==================== */
@media (max-width: 900px) {
    .dir-scene-card {
        width: 140px;
        flex-shrink: 0;
    }
    .dir-selections-list.dir-scenes-scroll {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
    }
}

/* ==================== IMAGE LIGHTBOX ==================== */
.dir-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dir-lightbox-overlay.active {
    opacity: 1;
}

.dir-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(92, 232, 154, 0.2);
    background: rgba(92, 232, 154, 0.08);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    z-index: 10;
}

.dir-lightbox-close:hover {
    background: rgba(92, 232, 154, 0.2);
    color: #fff;
}

.dir-lightbox-label {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
}

.dir-lightbox-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 85vw;
    max-height: 88vh;
    background: rgba(14, 20, 16, 0.85);
    border: 1px solid rgba(92, 232, 154, 0.15);
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(92, 232, 154, 0.04);
}

.dir-lightbox-img {
    max-height: 70vh;
    max-width: 85vw;
    object-fit: contain;
    display: block;
    border-radius: 14px 14px 0 0;
}

.dir-lightbox-prompt-label {
    width: 100%;
    padding: 8px 16px 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(92, 232, 154, 0.6);
    box-sizing: border-box;
}

.dir-lightbox-prompt {
    width: 100%;
    padding: 4px 16px 10px;
    font-size: 14px;
    color: var(--text-tertiary);
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
    border-top: none;
    box-sizing: border-box;
    user-select: text;
}

.dir-lightbox-prompt::-webkit-scrollbar {
    width: 4px;
}

.dir-lightbox-prompt::-webkit-scrollbar-thumb {
    background: rgba(92, 232, 154, 0.2);
    border-radius: 2px;
}

.dir-lightbox-actions {
    display: flex;
    gap: 6px;
    padding: 10px 16px 12px;
    width: 100%;
    justify-content: center;
    border-top: 1px solid rgba(92, 232, 154, 0.08);
    box-sizing: border-box;
}

.dir-lightbox-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(92, 232, 154, 0.06);
    color: var(--text-tertiary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.dir-lightbox-action-btn:hover {
    background: rgba(92, 232, 154, 0.15);
    color: #fff;
    border-color: rgba(92, 232, 154, 0.3);
}

.dir-lightbox-action-btn.active {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

.dir-lightbox-action-btn.active:hover {
    background: rgba(248, 113, 113, 0.1);
}

.dir-lightbox-action-btn span {
    font-size: 14px;
}

.dir-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(92, 232, 154, 0.15);
    background: rgba(92, 232, 154, 0.06);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    z-index: 10;
}

.dir-lightbox-nav:hover {
    background: rgba(92, 232, 154, 0.18);
    color: #fff;
    border-color: rgba(92, 232, 154, 0.3);
}

.dir-lightbox-nav-left {
    left: 20px;
}

.dir-lightbox-nav-right {
    right: 20px;
}

/* Lightbox responsive */
@media (max-width: 768px) {
    .dir-lightbox-img {
        max-height: 55vh;
        max-width: 95vw;
    }

    .dir-lightbox-card {
        max-width: 95vw;
    }

    .dir-lightbox-nav-left {
        left: 8px;
    }

    .dir-lightbox-nav-right {
        right: 8px;
    }

    .dir-lightbox-actions {
        flex-wrap: wrap;
    }

    .dir-lightbox-action-btn span {
        display: none;
    }
}
