/* ============================================================
   全局设计令牌
   ============================================================ */
:root {
    --sp-bg: #f4f5f7;
    --sp-surface: #ffffff;
    --sp-surface-hover: #f8f9fa;
    --sp-border: #e8e8e8;
    --sp-border-light: #f0f0f0;
    --sp-border-hover: #d8d8d8;
    --sp-text: #1a1a1a;
    --sp-text-secondary: #555555;
    --sp-text-muted: #888888;
    --sp-accent: #d93025;
    --sp-accent-hover: #b52b20;
    --sp-accent-light: rgba(217, 48, 37, 0.08);
    --sp-accent-glow: rgba(217, 48, 37, 0.12);
    --sp-shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --sp-shadow: 0 2px 8px rgba(0,0,0,0.06);
    --sp-shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --sp-shadow-lg: 0 12px 40px rgba(0,0,0,0.10);
    --sp-radius-sm: 8px;
    --sp-radius: 12px;
    --sp-radius-lg: 16px;
    --sp-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sp-transition-fast: all 0.2s ease;
    --header-height: 64px;
}

html.dark {
    --sp-bg: #0f1115;
    --sp-surface: #1a1d24;
    --sp-surface-hover: #22262e;
    --sp-border: #2a2e38;
    --sp-border-light: #252a34;
    --sp-border-hover: #3a3f4a;
    --sp-text: #f0f2f5;
    --sp-text-secondary: #a0a8b8;
    --sp-text-muted: #6b7280;
    --sp-accent: #ff6b6b;
    --sp-accent-hover: #ff8585;
    --sp-accent-light: rgba(255, 107, 107, 0.10);
    --sp-accent-glow: rgba(255, 107, 107, 0.15);
    --sp-shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --sp-shadow: 0 2px 8px rgba(0,0,0,0.25);
    --sp-shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --sp-shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
}

*, *::before, *::after {
    transition: background-color 0.25s ease, color 0.2s ease, border-color 0.2s ease;
}

:root {
    --dm-bg: #ffffff;
    --dm-bg-secondary: #f5f5f5;
    --dm-bg-tertiary: #fafafa;
    --dm-text: #111111;
    --dm-text-secondary: #555555;
    --dm-text-muted: #999999;
    --dm-border: #e5e5e5;
    --dm-border-light: #f0f0f0;
    --dm-shadow: rgba(0,0,0,0.06);
    --dm-card: #ffffff;
    --dm-input: #fafafa;
    --header-height: 64px;
}

html.dark {
    --dm-bg: #0a0a0a;
    --dm-bg-secondary: #111111;
    --dm-bg-tertiary: #111111;
    --dm-text: #f0f0f0;
    --dm-text-secondary: #b0b0b0;
    --dm-text-muted: #777777;
    --dm-border: #222222;
    --dm-border-light: #1a1a1a;
    --dm-shadow: rgba(0,0,0,0.5);
    --dm-card: #111111;
    --dm-input: #1a1a1a;
}

*, *::before, *::after {
    transition: background-color 0.25s ease, color 0.2s ease, border-color 0.2s ease;
}
/* ========== 图标+文字导航 ========== */
.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 32px;
    margin-right: auto;
}

.main-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: all .2s ease;
    white-space: nowrap;
}

.main-nav .nav-link:hover {
    background: rgba(0,0,0,0.04);
    color: #1a1a1a;
}

.main-nav .nav-link svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity .2s;
}

.main-nav .nav-link:hover svg {
    opacity: 1;
}

.main-nav .nav-link.active {
    color: #1a1a1a;
    font-weight: 600;
}

.main-nav .nav-link.active svg {
    opacity: 1;
}

/* 下拉箭头 */
.nav-arrow {
    margin-left: 2px;
    opacity: 0.5;
    transition: transform .2s;
}

.nav-dropdown:hover .nav-arrow {
    transform: rotate(180deg);
}

/* 下拉菜单 */
.nav-dropdown {
    position: relative;
}

.nav-dropdown .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    transform: translateY(-4px);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 6px 0;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.dropdown-arrow {
    position: absolute;
    top: -5px;
    left: 20px;
    transform: rotate(45deg);
    width: 10px;
    height: 10px;
    background: #fff;
    border-left: 1px solid #f0f0f0;
    border-top: 1px solid #f0f0f0;
    z-index: 1;
}

.dropdown-inner {
    position: relative;
    z-index: 2;
}

