#sidebar {
    flex-shrink: 0;
    display: none;
    position: sticky;
    top: var(--header-height, 56px);
    width: 240px;
    max-width: 50vw;
    height: calc(100vh - var(--header-height, 56px));
    padding-right: 2px;
    border-right: 1px solid #e5e7eb;
    background-color: #fff;
    box-shadow: 0px 0 4px rgba(0, 0, 0, 0.1);
    z-index: 97;
    --text-color: #676767;
    --item-padding: 6px 6px 6px 12px;
    --hover-bg: #f5f5f4;
    --active-bg: #edf2fa;
    --loading-icon: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNzQyMzU2MjM3Mzg5IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQ3NTkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiPjxwYXRoIGQ9Ik0yMDQuOCAyMDQuOG0tMjA0LjggMGEyMDQuOCAyMDQuOCAwIDEgMCA0MDkuNiAwIDIwNC44IDIwNC44IDAgMSAwLTQwOS42IDBaIiBmaWxsPSIjRUJGMkZDIiBwLWlkPSI0NzYwIj48L3BhdGg+PHBhdGggZD0iTTgxOS4yIDIwNC44bS0yMDQuOCAwYTIwNC44IDIwNC44IDAgMSAwIDQwOS42IDAgMjA0LjggMjA0LjggMCAxIDAtNDA5LjYgMFoiIGZpbGw9IiNCNUQyRjMiIHAtaWQ9IjQ3NjEiPjwvcGF0aD48cGF0aCBkPSJNODE5LjIgODE5LjJtLTIwNC44IDBhMjA0LjggMjA0LjggMCAxIDAgNDA5LjYgMCAyMDQuOCAyMDQuOCAwIDEgMC00MDkuNiAwWiIgZmlsbD0iIzdGQjBFQSIgcC1pZD0iNDc2MiI+PC9wYXRoPjxwYXRoIGQ9Ik0yMDQuOCA4MTkuMm0tMjA0LjggMGEyMDQuOCAyMDQuOCAwIDEgMCA0MDkuNiAwIDIwNC44IDIwNC44IDAgMSAwLTQwOS42IDBaIiBmaWxsPSIjNEE5MEUyIiBwLWlkPSI0NzYzIj48L3BhdGg+PC9zdmc+");
}

#sidebar.isShow {
    display: block;
}

@media screen and (max-width: 768px) {
    #sidebar.isShow {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        width: unset;
        max-width: unset;
        height: unset;
        margin-right: 0;
    }
}

.sidebar-header {
    height: 64px;
    padding: 0 6px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header .sidebar-upload-btn {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    color: #606266;
    cursor: pointer;
}

.sidebar-header .sidebar-upload-btn svg {
    width: 1.2em;
    height: 1.2em;
    fill: currentColor;
}

.sidebar-header .sidebar-upload-btn.uploading {
    pointer-events: none;
    cursor: default;
}

.sidebar-header .sidebar-upload-btn.uploading>* {
    visibility: hidden;
}

.sidebar-header .sidebar-upload-btn.uploading::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--loading-icon) center center / 16px no-repeat;
    animation: loading-rotate 1.5s linear infinite;
}

.sidebar-header .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: none;
    background-color: transparent;
    outline: none;
    cursor: pointer;
}

.sidebar-content {
    height: calc(100% - 64px);
    padding: 0 4px 0 6px;
    scrollbar-width: thin;
    overflow: hidden auto;
}

.section-group {
    display: block;
    margin-bottom: 12px;
}

.section-group[chat],
.section-group[folder] {
    display: block !important;
}

.section-group:has(.section-body:empty) {
    display: none;
}

.section-header {
    height: 34px;
    padding: 0 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    color: #999;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.section-header__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    font-size: 14px;
    color: #333;
    font-weight: 500;
    overflow: hidden;
}

.section-header__title svg {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.section-header__expand-btn {
    padding: 0;
    border: none;
    background-color: transparent;
    outline: none;
    font-size: 14px;
    color: inherit;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
}

.section-header__expand-btn svg {
    width: 0.9em;
    height: 0.9em;
    fill: currentColor;
}

.section-header.more:hover {
    background: var(--hover-bg);
    color: #333;
    cursor: pointer;
}

.section-header.more .section-header__expand-btn {
    display: flex;
}

.section-placeholder button {
    width: 100%;
    height: 36px;
    padding: var(--item-padding);
    border: none;
    border-radius: 6px;
    background-color: #fff;
    outline: none;
    transition: background-color 0.2s, color 0.2s;
    font-size: 14px;
    color: #a6a09b;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.section-placeholder button:hover {
    background-color: var(--hover-bg);
    color: var(--text-color);
}

.section-placeholder button svg {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.section-body {
    min-height: 20px;
}

#sidebar .dropdown-menu {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 97;
    padding: 6px;
    border-radius: 6px;
    background-color: #fff;
    box-shadow: 0 2px 6px 3px rgba(0, 0, 0, 0.1);
}

#sidebar .dropdown-menu .menu-item {
    all: initial;
    display: block;
    position: relative;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
    font-size: 14px;
    color: #79716b;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

#sidebar .dropdown-menu .menu-item:hover {
    background-color: var(--hover-bg);
}

