/* --- 全局和颜色变量 --- */
:root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --text-color: #e0e0e0;
    --text-secondary-color: #a0a0a0;
    --border-color: #333;
    --card-text-color: #ffffff;
    --card-border-color: rgba(255, 255, 255, 0.18);
    --card-bg-color: rgba(0, 0, 0, 0.45);
    --card-text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
body.light-mode {
    --bg-color: #f0f2f5;
    --surface-color: #ffffff;
    --primary-color: #6200ee;
    --text-color: #000000;
    --text-secondary-color: #5f6368;
    --border-color: #e0e0e0;
    --card-text-color: #000000;
    --card-border-color: rgba(0, 0, 0, 0.1);
    --card-bg-color: rgba(255, 255, 255, 0.55);
    --card-text-shadow: none;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    color: var(--text-color);
    background-color: var(--bg-color);
}
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-image: url('../images/background-desktop.webp');
    background-size: cover;
    background-position: center;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 20px 0; 
    padding-top: 20px; 
}

/* --- 主导航栏布局 --- */
.main-nav {
    position: sticky;
    top: 0; 
    z-index: 10;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
    margin-left: 0;
    margin-right: 0;
    padding-left: 20px;
    padding-right: 20px;
    margin-top: 0; 
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px; 
}

.logo-title { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }
.header-logo { width: 36px; height: 36px; background-image: url('/logo.svg'); background-size: contain; background-position: center; background-repeat: no-repeat; }

/* 标题样式 (在搜索栏用到) */
/* 修改：将颜色改为 var(--primary-color) 以跟随选中菜单颜色 */
h1 { 
    font-size: 1.2rem; 
    color: var(--primary-color); 
    margin: 0; 
    white-space: nowrap; 
}

.main-nav ul { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
    display: flex; 
    justify-content: center; 
    flex-wrap: wrap;
    flex: 1; 
}
.main-nav li { position: relative; }
.main-nav li a { 
    display: block; 
    padding: 0.8rem 1rem; 
    text-decoration: none; 
    color: var(--text-secondary-color); 
    font-weight: 500; 
    transition: color 0.2s;
    border-bottom: 2px solid transparent; 
    cursor: pointer; 
    position: relative; 
}
.main-nav li a:hover { color: var(--primary-color); }
.main-nav li a.active { 
    color: var(--primary-color); 
    font-weight: bold;
}
.main-nav li a.active::after {
    content: '';
    position: absolute;
    bottom: 0.2rem; 
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.theme-switcher { display: flex; align-items: center; flex-shrink: 0; }
.theme-switcher label { width: 30px; height: 30px; cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center; }
.theme-switcher svg { position: absolute; width: 12px; height: 12px; transition: opacity 0.3s ease; stroke: var(--text-color); }
.theme-switcher .sun-icon { opacity: 0; transform: rotate(-90deg); }
.theme-switcher .moon-icon { opacity: 1; transform: rotate(0deg); } body.light-mode .theme-switcher .sun-icon { opacity: 1; } body.light-mode .theme-switcher .moon-icon { opacity: 0; }
.theme-switcher input { display: none; }
.theme-switcher input:checked + label .sun-icon { opacity: 1; transform: rotate(0deg); }
.theme-switcher input:checked + label .moon-icon { opacity: 0; transform: rotate(90deg); }

.dropdown-content { opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s; position: absolute; background-color: transparent; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; list-style: none; padding: 5px; margin-top: -2px; }
.dropdown-content.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-content a { padding: 10px 14px; border-bottom: none !important; border-radius: 6px; text-shadow: var(--card-text-shadow); }
.dropdown-content a:hover { background-color: rgba(255, 255, 255, 0.1); }
.dropdown-content a.active { color: var(--primary-color); font-weight: bold; }

/* --- 搜索区域样式 (核心修改部分) --- */
.search-section { 
    max-width: 600px; 
    margin: 2.5rem auto; 
    padding-left: 20px; 
    padding-right: 20px;
}

/* 修改：垂直堆叠布局 + 居中对齐 */
.search-header {
    display: flex;
    flex-direction: column; /* 上下排列 */
    align-items: center; /* 修改：改为居中对齐 */
    margin-bottom: 10px; 
    gap: 8px; 
}

.search-tabs { 
    display: flex; 
    justify-content: center; /* 修改：改为居中对齐 */
    gap: 15px; 
    flex-wrap: wrap; 
}

.search-tab { position: relative; display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; cursor: pointer; background: transparent; border: 1px solid transparent; transition: background-color 0.2s; }
.search-tab:hover { background: rgba(255,255,255,0.1); }
.search-tab.active::after { content: ''; position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; background-color: var(--primary-color); border-radius: 50%; }
.search-tab span { color: var(--text-secondary-color); font-weight: 500; font-size: 0.95rem; }
.search-tab.active span { color: var(--text-color); }
.search-input-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.search-input { width: 100%; background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--card-border-color); border-radius: 12px; padding: 15px 60px 15px 20px; font-size: 1.1rem; color: var(--text-color); outline: none; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); box-sizing: border-box; }
body.light-mode .search-input { background: rgba(255, 255, 255, 0.4); }
.search-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: transparent; border: none; border-radius: 8px; width: 40px; height: 40px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.search-button svg { stroke: var(--text-secondary-color); transition: stroke 0.2s; }
.search-button:hover svg { stroke: var(--primary-color); }

