@charset "UTF-8";

/* 手机端（768以下）头部样式 - 恢复BookStack原生实现 */

/* 确保header元素始终可见并固定在顶部 */
header {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    flex-direction: column !important;
    background: #edeef0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 手机端一行结构header样式 */
.mobile-header-one-line {
    flex-direction: row !important;
    align-items: center !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    width: calc(100% - 2px) !important;
    max-width: calc(100% - 2px) !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.mobile-header-container {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    padding: 8px 16px !important;
    box-sizing: border-box !important;
    gap: 10px !important;
    border-bottom: none !important;
}

/* 左边：Logo */
.mobile-header-left {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex: 0 0 auto !important;
}

.mobile-header-left .logo {
    width: 36px !important;
    max-width: 36px !important;
    min-width: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* 回退按钮样式 */
.mobile-back-button {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    color: #666666 !important; /* 浅色模式浅灰色，比之前稍深 */
    padding: 8px 0 !important; /* 左右padding为0，减小点击区域 */
    margin: 0 !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    min-height: 36px !important;
    box-sizing: border-box !important;
    text-decoration: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    z-index: 9999 !important; /* 确保在顶层，能接收点击事件 */
    position: relative !important;
    overflow: visible !important;
}

.mobile-back-button:focus,
.mobile-back-button:active,
.mobile-back-button:hover {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    -webkit-tap-highlight-color: transparent !important;
    text-decoration: none !important;
    color: #666666 !important; /* 保持浅灰色，不继承父元素颜色 */
}

/* 确保a标签在所有状态下都没有下划线 */
.mobile-back-button:link,
.mobile-back-button:visited,
.mobile-back-button:hover,
.mobile-back-button:active {
    text-decoration: none !important;
    color: #666666 !important; /* 保持浅灰色，不继承父元素颜色 */
}

/* 回退按钮SVG样式 */
.mobile-back-button svg {
    width: 36px !important;
    height: 36px !important;
    fill: currentColor !important;
    color: inherit !important;
    display: block !important;
    pointer-events: none !important; /* 确保点击事件传递给按钮 */
    stroke-width: 1.5 !important; /* 线条更细，更美观 */
}

/* 确保mobile-header-left有足够空间并能接收点击 */
.mobile-header-left {
    z-index: 1000 !important;
    position: relative !important;
    overflow: visible !important;
}

/* 深色模式下的回退按钮样式 */
html.dark-mode .mobile-back-button {
    color: #e5e7eb !important; /* 深色模式浅白色 */
}

/* 隐藏logo文字 "慈氏电子书馆" */
.mobile-header-left .logo-text {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* 中间：搜索框 */
.mobile-header-center {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    min-width: 0 !important;
}

.mobile-header-center .search-box {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    z-index: 999 !important;
}

/* 右边：注册登录链接 */
.mobile-header-right {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    gap: 8px !important;
    margin-left: auto !important;
    width: auto !important;
}

/* 注册登录链接样式 */
.mobile-header-right .header-links-right {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
}

/* 搜索框样式调整 */
.mobile-header-center .search-box input {
    height: 36px !important;
    line-height: 36px !important;
    font-size: 14px !important;
    padding: 0 12px 0 32px !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background-color: #fff !important;
    color: #333333 !important;
}

/* 搜索按钮样式 - 参考桌面端样式，彻底移除边框 */
.mobile-header-center #header-search-box-button {
    left: 14px !important;
    transform: translateY(-50%) !important;
    top: 50% !important;
    z-index: 1000 !important;
    color: #999999 !important;
    opacity: 1 !important;
    background: none !important;
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
    display: block !important;
    overflow: visible !important;
    width: auto !important;
    height: auto !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.mobile-header-center #header-search-box-button:focus,
.mobile-header-center #header-search-box-button:active {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* 搜索图标样式 - 参考桌面端美化 */
.mobile-header-center #header-search-box-button svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
    color: inherit !important;
    border: none !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
}

.mobile-header-center #header-search-box-button:hover svg {
    color: #07c160 !important;
    transform: scale(1.1) !important;
}

/* 修复搜索下拉菜单位置 - 将其显示在搜索框下方 */
.search-box {
    position: relative !important;
    display: inline-block !important;
    width: 100% !important;
}

/* 搜索建议框样式 - 显示在搜索框下方 */
.global-search-suggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
    margin-top: 4px !important;
    width: 100% !important;
    max-width: none !important;
    transform: none !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    border: 1px solid #e5e5e5 !important;
    border-radius: 8px !important;
    background-color: #ffffff !important;
}

/* 确保搜索建议框在移动端正确显示 */
@media (max-width: 768px) {
    .global-search-suggestions {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 4px !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
    }
}

/* 确保搜索建议框在小屏幕移动端正确显示 */
@media (max-width: 480px) {
    .global-search-suggestions {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 60vh !important;
    }
}

/* 搜索框默认文字颜色 */
.mobile-header-center .search-box input::placeholder {
    color: #666666 !important;
    opacity: 1 !important;
}

/* 搜索框默认文字颜色 - 兼容不同浏览器 */
.mobile-header-center .search-box input::-webkit-input-placeholder {
    color: #666666 !important;
}

.mobile-header-center .search-box input::-moz-placeholder {
    color: #666666 !important;
    opacity: 1 !important;
}

.mobile-header-center .search-box input:-ms-input-placeholder {
    color: #666666 !important;
}

.mobile-header-center .search-box input:-moz-placeholder {
    color: #666666 !important;
    opacity: 1 !important;
}

/* 搜索按钮定位调整 */
.mobile-header-center #header-search-box-button {
    left: 12px !important;
    transform: translateY(-50%) !important;
    top: 50% !important;
    z-index: 1000 !important;
}

