@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

body { font-family: 'Inter', sans-serif; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #09090b; }
::-webkit-scrollbar-thumb { background: #27272a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }

.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

.bg-checkered {
    background-image: linear-gradient(45deg, #18181b 25%, transparent 25%), linear-gradient(-45deg, #18181b 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #18181b 75%), linear-gradient(-45deg, transparent 75%, #18181b 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.loader { 
    border: 2px solid rgba(255, 255, 255, 0.1); 
    border-top: 2px solid #ffffff; 
    border-radius: 50%; 
    animation: spin 0.8s linear infinite; 
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.animate-fade-in { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.safe-area-pb { padding-bottom: env(safe-area-inset-bottom, 20px); }

.mobile-settings-content {
    transition: height 0.3s ease, opacity 0.3s ease;
    overflow-y: auto;
    background-color: #121214;
}

.settings-expanded {
    height: 45vh; 
    opacity: 1;
    border-bottom: 1px solid #27272a;
}

.settings-collapsed {
    height: 0;
    opacity: 0;
    overflow: hidden;
    border-bottom: none;
}

@media (min-width: 768px) {
    .mobile-settings-content {
        height: auto !important;
        flex: 1;
        opacity: 1 !important;
        border-bottom: none;
    }
    .settings-expanded, .settings-collapsed {
        height: auto !important;
    }
}

.storage-settings-content {
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    overflow: hidden;
    background-color: #121214;
}

.storage-expanded {
    max-height: 300px;
    opacity: 1;
    padding: 12px;
}

.storage-collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 12px;
}

#storageGrid > div {
    content-visibility: auto; 
    contain-intrinsic-size: 100px;
}

.toggle-handle {
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background-color: #121214;
    border-top: 1px solid #27272a;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-handle:hover { background-color: #18181b; }
.toggle-handle-bar {
    width: 40px;
    height: 4px;
    background-color: #52525b;
    border-radius: 9999px;
}

.btn-glow {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s ease;
}
.btn-glow:active { transform: scale(0.98); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }

.fab-btn {
    width: 48px; height: 48px; border-radius: 50%; background-color: #2563eb; color: white; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: transform 0.2s; z-index: 50;
}
.fab-btn:active { transform: scale(0.9); }

.mobile-tool-popup {
    position: absolute; bottom: 60px; right: 0; background-color: #18181b; border: 1px solid #27272a; border-radius: 12px; padding: 12px; width: 200px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); z-index: 50; max-height: 300px; overflow-y: auto; transform-origin: bottom right; animation: popUp 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popUp { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

.vertical-toolbar {
    width: 60px; background-color: #121214; border-left: 1px solid #27272a; display: flex; flex-direction: column; align-items: center; padding: 16px 0; gap: 16px; z-index: 20;
}

.tool-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: #a1a1aa; transition: all 0.2s; cursor: pointer; }
.tool-btn:hover { color: white; background: #27272a; }
.tool-btn.active { color: #3b82f6; background: #2563eb20; border: 1px solid #2563eb; }

.input-dark { background: #09090b; border: 1px solid #27272a; color: #e4e4e7; outline: none; transition: all 0.2s; }
.input-dark:focus { border-color: #3b82f6; background: #121214; }
textarea.input-dark { resize: none; }
@media (min-width: 768px) { textarea.input-dark { resize: vertical; min-height: 120px; } }

.nav-btn { color: #a1a1aa; transition: all 0.2s; font-weight: 500; }
.nav-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-btn.active { background: #27272a; color: #fff; }

.chat-bubble { max-width: 85%; padding: 12px 16px; border-radius: 16px; font-size: 0.95rem; line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.2); position: relative; display: flex; flex-direction: column; gap: 8px; }
.user-bubble { background: #3b82f6; color: #fff; border-bottom-left-radius: 4px; border-bottom-right-radius: 16px; }
.bot-bubble { background: #27272a; color: #e4e4e7; border: 1px solid #3f3f46; border-bottom-left-radius: 4px; }
#chatFilePreview::-webkit-scrollbar { height: 4px; }
#chatFilePreview::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 2px; }

@media (max-width: 768px) {
    .view-section { flex-direction: column; }
    .mobile-scroll-x { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .director-source-container { height: 300px !important; }
}

.char-prompt-card { transition: border-color 0.2s; }
.char-prompt-card:hover { border-color: #3b82f6; }
.coords-popup { animation: fadeIn 0.1s ease-out; }
.cropper-point { background-color: #3b82f6; width: 8px; height: 8px; }

@media (min-width: 768px) {
    #mainSidebar.desktop-collapsed { width: 0 !important; min-width: 0 !important; flex-basis: 0 !important; border-right: none !important; padding: 0 !important; margin: 0 !important; opacity: 0 !important; pointer-events: none !important; }
}

.highlight-wrapper {
    position: relative;
    width: 100%;
    display: block;
    background-color: #18181b; 
    border: 1px solid #27272a; 
    border-radius: 0.375rem; 
    transition: border-color 0.2s, background-color 0.2s;
}

.highlight-wrapper:focus-within {
    border-color: #3b82f6; 
    background-color: #18181b;
}

.highlight-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
    font-family: inherit;
    font-size: 12px;
    line-height: 1.5;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0.5rem;
    background-color: transparent;
    border-radius: 0.375rem;
}

.highlight-wrapper textarea {
    display: block;
    width: 100%;
    background: transparent !important;
    color: #e4e4e7;
    position: relative;
    z-index: 2;
    line-height: 1.5;
    font-size: 12px;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0.375rem;
    padding: 0.5rem;
    margin: 0;
    resize: vertical !important;
    min-height: 80px; 
    overflow: auto;
}

.emphasis-1 { background: rgba(34, 197, 94, 0.3); border-radius: 2px; }
.emphasis-2 { background: rgba(34, 197, 94, 0.5); border-radius: 2px; }
.emphasis-3 { background: rgba(34, 197, 94, 0.7); border-radius: 2px; }

.deemphasis-1 { background: rgba(239, 68, 68, 0.3); border-radius: 2px; }
.deemphasis-2 { background: rgba(239, 68, 68, 0.5); border-radius: 2px; }
.deemphasis-3 { background: rgba(239, 68, 68, 0.7); border-radius: 2px; }

.history-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    background-color: #09090b;
    border-left: 1px solid #27272a;
    z-index: 60; 
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0,0,0,0.5);
}

.history-sidebar.open {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .history-sidebar {
        width: 85%;
        max-width: 320px;
        z-index: 60;
    }
}

.history-toggle-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background-color: #121214;
    border: 1px solid #27272a;
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: #71717a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
    transition: all 0.2s;
}
.history-toggle-btn:hover {
    background-color: #27272a;
    color: #fff;
    width: 28px;
}

.history-mobile-hint {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 60px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px 0 0 4px;
    z-index: 35;
    pointer-events: none; 
    animation: hintPulse 2s infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

.history-sidebar.open + .history-mobile-hint, 
.history-sidebar.open ~ .history-mobile-hint {
    display: none;
}

/* --- Image Aspect Ratio Fix --- */
#genResultImg, #naiGeneratedImage, #directorResultImg, #imageViewerImg {
    width: auto !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}