/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "PingFang SC", "Microsoft Yahei", Arial, sans-serif;
}
ul, li {
    list-style: none;
}
a {
    text-decoration: none;
    color: #333;
    transition: all 0.3s ease;
}
img {
    max-width: 100%;
    vertical-align: middle;
    transition: all 0.3s ease;
}
.clearfix::after {
    content: "";
    display: block;
    clear: both;
}
.ellipsis_1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 全局样式 - 大气感核心 */
:root {
    --primary: #0066cc; /* 深海蓝主色，更沉稳大气 */
    --primary-light: #0078e7;
    --accent: #ff9500; /* 暖橙强调色，提升活力 */
    --accent-hover: #e88800;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-600: #6c757d;
    --gray-800: #343a40;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --spacing-xs: 8px;
    --spacing-sm: 13px;
    --spacing-md: 18px;
    --spacing-lg: 20px;
}

body {
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 15px;
    line-height: 1.6;
    padding-bottom: 40px;
    /* 移动端优化：增加点击区域，优化触控 */
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

/* 容器优化 - 加宽+居中，提升大气感 */
.container {
    max-width: 1280px; /* 加宽主容器 */
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
}

/* 模块卡片 - 优化圆角、阴影、留白 */
.mybox {
    background: #fff;
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: 3px; /* 调整这个数值：越大，模块之间的间隙越宽（原是var(--spacing-md)） */
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.3s ease;
}
.mybox:hover {
    box-shadow: var(--shadow-md);
}

/* 标题样式 - 强化层级 */
.mytitle {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--primary-light);
    margin-bottom: var(--spacing-md);
    position: relative;
}
.mytitle::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--accent);
}
.mytitle2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-800);
    padding: var(--spacing-xs) 0;
    margin-bottom: var(--spacing-sm);
    border-left: 4px solid var(--primary);
    padding-left: var(--spacing-xs);
}

/* 头部样式 - 移动端重点优化 */
header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light)); /* 渐变背景 */
    color: #fff;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    /* 移动端优化：适配刘海屏/底部导航 */
    padding-top: max(12px, env(safe-area-inset-top));
}
.headbox {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs); /* 统一间距 */
}

/* 菜单按钮 - 移动端优化触控区域 */
.menubtn {
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: block;
    width: 44px; /* 触控优化：44px最小点击区域 */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    transition: background 0.3s ease;
    /* 移动端优化：增加点击反馈 */
    touch-action: manipulation;
    /* 新增：flex垂直排列图标和文字 */
    flex-direction: column;
    position: relative;
    padding: 0;
}
/* 图标样式微调 - 缩小图标，给文字留出空间 */
.menubtn i.iconfont {
    font-size: 16px; /* 原22px，缩小适配文字 */
    line-height: 1;
    margin-bottom: 2px; /* 图标与文字间距 */
}
/* 分类文字样式 - 嵌入按钮内部 */
.menubtn .menu-text {
    font-size: 10px; /* 超小字体，适配按钮尺寸 */
    color: #fff; /* 文字白色，与按钮背景对比 */
    line-height: 1;
    white-space: nowrap;
    font-weight: 500; /* 加粗提升可读性 */
}
.menubtn:hover {
    background: rgba(255,255,255,0.2);
}

/* Logo样式 - 移动端优化 */
.logo {
    flex: 0 0 auto;
}
.logo a {
    color: #fff;
    font-size: 20px; /* 移动端略减小，适配屏幕 */
    font-weight: 700;
    letter-spacing: 1px; /* 字间距提升大气感 */
}

/* 简化版搜索框 - 核心优化 */
.search-wrapper {
    flex: 1;
    position: relative;
    min-width: 120px;
}
.search-input {
    width: 100%;
    height: 40px;
    padding: 0 15px;
    border: none;
    border-radius: 20px; /* 圆形搜索框更简洁 */
    outline: none;
    font-size: 14px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    -webkit-appearance: none;
    appearance: none;
}
.search-btn {
    position: absolute;
    right: 0;
    top: 0;
    height: 40px;
    width: 70px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 0 20px 20px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s ease;
    touch-action: manipulation;
}
.search-btn:hover {
    background: var(--accent-hover);
}