.dropdown-inner a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.dropdown-inner a:hover {
    background: rgba(0,0,0,0.03);
}

/* 缩短导航下划线（active状态） */
.main-nav .nav-link.active {
    border-bottom: none !important;
    position: relative;
}

.main-nav .nav-link.active::after {
    content: '' !important;
    position: absolute !important;
    bottom: 2px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 20px !important;
    height: 2px !important;
    background: #111 !important;
    border-radius: 1px !important;
    display: block !important;
}

/* 大屏平板横屏紧凑布局 */
@media (min-width: 992px) and (max-width: 1200px) {
    .main-nav {
        margin-left: 20px;
        gap: 2px;
    }
    .main-nav .nav-link {
        padding: 8px 10px;
        font-size: 13px;
    }
    .main-nav .nav-link svg {
        width: 14px;
        height: 14px;
    }
}

/* 移动端菜单图标+文字 */

/* 头部登录/注册链接 */
.header-auth-link {
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: all .2s;
}
.header-auth-link:hover {
    background: rgba(0,0,0,0.04);
}
html.dark .header-auth-link {
    color: var(--dm-text-secondary) !important;
}
html.dark .header-auth-link:hover {
    background: rgba(255,255,255,0.04) !important;
    color: var(--dm-text) !important;
}

/* ========== 头部登录/注册按钮（触发弹窗） ========== */
.auth-trigger {
    padding: 8px 10px;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.5;
    transition: all .2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    box-sizing: border-box;
}
.auth-trigger:hover {
    background: rgba(0,0,0,0.04);
    color: #1a1a1a;
}
html.dark .auth-trigger {
    color: var(--dm-text-secondary);
}
html.dark .auth-trigger:hover {
    background: rgba(255,255,255,0.04);
    color: var(--dm-text);
}

/* ========== 统一 header 右侧所有元素间距 ========== */
/* 搜索按钮在 .header-actions 外面，margin-right 要和内部 gap 一致 */
.search-toggle {
    margin-right: 8px !important;
}

/* .header-actions 内部统一 gap */
.header-actions {
    gap: 8px !important;
}

/* 清掉所有元素自带的 margin-right，避免和 gap 叠加 */
.msg-dropdown,
.msg-trigger,
.user-menu-dropdown,
.user-menu-trigger,
.theme-toggle,
.lang-toggle {
    margin-right: 0 !important;
}

.mobile-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
}



html.dark body {
    background: var(--dm-bg) !important;
    color: var(--dm-text) !important;
}

html.dark .site-header,
html.dark header {
    background: var(--dm-bg) !important;
    border-bottom: 1px solid var(--dm-border) !important;
}

/* 修正：全局规则会把页头内的 .container 刷成 #111，导致页头两侧与中间颜色不一致 */
html.dark .site-header .header-inner,
html.dark header .header-inner {
    background: transparent !important;
}

html.dark .logo span:first-child {
    background-color: #ffffff !important;
    color: #2e2e2e !important;
}
html.dark .logo span:last-child {
    color: #f0f0f0 !important;
}
/* LOGO 图标（SVG）：黑夜模式反转为白底黑 M */
html.dark .logo svg rect {
    fill: #ffffff !important;
}
html.dark .logo svg path {
    stroke: #111111 !important;
}

html.dark .search-toggle {
    background: transparent !important;
    color: #f0f0f0 !important;
    border: none !important;
}
html.dark .search-toggle:hover {
    background: #1a1a1a !important;
    border-radius: 8px !important;
}

html.dark .mobile-menu-toggle {
    color: var(--dm-text) !important;
}
html.dark .mobile-menu-toggle span {
    background: var(--dm-text) !important;
}

html.dark .site-footer,
html.dark footer {
    background: var(--dm-bg-secondary) !important;
    border-top: 1px solid var(--dm-border) !important;
    color: var(--dm-text-secondary) !important;
}

/* 已移除：.post-card、.comments-card、article、section、[class*="card"] */
html.dark .admin-card,
html.dark .ask-card,
html.dark .question-card,
html.dark .answers-section,
html.dark .answer-form-card,
html.dark .qna-main,
html.dark .sidebar-card,
html.dark .page-content,
html.dark .admin-page > div[class*="card"],
html.dark .main-content,
html.dark .content-area,
html.dark .site-main,
html.dark .primary,
html.dark #primary,
html.dark .sidebar,
html.dark .widget-area,
html.dark .secondary,
html.dark #secondary,
html.dark aside[class*="widget"],
html.dark [class*="sidebar"],
html.dark [class*="widget-area"],
html.dark .container,
html.dark .wrapper,
html.dark .box,
html.dark .panel,
html.dark .module {
    background: var(--dm-bg-secondary) !important;
    border-color: var(--dm-border) !important;
}

