@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-appear {
    animation: fadeIn 0.25s ease-out;
}

#messages-container::-webkit-scrollbar {
    width: 6px;
}
#messages-container::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 3px;
}

#session-list::-webkit-scrollbar {
    width: 4px;
}
#session-list::-webkit-scrollbar-thumb {
    background: #36344d;
    border-radius: 2px;
}

/* Menú de la app: panel flotante con scroll propio. */
.ks-sidebar-app-nav {
    scrollbar-width: thin;
    scrollbar-color: #3f3f46 transparent;
}
.ks-sidebar-app-nav::-webkit-scrollbar {
    width: 5px;
}
.ks-sidebar-app-nav::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 4px;
}

/* Ancho del sidebar (arrastre); fallback hasta que cargue JS */
.ks-sidebar-root {
    --ks-sidebar-width: 384px;
}

.ks-app-sidebar {
    width: min(var(--ks-sidebar-width), calc(100vw - 2rem));
    min-width: min(220px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
}

.sidebar-main-stack {
    overflow: hidden;
}

.sidebar-main-stack .ks-sidebar-scroll-main,
.sidebar-main-stack[data-app-menu-expanded="true"] .ks-sidebar-scroll-main,
.sidebar-main-stack[data-app-menu-expanded="false"] .ks-sidebar-scroll-main {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

#sidebar-app-menu-shell {
    flex: 0 0 auto;
    background: #1d1e20;
    position: relative;
    z-index: 20;
}

.ks-sidebar-footer {
    position: relative;
    z-index: 20;
    background: #1d1e20;
}

.ks-sidebar-app-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(1px);
}

.ks-sidebar-app-nav-panel {
    position: fixed;
    z-index: 50;
    top: 1rem;
    bottom: 1rem;
    left: max(0.75rem, min(calc(var(--ks-sidebar-width) + 0.75rem), calc(100vw - 23rem)));
    width: min(22rem, calc(100vw - 1.5rem));
    padding: 0.85rem;
    border: 1px solid rgba(55, 65, 81, 0.9);
    border-radius: 1.25rem;
    background: #1d1e20;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.ks-sidebar-app-nav-panel:focus {
    outline: none;
}

@media (max-width: 640px) {
    .ks-app-sidebar {
        width: min(var(--ks-sidebar-width), calc(100vw - 0.5rem));
        min-width: min(210px, calc(100vw - 0.5rem));
        max-width: calc(100vw - 0.5rem);
    }

    .ks-sidebar-app-nav-panel {
        inset: 0.5rem;
        width: auto;
        border-radius: 1rem;
    }
}

.ks-sidebar-resize-handle {
    width: 6px;
    flex-shrink: 0;
    cursor: col-resize;
    align-self: stretch;
    touch-action: none;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    transition: background-color 0.15s ease;
}

.ks-sidebar-resize-handle:hover,
.ks-sidebar-resize-handle:focus-visible {
    background-color: rgba(23, 107, 224, 0.35);
    outline: none;
}

body.ks-sidebar-resizing {
    cursor: col-resize !important;
    user-select: none;
}

textarea#message-input {
    max-height: 200px;
    overflow-y: auto;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #176BE0;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

input:focus, select:focus, textarea:focus {
    outline: none;
}

.ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 16px;
    font-size: 13px;
    text-align: left;
    transition: background 0.1s;
}
.ctx-item:hover {
    background: #f2f3f6;
}

#folder-tree::-webkit-scrollbar {
    width: 4px;
}
#folder-tree::-webkit-scrollbar-thumb {
    background: #36344d;
    border-radius: 2px;
}