/* PC端导航 - 移动端隐藏 */
.menu1 {
    display: none;
}
.menu1 ul {
    display: flex;
    gap: 20px; /* 加大导航间距 */
}
.menu1 a {
    color: #fff;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}
.menu1 a:hover {
    color: #fff;
    background: rgba(255,255,255,0.2);
}

/* 左侧侧边栏 - 移动端重点优化 */
.leftmenu {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px; /* 保持宽度，但优化动画 */
    max-width: 90vw; /* 移动端最大宽度限制，适配小屏 */
    height: 100vh;
    background: #fff;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-out;
    box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    padding-top: max(70px, env(safe-area-inset-top) + 20px); /* 适配刘海屏 */
    border-right: 1px solid var(--gray-200);
    /* 移动端优化：增加滚动条 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.leftmenu.show {
    transform: translateX(0);
}
.menu_close_btn {
    position: absolute;
    top: max(20px, env(safe-area-inset-top) + 10px); /* 适配刘海屏 */
    right: 20px;
    font-size: 22px;
    cursor: pointer;
    color: var(--gray-600);
    width: 44px; /* 触控优化 */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--gray-100);
    transition: all 0.3s ease;
    touch-action: manipulation;
}
.menu_close_btn:hover {
    background: var(--gray-200);
    color: var(--primary);
}
.menu2 ul {
    padding: 0 var(--spacing-md);
}
.menu2 li {
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-200);
}
.menu2 li:last-child {
    border-bottom: none;
}
.menu2 a {
    font-size: 16px;
    display: block;
    padding: 12px 15px; /* 加大点击区域 */
    border-radius: var(--radius-sm);
    /* 移动端优化：触控反馈 */
    touch-action: manipulation;
}
.menu2 a:hover {
    color: var(--primary);
    background: var(--gray-100);
    padding-left: 18px;
}

/* 遮罩层 - 移动端优化 */
.modbg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(2px); /* 毛玻璃效果 */
    /* 移动端优化：适配安全区域 */
    padding-bottom: env(safe-area-inset-bottom);
}
.modbg.show {
    display: block;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 主体布局 - 移动端重点优化 */
main {
    padding: var(--spacing-md) 0; /* 移动端减小上下内边距 */
    /* 移动端优化：适配底部安全区域 */
    padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
}
.row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

/* 小说列表 - 移动端核心优化 */
.newnovels ul {
    display: grid;
    /* 移动端优化：自适应列数，最小宽度调整 */
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-sm); /* 移动端减小间距 */
    align-items: start;
}
.newnovels li {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    /* 移动端优化：增加点击区域 */
    touch-action: manipulation;
}
.indeximgbox {
    width: 100%;
    aspect-ratio: 3/4;
    overflow: hidden;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-xs);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.indeximgbox img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 图片等比填充，避免拉伸变形 */
    /* 移动端优化：图片加载优化 */
    will-change: transform;
}
.newnovels li:hover img {
    transform: scale(1.05); /* 移动端减小缩放比例 */
    filter: brightness(1.05);
}
.novel-info {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 4px; /* 移动端增加左右内边距 */
}
.newnovels h3 {
    font-size: 14px; /* 移动端减小字体 */
    margin-bottom: 4px;
    font-weight: 600;
    height: 20px; /* 固定标题高度，确保对齐 */
    line-height: 20px;
}
.newnovels h4 {
    font-size: 12px; /* 移动端减小字体 */
    color: var(--gray-600);
    font-weight: normal;
    height: 16px; /* 固定作者名高度，确保对齐 */
    line-height: 16px;
}