/* 手机端header布局改造：logo、搜索、注册登陆在同一行 */
@media (max-width: 768px) {
    /* 手机端header改为flex布局，垂直方向排列 */
    header {
        flex-direction: column !important;
        background: #edeef0 !important;
        padding: 5px 10px !important;
        gap: 0 !important;
        height: auto !important;
        min-height: auto !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    
    /* 手机端顶部导航区域改为flex布局，包含logo、搜索、菜单按钮 */
    header .header-top {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        align-items: stretch !important;
        padding: 0 !important;
        background: #edeef0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: relative !important;
        gap: 10px !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    
    /* 重置导航容器样式，包含logo、搜索框、菜单按钮 */
    header nav.header-top {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background: transparent !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex: 1 !important;
        gap: 10px !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    
    /* 为links容器设置样式，包含logo和菜单按钮 */
    header .header-top .links {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex: 1 !important;
        gap: 10px !important;
    }
    
    /* 重置header-links-container样式，包含logo和菜单 */
    .header-links-container {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 0 !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        background: transparent !important;
        overflow: visible !important;
        flex: 1 !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }
    
    /* Logo样式：居左，仅显示图标，隐藏文字 */
    header .logo {
        width: 40px !important;
        max-width: 40px !important;
        min-width: 40px !important;
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 auto !important;
        position: static !important;
        transform: none !important;
        z-index: 1000 !important;
    }
    
    /* 隐藏logo文字 "慈氏电子书馆" */
    header .logo-text {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* Logo图片自适应大小 */
    header .logo-image {
        height: 28px !important;
        width: 28px !important;
        max-height: 28px !important;
        max-width: 28px !important;
        object-fit: contain !important;
    }
    
    /* 调整搜索框高度为30px */
    header .search-box input {
        height: 30px !important;
        line-height: 30px !important;
        font-size: 13px !important;
        color: #333333 !important;
    }
    
    /* 搜索框默认文字颜色 */
    header .search-box input::placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    /* 搜索框默认文字颜色 - 兼容不同浏览器 */
    header .search-box input::-webkit-input-placeholder {
        color: #666666 !important;
    }
    
    header .search-box input::-moz-placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    header .search-box input:-ms-input-placeholder {
        color: #666666 !important;
    }
    
    header .search-box input:-moz-placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    /* 搜索按钮样式 - 参考桌面端样式，彻底移除边框 */
    #header-search-box-button {
        left: 14px !important;
        transform: translateY(-50%) !important;
        top: 50% !important;
        z-index: 1000 !important;
        color: #999999 !important;
        opacity: 1 !important;
        background: none !important;
        border: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        cursor: pointer !important;
        display: block !important;
        overflow: visible !important;
        width: auto !important;
        height: auto !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    #header-search-box-button:focus,
    #header-search-box-button:active {
        outline: none !important;
        border: none !important;
        box-shadow: none !important;
        background: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* 搜索图标样式 - 参考桌面端美化 */
    #header-search-box-button svg {
        width: 18px !important;
        height: 18px !important;
        fill: currentColor !important;
        color: inherit !important;
        border: none !important;
        outline: none !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #header-search-box-button:hover svg {
        color: #07c160 !important;
        transform: scale(1.1) !important;
    }
    
    /* 调整中间区域，隐藏并移到header-top中 */
    header .header-middle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* 调整底部区域，隐藏并移到header-top中 */
    header .header-bottom {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    
    /* 移除搜索框容器伪元素，避免影响布局 */
    .header-links-container::after {
        content: none !important;
        display: none !important;
        width: 0 !important;
        flex: 0 !important;
        margin: 0 !important;
    }
    
    /* 搜索框样式：居中，自适应宽度 */
    header .search-box {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        max-width: none !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        z-index: 999 !important;
    }
    
    /* 搜索按钮定位调整 */
    #header-search-box-button {
        left: 12px !important;
        transform: translateY(-50%) !important;
        top: 50% !important;
        z-index: 1000 !important;
    }
    
    /* 右侧导航样式 */
    .mobile-header-right {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        flex: 0 0 auto !important;
        gap: 8px !important;
        margin-left: auto !important;
        width: auto !important;
    }
    
    .header-links-right {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    /* 确保用户菜单容器显示 - 仅使用必要样式 */
    .header-links-right .dropdown-container {
        /* 使用BookStack原生样式，仅保留必要定位 */
        position: relative !important;
        display: block !important;
    }
    
    /* 确保用户菜单按钮显示 */
    .header-links-right .user-name {
        /* 使用BookStack原生样式 */
        display: flex !important;
        cursor: pointer !important;
    }
    
    /* 确保头像显示 */
    .header-links-right .avatar {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 30px !important;
        height: 30px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
    }
    
    /* 确保hide-under-l类在移动端正确显示 */
    .hide-under-l {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* 只隐藏header-links-right下边的SVG-icon，保留下拉菜单中的SVG */
    /* 隐藏注册/登录链接中的svg-icon类图标（直接子元素） */
    .header-links-right > a > .svg-icon {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        color: #333333 !important;
        fill: #333333 !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
    }
    
    /* 隐藏用户菜单按钮中的下拉箭头 */
    .user-name .icon-caret-down {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        color: #333333 !important;
        fill: #333333 !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
    }
    
    /* 确保手机端菜单按钮显示 */
    #header .mobile-menu-toggle {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        right: 0 !important;
        top: 0 !important;
        transform: none !important;
        z-index: 1000 !important;
    }
    
    /* 导航链接样式调整 */
    .header-links-right a[href*="/register"],
    .header-links-right a[href*="/login"] {
        font-size: 14px !important;
        font-weight: normal !important;
        color: #666666 !important;
        padding: 2px 8px !important;
    }
    
    /* 确保搜索框在手机端显示 */
    #header .search-box {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* 确保热搜标签在搜索框下方显示 */
    header .search-box + .wr_index_page_header_search_tags_wrapper {
        max-width: 100% !important;
        margin: 5px auto 0 auto !important;
        padding: 0 10px !important;
        box-sizing: border-box !important;
        flex-wrap: wrap !important;
    }
    
    /* 手机端header padding设置 */
    header {
        padding: 0 0 0 0 !important;
    }
    
    /* 768以下尺寸隐藏用户名 */
    header .user-name .name {
        display: none !important;
    }
    
    /* 重置导航栏容器样式 */
    header nav.header-top {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background: #edeef0 !important;
        overflow: visible !important;
    }
    
    /* 为links容器添加内边距，确保内容不被边框压住 */
    header .header-top .links {
        padding: 0 0 0 24px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* 重置header-links-container样式，添加溢出控制 */
    .header-links-container {
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 16px !important;
        padding: 0 0 0 12px !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        background: transparent !important;
        overflow: visible !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
    }
    
    /* 隐藏滚动条 */
    .header-links-container::-webkit-scrollbar {
        display: none !important;
    }
    
    /* 显示手机端左侧菜单链接：首页、类目、典籍 */
    .header-links-left {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        flex: none !important;
        flex-direction: column !important;
    }
    
    /* 右侧导航样式：居右 */
    .header-links-right {
        width: auto !important;
        flex-wrap: nowrap !important;
        gap: 16px !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        background: transparent !important;
        overflow: visible !important;
    }
    
    /* 设置导航链接样式 */
    .header-links-left {
        justify-content: flex-start !important;
    }
    
    .header-links-right {
        justify-content: flex-end !important;
    }
    
    /* 为首页链接添加额外的左边距，确保不被边框压住 */
    .header-links-left a:first-child {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    
    /* 确保header-links-left的内容不会超出容器 */
    .header-links-left {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    
    /* 优化导航链接悬停效果 */
    .header-links-left a:hover,
    .header-links-right a:hover {
        color: #07c160 !important;
        background: none !important;
    }
    
    /* 优化Logo显示 */
    header .logo {
        width: 200px !important;
        max-width: 200px !important;
        min-width: 200px !important;
        margin: 0 auto 8px auto !important;
    }
    
    header .logo-text {
        font-size: 20px !important;
    }
    
    /* 优化中间区域高度 */
    header .header-middle {
        padding: 10px 0 !important;
    }
    
    /* 移动端热搜标签样式 - 确保水平居中 */
    header .search-box + .wr_index_page_header_search_tags_wrapper {
        gap: 4px !important;
        padding: 0 8px !important;
        margin: 7px auto 0 auto !important;
        justify-content: center !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 600px !important;
        box-sizing: border-box !important;
    }
    
    .wr_index_page_header_search_tag_pre {
        font-size: 10px !important;
        margin-right: 3px !important;
    }
    
    .wr_index_page_header_search_tag {
        font-size: 9px !important;
        margin-right: 3px !important;
        padding: 1px 3px !important;
        border-radius: 6px !important;
        line-height: 1.1 !important;
        min-width: auto !important;
        white-space: nowrap !important;
        letter-spacing: -0.2px !important;
        word-spacing: -0.2px !important;
    }
    
    /* 搜索框响应式设计 */
    .search-box {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 16px !important;
        box-sizing: border-box !important;
    }
    
    header .header-bottom {
        padding-bottom: 25px !important;
    }
    
    /* 确保搜索按钮在移动端正确定位 */
    #header-search-box-button {
        left: 26px !important;
        transform: translateY(-50%) !important;
    }
    
    /* 移动端热搜样式 */
    header .search-box + .wr_index_page_header_search_tags_wrapper {
        max-width: 100% !important;
        margin: 15px auto 0 auto !important;
        padding: 0 16px 0 16px !important;
        box-sizing: border-box !important;
        flex-wrap: wrap !important;
    }
    
    /* 移动端搜索建议框样式 */
    .global-search-suggestions {
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
        left: 16px !important;
        right: 16px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* 移动端搜索建议项左对齐强化 */
    header .search-box .global-search-suggestions li a {
        justify-content: flex-start !important;
        text-align: left !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    header .search-box .global-search-suggestions .suggestion-item {
        justify-content: flex-start !important;
        text-align: left !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
    
    /* 修复搜索建议框在移动端的宽度问题 */
    header .header-bottom .search-box .global-search-suggestions {
        width: calc(100% - 32px) !important;
        max-width: calc(100% - 32px) !important;
        left: 16px !important;
        right: 16px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* 恢复原生的导航菜单逻辑 */
    header .header-links {
        /* 恢复原生的导航菜单隐藏状态 */
        display: none !important;
    }
    
    /* 恢复原生的导航菜单显示状态 */
    header .header-links.show {
        display: block !important;
    }
    
    /* 确保下拉菜单容器是相对定位的 - 与网页端保持一致 */
    #header .dropdown-container,
    #header .user-menu-container,
    header .dropdown-container,
    header .user-menu-container {
        position: relative !important;
        z-index: 10001 !important;
        overflow: visible !important;
        contain: none !important;
    }
    
    /* 确保下拉菜单在.user-menu-container内正确定位 - 与网页端保持一致 */
    #header .user-menu-container .dropdown-menu,
    #header .user-menu-container .dropdown-container .dropdown-menu,
    header .user-menu-container .dropdown-menu,
    header .user-menu-container .dropdown-container .dropdown-menu {
        /* 只保留样式，不控制显示/隐藏，让BookStack原生组件控制 */
        position: absolute !important;
        top: 80% !important;
        right: 0 !important;
        left: auto !important;
        margin-top: 4px !important;
        z-index: 99999 !important;
        /* 添加白色背景 */
        background-color: #ffffff !important;
        border: 1px solid #e5e5e5 !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
        padding: 8px 0 !important;
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
    }
    
    /* 使用更具体的选择器确保菜单默认隐藏，同时让JavaScript能够覆盖 */
    header .header-top .links .header-links-container .header-links-right .user-menu-container .dropdown-container .dropdown-menu {
        display: none;
    }
    
    /* 覆盖可能存在的强制显示规则，确保移动端下拉菜单默认隐藏 */
    @media (max-width: 768px) {
        header .dropdown-container ul.dropdown-menu {
            display: none !important;
        }
        
        /* 确保JavaScript添加的display: block能够正常工作 */
        header .dropdown-container ul.dropdown-menu[style*="display: block"] {
            display: block !important;
        }
    }
    
    /* 确保桌面端hover效果 - 与JavaScript保持兼容 */
    @media (min-width: 769px) {
        .user-menu-container:hover .dropdown-menu,
        .user-menu-container:hover .dropdown-container .dropdown-menu,
        #header .dropdown-container:hover .dropdown-menu,
        header .dropdown-container:hover .dropdown-menu {
            opacity: 1 !important;
            visibility: visible !important;
            display: block !important;
        }
        
        /* 确保桌面端hover时菜单保持显示 */
        .user-menu-container:hover .dropdown-menu[style*="display: none"],
        .user-menu-container:hover .dropdown-container .dropdown-menu[style*="display: none"],
        #header .dropdown-container:hover .dropdown-menu[style*="display: none"],
        header .dropdown-container:hover .dropdown-menu[style*="display: none"] {
            display: block !important;
        }
    }
    
    /* 隐藏下拉箭头 */
    .user-name .icon-caret-down {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 16px !important;
        height: 16px !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #333333 !important;
        fill: #333333 !important;
    }
}

/* 手机端头部深色模式样式 */
html.dark-mode header {
    background: #1a1a1a !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

html.dark-mode .mobile-header-container {
    background: #1a1a1a !important;
}

html.dark-mode .mobile-header-center .search-box input {
    background-color: #2d2d2d !important;
    color: #e5e7eb !important;
    border-color: #3d3d3d !important;
}

html.dark-mode .mobile-header-center .search-box input::placeholder {
    color: #999999 !important;
}

html.dark-mode .mobile-header-center #header-search-box-button {
    color: #999999 !important;
}

html.dark-mode .header-links-right a[href*="/register"],
html.dark-mode .header-links-right a[href*="/login"] {
    color: #e5e7eb !important;
}

/* 只隐藏header-links-right下边的SVG-icon，保留下拉菜单中的SVG */
/* 隐藏注册/登录链接中的svg-icon类图标（直接子元素，深色模式） */
html.dark-mode .header-links-right > a > .svg-icon {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    color: #e5e7eb !important;
    fill: #e5e7eb !important;
}

/* 隐藏用户菜单按钮中的下拉箭头（深色模式） */
html.dark-mode .user-name .icon-caret-down {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    color: #e5e7eb !important;
    fill: #e5e7eb !important;
}

/* 头像下拉菜单中的图标项样式 - 浅色模式 */
.dropdown-menu .icon-item,
.dropdown-menu .text-item,
.dropdown-menu .label-item {
    color: #666666 !important;
    fill: currentColor !important;
}

/* 头像下拉菜单中的图标项样式 - 深色模式 */
html.dark-mode .dropdown-menu .icon-item,
html.dark-mode .dropdown-menu .text-item,
html.dark-mode .dropdown-menu .label-item {
    color: #e5e7eb !important;
    fill: currentColor !important;
}

/* 重新定义user-name样式，解决颜色继承问题 */
header .user-name {
    color: #666666 !important;
    fill: currentColor !important;
}

/* 深色模式下的user-name样式 */
html.dark-mode header .user-name {
    color: #e5e7eb !important;
    fill: currentColor !important;
}

/* 搜索建议框深色模式 */
html.dark-mode .global-search-suggestions {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
}

/* 热搜标签深色模式 */
html.dark-mode .wr_index_page_header_search_tag_pre,
html.dark-mode .wr_index_page_header_search_tag {
    color: #e5e7eb !important;
    background-color: #374151 !important;
}

/* 头像下拉菜单深色模式 */
html.dark-mode #header .user-menu-container .dropdown-menu,
html.dark-mode #header .user-menu-container .dropdown-container .dropdown-menu,
html.dark-mode header .user-menu-container .dropdown-menu,
html.dark-mode header .user-menu-container .dropdown-container .dropdown-menu {
    background-color: #1f2937 !important;
    border: 1px solid #374151 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3) !important;
}

/* 下拉菜单选项深色模式 */
html.dark-mode .dropdown-menu li a,
html.dark-mode .dropdown-menu li button {
    color: #e5e7eb !important;
    background-color: transparent !important;
}

html.dark-mode .dropdown-menu li a:hover,
html.dark-mode .dropdown-menu li button:hover {
    background-color: #374151 !important;
    color: #ffffff !important;
}

/* 小屏幕设备优化 */
@media (max-width: 480px) {
    /* 导航栏小屏幕优化 */
    header nav.header-top {
        padding: 0 8px !important;
    }
    
    .header-links-container {
        gap: 12px !important;
        padding: 8px 0 !important;
    }
    
    .header-links-left,
    .header-links-right {
        gap: 12px !important;
    }
    
    /* 小屏幕设备注册和登录按钮样式 */
    .header-links-right a[href*="/register"],
    .header-links-right a[href*="/login"] {
        font-size: 13px !important;
        font-weight: normal !important;
        color: #666666 !important;
    }
    
    /* 搜索框小屏幕优化 */
    .search-box {
        padding: 0 12px !important;
    }
    
    .search-box input {
        height: 48px !important;
        line-height: 48px !important;
        font-size: 13px !important;
        padding-left: 32px !important;
        padding-right: 12px !important;
        color: #333333 !important;
    }
    
    /* 搜索框默认文字颜色 - 小屏幕 */
    .search-box input::placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    /* 搜索框默认文字颜色 - 兼容不同浏览器 */
    .search-box input::-webkit-input-placeholder {
        color: #666666 !important;
    }
    
    .search-box input::-moz-placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    .search-box input:-ms-input-placeholder {
        color: #666666 !important;
    }
    
    .search-box input:-moz-placeholder {
        color: #666666 !important;
        opacity: 1 !important;
    }
    
    /* 搜索按钮样式 - 参考桌面端样式，彻底移除边框 */
    #header-search-box-button {
        left: 22px !important;
        transform: translateY(-50%) !important;
        color: #999999 !important;
        opacity: 1 !important;
        background: none !important;
        border: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        cursor: pointer !important;
        display: block !important;
        overflow: visible !important;
        width: auto !important;
        height: auto !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    #header-search-box-button:focus,
    #header-search-box-button:active {
        outline: none !important;
        border: none !important;
        box-shadow: none !important;
        background: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* 搜索图标样式 - 参考桌面端美化 */
    #header-search-box-button svg {
        width: 18px !important;
        height: 18px !important;
        fill: currentColor !important;
        color: inherit !important;
        border: none !important;
        outline: none !important;
        transition: all 0.2s ease !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #header-search-box-button:hover svg {
        color: #07c160 !important;
        transform: scale(1.1) !important;
    }
    
    /* 热搜区域小屏幕优化 - 确保水平居中 */
    header .search-box + .wr_index_page_header_search_tags_wrapper {
        padding: 0 12px 0 16px !important;
        gap: 3px !important;
        margin: 7px auto 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        text-align: center !important;
        width: 100% !important;
        max-width: 600px !important;
        box-sizing: border-box !important;
    }
    
    /* 480px以下超紧凑热搜标签样式 */
    .wr_index_page_header_search_tag_pre {
        font-size: 9px !important;
        margin-right: 2px !important;
    }
    
    .wr_index_page_header_search_tag {
        font-size: 8px !important;
        margin-right: 2px !important;
        padding: 1px 2px !important;
        border-radius: 5px !important;
        line-height: 1.0 !important;
        letter-spacing: -0.3px !important;
        word-spacing: -0.3px !important;
    }
    
    /* 搜索建议框小屏幕优化 */
    .global-search-suggestions,
    header .header-bottom .search-box .global-search-suggestions {
        width: calc(100% - 24px) !important;
        max-width: calc(100% - 24px) !important;
        left: 12px !important;
        right: 12px !important;
    }
    
    /* 480px以下搜索建议项左对齐强化 */
    header .search-box .global-search-suggestions li a {
        justify-content: flex-start !important;
        text-align: left !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    header .search-box .global-search-suggestions .suggestion-item {
        justify-content: flex-start !important;
        text-align: left !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}
