
/* 针对桌面端和中型屏幕，维持比例布局，不使用固定像素 */
@media (min-width: 1151px) {
    .wrapper {
        grid-template-columns: 18% 1fr 20%; 
        gap: 25px;
    }
    .sidebar, .extra-sidebar { width: 100%; }
}

/* 针对窄屏笔记本或横向平板 (1150px 以下) */
@media (max-width: 1150px) {
    .wrapper {
        grid-template-columns: 22% 1fr; /* 隐藏右侧，调大左侧比例 */
        gap: 20px;
        padding: 30px 20px;
    }
    .extra-sidebar {
        display: none; 
    }
}

/* 移动端处理 (768px 以下) */
@media (max-width: 768px) {
    .wrapper {
        display: block;
        padding: 70px 12px 20px;
        z-index: auto !important; 
    }

    /* 左侧侧边栏移动端样式 (抽屉) */
    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        width: 290px;
        height: 100vh;
        z-index: 10001; 
        transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 15px 0 50px rgba(0,0,0,0.3);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(15px) saturate(180%);
        -webkit-backdrop-filter: blur(15px) saturate(180%);
        padding: 80px 20px 40px !important;
    }

    /* 右侧侧边栏移动端样式 (抽屉) */
    .extra-sidebar {
        display: flex !important;
        position: fixed;
        right: -320px;
        top: 0;
        width: 290px;
        height: 100vh;
        z-index: 10001;
        transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: -15px 0 50px rgba(0,0,0,0.3);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(15px) saturate(180%);
        -webkit-backdrop-filter: blur(15px) saturate(180%);
        padding: 80px 15px 40px !important;
    }

    .sidebar.active { left: 0; }
    .extra-sidebar.active { right: 0; }

    /* 优化侧边栏滚动条 */
    .sidebar::-webkit-scrollbar, .extra-sidebar::-webkit-scrollbar {
        width: 4px;
    }
    .sidebar::-webkit-scrollbar-thumb, .extra-sidebar::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 0;
        opacity: 0.5;
    }

    .dark-mode .sidebar, .dark-mode .extra-sidebar {
        background: rgba(20, 20, 25, 0.85) !important;
    }

    /* 按钮控制 */
    #mobile-menu-toggle, #mobile-extra-toggle, #mobile-search-toggle, #theme-toggle {
        display: flex !important;
        position: fixed;
        top: 15px;
        width: 42px;
        height: 42px;
        border-radius: 0;
        background: var(--glass-bg);
        backdrop-filter: blur(15px);
        border: 1px solid var(--glass-border);
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
        z-index: 10005;
        align-items: center;
        justify-content: center;
        font-size: 1.1em;
        color: var(--primary-color);
        cursor: pointer;
    }

    #mobile-menu-toggle { left: 15px; }
    #mobile-extra-toggle { right: 119px; } 
    #mobile-search-toggle { right: 67px; } 
    #theme-toggle { right: 15px !important; top: 15px !important; }

    .search-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        z-index: 2000000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .search-overlay.active {
        display: flex;
        opacity: 1;
        justify-content: center;
        align-items: flex-start;
        padding-top: 80px;
    }

    .search-overlay-content {
        width: 90%;
        max-width: 500px;
        position: relative;
    }

    .close-search-btn {
        position: absolute;
        top: -50px;
        right: 0;
        background: none;
        border: none;
        color: white;
        font-size: 1.5em;
        cursor: pointer;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.4);
        z-index: 10000; 
        backdrop-filter: blur(5px);
    }
    
    .sidebar-overlay.active { display: block; }

    .email-pop {
        z-index: 2147483647 !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    }

    .content-card {
        padding: 24px 16px;
    }

    .post-content {
        font-size: 1em !important;
    }

    .post-content h2,
    .post-content h3 {
        padding-left: 10px !important;
    }

    .post-content table {
        font-size: 0.88em;
    }

    .post-content th,
    .post-content td {
        padding: 8px 10px;
    }

    .post-content pre {
        font-size: 0.9em;
    }

    .post-content img {
        max-width: 100% !important;
    }
}

@media (min-width: 769px) {
    #mobile-menu-toggle, #mobile-extra-toggle, #mobile-search-toggle, .search-overlay { display: none !important; }
}

img { max-width: 100%; height: auto; }
