.cp-left-sidebar {
    position: fixed;
    top: var(--header-height, 70px);
    left: -320px;
    width: 70px;
    height: calc(100vh - var(--header-height, 70px));
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    z-index: var(--z-sidebar);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 20px rgba(0, 0, 0, 0.4);
    overflow-x: hidden;
    white-space: nowrap;
}

.cp-left-sidebar.open { left: 0; }
.cp-left-sidebar.expanded { width: 320px; }

.cp-left-sidebar-header,
.cp-left-list,
.cp-left-bottom-action {
    width: 320px;
    min-width: 320px;
    box-sizing: border-box;
}

.cp-left-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: var(--bg-header-tabs);
    border-bottom: 1px solid var(--border-color);
}

.cp-left-sidebar-actions { display: flex; gap: 4px; }
.cp-left-sidebar-tabs {
    width: 84px; height: 40px; overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cp-left-sidebar-tabs-inner {
    display: flex; gap: 4px; width: 84px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cp-tab-btn {
    position: relative; background: transparent; border: none;
    color: var(--text-dim); width: 40px; height: 40px; padding: 0;
    border-radius: 8px; cursor: pointer; transition: var(--transition);
    display: flex; justify-content: center; align-items: center; flex-shrink: 0;
}
.cp-tab-btn svg { width: 20px; height: 20px; }
.cp-tab-btn:hover { color: var(--text-pure); background: var(--border-lighter); }
.cp-tab-btn.active { color: var(--primary); background: rgba(var(--primary-rgb), 0.1); }

.cp-badge {
    position: absolute; top: -2px; right: -2px;
    background: var(--danger); color: white; font-size: 9px;
    font-weight: bold; min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; display: flex; justify-content: center; align-items: center;
    border: 2px solid var(--bg-header-tabs); box-sizing: border-box; z-index: 10;
}

.cp-left-tab-content { display: none; flex-direction: column; flex: 1; overflow: hidden; width: 320px; min-width: 320px; }
.cp-left-tab-content.active { display: flex; }

.cp-chat-views-container { position: relative; flex: 1; overflow: hidden; display: flex; width: 100%; }
.cp-chat-view { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; flex-direction: column; }
.cp-chat-view.list-view { z-index: 1; }
.cp-chat-view.active-view {
    z-index: 2; background-color: var(--bg-panel);
    transform: translateX(100%); transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.cp-chat-view.active-view.active { transform: translateX(0); }

.cp-search-wrapper { padding: 10px 15px 5px 15px; width: 320px; box-sizing: border-box; }
.cp-search-container {
    display: flex; align-items: center; background: var(--bg-item);
    border: 1px solid var(--border-color); border-radius: 8px; height: 40px;
    width: 100%; transition: all 0.3s; overflow: hidden;
}
.cp-search-icon { width: 18px; height: 18px; color: var(--text-dim); margin: 0 11px; flex-shrink: 0; }
.cp-search-input { background: transparent; border: none; color: var(--text-pure); outline: none; width: 100%; font-size: 0.9rem; transition: opacity 0.2s; }
.cp-clear-search { background: transparent; border: none; color: var(--text-dim); width: 30px; height: 100%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: color 0.2s; }
.cp-clear-search:hover { color: var(--text-pure); }
.cp-clear-search svg { width: 16px; height: 16px; }

.cp-left-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 5px 0 10px 0; }
.cp-left-item { display: flex; align-items: center; padding: 12px 15px; gap: 15px; cursor: pointer; transition: background-color 0.2s; user-select: none; width: 100%; box-sizing: border-box; }
.cp-left-item:hover { background-color: var(--bg-item); }

.chat-user-item .cp-layered-avatar,
.cp-active-chat-user .cp-layered-avatar {
    overflow: visible !important;
}
.chat-user-item .cp-layered-avatar > div,
.cp-active-chat-user .cp-layered-avatar > div {
    border-radius: 50%; overflow: hidden;
}

.online .cp-layered-avatar::after {
    content: ''; position: absolute; bottom: 0; right: -2px; width: 12px; height: 12px;
    background: var(--success); border: 2px solid var(--bg-panel); border-radius: 50%; z-index: 5;
}
.is-favorite .cp-layered-avatar::before {
    content: '★'; position: absolute; bottom: -4px; left: -4px; color: var(--warning); font-size: 14px;
    display: flex; justify-content: center; align-items: center; border-radius: 50%; text-shadow: 0 1px 3px rgba(0,0,0,0.8); z-index: 6;
}
.offline .cp-layered-avatar { opacity: 0.6; }

.cp-left-sidebar:not(.expanded) .cp-layered-avatar { opacity: 1 !important; }

.cp-left-info { display: flex; flex-direction: column; min-width: 0; flex: 1; transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s; max-width: 250px; overflow: hidden; white-space: nowrap; }
.cp-left-name { color: var(--text-pure); font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; }
.cp-left-subtext { color: var(--text-dim); font-size: 0.8rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; transition: color 0.2s; }

.cp-chat-unread { background: var(--danger); color: white; font-size: 0.75rem; font-weight: bold; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: flex; justify-content: center; align-items: center; box-sizing: border-box; transition: opacity 0.2s; }

.cp-left-bottom-action { display: flex; padding: 15px; background-color: var(--bg-header-tabs); border-top: 1px solid var(--border-color); width: 320px; min-width: 320px; box-sizing: border-box; }
.cp-new-chat-btn { width: 290px; height: 40px; background: rgba(var(--primary-rgb), 0.1); color: var(--primary); border: 1px solid rgba(var(--primary-rgb), 0.2); padding: 0; border-radius: 8px; display: flex; justify-content: center; align-items: center; font-weight: 600; cursor: pointer; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s, color 0.2s; overflow: hidden; white-space: nowrap; }
.cp-new-chat-btn:hover { background: var(--primary); color: white; }
.cp-new-chat-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.cp-new-chat-btn span { margin-left: 8px; transition: max-width 0.3s, opacity 0.2s; max-width: 150px; opacity: 1; }

.cp-active-chat-header { display: flex; align-items: center; gap: 10px; padding: 10px 15px; background: var(--bg-header-tabs); border-bottom: 1px solid var(--border-color); width: 320px; box-sizing: border-box; transition: background 0.2s; }
#backToChatList { transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s, margin 0.3s; max-width: 40px; overflow: hidden; padding: 4px; }

.cp-active-chat-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.cp-active-chat-user .cp-left-name { transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s; max-width: 200px; white-space: nowrap; overflow: hidden; }

.cp-chat-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 15px 10px 15px 15px; display: flex; flex-direction: column; gap: 12px; }
.cp-message { display: flex; flex-direction: column; max-width: 85%; }
.cp-message.received { align-self: flex-start; }
.cp-message.sent { align-self: flex-end; align-items: flex-end; }
.cp-msg-bubble { padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; color: var(--text-pure); white-space: pre-wrap; word-break: break-word; }
.cp-message.received .cp-msg-bubble { background: var(--bg-item); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; }
.cp-message.sent .cp-msg-bubble { background: var(--primary); border-bottom-right-radius: 4px; }
.cp-msg-time { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }

.cp-chat-input-area { padding: 15px; background-color: var(--bg-header-tabs); border-top: 1px solid var(--border-color); width: 320px; box-sizing: border-box; }
.cp-chat-input-wrapper { display: flex; align-items: flex-end; gap: 8px; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 12px; padding: 6px 10px; }
.cp-chat-input-wrapper:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2); }
.cp-chat-input-wrapper textarea { flex: 1; background: transparent; border: none; color: var(--text-pure); font-size: 0.9rem; line-height: 1.4; resize: none; outline: none; padding: 4px 8px 4px 0; margin: 0; max-height: 100px; overflow-y: auto; }