html.dark h1, html.dark h2, html.dark h3, html.dark h4, html.dark h5, html.dark h6,
html.dark .post-title, html.dark .question-title, html.dark .ask-title,
html.dark .admin-title, html.dark .sidebar-title, html.dark .footer-logo,
html.dark .entry-title, html.dark .page-title, html.dark .widget-title {
    color: var(--dm-text) !important;
}

html.dark p, html.dark span, html.dark div,
html.dark .post-content, html.dark .answer-content, html.dark .reply-content,
html.dark .question-content, html.dark .comment-body,
html.dark .entry-content, html.dark .article-content,
html.dark .post-excerpt, html.dark .entry-summary {
    color: var(--dm-text-secondary) !important;
}

html.dark small, html.dark .post-meta, html.dark .question-meta,
html.dark .answer-time, html.dark .reply-time, html.dark .footer-desc,
html.dark .entry-meta, html.dark .byline, html.dark .posted-on,
html.dark .cat-links, html.dark .tags-links, html.dark .comments-link {
    color: var(--dm-text-muted) !important;
}

html.dark strong, html.dark b {
    color: var(--dm-text) !important;
    font-weight: 700 !important;
}
html.dark em, html.dark i {
    color: var(--dm-text-secondary) !important;
}

html.dark a {
    color: var(--dm-text) !important;
}
html.dark a:hover {
    color: #ffffff !important;
}
html.dark .nav-link {
    color: var(--dm-text-secondary) !important;
}
html.dark .nav-link:hover {
    background: rgba(255,255,255,0.04) !important;
    color: var(--dm-text) !important;
}
html.dark .nav-link.active {
    color: var(--dm-text) !important;
}
html.dark .main-nav .nav-link svg {
    opacity: 0.6;
}
html.dark .main-nav .nav-link:hover svg,
html.dark .main-nav .nav-link.active svg {
    opacity: 1;
}
html.dark .nav-arrow {
    opacity: 0.4;
}
html.dark .main-nav .nav-link.active::after {
    background: #f0f0f0 !important;
}
html.dark .dropdown-arrow {
    background: #111 !important;
    border-color: #222 !important;
}

html.dark input,
html.dark textarea,
html.dark select,
html.dark .form-control,
html.dark .search-box input,
html.dark .comment-form input,
html.dark .comment-form textarea,
html.dark .answer-form input,
html.dark .answer-form textarea,
html.dark .reply-form-inline input,
html.dark .reply-form-inline textarea {
    background: var(--dm-input) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html.dark input:focus,
html.dark textarea:focus,
html.dark .form-control:focus {
    border-color: #444 !important;
    box-shadow: none !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--dm-text-muted) !important;
}

html.dark .admin-table,
html.dark table {
    background: var(--dm-bg-secondary) !important;
}
html.dark .admin-table th,
html.dark .admin-table td,
html.dark table th,
html.dark table td {
    border-color: var(--dm-border) !important;
    color: var(--dm-text-secondary) !important;
}
html.dark .admin-table thead {
    background: var(--dm-bg-secondary) !important;
}