/* 最近更新 - 基础样式（统一结构） */
.recentupdate ul {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.recentupdate li {
    display: flex;
    padding: 10px 12px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    touch-action: manipulation;
}
.recentupdate li:hover {
    border-left-color: var(--primary);
    background: #f0f7ff;
    transform: translateX(2px);
}
/* 小说标题 */
.recentupdate li > a:first-child {
    font-weight: 600;
    color: var(--gray-800);
}
.recentupdate li > a:first-child:hover {
    color: var(--primary);
}
/* 章节名（核心：默认右对齐，PC端强制左对齐） */
.recentupdate li > a:nth-child(2) {
    color: var(--gray-600);
    margin: 0 8px;
}
/* 更新时间 */
.recentupdate li > span {
    color: var(--gray-600);
    text-align: right;
    white-space: nowrap;
}

/* 排行榜 - 移动端优化 */
.tabs2 {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: var(--spacing-md);
}
.tabs2 li {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 14px; /* 移动端减小字体 */
    touch-action: manipulation;
}
.tabs2 li.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}
.tabs2 li:hover:not(.active) {
    border-bottom-color: var(--gray-300);
    color: var(--primary-light);
}
.ranking ul {
    display: flex;
    flex-direction: column;
    gap: 8px; /* 移动端减小间距 */
}
.ranking li {
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    touch-action: manipulation;
    width: 100%;
}
.ranking li:last-child {
    border-bottom: none;
}
.ranking li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.rank_left {
    flex: 1;
    margin-right: 10px;
}
.ranktit {
    font-size: 14px; /* 移动端减小字体 */
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
}
.ranktit:hover {
    color: var(--primary);
}
.rank_right {
    color: var(--gray-600);
    font-size: 12px; /* 移动端减小字体 */
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 10px;
    flex: 0 0 auto;
    white-space: nowrap;
    vertical-align: middle;
}

/* 友情链接 - 移动端优化 */
.home-tuijian .ranking ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* 移动端减小间距 */
}
.home-tuijian .ranking a {
    padding: 6px 10px; /* 移动端减小内边距 */
    background: #e6f0ff;
    border-radius: 20px;
    font-size: 13px; /* 移动端减小字体 */
    color: var(--primary);
    border: 1px solid var(--primary-light);
    touch-action: manipulation;
}
.home-tuijian .ranking a:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

/* 悬浮按钮 - 移动端重点优化 */
.home-recent-read {
    position: fixed;
    bottom: max(30px, env(safe-area-inset-bottom) + 10px); /* 适配底部安全区域 */
    right: 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    width: 50px; /* 移动端减小尺寸 */
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,102,204,0.3);
    z-index: 99;
    font-size: 11px; /* 移动端减小字体 */
    text-align: center;
    transition: all 0.3s ease;
    touch-action: manipulation;
    /* 移动端优化：增加点击区域 */
    transform: translateZ(0);
}
.home-recent-read:hover {
    transform: scale(1.08) translateZ(0); /* 移动端减小缩放 */
    box-shadow: 0 6px 20px rgba(0,102,204,0.4);
}

/* 返回顶部 - 移动端优化 */
.back-to-top {
    position: fixed;
    bottom: max(90px, env(safe-area-inset-bottom) + 70px); /* 适配底部安全区域 */
    right: 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    width: 50px; /* 移动端减小尺寸 */
    height: 50px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,102,204,0.3);
    z-index: 99;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
    transform: translateZ(0);
}
.back-to-top.show {
    display: flex;
    animation: popIn 0.3s ease;
}
@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.back-to-top:hover {
    transform: scale(1.08) translateZ(0);
    box-shadow: 0 6px 20px rgba(0,102,204,0.4);
}

/* 底部样式 - 移动端优化 */
.foot {
    background: var(--gray-800);
    color: #ccc;
    padding: var(--spacing-md) 0; /* 移动端减小内边距 */
    margin-top: var(--spacing-md);
    /* 移动端优化：适配底部安全区域 */
    padding-bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom));
}
.copyright {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--spacing-sm);
    font-size: 13px; /* 移动端减小字体 */
    line-height: 1.8;
    text-align: center;
}
.copyright p {
    margin-bottom: 8px;
}

