:root {
    --sidebar-width: 260px;
    --primary-color: #4285f4;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --header-height: 60px;
}

/* 基础重置 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body { 
    font-family: system-ui, -apple-system, sans-serif; 
    background: var(--bg-color); 
    display: flex; 
    color: #333;
    width: 100%;
    overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

/* 遮罩层 */
#sidebar-overlay { 
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.3); z-index: 998; 
}

/* 侧边栏整体 */
#sidebar { 
    width: var(--sidebar-width); height: 100vh; background: #fff; 
    border-right: 1px solid #eee; position: fixed; left: 0; top: 0; 
    overflow-y: auto; transition: transform 0.3s ease; z-index: 1000;
}

/* --- 侧边栏 Logo 区域：水平齐平且居中 --- */
.logo-container {
    display: flex;
    flex-direction: row;    /* 水平齐平 */
    align-items: center;    /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    padding: 30px 10px;
    gap: 12px;
    border-bottom: 1px solid #f5f5f5;
    margin-bottom: 10px;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* 菜单样式 */
.nav-item { padding: 12px 20px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: #555; text-decoration: none; }
.nav-item:hover { background: #f0f7ff; color: var(--primary-color); }
.folder-header { font-weight: 600; background: #fcfcfc; }
.arrow { font-size: 10px; transition: transform 0.3s; color: #ccc; }
.sub-menu { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; background: #fafafa; padding-left: 12px; }
.folder-wrapper.open > .sub-menu { max-height: 3000px; }
.folder-wrapper.open > .folder-header .arrow { transform: rotate(90deg); }

/* 主内容区 */
#main-content { 
    margin-left: var(--sidebar-width); 
    flex: 1; 
    padding: 30px; 
    min-width: 0;
    width: 100%;
}

/* 搜索组件 */
.search-wrapper { display: flex; justify-content: center; margin: 30px 0 60px 0; width: 100%; }
.search-container { 
    display: flex; align-items: center; background: #fff; 
    border: 2px solid #eee; border-radius: 35px; 
    padding: 8px 18px; width: 100%; max-width: 600px;
}
.search-container:focus-within { border-color: var(--primary-color); box-shadow: 0 8px 20px rgba(0,0,0,0.06); }

.engine-selector { position: relative; cursor: pointer; display: flex; align-items: center; padding-right: 12px; border-right: 1px solid #eee; flex-shrink: 0; }
.engine-selector img { width: 20px; height: 20px; }
.engine-list { 
    position: absolute; top: 45px; left: -10px; background: #fff; 
    border: 1px solid #eee; border-radius: 12px; list-style: none; 
    display: none; width: 110px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 101;
}
.engine-list.show { display: block; }
.engine-list li { padding: 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }

#search-input { border: none; outline: none; padding: 10px; flex: 1; font-size: 16px; background: transparent; min-width: 0; }
#search-btn { background: none; border: none; color: var(--primary-color); font-weight: bold; cursor: pointer; padding-left: 10px; flex-shrink: 0; }

/* 书签卡片 Grid */
.section { margin-bottom: 40px; scroll-margin-top: 80px; width: 100%; }
.section-title { font-size: 18px; margin-bottom: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; width: 100%; }
.card { background: var(--card-bg); padding: 12px; border-radius: 10px; text-decoration: none; color: #444; display: flex; align-items: center; gap: 10px; border: 1px solid #eee; overflow: hidden; }
.card img { width: 16px; height: 16px; flex-shrink: 0; }
.card span { font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 手机端 Header */
.mobile-header {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height); background: #fff; border-bottom: 1px solid #eee;
    align-items: center; justify-content: center;
    padding: 0 15px; z-index: 999;
}

#menu-toggle {
    position: absolute;
    left: 15px;
    background: var(--primary-color); color: white; border: none;
    width: 36px; height: 36px; border-radius: 6px; font-size: 20px;
    display: flex; align-items: center; justify-content: center;
}

.mobile-logo-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-logo-box img { height: 26px; }
.mobile-logo-box span { font-weight: 700; font-size: 18px; color: #1a1a1a; }

#back-to-top-pc { position: fixed; bottom: 30px; right: 20px; width: 45px; height: 45px; background: #fff; border: 1px solid #eee; border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 997; }

/* --- 手机端适配 (修复核心) --- */
@media (max-width: 768px) {
    .mobile-header { display: flex; }
    #sidebar { transform: translateX(-100%); padding-top: 0; }
    #sidebar.open { transform: translateX(0); }
    #sidebar.open + #sidebar-overlay { display: block; }
    
    #main-content { 
        margin-left: 0; 
        padding: calc(var(--header-height) + 20px) 15px 20px; 
        width: 100%;
    }

    /* 恢复手机端双栏显示 */
    .grid { 
        grid-template-columns: 1fr 1fr !important; 
        gap: 10px; 
    }
}

/* 辅助样式 */
.icon-container { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 4px; background: #f0f0f0; flex-shrink: 0; }
.favicon { width: 100%; height: 100%; opacity: 0; transition: opacity 0.2s; }
.letter-icon { display: none; font-size: 14px; font-weight: bold; color: #fff; }
.icon-container.no-icon { background: #4a90e2; }
.icon-container.no-icon .letter-icon { display: block; }
#current-engine-icon { width: 24px; height: 24px; object-fit: contain; image-rendering: -webkit-optimize-contrast; }
#main-content {
    min-height: 100vh; /* 确保内容不满一屏时，footer 也能沉在下面 */
    display: flex;
    flex-direction: column;
}

#nav-display {
    flex: 1; /* 这会让导航内容占据剩余空间，把 footer 挤到底部 */
}