html.dark .btn:not(.btn-primary):not(.btn-danger) {
    background: var(--dm-bg-secondary) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html.dark .btn:hover {
    background: var(--dm-border) !important;
}

html.dark .pagination a,
html.dark .qna-pagination a,
html.dark .pagination span,
html.dark .qna-pagination span {
    background: var(--dm-bg-secondary) !important;
    color: var(--dm-text-secondary) !important;
    border-color: var(--dm-border) !important;
}
html.dark .pagination a:hover,
html.dark .qna-pagination a:hover {
    color: var(--dm-text) !important;
    border-color: var(--dm-text-muted) !important;
}
html.dark .pagination .current,
html.dark .qna-pagination .current {
    background: var(--dm-text) !important;
    color: var(--dm-bg) !important;
    border-color: var(--dm-text) !important;
}

html.dark .search-overlay {
    background: rgba(0,0,0,0.8) !important;
}
html.dark .search-box {
    background: var(--dm-bg-secondary) !important;
}
html.dark .search-box button[type="submit"] {
    background: #333333 !important;
    color: #ffffff !important;
    border: 1px solid #444444 !important;
}
html.dark .search-box button[type="submit"]:hover {
    background: #444444 !important;
}
html.dark .mobile-menu {
    background: var(--dm-bg-secondary) !important;
    border-left: 1px solid var(--dm-border) !important;
}
html.dark .mobile-menu a {
    color: var(--dm-text) !important;
    border-bottom: 1px solid var(--dm-border) !important;
}

html.dark .ql-toolbar {
    background: var(--dm-bg-secondary) !important;
    border-color: var(--dm-border) !important;
}
html.dark .ql-toolbar button,
html.dark .ql-toolbar .ql-picker-label {
    color: var(--dm-text-secondary) !important;
}
html.dark .ql-toolbar button:hover {
    color: var(--dm-text) !important;
}
html.dark .ql-container {
    background: var(--dm-bg-secondary) !important;
    border-color: var(--dm-border) !important;
}
html.dark .ql-editor {
    color: var(--dm-text) !important;
}
html.dark .ql-editor.ql-blank::before {
    color: var(--dm-text-muted) !important;
}

html.dark pre,
html.dark code,
html.dark .ql-editor pre.ql-syntax {
    background: var(--dm-bg-secondary) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}

html.dark .badge,
html.dark .qna-cat-tag,
html.dark .question-cat-tag,
html.dark .post-tag,
html.dark .category-tag,
html.dark .cat-tag,
html.dark .tag,
html.dark a.badge,
html.dark a.tag,
html.dark a[class*="tag"],
html.dark a[class*="cat"],
html.dark [class*="tag"]:not(.ql-toolbar):not(.ql-container):not(.ql-editor) {
    background: #222222 !important;
    color: #ffffff !important;
    border: 1px solid #333333 !important;
}

html.dark .back-to-top {
    background: var(--dm-bg-secondary) !important;
    border-color: var(--dm-border) !important;
    color: var(--dm-text) !important;
}

html.dark hr,
html.dark .footer-bottom {
    border-color: var(--dm-border) !important;
}

html.dark .admin-sidebar {
    background: var(--dm-bg-secondary) !important;
    border-right: 1px solid var(--dm-border) !important;
}
html.dark .sidebar-nav .nav-item {
    color: var(--dm-text-secondary) !important;
}
html.dark .sidebar-nav .nav-item:hover,
html.dark .sidebar-nav .nav-item.active {
    background: var(--dm-border) !important;
    color: var(--dm-text) !important;
}

html.dark .empty-state,
html.dark .empty-qna,
html.dark .no-answers,
html.dark .no-comments {
    color: var(--dm-text-muted) !important;
}

html.dark .replies-list {
    background: var(--dm-bg-secondary) !important;
}
html.dark .reply-form-inline {
    background: var(--dm-bg-secondary) !important;
}

html.dark .img-preview-mask {
    background: rgba(0,0,0,0.9) !important;
}

/* ========== 主题切换按钮 ========== */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid #e0e0e0; background: #fff;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    margin-right: 8px; color: #333;
    transition: all 0.3s ease; flex-shrink: 0;
    margin-right: 10px !important;
}
.theme-toggle:hover {
    background: #f4f5f7; transform: scale(1.05);
}
html.dark .theme-toggle {
    border-color: #333; background: #1a1a1a; color: #f0f0f0;
}
html.dark .theme-toggle:hover {
    background: #2a2a2a;
}

/* ========== 语言切换按钮（EN/CN，与主题按钮同风格） ========== */
.lang-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid #e0e0e0; background: #fff;
    cursor: pointer; display: flex;
    align-items: center; justify-content: center;
    margin-right: 8px; color: #333;
    font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
    text-decoration: none; font-family: inherit;
    transition: all 0.3s ease; flex-shrink: 0;
    box-sizing: border-box;
}
.lang-toggle:hover {
    background: #f4f5f7; /* 不变换大小，文字不动 */
}
html.dark .lang-toggle {
    border-color: #333 !important; background: #1a1a1a !important; color: #f0f0f0 !important;
}
html.dark .lang-toggle:hover {
    background: #2a2a2a !important;
}
html.dark .user-menu-dropdown .user-menu-trigger {
    color: #f0f0f0 !important;
}
html.dark .user-menu-panel {
    background: #111111 !important;
    border-color: #222222 !important;
}
html.dark .user-menu-panel a {
    color: #cccccc !important;
}
html.dark .user-menu-panel a:hover {
    background: #1a1a1a !important;
    color: #f0f0f0 !important;
}