.cp-send-btn { background: var(--primary); color: white; border: none; border-radius: 8px; width: 28px; height: 28px; display: flex; justify-content: center; align-items: center; cursor: pointer; flex-shrink: 0; transition: var(--transition); padding: 0; margin-bottom: 2px; }
.cp-send-btn:hover { background: var(--primary-hover); }
.cp-send-btn svg { width: 14px; height: 14px; }

.cp-coming-soon { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 30px; text-align: center; color: var(--text-dim); }
.cp-coming-soon svg { width: 48px; height: 48px; margin-bottom: 15px; opacity: 0.5; }
.cp-coming-soon h3 { color: var(--text-main); margin: 0 0 10px 0; font-size: 1.1rem; }
.cp-coming-soon p { font-size: 0.85rem; line-height: 1.5; margin: 0; }

.cp-context-menu { position: fixed; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 6px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); padding: 6px 0; min-width: 190px; z-index: 9999; display: none; }
.cp-menu-item { display: block; width: 100%; text-align: left; padding: 10px 18px; background: none; border: none; color: var(--text-main); font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: background 0.2s; text-transform: none; letter-spacing: normal; }
.cp-menu-item:hover { background: var(--bg-item); color: var(--text-pure); }

.cp-left-sidebar:not(.expanded) .cp-left-sidebar-tabs { width: 40px; }
.cp-left-sidebar:not(.expanded) .cp-left-sidebar-tabs:has(.cp-tab-btn[data-target="tab-quests"].active) .cp-left-sidebar-tabs-inner { transform: translateX(-44px); }
.cp-left-sidebar:not(.expanded) .cp-search-container { width: 40px; background: transparent; border-color: transparent; cursor: pointer; }
.cp-left-sidebar:not(.expanded) .cp-search-container:hover { background: var(--border-lighter); }
.cp-left-sidebar:not(.expanded) .cp-search-input, .cp-left-sidebar:not(.expanded) .cp-clear-search { opacity: 0; pointer-events: none; }
.cp-left-sidebar:not(.expanded) .cp-new-chat-btn { width: 40px; }
.cp-left-sidebar:not(.expanded) .cp-new-chat-btn span { max-width: 0; opacity: 0; margin-left: 0; }