#sidebar .dropdown-menu .menu-item.disabled {
    background-color: transparent !important;
    color: #ccc;
    cursor: default;
}

#sidebar .dropdown-menu .submenu {
    position: absolute;
    left: 100%;
    top: -6px;
    min-width: 150px;
    max-width: 200px;
    max-height: 50vh;
    padding: 6px;
    border-radius: 8px;
    background-color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.2s ease;
    scrollbar-width: thin;
    overflow: auto;
    display: none;
}

#sidebar .dropdown-menu .submenu-left {
    left: auto;
    right: 100%;
}

#sidebar .dropdown-menu .submenu-top {
    top: auto;
    bottom: 0;
}

#sidebar .dropdown-menu .menu-item:hover>.submenu {
    display: block;
}

#sidebar .dropdown-menu .menu-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 5px 0;
}

/* chat-item */
.chat-item {
    position: relative;
    margin-top: 2px;
    padding: var(--item-padding);
    border-radius: 6px;
    background-color: transparent;
    transition: background-color 0.2s;
    font-size: 15px;
    color: #79716b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item:hover {
    background-color: var(--hover-bg);
}

.chat-item.selected {
    background-color: var(--active-bg);
}

.chat-item__name {
    flex: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.chat-item__more {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 6px;
}

.chat-item__more:hover {
    background-color: #fff;
}

/* folder-item */
.folder-item {
    position: relative;
    margin-top: 2px;
    font-size: 15px;
    color: #79716b;
    cursor: pointer;
}

.folder-header {
    position: relative;
    padding: var(--item-padding);
    border-radius: 6px;
    background-color: transparent;
    transition: background-color 0.1s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.folder-header:hover {
    background-color: var(--hover-bg);
    --action-visiable: visible;
}

.folder-header__name {
    flex: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.folder-header__expand,
.folder-header__more {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: var(--action-visiable, hidden);
}

.folder-header__expand:hover,
.folder-header__more:hover {
    background-color: #fff;
}

.folder-header__expand svg {
    transform: rotate(0);
    transition: transform 0.3s;
}

.folder-files {
    max-height: 0;
    transition: max-height 0.3s, padding 0.3s;
    overflow: hidden;
}

.folder-files__inner {
    padding: 4px;
    border: 1px solid #e7e5e4;
    border-radius: 0 0 6px 6px;
    background-color: #f9fafb;
}

.folder-files__inner .empty-upload-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: var(--item-padding);
    border: none;
    border-radius: 6px;
    background-color: transparent;
    outline: none;
    font-size: 14px;
    color: #888;
    cursor: pointer;
}

.folder-files__inner .empty-upload-btn:hover {
    background-color: var(--hover-bg);
    color: #666;
}

.folder-files__inner:has(.chat-item) .empty-upload-btn {
    display: none;
}

.folder-item.expanded .folder-header {
    background-color: #e7e5e4;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.folder-item.expanded .folder-header__expand svg {
    transform: rotate(180deg);
}

.folder-item.expanded .folder-files {
    max-height: var(--max-height, 9999px);
}

/* flashcard-item */
.flashcard-item {
    position: relative;
    margin-top: 2px;
    padding: var(--item-padding);
    border-radius: 6px;
    background-color: #fff;
    transition: background-color 0.2s;
    font-size: 15px;
    color: #79716b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.flashcard-item:hover {
    background-color: var(--hover-bg);
}

.flashcard-item.selected {
    background-color: var(--active-bg);
}

.flashcard-item__name {
    flex: 1;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.flashcard-item__more {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 4px;
    border-radius: 6px;
}

.flashcard-item__more:hover {
    background-color: #fff;
}

#fixed-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 250px;
    right: 0;
    bottom: 0;
    z-index: 97;
    background-color: rgba(0, 0, 0, 0.2);
}

.drawer-container {
    position: relative;
    width: 320px;
    height: 100%;
    background: #fff;
    overflow: hidden auto;
    display: flex;
    flex-direction: column;
}

.drawer-header {
    height: 40px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-header__title {
    margin: 0;
    padding: 0;
    font-size: 15px;
    color: #333;
    font-weight: 500;
}

.drawer-header__close {
    padding: 8px;
    border: none;
    background-color: transparent;
    color: #a6a09b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.drawer-body {
    flex: 1;
    margin-top: 8px;
    padding: 0 8px;
    scrollbar-width: thin;
    overflow: hidden auto;
}

@media screen and (max-width: 768px) {
    #fixed-drawer {
        top: 0 !important;
        left: 0 !important;
        width: 100%;
        height: 100%;
    }

    #fixed-drawer .drawer-container {
        width: 100%;
    }
}

/* rename-popup */
#rename-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
}