/* 导航 badge 黑夜模式适配 */
html.dark .nav-badge {
background: #ff6600 !important;  /* 稍亮一点的红色，在深色背景更醒目 */
box-shadow: 0 0 8px rgba(255, 77, 79, 0.35);  /* 微发光效果 */
color: #fff !important;
}

/* ========== 消息中心入口 ========== */
.msg-dropdown { position: relative; display: inline-block; margin-right: 4px; }
.msg-trigger {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #333; position: relative; transition: all .2s;
}
.msg-trigger:hover { background: #f4f5f7; }
.msg-badge {
    position: absolute; top: -2px; right: -2px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: #ff4d4f; color: #fff; border-radius: 8px;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.msg-panel {
    display: none; position: absolute;
    top: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    background: #fff; border: 1px solid #e0e0e0;
    border-radius: 10px; padding: 6px 0;
    min-width: 170px; box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    z-index: 100;
}
.msg-panel a {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; font-size: 15px; color: #333;
    text-decoration: none; transition: background 0.2s;
}
.msg-panel a + a { border-top: 1px solid #f5f5f5; }
.msg-panel a:hover { background: #f8f9fa; }
.msg-count {
    background: #ff4d4f; color: #fff; border-radius: 8px;
    padding: 1px 7px; font-size: 11px; font-weight: 700;
}
html.dark .msg-trigger { color: #f0f0f0 !important; }
html.dark .msg-trigger:hover { background: #1a1a1a !important; }
html.dark .msg-panel { background: #111111 !important; border-color: #222222 !important; }
html.dark .msg-panel a { color: #cccccc !important; }
html.dark .msg-panel a:hover { background: #1a1a1a !important; color: #f0f0f0 !important; }
html.dark .msg-panel a + a { border-color: #222222 !important; }

/* ========== 移动端菜单 ========== */
.mobile-menu-toggle {
    display: none;
    width: 40px; height: 40px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none; border: none;
    cursor: pointer; padding: 0;
    flex-shrink: 0;
}
.mobile-menu-toggle span {
    display: block; width: 22px; height: 2px;
    background: #333; border-radius: 2px;
    transition: all 0.3s ease;
}
.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.mobile-menu {
    display: none;
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 80%;
    max-width: 320px;
    height: calc(100% - var(--header-height));
    background: #fff;
    z-index: 999;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    -webkit-overflow-scrolling: touch;
}
.mobile-menu.show {
    display: flex;
    animation: menuSlideIn 0.3s ease forwards;
}
@keyframes menuSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.mobile-menu a {
    display: block; padding: 14px 0;
    font-size: 16px; font-weight: 600;
    color: #333; text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: color 0.2s;
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover,
.mobile-menu a.active { color: #1a1a1a; }
.mobile-menu .mobile-user-section {
    padding: 16px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 10px;
}
.mobile-menu .mobile-user-name {
    font-size: 18px; font-weight: 700;
    color: #1a1a1a; margin-bottom: 12px;
}
.mobile-menu .mobile-user-actions {
    display: flex; gap: 10px;
}
.mobile-menu .mobile-user-actions a {
    padding: 8px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    border: none; flex: 1; text-align: center;
}
.mobile-menu .mobile-user-actions a.btn-primary {
    background: #111; color: #fff;
}
.mobile-menu .mobile-user-actions a.btn-secondary {
    background: #f4f5f7; color: #333;
}

.mobile-menu-mask {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.35);
    z-index: 998;
}
.mobile-menu-mask.show {
    display: block;
    animation: maskFadeIn 0.3s ease forwards;
}
@keyframes maskFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========== 搜索弹窗 ========== */
.search-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 9999;
    align-items: flex-start;
    justify-content: center;
    padding-top: 120px;
}
.search-overlay.show { display: flex; }
.search-box {
    background: #fff; border-radius: 14px;
    width: 90%; max-width: 560px;
    padding: 24px; position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
.search-box form { display: flex; gap: 10px; }
.search-box input {
    flex: 1; padding: 12px 16px;
    border: 1px solid #e0e0e0; border-radius: 10px;
    font-size: 15px; outline: none; font-family: inherit;
}
.search-box input:focus { border-color: #1a1a1a; }
.search-box button[type="submit"] {
    padding: 12px 24px; background: #111;
    color: #fff; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600; cursor: pointer;
}
.search-close {
    position: absolute; top: -40px; right: 0;
    background: none; border: none;
    color: #fff; font-size: 24px;
    cursor: pointer; padding: 8px;
}

/* ========== 缩短导航下划线 ========== */
.main-nav .nav-link.active {
    border-bottom: none !important;
    position: relative;
}
.main-nav .nav-link.active::after {
    content: '' !important;
    position: absolute !important;
    bottom: 4px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 32px !important;
    height: 2px !important;
    background: #111 !important;
    border-radius: 1px !important;
    display: block !important;
}
html.dark .main-nav .nav-link.active::after {
    background: #f0f0f0 !important;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .main-nav { display: none !important; }
    .mobile-menu-toggle { display: flex !important; }
    .header-actions .user-menu-dropdown { display: none !important; }
    .header-actions .msg-dropdown { display: none !important; }
    .header-actions > a.nav-link { display: none !important; }
    .header-actions .auth-trigger { display: none !important; }
    .search-box { width: 95%; padding: 16px; }
    .search-box form { flex-direction: column; }
    .search-box button[type="submit"] { width: 100%; }
}

/* ========== 平板与横屏适配（新增） ========== */
/* 平板竖屏（769px–991px）：启用移动端菜单，搜索保持横向布局 */
@media (max-width: 991px) and (min-width: 769px) {
    .main-nav { display: none !important; }
    .mobile-menu-toggle { display: flex !important; }
    .header-actions .user-menu-dropdown { display: none !important; }
    .header-actions .msg-dropdown { display: none !important; }
    .header-actions > a.nav-link { display: none !important; }
    .header-actions .auth-trigger { display: none !important; }
    .search-box { width: 75%; max-width: 520px; }
    .search-box form { flex-direction: row !important; }
    .search-box button[type="submit"] { width: auto !important; }
}
/* 横屏设备（≤1024px）：收窄侧边菜单，优化搜索位置 */
@media (orientation: landscape) and (max-width: 1024px) {
    .mobile-menu {
        width: 40%;
        max-width: 360px;
        padding-top: calc(var(--header-height) + 16px);
    }
    .search-box {
        margin-top: 50px;
        max-width: 580px;
    }
}
/* 小屏横屏（手机横屏）：进一步压缩菜单与搜索 */
@media (orientation: landscape) and (max-height: 500px) {
    .mobile-menu {
        width: 36%;
        max-width: 300px;
        padding-top: calc(var(--header-height) + 8px);
    }
    .mobile-menu a {
        padding: 10px 0;
        font-size: 15px;
    }
    .mobile-menu .mobile-user-section {
        padding: 12px 0;
        margin-bottom: 6px;
    }
    .search-box {
        margin-top: 20px;
        padding: 16px;
    }
}
/* 大屏平板横屏（992px–1200px）：紧凑导航布局 */
@media (min-width: 992px) and (max-width: 1200px) {
    .header-inner {
        padding: 0 20px !important;
    }
    .main-nav {
        margin-left: 24px !important;
        gap: 0 !important;
    }
    .main-nav .nav-link {
        padding: 8px 10px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    :root { --header-height: 56px; }
    .site-header .header-inner { padding: 0 12px; }
    .logo span:last-child { font-size: 16px !important; }
    .theme-toggle { width: 32px; height: 32px; margin-right: 4px; }
    .lang-toggle { width: 32px; height: 32px; margin-right: 4px; font-size: 11px; }
    .search-toggle { width: 32px; height: 32px; padding: 0; }
    .mobile-menu-toggle { width: 36px; height: 36px; }
}

.user-menu-panel a:hover { background: #f4f5f7; }

html.dark .mobile-menu-toggle span { background: #f0f0f0; }
html.dark .mobile-menu {
    background: #111111 !important;
    border-left: 1px solid #222222 !important;
    box-shadow: -4px 0 24px rgba(0,0,0,0.5) !important;
}
html.dark .mobile-menu a {
    color: #f0f0f0; border-color: #222;
}
html.dark .mobile-menu a:hover,
html.dark .mobile-menu a.active { color: #fff; }
html.dark .mobile-menu .mobile-user-section { border-color: #222; }
html.dark .mobile-menu .mobile-user-name { color: #f0f0f0; }
html.dark .mobile-menu .mobile-user-actions a.btn-primary {
    background: #ffffff !important; color: #111 !important;
}
html.dark .mobile-menu .mobile-user-actions a.btn-secondary {
    background: transparent !important; color: #fff !important;
    border: 1px solid #444 !important;
}
html.dark .mobile-menu-mask {
    background: rgba(0,0,0,0.6) !important;
}

/* ========== 下拉菜单 ========== */
.nav-dropdown { position: relative; }
.nav-dropdown .dropdown-menu a:hover { background: rgba(0,0,0,0.03) !important; }
html.dark .nav-dropdown .dropdown-menu { background: #111 !important; border-color: #222 !important; }
html.dark .nav-dropdown .dropdown-menu > div:first-child { background: #111 !important; border-color: #222 !important; }
html.dark .nav-dropdown .dropdown-menu a { color: #ccc !important; }
html.dark .nav-dropdown .dropdown-menu a:hover { background: #1a1a1a !important; color: #f0f0f0 !important; }

/* ========== 文章页特殊处理：去除底板感 ========== */
html.dark article.post-wrap,
html.dark section.post-wrap,
html.dark .post-card,
html.dark .post-wrap .post-card,
html.dark .comments-card {
    background: transparent !important;
    border-color: #1a1a1a !important;
    box-shadow: none !important;
}
/* 标题区域保留精致小卡片 */
html.dark .post-header {
    background: #111 !important;
    border: 1px solid #222 !important;
    border-radius: 16px !important;
    padding: 40px 48px !important;
    margin-bottom: 32px !important;
}
@media (max-width: 768px) {
    html.dark .post-header {
        padding: 28px 24px !important;
        margin-bottom: 24px !important;
        border-radius: 12px !important;
    }
}

/* ========== Announcement Bar ========== */

.ann-bar {
    width: 100%;
    background: #111;
    color: #f0f0f0;
    overflow: hidden;
    max-height: 80px;
    transition: max-height .4s ease, opacity .4s ease;
}
.ann-bar.ann-hide { max-height: 0; opacity: 0; }
.ann-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 11px 44px 11px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    position: relative;
}
.ann-icon { flex-shrink: 0; }
.ann-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ann-link { color: #ffd666; text-decoration: none; font-weight: 600; flex-shrink: 0; }
.ann-link:hover { text-decoration: underline; }
.ann-close {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: #999; font-size: 14px; cursor: pointer;
    padding: 6px; line-height: 1;
    transition: color .2s;
}
.ann-close:hover { color: #fff; }
html.dark .ann-bar {
    background: var(--dm-bg) !important;
    color: var(--dm-text) !important;
    border-bottom: 1px solid var(--dm-border) !important;
}
/* 覆盖主题全局黑夜规则（html.dark div/span 强制灰字），与 header 同色系统一 */
html.dark .ann-bar .ann-inner,
html.dark .ann-bar .ann-text { color: var(--dm-text) !important; }
html.dark .ann-bar .ann-icon { color: var(--dm-text) !important; }
html.dark .ann-link { color: #ffd666 !important; }
html.dark .ann-close { color: #888 !important; }
html.dark .ann-close:hover { color: #f0f0f0 !important; }
@media (max-width: 480px) {
    .ann-inner { padding: 9px 40px 9px 14px; font-size: 13px; }
}

/* ========== 🔧 移动端修复补丁 ========== */

/* 菜单内部显式关闭按钮 */
.mobile-menu-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f5f7;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: #333;
    z-index: 10;
    line-height: 1;
}
html.dark .mobile-menu-close {
    background: #222;
    color: #f0f0f0;
}

/* 移动端菜单内登录/注册按钮样式 */
.mobile-menu .mobile-user-actions button {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    flex: 1;
    text-align: center;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.5;
}
.mobile-menu .mobile-user-actions button.auth-trigger-login {
    background: #111;
    color: #fff;
}
.mobile-menu .mobile-user-actions button.auth-trigger-register {
    background: #f4f5f7;
    color: #333;
}
html.dark .mobile-menu .mobile-user-actions button.auth-trigger-login {
    background: #ffffff !important;
    color: #111 !important;
}
html.dark .mobile-menu .mobile-user-actions button.auth-trigger-register {
    background: transparent !important;
    color: #fff !important;
    border: 1px solid #444 !important;
}

/* 菜单内容防溢出 */
.mobile-menu a {
    overflow-wrap: break-word;
    min-width: 0;
}