/* ========== 媒体查询分层：先PC，后移动端 ========== */
/* PC端适配（768px以上）- 最高优先级 */
@media (min-width: 768px) {
    /* 隐藏移动端菜单按钮 */
    .headbox .menubtn {
        display: none !important;
    }
    /* 显示PC端导航 */
    .menu1 {
        display: block;
    }
    /* 主体布局分栏 */
    .row {
        grid-template-columns: 2fr 1fr;
    }
    /* 小说列表5列 */
    .newnovels ul {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: var(--spacing-md);
    }
    .indeximgbox {
        aspect-ratio: 3/4;
    }
    .newnovels h3 {
        font-size: 15px;
    }
    .newnovels h4 {
        font-size: 13px;
    }

    /* 【核心生效】PC端最近更新章节名强制左对齐 */
    .recentupdate li {
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 15px !important;
    }
    /* 小说标题 */
    .recentupdate li > a:first-child {
        flex: 1 !important;
        font-size: 15px !important;
    }
    /* 章节名：强制左对齐 + 宽占比 */
    .recentupdate li > a:nth-child(2) {
        flex: 2 !important;
        font-size: 14px !important;
        text-align: left !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* 更新时间：固定宽度+右对齐 */
    .recentupdate li > span {
        flex: 0 0 80px !important;
        font-size: 13px !important;
        text-align: right !important;
    }

    /* 其他PC端样式 */
    .ranktit {
        font-size: 15px;
    }
    .rank_right {
        font-size: 13px;
    }
    .home-recent-read {
        width: 56px;
        height: 56px;
        font-size: 12px;
    }
    .back-to-top {
        width: 56px;
        height: 56px;
    }
    .search-input {
        height: 44px;
        font-size: 15px;
    }
    .search-btn {
        height: 44px;
        width: 90px;
        font-size: 16px;
    }
    .logo a {
        font-size: 22px;
    }
    main {
        padding: var(--spacing-lg) 0;
    }
    .foot {
        padding: var(--spacing-lg) 0;
    }
    .copyright {
        font-size: 14px;
    }
}

/* 大屏适配（1200px以上） */
@media (min-width: 1200px) {
    .newnovels ul {
        grid-template-columns: repeat(5, 1fr) !important;
    }
}

/* 移动端核心适配（767px以下） */
@media (max-width: 767px) {
    /* 隐藏章节名 */
    .recentupdate li > a:nth-child(2) {
        display: none !important;
    }
    /* 调整移动端最近更新布局 */
    .recentupdate li {
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
    }
    .recentupdate li > a:first-child {
        flex: 1 !important;
        font-size: 14px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .recentupdate li > span {
        flex: 0 0 60px !important;
        font-size: 12px !important;
        text-align: right !important;
    }

    /* 小说列表2列+仅显示前2个 */
    .newnovels ul {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--spacing-sm) !important;
    }
    .newnovels ul li:nth-child(n+3) {
        display: none !important;
    }
}

/* 小屏移动端适配（375px以下） */
@media (max-width: 375px) {
    :root {
        --spacing-sm: 10px;
        --spacing-md: 15px;
        --spacing-lg: 20px;
    }
    .newnovels ul {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--spacing-sm) !important;
    }
    .mytitle {
        font-size: 16px;
    }
    .mytitle2 {
        font-size: 15px;
    }
    .mybox {
        padding: var(--spacing-sm);
    }
    .search-btn {
        width: 60px;
        font-size: 13px;
    }
    .home-recent-read, .back-to-top {
        width: 46px;
        height: 46px;
    }
}

/* 横屏适配 */
@media (orientation: landscape) and (max-width: 767px) {
    .leftmenu {
        width: 240px;
    }
    .newnovels ul {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--spacing-xs) !important;
    }
    header {
        padding: 8px 0;
    }
    .headbox {
        gap: var(--spacing-xs);
    }
}

/* ========== 终极兜底：全局强制PC端章节名左对齐 ========== */
@media screen and (min-width: 768px) {
    .recentupdate li a[href*=".html"][target="_blank"] {
        text-align: left !important;
        display: inline-block !important;
        width: auto !important;
        flex: 2 !important;
    }
}