/* --- 卡片样式 --- */
.link-group { margin-top: 2rem; }
.link-group ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }
.link-group a { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--card-text-color); border-radius: 12px; padding: 15px; height: 110px; box-sizing: border-box; text-align: center; 
    background: var(--card-bg-color);
    backdrop-filter: blur(1px); 
    -webkit-backdrop-filter: blur(1px);
    border: 1px solid var(--card-border-color); box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out, box-shadow 0.2s ease-in-out;
    will-change: transform;
    opacity: 0;
    animation: card-pop-in 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    position: relative;
    overflow: hidden;
}
@keyframes card-pop-in { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.link-group li:nth-child(1) a { animation-delay: 0.05s; } .link-group li:nth-child(2) a { animation-delay: 0.1s; } .link-group li:nth-child(3) a { animation-delay: 0.15s; } .link-group li:nth-child(4) a { animation-delay: 0.2s; } 
.link-group a:hover { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2); transform: translateY(-5px); }
.link-group a::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(100deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0) 80%); transform: translateX(-150%) skewX(-20deg); transition: transform 0.7s cubic-bezier(0.23, 1, 0.32, 1); }
.link-group a:hover::before { transform: translateX(150%) skewX(-20deg); }
.card-icon { width: 36px; height: 36px; margin-bottom: 12px; border-radius: 50%; background-color: transparent; background-size: cover; background-position: center; background-repeat: no-repeat; background-image: none; }
.card-name { font-weight: 500; font-size: 1rem; line-height: 1.2; word-break: break-word; text-shadow: var(--card-text-shadow); }
.placeholder { text-align: center; font-size: 1.2rem; color: var(--text-secondary-color); padding: 4rem; }
.placeholder.error { color: var(--error-color); }


/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .container { padding: 15px 0; padding-top: 0; }
    .main-nav {
        background: var(--card-bg-color);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
        margin-left: 0; margin-right: 0; padding-left: 15px; padding-right: 15px;
        height: auto;
        flex-wrap: wrap;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .logo-title { order: 1; }
    .theme-switcher { order: 2; }
    .main-nav ul { 
        order: 3; 
        width: 100%; 
        justify-content: flex-start; 
        overflow-x: auto;
        margin-top: 10px;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }
    body::before { background-image: url('../images/background-mobile.webp'); background-attachment: scroll; }
    h1 { font-size: 1.2rem; }
    .header-logo { width: 24px; height: 24px; }
    .link-group ul { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
    .main-nav li a { padding: 0.6rem 0.8rem; font-size: 0.9rem; padding-top: 2.1625rem; padding-bottom: 2.1625rem; }
    .main-nav li a.active::after { content: none; }
    .card-icon { width: 30px; height: 30px; margin-bottom: 8px; }
    .card-name { font-size: 0.8rem; }
    .link-group a { height: 90px; backdrop-filter: none; -webkit-backdrop-filter: none; animation: none; opacity: 1; transform-style: flat; transition: none; }
    .link-group a:hover { transform: none; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); }
    .link-group a::before { display: none; }
    .dropdown-content { backdrop-filter: none; -webkit-backdrop-filter: none; background-color: var(--surface-color); }
    .search-input { backdrop-filter: none; -webkit-backdrop-filter: none; }
    .search-section { margin: 1.5rem auto; }
    .search-input { padding: 12px 50px 12px 15px; font-size: 1rem; }
    .search-button { width: 36px; height: 36px; }
    .search-tab { padding: 6px 10px; }
    .search-tab span { font-size: 0.9rem; }
}
