:root {
    --nav-bg: #ffffff;
    --nav-text: #333333;
    --primary: #4a6cf7;
    --primary-hover: #3856e0;
    --border-color: #e5e7eb;
    --body-bg: #f4f6f9;
    --body-text: #333333;
    --text-secondary: #555555;
    --input-bg: #ffffff;
    --focus-ring: rgba(74, 108, 247, 0.15);
    --link-color: #4a6cf7;
}

html.dark-mode {
    --nav-bg: #1f2937;
    --nav-text: #f3f4f6;
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --border-color: #374151;
    --body-bg: #111827;
    --body-text: #f3f4f6;
    --text-secondary: #9ca3af;
    --input-bg: #374151;
    --focus-ring: rgba(96, 165, 250, 0.25);
    --link-color: #60a5fa;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--body-bg);
    color: var(--body-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { 
    color: var(--link-color); 
    text-decoration: none; 
}

header { 
    background-color: var(--nav-bg); 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    border-bottom: 1px solid var(--border-color); 
}

.header-content { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 20px; 
    height: 70px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 15px; /* 增加头部主区域收缩间距 */
}

/* 品牌 Logo 区域 */
.brand-logo { 
    display: flex; 
    align-items: center; 
    color: var(--nav-text); 
    font-weight: 600; 
    font-size: 1.15rem; 
    gap: 10px; 
    flex-shrink: 0; /* 防止Logo被挤压 */
    white-space: nowrap;
}

.logo-img { 
    max-height: 36px; 
    width: auto; 
}

.brand-text-wrap { 
    display: flex; 
    flex-direction: column; 
}

.site-title { 
    line-height: 1.2; 
}

.site-subtitle { 
    font-size: 0.75rem; 
    color: var(--text-secondary); 
    font-weight: normal; 
    margin-top: 2px; 
}

/* 控制按钮与右侧区域 */
.right-section, .header-controls { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.mobile-only-controls { 
    display: none; 
}

.pc-only-controls { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-left: 4px; 
    list-style: none; 
    flex-shrink: 0; /* 防止控件被压缩 */
}

.menu-toggle { 
    display: none; 
    background: none; 
    border: none; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: var(--nav-text); 
}

/* 导航菜单容器 */
.nav-links { 
    list-style: none; 
    margin: 0; 
    padding: 0; 
    display: flex; 
    align-items: center; 
    gap: 8px; /* 稍微缩减默认间距，给长英文留空间 */
    flex-wrap: nowrap; /* 强制单行排开，禁止换行 */
}

.nav-links > li {
    display: flex;
    align-items: center;
    white-space: nowrap; /* 确保列表项不换行 */
    flex-shrink: 0; /* 防止菜单项缩窄变虚 */
}

/* 菜单项文字样式优化 */
.menu-item {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 6px 10px; /* 适当精简内边距，提升横向容纳度 */
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap; /* 核心：防止英文短语断行换行 */
    display: inline-block;
}

.menu-item:hover, .menu-item.active {
    color: var(--primary);
    background-color: rgba(74, 108, 247, 0.08);
}

html.dark-mode .menu-item:hover, html.dark-mode .menu-item.active {
    background-color: rgba(96, 165, 250, 0.12);
}

.nav-avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    border: 1px solid var(--border-color); 
    object-fit: cover; 
    flex-shrink: 0;
}

/* 搜索框自适应宽度优化 */
.search-form { 
    display: flex; 
    align-items: center; 
    background: var(--input-bg); 
    border-radius: 6px; 
    padding: 2px 6px; 
    border: 1px solid var(--border-color); 
    flex-shrink: 1; /* 空间不足时优先缩小搜索框 */
}

.search-input { 
    border: none; 
    background: transparent; 
    outline: none; 
    padding: 6px 6px; 
    font-size: 0.88rem; 
    width: 110px; /* 适当缩减默认宽度，增强排版兼容性 */
    transition: width 0.3s ease;
    color: var(--body-text); 
}

/* 搜索框获得焦点时自动展开 */
.search-input:focus {
    width: 150px;
}

.search-btn { 
    background: none; 
    border: none; 
    cursor: pointer; 
    padding: 0 4px;
}

/* 用户功能区 */
.user-nav { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-link, .btn-logout, .btn-primary { 
    padding: 6px 12px; 
    border-radius: 6px; 
    font-size: 0.9rem; 
    font-weight: 500; 
    white-space: nowrap; 
    display: inline-block;
}

.btn-link { color: var(--text-secondary); }
.btn-logout { color: #ef4444; }
.btn-primary { color: #fff; background: var(--primary); }

/* 翻译选择框与主题切换 */
.translate-select {
    padding: 5px 20px 5px 8px;
    border-radius: 20px;
    border: 1px solid var(--primary);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    outline: none;
    white-space: nowrap;
}

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: var(--nav-text);
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.theme-toggle-btn svg { 
    width: 18px; 
    height: 18px; 
}

html.dark-mode .theme-toggle-btn {
    color: #ffffff;
    border-color: #4b5563;
}

/* 响应式适配 (移动端及中等屏幕) */
@media (max-width: 992px) and (min-width: 769px) {
    /* 中等屏幕（如 iPad 或小屏笔记本）菜单过多时的优化 */
    .site-subtitle { display: none; }
    .search-input { width: 90px; }
    .search-input:focus { width: 120px; }
    .nav-links { gap: 4px; }
    .menu-item { padding: 6px 8px; font-size: 0.88rem; }
}

@media (max-width: 768px) {
    .site-subtitle, .pc-only-controls { display: none !important; }
    .menu-toggle, .mobile-only-controls { display: block; }
    .mobile-only-controls { display: flex; }

    .nav-links {
        position: absolute;
        top: 65px;
        right: 15px;
        background: var(--nav-bg);
        flex-direction: column;
        align-items: stretch; /* 移动端菜单全宽撑开 */
        padding: 12px 16px;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        display: none;
        gap: 10px;
    }

    .nav-links.active { 
        display: flex; 
    }

    .nav-links > li {
        width: 100%;
    }

    .menu-item {
        width: 100%;
        box-sizing: border-box;
    }

    .search-form {
        width: 100%;
    }

    .search-input {
        width: 100%;
    }

    .search-input:focus {
        width: 100%;
    }

    .user-nav {
        width: 100%;
        justify-content: space-between;
    }
}