.cp-left-sidebar:not(.expanded) .cp-left-list::-webkit-scrollbar { display: none; }
.cp-left-sidebar:not(.expanded) .cp-left-list { -ms-overflow-style: none; scrollbar-width: none; }

.cp-left-sidebar:not(.expanded) .cp-left-info,
.cp-left-sidebar:not(.expanded) .cp-active-chat-user .cp-left-name { max-width: 0; opacity: 0; }

.cp-left-sidebar:not(.expanded) .cp-chat-unread,
.cp-left-sidebar:not(.expanded) .cp-chat-messages,
.cp-left-sidebar:not(.expanded) .cp-chat-input-area,
.cp-left-sidebar:not(.expanded) .cp-coming-soon { opacity: 0; pointer-events: none; transition: opacity 0.2s; }

.cp-left-sidebar:not(.expanded) #backToChatList { max-width: 0; margin: 0; opacity: 0; pointer-events: none; padding: 0; }

.cp-left-sidebar:not(.expanded) .cp-layered-avatar { width: 40px !important; height: 40px !important; }
.cp-left-sidebar:not(.expanded) .cp-active-chat-header { cursor: pointer; padding: 15px 0; justify-content: center; width: 70px; }
.cp-left-sidebar:not(.expanded) .cp-active-chat-header:hover { background: var(--border-lighter); }
.cp-left-sidebar:not(.expanded) .cp-active-chat-user { justify-content: center; width: 100%; }

#pinLeftBtn { transition: color 0.2s, background 0.2s; }
#pinLeftBtn svg { transform: rotate(45deg); transition: transform 0.3s ease; }
#pinLeftBtn.pinned { color: var(--primary); background: rgba(var(--primary-rgb), 0.1); border-radius: 6px; }
#pinLeftBtn.pinned svg { transform: rotate(0deg); }

.challenge-bubble { background: var(--bg-item) !important; border: 1px solid var(--border-color) !important; text-align: center; min-width: 200px; display: flex; flex-direction: column; gap: 10px; }
.chal-title { font-weight: 800; color: var(--text-main); font-size: 1rem; margin-bottom: 2px; }
.chal-time { font-size: 0.85rem; color: var(--text-pure); font-weight: 600; }
.chal-wait { font-size: 0.8rem; color: var(--text-dim); font-style: italic; }
.chal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 5px; }

.chal-btn { background: var(--border-lighter); border: 1px solid var(--border-light); width: 38px; height: 38px; border-radius: 8px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s ease; }
.chal-btn svg { width: 20px; height: 20px; }
.chal-btn.accept { color: var(--success); }
.chal-btn.accept:hover { background: rgba(var(--success-rgb), 0.15); border-color: var(--success); }
.chal-btn.decline { color: var(--danger); }
.chal-btn.decline:hover { background: rgba(var(--danger-rgb), 0.15); border-color: var(--danger); }

.cp-left-sidebar:not(.expanded) .cp-left-item { padding: 12px 15px !important; justify-content: flex-start !important; gap: 15px !important; }
.cp-left-sidebar:not(.expanded) .cp-search-wrapper { padding: 10px 15px 5px 15px !important; display: block !important; }
.cp-left-sidebar:not(.expanded) .cp-search-container { margin: 0 !important; }

@media (max-width: 900px) {
    .cp-left-sidebar {
        left: -100vw;
    }
    .cp-left-sidebar.open, .cp-left-sidebar.expanded {
        width: 100vw;
        left: 0;
    }
    .cp-left-sidebar-header,
    .cp-left-list,
    .cp-left-bottom-action,
    .cp-left-tab-content,
    .cp-search-wrapper,
    .cp-active-chat-header,
    .cp-chat-input-area {
        width: 100vw;
        min-width: 100vw;
    }
    #pinLeftBtn {
        display: none;
    }
}