#rename-popup .popup-container {
    position: relative;
    width: 95%;
    max-width: 500px;
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    animation: popup-slide-up 0.2s ease-out;
}

#rename-popup .popup-header__title {
    margin: 0;
    padding: 0;
    font-size: 16px;
    color: #222;
    line-height: normal;
    font-weight: 500;
}

#rename-popup .popup-header__close {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
    outline: none;
    color: #a6a09b;
    cursor: pointer;
}

#rename-popup .popup-content {
    padding: 20px 0;
}

#rename-popup input {
    width: 100%;
    height: 36px;
    padding: 4px 12px;
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    background-color: #fff;
    outline: none;
    font-size: 15px;
    color: #333;
}

#rename-popup input:focus {
    border-color: #009c4c;
}

#rename-popup input.error {
    border-color: #ff0000;
}

#rename-popup .popup-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#rename-popup .popup-footer button {
    min-width: 90px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background-color: #f1f1f1;
    transition: background-color 0.2s;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#rename-popup .popup-footer button:disabled {
    background-color: #e6e6e6 !important;
    cursor: not-allowed;
}

#rename-popup .popup-footer .confirm-btn {
    background-color: #009c4c;
    color: #fff;
}

#rename-popup .popup-footer .confirm-btn:hover {
    background-color: #008037;
}

#rename-popup .popup-footer .cancel-btn {
    background-color: #f1f1f1;
    color: #333;
}

#rename-popup .popup-footer .cancel-btn:hover {
    background-color: #f5f5f5;
}

/* create-folder-popup */
#create-folder-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
    display: none;
    align-items: center;
    justify-content: center;
}

#create-folder-popup .popup-container {
    position: relative;
    width: 95%;
    max-width: 500px;
    padding: 20px;
    border-radius: 8px;
    background-color: #fff;
    animation: popup-slide-up 0.2s ease-out;
}

#create-folder-popup .popup-header__title {
    margin: 0;
    padding: 0;
    font-size: 16px;
    color: #222;
    line-height: normal;
    font-weight: 500;
}

#create-folder-popup .popup-header__close {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background-color: transparent;
    outline: none;
    color: #a6a09b;
    cursor: pointer;
}

#create-folder-popup .popup-content {
    padding: 20px 0;
}

#create-folder-popup .placehodler-text {
    margin-top: 20px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 14px;
    color: #333333;
    line-height: 28px;
}

#create-folder-popup .placehodler-text ul {
    margin: 0;
    padding-left: 2em;
}

#create-folder-popup input {
    width: 100%;
    height: 36px;
    padding: 4px 12px;
    border: 1px solid #e7e5e4;
    border-radius: 6px;
    background-color: #fff;
    outline: none;
    font-size: 15px;
    color: #333;
}

#create-folder-popup input:focus {
    border-color: #009c4c;
}

#create-folder-popup input.error {
    border-color: #ff0000;
}

#create-folder-popup .popup-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

#create-folder-popup .popup-footer button {
    min-width: 90px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background-color: #f1f1f1;
    transition: background-color 0.2s;
    font-size: 15px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#create-folder-popup .popup-footer button:disabled {
    background-color: #e6e6e6 !important;
    cursor: not-allowed;
}

#create-folder-popup .popup-footer .confirm-btn {
    background-color: #009c4c;
    color: #fff;
}

#create-folder-popup .popup-footer .confirm-btn:hover {
    background-color: #008844;
}

/* #upload-dialog */
#upload-dialog {
    width: 360px;
    max-width: 90vw;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#upload-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.2);
}

#upload-dialog .dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

#upload-dialog .dialog-header__title {
    margin: 0;
    font-size: 15px;
    color: #222;
    font-weight: 500;
}

#upload-dialog .dialog-header__close {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: none;
    background: none;
    outline: none;
    cursor: pointer;
    color: #a6a09b;
}

#upload-dialog .dialog-content {
    position: relative;
    margin: 20px 16px;
    overflow-y: auto;
}

#upload-dialog .dialog-footer {
    display: flex;
    justify-content: center;
    padding: 12px;
    border-top: 1px solid #eee;
}

#upload-dialog .dialog-footer button {
    min-width: 120px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #f1f1f1;
    outline: none;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

#upload-dialog .dialog-footer button:hover {
    background-color: #f5f5f5;
}

@keyframes rename-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loading-rotate {
    to {
        transform: rotate(360deg);
    }
}